From 724e0ac3d9d5b7f3189103c3850fbc6f9120cf73 Mon Sep 17 00:00:00 2001 From: 0x01fe Date: Mon, 1 Jul 2024 09:35:53 -0500 Subject: [PATCH] consolidated some pages --- app/app.py | 48 +++++++++++++++--------------- app/templates/about.html | 8 ++--- app/templates/games.html | 35 ---------------------- app/templates/index.html | 8 ++--- app/templates/motion-pictures.html | 35 ---------------------- app/templates/music.html | 34 +++++++++++++++++---- app/templates/programming.html | 34 +++++++++++++++++---- 7 files changed, 90 insertions(+), 112 deletions(-) delete mode 100644 app/templates/games.html delete mode 100644 app/templates/motion-pictures.html diff --git a/app/app.py b/app/app.py index 99679d7..b687b85 100644 --- a/app/app.py +++ b/app/app.py @@ -139,7 +139,7 @@ def index(): # Setup Comment Form form = comment.CommentForm() - return flask.render_template('index.html', posts=posts_and_comments, status=status, form=form, user=user) + return flask.render_template('index.html', posts=posts_and_comments, status=status, form=form, user=user, title='0x01fe.net') # Posts @app.route('/post/') @@ -157,25 +157,41 @@ def post(post_name: str): # Setup Comment Form form = comment.CommentForm() - return flask.render_template('index.html', posts=[[{'body': post.body, 'title': post.title}, comments]], status=get_status(), form=form, user=user) + return flask.render_template('index.html', posts=[[{'body': post.body, 'title': post.title}, comments]], status=get_status(), form=form, user=user, title='0x01fe.net') flask.abort(404) # Games Page -@app.route('/games/') -def games(): +@app.route('/category//') +def category_filter(category: str): # Get posts - posts = get_posts(category_filter="games") + posts = get_posts(category_filter=category) - post_bodies = [] + if 'username' in flask.session: + user = flask.session['username'] + else: + user = 'Anon' + + # Get Comments + posts_and_comments = [] for post in posts: - post_bodies.append(post.body) + + comments = comment.get_comments(post.title) + posts_and_comments.append(({ + "body" : post.body, + "title" : post.title, + "date" : post.get_date() + }, + comments)) # Get status status = get_status() - return flask.render_template('games.html', posts=post_bodies, status=status) + # Setup Comment Form + form = comment.CommentForm() + + return flask.render_template('index.html', posts=posts_and_comments, status=status, form=form, user=user, title=category.replace('-', ' ')) # Music Page @app.route('/music/') @@ -211,22 +227,6 @@ def music(): return flask.render_template('music.html', posts=post_bodies, status=status, top_albums=top_albums) -# Motion Pictures Page -@app.route('/motion-pictures/') -def motion_pictures(): - - # Get posts - posts = get_posts(category_filter="motion-pictures") - - post_bodies = [] - for post in posts: - post_bodies.append(post.body) - - # Get status - status = get_status() - - return flask.render_template('motion-pictures.html', posts=post_bodies, status=status) - # Programming Page @app.route('/programming/') def programming(): diff --git a/app/templates/about.html b/app/templates/about.html index 822612a..d85d1ce 100644 --- a/app/templates/about.html +++ b/app/templates/about.html @@ -13,13 +13,13 @@
diff --git a/app/templates/games.html b/app/templates/games.html deleted file mode 100644 index 9a36348..0000000 --- a/app/templates/games.html +++ /dev/null @@ -1,35 +0,0 @@ - - -
- - - 0x01fe.net - Games -
- -
-

Games

- {{ status|safe }} -
-
- - - - - -
- {% for post in posts %} -
{{ post|safe }}
- {% endfor %} -
-
- - diff --git a/app/templates/index.html b/app/templates/index.html index a38e515..a395ad5 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -3,20 +3,20 @@
- 0x01fe.net + 0x01fe.net - {{ title }}
-

0x01fe.net

+

{{ title }}

{{ status|safe }}