def render_post(content_id): tag_chunks = [] tags = json.loads(get_tags_in_use()) if tags: if len(tags) > 16: tags = tags[:16] tag_chunks = chunks(tags, 4) content = Content.get(content_id) if not content: content = Content.filter(Content.slug == content_id).first() return render(content.template, user=import_user(), content=content, tag_chunks=tag_chunks, menu_items=get_menu_items())
def blog_index(page=1, tag=None): tag_chunks = [] tags = json.loads(get_tags_in_use()) if tags: if len(tags) > 16: tags = tags[:16] tag_chunks = chunks(tags, 4) limit = get_setting("posts-per-page", 4) posts = Content.filter(Content.published == True)\ .filter(Content.type == "post")\ .order_by(Content.published_on.desc()) if tag: posts = posts.filter(Content.tags.contains(tag)) posts, max_pages = paginate(posts, page, limit) return render('index.html', user=import_user(), posts=posts, current_page=page, max_pages=max_pages, tag_chunks=tag_chunks, tag=tag, menu_items=get_menu_items())