From d6b4dcbf7699543335666c43393f6a25b23815e7 Mon Sep 17 00:00:00 2001 From: citrons Date: Wed, 23 Jun 2021 09:37:17 +0000 Subject: subforum list --- apioforum/forum.py | 16 ++++++++++++++++ apioforum/static/style.css | 33 +++++++++------------------------ apioforum/templates/view_forum.html | 36 ++++++++++++++++++++++++++++++++---- 3 files changed, 57 insertions(+), 28 deletions(-) diff --git a/apioforum/forum.py b/apioforum/forum.py index dadc8b3..e379350 100644 --- a/apioforum/forum.py +++ b/apioforum/forum.py @@ -55,8 +55,24 @@ def view_forum(forum_id): """SELECT * FROM posts WHERE thread = ? ORDER BY created DESC; """,(thread['id'],)).fetchone() + + subforums = db.execute(""" + SELECT * FROM forums WHERE parent = ? ORDER BY name ASC + """,(forum_id,)).fetchall() + + forum_last_activity = {} + for subforum in subforums: + result = db.execute( + """SELECT updated FROM threads + WHERE forum = ? + ORDER BY updated DESC; + """,(subforum['id'],)).fetchone() + forum_last_activity[subforum['id']] = result[0] if result != None else None + return render_template("view_forum.html", forum=forum, + subforums=subforums, + forum_last_activity=forum_last_activity, threads=threads, thread_tags=thread_tags, preview_post=preview_post diff --git a/apioforum/static/style.css b/apioforum/static/style.css index b456e26..fcea239 100644 --- a/apioforum/static/style.css +++ b/apioforum/static/style.css @@ -88,26 +88,27 @@ nav#navbar .links { display: flex; } /* todo: make the navbar less bad */ .flashmsg { border: 1px solid black; background-color: yellow; max-width: max-content; padding: 5px; clear: both;} -.thread-listing:nth-child(even) { background-color: var(--alternating-colour-even) } -.thread-listing:nth-child(odd) { background-color: var(--alternating-colour-odd) } +.listing:nth-child(even) { background-color: var(--alternating-colour-even) } +.listing:nth-child(odd) { background-color: var(--alternating-colour-odd) } -.thread-listing { +.listing { border-left: 1px solid black; border-right: 1px solid black; border-top: 1px solid black; padding: 10px; } -.thread-listing:last-of-type { border-bottom: 1px solid black; } -.thread-listing-main { +.listing:last-of-type { border-bottom: 1px solid black; } +.listing-main { display: flex; align-items: center; } -.thread-listing-title { +.listing-title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; flex-grow: 1; } + .thread-listing-tags { display: flex; align-items: center; @@ -121,7 +122,7 @@ nav#navbar .links { display: flex; } flex-wrap: nowrap; } .thread-listing-creator { margin-right: 5px; } -.thread-preview { +.listing-caption { overflow: hidden; font-size: smaller; white-space: nowrap; @@ -137,7 +138,7 @@ nav#navbar .links { display: flex; } /* wide screens */ @media all and (min-width: 600px) { - .thread-listing-title { font-size: larger; } + .listing-title { font-size: larger; } } /* small screens */ @@ -151,22 +152,6 @@ nav#navbar .links { display: flex; } } } - -.threadlisting-part { - background-color: inherit; - display: table-cell; - vertical-align: middle; - padding: 3px; - text-align: center; -} - -.threadlisting-part-title { - text-overflow: ellipsis; - overflow: hidden; -} - -.threadlisting-header { font-weight: bold } - .actionbutton::before { content: "["; color: grey; diff --git a/apioforum/templates/view_forum.html b/apioforum/templates/view_forum.html index 2044d54..926980e 100644 --- a/apioforum/templates/view_forum.html +++ b/apioforum/templates/view_forum.html @@ -10,6 +10,33 @@ {%block nmcontent%}
{{forum.description|md|safe}} + + +{% if subforums %} +

subforae

+
+ {% for subforum in subforums %} +
+ +
+ {% if forum_last_activity[subforum.id] %} + last activity {{ts(forum_last_activity[subforum.id])}} ago + {% else %} + no threads + {% endif %} +
+
+ {% endfor %} +
+{% endif %} + +

threads

{% if g.user %}

create new thread

{% else %} @@ -17,9 +44,9 @@ {% endif %}
{%for thread in threads%} -
-
-
+
+
+
{{- thread.title -}} @@ -37,7 +64,7 @@
{% if preview_post[thread.id] %} -
+
{{ disp_user(preview_post[thread.id].author) }} {{ ts(preview_post[thread.id].created) }} @@ -52,5 +79,6 @@
{%endfor%}
+
{%endblock%} -- cgit v1.2.3