aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorubq323 <ubq323>2021-06-15 19:12:30 +0000
committerubq323 <ubq323>2021-06-15 19:12:30 +0000
commitf2fb2736afac2326a8ed16d702a9a6a2d10101d0 (patch)
tree1a7997cf9ee85e949249a612dad97c519d302f4d
parent8481d0c07475aee7b9ad4a6aa899bcc9af437e64 (diff)
display tags on thread page
-rw-r--r--apioforum/static/style.css14
-rw-r--r--apioforum/templates/view_thread.html21
-rw-r--r--apioforum/thread.py6
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 %}
<h1>{%block title %}{{thread.title}}{% endblock %}</h1>
{% endblock %}
{%block content%}
-{% if g.user == thread.creator %}
-<a class="actionbutton" href="{{url_for('thread.config_thread',thread_id=thread_id)}}">configure thread</a>
-{% endif %}
+<div class="thread-top-bar">
+ <span class="thread-top-bar-a">
+ {% if g.user == thread.creator %}
+ <a class="actionbutton" href="{{url_for('thread.config_thread',thread_id=thread.id)}}">configure thread</a>
+ {% endif %}
+ </span>
+ &nbsp;
+ <span class="thread-top-bar-b">
+ {% for the_tag in tags %}
+ {{ tag(the_tag) }}
+ {% endfor %}
+ </span>
+</div>
+
<div class="posts">
{% for post in posts %}
{% call disp_post(post, True) %}
@@ -16,7 +27,7 @@
{% endfor %}
</div>
{% if g.user %}
-<form class="new-post" action="{{url_for('thread.create_post',thread_id=thread_id)}}" method="POST">
+<form class="new-post" action="{{url_for('thread.create_post',thread_id=thread.id)}}" method="POST">
<textarea class="new-post-box" placeholder="your post here..." name="content"></textarea>
<input type="submit" value="yes">
</form>
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("/<int:thread_id>/create_post", methods=("POST",))
def create_post(thread_id):