From f2fb2736afac2326a8ed16d702a9a6a2d10101d0 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Tue, 15 Jun 2021 19:12:30 +0000 Subject: display tags on thread page --- apioforum/static/style.css | 14 ++++++++++++++ apioforum/templates/view_thread.html | 21 ++++++++++++++++----- apioforum/thread.py | 6 +++++- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/apioforum/static/style.css b/apioforum/static/style.css index 0672548..66f7faa 100644 --- a/apioforum/static/style.css +++ b/apioforum/static/style.css @@ -30,6 +30,20 @@ body { font-family: sans-serif } .post-anchor-link { color: hsl(0,0%,25%); } +.thread-top-bar { + margin-bottom: 4px; +} + +.thread-top-bar-b { + float: right; + margin-right: -2px; +} + +.thread-top-bar-b .tag { + font-size: .9rem; +} + + .un-col-1 { color: hsl(0, 100%, 30%) } .un-col-2 { color: hsl(22.5, 100%, 30%) } .un-col-3 { color: hsl(45.0, 100%, 30%) } diff --git a/apioforum/templates/view_thread.html b/apioforum/templates/view_thread.html index eaaf581..abd6aaa 100644 --- a/apioforum/templates/view_thread.html +++ b/apioforum/templates/view_thread.html @@ -1,13 +1,24 @@ -{% from 'common.html' import disp_post %} +{% from 'common.html' import disp_post,tag %} {% extends 'base.html' %} {% block header %}

{%block title %}{{thread.title}}{% endblock %}

{% endblock %} {%block content%} -{% if g.user == thread.creator %} -configure thread -{% endif %} +
+ + {% if g.user == thread.creator %} + configure thread + {% endif %} + +   + + {% for the_tag in tags %} + {{ tag(the_tag) }} + {% endfor %} + +
+
{% for post in posts %} {% call disp_post(post, True) %} @@ -16,7 +27,7 @@ {% endfor %}
{% if g.user %} -
+
diff --git a/apioforum/thread.py b/apioforum/thread.py index 12ced72..e881a69 100644 --- a/apioforum/thread.py +++ b/apioforum/thread.py @@ -23,8 +23,12 @@ def view_thread(thread_id): "SELECT * FROM posts WHERE thread = ? ORDER BY created ASC;", (thread_id,) ).fetchall() + tags = db.execute( + """SELECT tags.* FROM tags + INNER JOIN thread_tags ON thread_tags.tag = tags.id + WHERE thread_tags.thread = ?""",(thread_id,)).fetchall() rendered_posts = [render(q['content']) for q in posts] - return render_template("view_thread.html",posts=posts,thread=thread,thread_id=thread_id,rendered_posts=rendered_posts) + return render_template("view_thread.html",posts=posts,thread=thread,rendered_posts=rendered_posts,tags=tags) @bp.route("//create_post", methods=("POST",)) def create_post(thread_id): -- cgit v1.2.3