from flask import Blueprint,render_template,request,current_app from flask_login import current_user from emails import send_new_comment_email,send_new_reply_email from utils import redirect_back from models import Post,Category,Comment
blog_bp=Blueprint('blog',name)
@blog_bp.route("/") def index(): page=request.args.get('page',1,type=int) per_page=current_app.config['FLASKBLOG_POST_PER_PAGE'] pagination=Post.query.order_by(Post.timestamp.desc()).paginate(page,per_page=per_page) posts=pagination.items return render_template('blog/index.html',pagination=pagination,posts=posts)
{% extends 'base.html' %} {% from 'bootstrap/pagination.html' import render_pager %}
{% block title %}Home{% endblock %}
{% block content %} <div class="page-header"> <h1 class="display-3">{{ admin.blog_title|default('Blog Title') }}</h1> <h4 class="text-muted"> {{ admin.blog_sub_title|default('Blog Subtitle') }}</h4> </div> <div class="row"> <div class="col-sm-8"> {% include 'blog/_posts.html' %} {% if posts %} <div class="page-footer">{{ render_pager(pagination) }}</div> {% endif %} </div> <div class="col-sm-4 sidebar"> {% include 'blog/_sidebar.html' %} </div> </div>