old_contents: """
  This Blueprint implements Blog related views.
  """
  from flask import Blueprint, render_template, abort
  from flask_misaka import markdown
  
  from models import Post
  
  
  blog = Blueprint('blog', __name__)
  
  
  @blog.route('/')
  def blog_index():
      all_posts = Post.query.all()
      return render_template('blog_list.html', posts=all_posts)
  
  
  @blog.route('/<post_url>')
  def blog_post(post_url):
      post = Post.query.filter_by(url=post_url).first()
      if post is None:
          abort(404)
      md_text = post.content
      html = markdown(md_text, fenced_code=True, math=True)
      # https://flask-misaka.readthedocs.io/en/latest/
      # http://misaka.61924.nl/#
      return render_template('blog_post.html', post=html, date=post.published_at)
  
new_contents: """
  This Blueprint implements Blog related views.
  """
  from flask import Blueprint, render_template, abort
  from flask_misaka import markdown
  
  from models import Post
  
  
  blog = Blueprint('blog', __name__)
  
  
  @blog.route('/')
  def blog_index():
      all_posts = Post.query.all()
      all_posts = sorted(all_posts, key=lambda p: p.published_at, reverse=True)
      return render_template('blog_list.html', posts=all_posts)
  
  
  @blog.route('/<post_url>')
  def blog_post(post_url):
      post = Post.query.filter_by(url=post_url).first()
      if post is None:
          abort(404)
      md_text = post.content
      html = markdown(md_text, fenced_code=True, math=True)
      # https://flask-misaka.readthedocs.io/en/latest/
      # http://misaka.61924.nl/#
      return render_template('blog_post.html', post=html, date=post.published_at)
  
subject: sort blog post list in reverse publish time