summaryrefslogtreecommitdiffstats
path: root/kyrias_website/views.py
blob: 3065aef660aeada8ec87dbf9bbfd0f7f13b07a44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from kyrias_website import app
from flask import render_template


# Render all static pages as fallback
@app.route('/<path:path>/')
def page(path):
    page = app.pages.get_or_404(path)
    return render_template('page.html', page=page)


@app.route('/blog/')
@app.route('/index/')
@app.route('/')
def index():
    current = app.journal_entries[-1]
    older = next(iter(app.journal_entries[-2:-1]), None)
    return render_template('entry.html', entry=current, older=older)


@app.route('/archive/')
def archive():
    return render_template('archive.html', entries=app.journal_entries)


@app.route('/tags/')
def tags():
    return render_template('tags.html', tags=app.journal_tags)


@app.route('/blog/<path:name>/')
def entry(name):
    entry = app.journal.get_or_404(name)

    index = app.journal_entries.index(entry)
    older = next(iter(app.journal_entries[index-1:index]), None)
    newer = next(iter(app.journal_entries[index+1:index+2]), None)

    return render_template('entry.html', entry=entry, older=older, newer=newer)