diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2017-06-09 21:50:59 +0100 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2017-06-09 22:51:50 +0200 |
commit | 9bee01ce26f7b5db038f2dae3227a9714233c844 (patch) | |
tree | 76a23ea830c989828a719f1ea217671da5798414 /kyrias_website/views.py | |
parent | 55bb964cf8a106679f369f8c3c7d9874f4711663 (diff) | |
download | kyrias-website-9bee01ce26f7b5db038f2dae3227a9714233c844.tar.xz |
Not much use in wrapping everything in the CustomFlask class, so put
everything at the top level of __init__.py.
Rename CustomFlatPages to JournalFlatPages and only use it for the
journal FlatPages instance. Also move the journal_entries and
journal_tags members to JournalFlatPages, renaming them to just entries
and tags.
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Diffstat (limited to 'kyrias_website/views.py')
-rw-r--r-- | kyrias_website/views.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/kyrias_website/views.py b/kyrias_website/views.py index 3065aef..14a81eb 100644 --- a/kyrias_website/views.py +++ b/kyrias_website/views.py @@ -1,11 +1,11 @@ -from kyrias_website import app +from kyrias_website import app, pages, journal 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) + page = pages.get_or_404(path) return render_template('page.html', page=page) @@ -13,27 +13,27 @@ def page(path): @app.route('/index/') @app.route('/') def index(): - current = app.journal_entries[-1] - older = next(iter(app.journal_entries[-2:-1]), None) + current = journal.entries[-1] + older = next(iter(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) + return render_template('archive.html', entries=journal.entries) @app.route('/tags/') def tags(): - return render_template('tags.html', tags=app.journal_tags) + return render_template('tags.html', tags=journal.tags) @app.route('/blog/<path:name>/') def entry(name): - entry = app.journal.get_or_404(name) + entry = 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) + index = journal.entries.index(entry) + older = next(iter(journal.entries[index-1:index]), None) + newer = next(iter(journal.entries[index+1:index+2]), None) return render_template('entry.html', entry=entry, older=older, newer=newer) |