Esempio n. 1
0
async def index(request, *, page='1'):
    user = request.__user__
    cats = await Category.findAll(orderBy='created_at desc')
    page_index = Page.page2int(page)
    num = await Blog.findNumber('*') - 1  # 去掉__about__页面
    p = Page(num,
             page_index,
             item_page=configs.blog_item_page,
             page_show=configs.page_show)
    p.pagelist()
    if num == 0:
        blogs = []
    else:
        blogs = await Blog.findAll(where='title<>?',
                                   args=['__about__'],
                                   orderBy='created_at desc',
                                   limit=(p.offset, p.limit))
        for blog in blogs:
            blog.html_summary = markdown(
                blog.summary, extras=['code-friendly', 'fenced-code-blocks'])
    return {
        '__template__': 'index.html',
        'web_meta': configs.web_meta,
        'user': user,
        'cats': cats,
        'page': p,
        'blogs': blogs,
        'disqus': configs.use_disqus
    }
Esempio n. 2
0
async def api_manage_category(*, page='1'):
    page_index = Page.page2int(page)
    num = await Category.findNumber('*')
    p = Page(num, page_index, item_page=configs.manage_item_page, page_show=configs.page_show)
    if num == 0:
        return dict(page=p, categories=())
    categories = await Category.findAll(orderBy='created_at desc', limit=(p.offset, p.limit))
    return dict(page=p, categories=categories)
Esempio n. 3
0
async def api_manage_category(*, page='1'):
    page_index = Page.page2int(page)
    num = await Category.findNumber('*')
    p = Page(num, page_index, item_page=configs.manage_item_page, page_show=configs.page_show)
    if num == 0:
        return dict(page=p, category=())
    categoyies = await Category.findall(orderBy='created_at desc', limit=(p.offset, p.limit))
    return dict(page=p, categoyies=categoyies)
Esempio n. 4
0
async def api_manage_blog(*, page='1'):
    page_index = Page.page2int(page)
    num = await Blog.findNumber('*')
    p = Page(num, page_index, item_page=configs.manage_item_page, page_show=configs.page_show)
    if num == 0:
        return dict(page=p, blogs=())
    col = ['id', 'user_id', 'user_name', 'title', 'created_at']
    blogs = await Blog.findall(col=col, orderBy='created_at desc', limit=(p.offset, p.limit))
    return dict(page=p, blogs=blogs)
Esempio n. 5
0
async def api_manage_blog(*, page='1'):
    page_index = Page.page2int(page)
    num = await Blog.findNumber('*')
    p = Page(num, page_index, item_page=configs.manage_item_page, page_show=configs.page_show)
    if num == 0:
        return dict(page=p, blogs=())
    col = ['id', 'user_id', 'user_name', 'title', 'created_at']
    blogs = await Blog.findAll(col=col, orderBy='created_at desc', limit=(p.offset, p.limit))
    return dict(page=p, blogs=blogs)
Esempio n. 6
0
async def api_manage_user(*, page='1'):
    page_index = Page.page2int(page)
    num = await User.findNumber('*')
    p = Page(num, page_index, item_page=configs.manage_item_page, page_show=configs.page_show)
    if num ==0:
        return dict(page=p, user=())
    users = await User.findall(orderBy='created_at desc', limit=(p.offset, p.limit))
    for u in users:
        u.password = '******'
    return dict(page=p, users=users)
Esempio n. 7
0
async def api_manage_user(*, page='1'):
    page_index = Page.page2int(page)
    num = await User.findNumber('*')
    p = Page(num, page_index, item_page=configs.manage_item_page, page_show=configs.page_show)
    if num == 0:
        return dict(page=p, user=())
    users = await User.findAll(orderBy='created_at desc', limit=(p.offset, p.limit))
    for u in users:
        u.password = '******'
    return dict(page=p, users=users)
Esempio n. 8
0
async def index(request, *, page='1'):
    user = request.__user__
    cats = await Category.findAll(orderBy='created_at desc')
    page_index = Page.page2int(page)
    num = await Blog.findNumber('*') - 1    # 去掉__about__页面
    p = Page(num, page_index, item_page=configs.blog_item_page, page_show=configs.page_show)
    p.pagelist()
    if num == 0:
        blogs = []
    else:
        blogs = await Blog.findAll(where='title<>?', args=['__about__'], orderBy='created_at desc', limit=(p.offset, p.limit))
        for blog in blogs:
            blog.html_summary = markdown(blog.summary, extras=['code-friendly', 'fenced-code-blocks'])
    return {
        '__template__': 'index.html',
        'web_meta': configs.web_meta,
        'user': user,
        'cats': cats,
        'page': p,
        'blogs': blogs,
        'disqus': configs.use_disqus
    }