diff options
Diffstat (limited to 'app.py')
| -rwxr-xr-x | app.py | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -33,7 +33,7 @@ def get_template_items(title, db): @app.route("/~") def index(): with database.Database() as db: - with open(os.path.join("static", "index.md"), "r") as f: + with open("static/index.md", "r") as f: return flask.render_template( "index.html.j2", **get_template_items("eva's site", db), @@ -48,9 +48,17 @@ def robots(): def get_thoughts(): with database.Database() as db: all_ = db.get_all_thoughts() + tree = {} + for id_, title, datetime, category in all_: + if category not in tree.keys(): + tree[category] = [(id_, title, datetime)] + else: + tree[category].append((id_, title, str(datetime))) + return flask.render_template( "thoughts.html.j2", **get_template_items("thoughts", db), + tree = tree ) @app.route("/thought") @@ -58,7 +66,7 @@ def get_thought(): thought_id = flask.request.args.get("id", type=int) with database.Database() as db: try: - title, datetime, parsed, headers, redirect = parser.get_thought_from_id(db. thought_id) + title, datetime, redirect, category_name, parsed, headers= parser.get_thought_from_id(db, thought_id) except TypeError: flask.abort(404) return @@ -71,7 +79,8 @@ def get_thought(): **get_template_items(title, db), md_html = parsed, contents_html = headers, - datetime = "published: " + str(datetime) + datetime = "published: " + str(datetime), + category = category_name ) if __name__ == "__main__": |
