def detail(slug): r = db_posts.scan(FilterExpression='published = :b AND slug = :s', ExpressionAttributeValues={ ":b": True, ":s": slug }) if len(r) > 0: post = r['Items'][0] # convert post content to HTML hilite = CodeHiliteExtension(linenums=False, css_class='highlight') extras = ExtraExtension() post['content'] = markdown(post['content'], extensions=[hilite, extras]) post['content'] = parse_html(post['content'], oembed_providers, urlize_all=True, maxwidth=app.config['SITE_WIDTH']) post['content'] = Markup(post['content']) return render_template('detail.html', post=post) else: flash('Post not found.', 'danger') return redirect(url_for('home'))
def blog(): # TODO implement search # TODO check if posts are sorted? r = db_posts.scan(FilterExpression='published = :b', ExpressionAttributeValues={":b": True}) posts = r['Items'] return render_template('blog.html', post_list=posts)
def home(): r = db_posts.scan(FilterExpression='published = :b AND featured = :b', ExpressionAttributeValues={":b": True}) posts = r['Items'] if len(posts) > 3: posts = posts[:2] return render_template('home.html', featured=posts, len=len(posts))
def drafts(): r = db_posts.scan(FilterExpression='published = :b', ExpressionAttributeValues={":b": False}) posts = r['Items'] return render_template('blog.html', post_list=posts)
def edit(slug): r = db_posts.scan(FilterExpression='slug = :s', ExpressionAttributeValues={":s": slug}) post = r['Items'][0] return _create_or_edit(post, 'edit.html')