示例#1
0
def view_page(slug):
    page = Page.gql("WHERE slug = :1", slug)[0]
    content = BeautifulSoup(page.content)
    codes = content.findAll('pre')
    for code in codes:
        code.contents[0].replaceWith(controllers.prettify_code(code.contents[0]))
    page.content = str(content)
    return render_template('cms_view_page.html', page=page)
示例#2
0
def view_post(category_slug, post_slug):
    category = Category.gql("WHERE slug = :1", category_slug)[0]
    all_posts = Post.all().order('-date_created')
    post = [x for x in all_posts if x.category.slug == category_slug and x.slug == post_slug][0]
    content = BeautifulSoup(post.content)
    codes = content.findAll('pre')
    for code in codes:
        code.contents[0].replaceWith(controllers.prettify_code(code.contents[0]))
    post.content = unicode(content)
    return render_template('cms_view_post.html', post=post)