From 09cb2df004ef2eb1f96b09598e0e0a5d88e946e3 Mon Sep 17 00:00:00 2001 From: David Hoppenbrouwers Date: Fri, 7 Oct 2022 19:13:16 +0200 Subject: [PATCH] Add theme --- main.py | 4 ++ static/theme.css | 91 ++++++++++++++++++++++++++++ templates/base.html | 16 +++-- templates/comment.html | 20 ++++-- templates/comments.html | 7 ++- templates/confirm_delete_thread.html | 14 +++-- templates/index.html | 11 +++- templates/new_thread.html | 14 ++++- templates/subforum.html | 13 ++-- templates/thread.html | 2 +- templates/user_edit.html | 4 +- 11 files changed, 164 insertions(+), 32 deletions(-) create mode 100644 static/theme.css diff --git a/main.py b/main.py index 9532faa..eacc23a 100644 --- a/main.py +++ b/main.py @@ -46,9 +46,13 @@ def comment(comment_id): user_id = session.get('user_id') thread_id, parent_id, title, comments = db.get_subcomments(comment_id) comments = create_comment_tree(comments) + reply_comment, = comments + comments = reply_comment.children + reply_comment.children = [] return render_template( 'comments.html', title = title, + reply_comment = reply_comment, comments = comments, parent_id = parent_id, thread_id = thread_id, diff --git a/static/theme.css b/static/theme.css new file mode 100644 index 0000000..f76324d --- /dev/null +++ b/static/theme.css @@ -0,0 +1,91 @@ +body { + margin: 0; + font-family: sans-serif; + background-color: #f2f2e2; + margin-bottom: 30px; +} + +body > * { + padding-left: 1em; + padding-right: 1em; +} + +nav { + padding: 0; + display: flex; + flex-direction: row; + flex-wrap: nowrap; + overflow-x: auto; + background-color: #ffca4b; +} + +nav > * { + margin-top: auto; + margin-bottom: auto; + padding: 20px; + color: black; +} + +main { + width: 80%; + margin: auto; +} + +a { + text-decoration: none; +} + +table { + border-collapse: collapse; + width: 100%; +} + +tr:not(:last-child) { + border-bottom: 1px solid; +} + +th, td { + padding: 5px; + text-align: left; +} + +textarea { + width: 50em; + height: 15em; + font-size: 1em; +} + +input[type=text] { + width: 50em; + font-family: monospace; + font-size: 1em; +} + +.logo { + margin: 0; + padding: 5px; + padding-left: 15px; + font-size: 3em; + font-weight: bold; +} + +table.form { + border-collapse: unset; + width: auto; +} + +table.form > * > tr > td, th { + vertical-align: top; +} + +.comment { + margin-left: 20px; + padding-left: 10px; + border-left: 1px dotted; +} + +.flash.success { + background-color: #ff4646; + border-radius: 5px; + padding: 8px; +} diff --git a/templates/base.html b/templates/base.html index 618d6b1..f444d8b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,23 +1,27 @@ {{ title }} + + + -

{{ title }}

- {% for category, msg in get_flashed_messages(True) %} -

{{ category}}: {{ msg }}

- {% endfor %}
+

{{ title }}

+ {% for category, msg in get_flashed_messages(True) %} +

{{ msg }}

+ {% endfor %} {% block content %}{% endblock %}
diff --git a/templates/comment.html b/templates/comment.html index b988c96..7387480 100644 --- a/templates/comment.html +++ b/templates/comment.html @@ -1,19 +1,27 @@ -{% macro render_comment(comment) %} -
-

{{ comment.author }}

+{% macro render_comment_pre(comment) %} +
+

{{ comment.author }}

{{ comment.text }}

- reply +{% endmacro %} + +{% macro render_comment_post(comment) %} {% for c in comment.children %} {{ render_comment(c) }} {% endfor %}
{% endmacro %} +{% macro render_comment(comment) %} +{{ render_comment_pre(comment) }} +reply +{{ render_comment_post(comment) }} +{% endmacro %} + {% macro reply() %} {% if 'user_id' in session %}
- - +

+

{% endif %} {% endmacro %} diff --git a/templates/comments.html b/templates/comments.html index 731b2e6..9642482 100644 --- a/templates/comments.html +++ b/templates/comments.html @@ -1,5 +1,5 @@ {% extends 'base.html' %} -{% from 'comment.html' import render_comment, reply %} +{% from 'comment.html' import render_comment, render_comment_pre, render_comment_post, reply %} {% block content %} thread @@ -7,9 +7,14 @@ parent {% endif %} +{{ render_comment_pre(reply_comment) }} + {{ reply() }} {% for c in comments %} {{ render_comment(c) }} {% endfor %} + +{{ render_comment_post(reply_comment) }} + {% endblock %} diff --git a/templates/confirm_delete_thread.html b/templates/confirm_delete_thread.html index fc78442..47f69b3 100644 --- a/templates/confirm_delete_thread.html +++ b/templates/confirm_delete_thread.html @@ -2,10 +2,12 @@ {% block content %}

Are you sure you want to delete "{{ thread_title }}"?

-
- -
-
- -
+

+

+ +
+
+ +
+

{% endblock %} diff --git a/templates/index.html b/templates/index.html index 962e8bc..71ad5c8 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,9 +1,14 @@ {% extends 'base.html' %} {% block content %} -
{% endif %} -

{{ author }} - rjgoire

+{{ author }}

{{ text }}

{{ reply() }} diff --git a/templates/user_edit.html b/templates/user_edit.html index f32fd7d..73079d9 100644 --- a/templates/user_edit.html +++ b/templates/user_edit.html @@ -3,7 +3,7 @@ {% block content %}

{{ name }}

- - +

+

{% endblock %}