Exemplo n.º 1
0
def api_comments(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Comment.findNumber('count(id)')
    p = Page(num, page_index)
    if num == 0:
        return dict(page=p, comments=())
    comments = yield from Comment.findAll(orderBy='created_at desc', limit=(p.offset, p.limit))
    return dict(page=p, comments=comments)
Exemplo n.º 2
0
def get_blog(id):
	blog = yield from Blogs.find('id=?',[id])
	comments = yield from Comment.findAll('blog_id=?',[id],orderby='created_at DESC')
	return {
	'__template__':'blog.html',
	'blog':blog,
	'comments':comments
	}
def api_comments(*,page='1'):
    page_index  = get_page_index(page)
    num = yield from Comment.findNumber('count(id)')
    p = Page(num,page_index)
    if num == 0 :
        return dict(page=p,comments = ())
    comments = yield from Comment.findAll(orderBy='created_at desc',limit=(p.offset,p.limit))
    return dict(page=p,comments=comments)
Exemplo n.º 4
0
def get_blog(id):
    blog = yield from Blog.find(id)
    comments = yield from Comment.findAll('blog_id=?', [id],
                                          orderBy='created_at desc')
    for c in comments:
        c.html_content = text2html(c.content)
    blog.html_content = markdown2.markdown(blog.content)
    return {'__template__': 'blog.html', 'blog': blog, 'comments': comments}
Exemplo n.º 5
0
def get_blog(id):
    blog = yield from Blog.find(id)
    comments = yield from Comment.findAll('blog_id=?', [id], orderBy='created_at desc')
    for c in comments:
        c.html_content = text2html(c.content)
    blog.html_content = markdown2.markdown(blog.content)
    return {
        '__template__': 'blog.html',
        'blog': blog,
        'comments': comments
    }