From 69240eafea18a4505bedc60cc9f79aa38ac9abd1 Mon Sep 17 00:00:00 2001
From: citrons
Date: Sat, 14 Jun 2025 01:03:34 -0500
Subject: integrated subforum list
the UI is more compact and aesthetically pleasing, and it allows seeing
activity in subforae more easily. as it stands, all subforae are hidden
away, so no one sees anything that anyone posts in them! this UI
implicitly shows up to four unread subforae.
---
apioforum/forum.py | 20 ++++++++---
apioforum/static/style.css | 21 ++++++++++++
apioforum/templates/view_forum.html | 68 ++++++++++++++++++++++---------------
3 files changed, 77 insertions(+), 32 deletions(-)
diff --git a/apioforum/forum.py b/apioforum/forum.py
index ce90853..c0c0ba4 100644
--- a/apioforum/forum.py
+++ b/apioforum/forum.py
@@ -216,16 +216,27 @@ def view_forum(forum,page=1):
LEFT OUTER JOIN threads ON threads.forum=forums.id
WHERE parent = ? AND unlisted = 0
GROUP BY forums.id
- ORDER BY name ASC
+ ORDER BY forums.updated DESC
""",(forum['id'],)).fetchall()
- subforums = []
+ unread_subforums = []
+ read_subforums = []
for s in subforums_rows:
a={}
a.update(s)
if a['updated'] is not None:
a['updated'] = datetime.datetime.fromisoformat(a['updated'])
if has_permission(a['id'],g.user,"p_view_forum",login_required=False):
- subforums.append(a)
+ if not read.is_read('forum', a['id']):
+ unread_subforums.append(a)
+ else:
+ read_subforums.append(a)
+
+ shown_subforums = unread_subforums[:4]
+ if len(shown_subforums) > 0:
+ hidden_subforums = unread_subforums[4:] + read_subforums
+ else:
+ shown_subforums = read_subforums[:1]
+ hidden_subforums = read_subforums[1:]
bureaucrats = db.execute("""
SELECT user FROM role_assignments
@@ -242,7 +253,8 @@ def view_forum(forum,page=1):
return render_template("view_forum.html",
forum=forum,
- subforums=subforums,
+ shown_subforums=shown_subforums,
+ hidden_subforums=hidden_subforums,
threads=threads,
thread_tags=thread_tags,
bureaucrats=bureaucrats,
diff --git a/apioforum/static/style.css b/apioforum/static/style.css
index 63c7347..2ca0e51 100644
--- a/apioforum/static/style.css
+++ b/apioforum/static/style.css
@@ -7,6 +7,7 @@ body { font-family: sans-serif; word-wrap: break-word; }
--gray: darkgray;
--light-colour: white;
--username-colour: hsl(0, 0%, 25%);
+ --grayish: hsl(0, 0%, 80%);
--read-colour: hsl(0, 0%, 30%);
--red: red;
--yellow: yellow;
@@ -198,6 +199,7 @@ nav#pages .pageno { align-self: center; }
border-left: 1px solid var(--dark-colour);
border-right: 1px solid var(--dark-colour);
border-top: 1px solid var(--dark-colour);
+ margin-top: -1px;
padding: 10px;
}
.listing:last-of-type { border-bottom: 1px solid var(--dark-colour); }
@@ -222,6 +224,24 @@ nav#pages .pageno { align-self: center; }
color: var(--dark-colour);
}
+.listing-header, .more-subforums summary {
+ font-weight: normal;
+ font-size: smaller;
+ border-left: 1px solid var(--dark-colour);
+ border-right: 1px solid var(--dark-colour);
+ border-top: 1px solid var(--dark-colour);
+ margin-top: -1px;
+ margin-bottom: 0;
+ padding: 2px 10px 2px 10px;
+ text-align: center;
+ color: var(--dark-colour);
+ background-color: var(--grayish);
+}
+
+.more-subforums summary {
+ background-color: var(--alternating-colour-even);
+}
+
.thread-listing-tags {
display: flex;
align-items: center;
@@ -368,6 +388,7 @@ textarea {
--alternating-colour-odd: hsl(0, 0%, 15%);
--dark-colour: white;
--gray: lightgray;
+ --grayish: hsl(0, 0%, 20%);
--light-colour: black;
--username-colour: hsl(0, 0%, 80%);
--read-colour: hsl(0, 0%, 70%);
diff --git a/apioforum/templates/view_forum.html b/apioforum/templates/view_forum.html
index 7732b21..7640439 100644
--- a/apioforum/templates/view_forum.html
+++ b/apioforum/templates/view_forum.html
@@ -42,34 +42,6 @@
{% endif %}
-{% if subforums %}
-subforæ
-
-show subforæ
-
- {% for subforum in subforums %}
-
-
-
- {% if subforum.updated %}
- last activity {{ts(subforum.updated)}} ago
- {% else %}
- no threads
- {% endif %}
-
-
- {% endfor %}
-
-
-{% endif %}
-
-threads
{% if has_permission(forum.id, g.user, "p_create_threads") %}
create new thread
@@ -126,7 +98,47 @@ you do not have permission to create threads in this forum
+
+
{{ pagination_nav(page,max_pageno,'forum.view_forum',forum_id=forum.id) }}
+
+{% macro subforum_listing(subforum) %}
+
+
+
+ {% if subforum.updated %}
+ last activity {{ts(subforum.updated)}} ago
+ {% else %}
+ no threads
+ {% endif %}
+
+
+{% endmacro %}
+
+{% if page == 1 and shown_subforums %}
+
+
+ {% for subforum in shown_subforums %}
+ {{subforum_listing(subforum)}}
+ {% endfor %}
+ {% if hidden_subforums %}
+
+ more...
+ {% for subforum in hidden_subforums %}
+ {{subforum_listing(subforum)}}
+ {% endfor %}
+
+ {% endif %}
+
+
+{% endif %}
+
{%for thread in threads%}
--
cgit v1.2.3