Esempio n. 1
0
def index_view():
    """
    Renders an index page with the most recent posts
    """
    latest_posts = get_latest_posts(5)
    return render_template_with_models('latest_posts.html',
                                       latest_posts=latest_posts)
Esempio n. 2
0
def not_found(error):
    """
    Renders a 404 page because something wasn't found

    :param error: error information
    """
    return render_template_with_models('error.html', code=404,
                                       email=app.config.get('ADMIN_EMAIL', '*****@*****.**')), 404
Esempio n. 3
0
def login_view():
    """
    Renders a login page and redirects to the index on completion
    """
    form = LoginForm(request.form)
    if request.method == 'POST' and form.validate():
        user = get_user(form.data['shortname'])
        login_user(user)
        return redirect(url_for('admin.index'))
    return render_template_with_models('login.html', form=form)
Esempio n. 4
0
def profile_view(name):
    """
    Renders a profile page for a user

    :param name: shortname to look up the user
    """
    user = get_user(name)
    if user is None:
        abort(404)
    return render_template_with_models('profile.html', user=user)
Esempio n. 5
0
def login_view():
    """
    Renders a login page and redirects to the index on completion
    """
    form = LoginForm(request.form)
    if request.method == 'POST' and form.validate():
        user = get_user(form.data['shortname'])
        login_user(user)
        return redirect(url_for('admin.index'))
    return render_template_with_models('login.html', form=form)
Esempio n. 6
0
def tag_view(slug):
    """
    Renders a page with a list of all posts with a tag

    :param slug: slug to look up the tag
    """
    tag = Tag.query.filter_by(slug=slug).first()
    if tag is None:
        abort(404)
    tag_posts = sorted(tag.posts, key=lambda x: x.date)
    return render_template_with_models('tag_posts.html', tag=tag, tag_posts=tag_posts)
Esempio n. 7
0
def user_view(name):
    """
    Render a page with a listing of all of a user's posts

    :param name: shortname to look up the user
    """
    user = get_user(name)
    if user is None:
        abort(404)
    user_posts = sorted(user.posts, key=lambda x: x.date)
    return render_template_with_models('user_posts.html', user=user, user_posts=user_posts)
Esempio n. 8
0
def not_found(error):
    """
    Renders a 404 page because something wasn't found

    :param error: error information
    """
    return render_template_with_models('error.html',
                                       code=404,
                                       email=app.config.get(
                                           'ADMIN_EMAIL',
                                           '*****@*****.**')), 404
Esempio n. 9
0
def post_view(slug):
    """
    Renders a page for an individual post

    :param slug: slug to look up the post
    """
    post = get_post(slug)
    if post is None:
        abort(404)
    user = get_user(post.user_shortname)
    services = user.services
    return render_template_with_models('post.html', post=post, user=user, services=services)
Esempio n. 10
0
def tag_view(slug):
    """
    Renders a page with a list of all posts with a tag

    :param slug: slug to look up the tag
    """
    tag = Tag.query.filter_by(slug=slug).first()
    if tag is None:
        abort(404)
    tag_posts = sorted(tag.posts, key=lambda x: x.date)
    return render_template_with_models('tag_posts.html',
                                       tag=tag,
                                       tag_posts=tag_posts)
Esempio n. 11
0
def user_view(name):
    """
    Render a page with a listing of all of a user's posts

    :param name: shortname to look up the user
    """
    user = get_user(name)
    if user is None:
        abort(404)
    user_posts = sorted(user.posts, key=lambda x: x.date)
    return render_template_with_models('user_posts.html',
                                       user=user,
                                       user_posts=user_posts)
Esempio n. 12
0
def post_view(slug):
    """
    Renders a page for an individual post

    :param slug: slug to look up the post
    """
    post = get_post(slug)
    if post is None:
        abort(404)
    user = get_user(post.user_shortname)
    services = user.services
    return render_template_with_models('post.html',
                                       post=post,
                                       user=user,
                                       services=services)
Esempio n. 13
0
def about_view():
    """
    Renders an about page with information about the blog
    """
    return render_template_with_models('about.html')
Esempio n. 14
0
def index_view():
    """
    Renders an index page with the most recent posts
    """
    latest_posts = get_latest_posts(5)
    return render_template_with_models('latest_posts.html', latest_posts=latest_posts)
Esempio n. 15
0
def about_view():
    """
    Renders an about page with information about the blog
    """
    return render_template_with_models('about.html')