diff options
author | ubq323 <ubq323> | 2021-06-06 16:54:26 +0000 |
---|---|---|
committer | ubq323 <ubq323> | 2021-06-06 16:54:26 +0000 |
commit | e2b8fc0582776a366def582d73b686c8968b44c3 (patch) | |
tree | 454bbc31040f1ca14a898d19bb7d749181dfff3f | |
parent | 6a2a05cd0e6aab46ca610dda3c2f408c6b9bd9e2 (diff) |
slightly improve css, add stubs of edit and delete, refactor some things
-rw-r--r-- | apioforum/static/style.css | 56 | ||||
-rw-r--r-- | apioforum/templates/base.html | 4 | ||||
-rw-r--r-- | apioforum/templates/common.html | 24 | ||||
-rw-r--r-- | apioforum/templates/view_forum.html | 25 | ||||
-rw-r--r-- | apioforum/templates/view_thread.html | 14 | ||||
-rw-r--r-- | apioforum/thread.py | 8 |
6 files changed, 106 insertions, 25 deletions
diff --git a/apioforum/static/style.css b/apioforum/static/style.css new file mode 100644 index 0000000..90b3b83 --- /dev/null +++ b/apioforum/static/style.css @@ -0,0 +1,56 @@ +body { font-family: sans-serif } + +.post { margin: 0px; } +.post:nth-child(even) { background-color: #eee } +.post:nth-child(odd) { background-color: #ddd } +.post { + border-left: 1px solid black; + border-right: 1px solid black; + border-top: 1px solid black; +} +.post:last-of-type { border-bottom: 1px solid black; } + +.post-heading { + color: grey; + font-size: smaller; +} +.post-content > * { margin-bottom: 0 } +.post-content > *:nth-child(1) { margin-top: 2px } + +img { max-width: 100% } + +.post-heading-b { float: right; margin-right: 0.5em } + +nav ul { list-style-type: none; margin: 0px; padding: 0px } +nav { width:max-content; padding: 5px; margin: 2px; border: 1px solid black } +nav li { margin-left: 15px; margin-bottom: 10px; margin-right: 10px } +nav li {display: inline } +nav li:first-of-type { margin-left:0.5em } +nav { float: right } +nav a { color: blue; text-decoration: none } + +.flashmsg { border: 1px solid black; background-color: yellow; width: max-content; padding: 5px; } + +.threadlisting:nth-child(even) { background-color: #eee } +.threadlisting:nth-child(odd) { background-color: #ddd } + +.threadlisting { display: flex; flex-flow: row wrap; text-align: center } +.threadlisting-part { flex: 1 0px; display: table-cell; vertical-align: middle; } +.threadlisting-part-title { flex: 3 0px } +@media all and (max-width: 800px) { + .threadlisting-part-title { flex: 2 100%; } + .threadlisting { margin-bottom: 5px; } +} + +.threadlisting-part-id { flex: 0.4 0px; } + +.threadlisting-part { border: 1px solid black } + +.actionbutton::before { + content: "["; + color: grey; +} +.actionbutton::after { + content: "]"; + color: grey; +} diff --git a/apioforum/templates/base.html b/apioforum/templates/base.html index ef60264..626d88d 100644 --- a/apioforum/templates/base.html +++ b/apioforum/templates/base.html @@ -10,6 +10,9 @@ <main> <nav> <ul> + <li> + <span style="font-family: monospace;"><b>apio</b><i>forum</i>™</span> + </li> {% if g.user %} <li>{{ g.user }}</li> @@ -30,6 +33,7 @@ {%block content %}{% endblock %} </main> + <script>/* bees */</script> </body> </html> diff --git a/apioforum/templates/common.html b/apioforum/templates/common.html new file mode 100644 index 0000000..a547f73 --- /dev/null +++ b/apioforum/templates/common.html @@ -0,0 +1,24 @@ +{% macro disp_post(post, thread_id, buttons=False) %} +<div class="post"> + <div class="post-heading"> + <span class="post-heading-a"> + {{post.author}} @{{post.created}} #{{post.id}} + </span> + {% if buttons and post.author == g.user %} + <span class="post-heading-b"> + <a class="actionbutton" + href="{{url_for('thread.edit_post',post_id=post.id,thread_id=thread_id)}}"> + edit + </a> + <a class="actionbutton" + href="{{url_for('thread.delete_post',post_id=post.id,thread_id=thread_id)}}"> + delete + </a> + </span> + {% endif %} + </div> + <div class="post-content"> + {{ caller() }} + </div> +</div> +{% endmacro %} diff --git a/apioforum/templates/view_forum.html b/apioforum/templates/view_forum.html index 13e35a8..c7f88f1 100644 --- a/apioforum/templates/view_forum.html +++ b/apioforum/templates/view_forum.html @@ -3,22 +3,15 @@ {%block content%} <p>the</p> <a href="{{url_for('forum.create_thread')}}">create thread</a> -<table> - <tr> - <th>id</th> - <th>title</th> - <th>creator</th> - <th>created</th> - <th>updated</th> - </tr> +<div class="threadlistings"> {%for thread in threads%} -<tr> - <td>#{{thread.id}}</td> - <td><a href="{{url_for('thread.view_thread',thread_id=thread.id)}}">{{thread.title}}</a></td> - <td>{{thread.creator}}</td> - <td>{{thread.created}}</td> - <td>{{thread.updated}}</td> -</tr> +<div class="threadlisting"> + <div class="threadlisting-part threadlisting-part-title"><a href="{{url_for('thread.view_thread',thread_id=thread.id)}}">{{thread.title}}</a></div> + <div class="threadlisting-part threadlisting-part-id">#{{thread.id}}</div> + <div class="threadlisting-part threadlisting-part-creator">{{thread.creator}}</div> + <div class="threadlisting-part threadlisting-part-created">{{thread.created}}</div> + <div class="threadlisting-part threadlisting-part-updated">{{thread.updated}}</div> +</div> {%endfor%} -</table> +</div> {%endblock%} diff --git a/apioforum/templates/view_thread.html b/apioforum/templates/view_thread.html index d9efe86..acd062f 100644 --- a/apioforum/templates/view_thread.html +++ b/apioforum/templates/view_thread.html @@ -1,3 +1,4 @@ +{% from 'common.html' import disp_post %} {% extends 'base.html' %} {% block header %} <h1>{%block title %}{{thread.title}}{% endblock %}</h1> @@ -6,14 +7,9 @@ {%block content%} <div class="posts"> {% for post in posts %} - <div class="post"> - <div class="post_heading"> - {{post.author}} @{{post.created}} - </div> - <div class="post_content"> - {{rendered_posts[loop.index0] | safe}} - </div> - </div> + {% call disp_post(post, thread_id, True) %} + {{ rendered_posts[loop.index0] | safe}} + {% endcall %} {% endfor %} </div> {% if g.user %} @@ -22,6 +18,6 @@ <input type="submit" value="yes"> </form> {% else %} -<p>not logged in</p> +<p>please log in to reply to this thread</p> {% endif %} {% endblock %} diff --git a/apioforum/thread.py b/apioforum/thread.py index 638ff7f..f22ca85 100644 --- a/apioforum/thread.py +++ b/apioforum/thread.py @@ -49,3 +49,11 @@ def create_post(thread_id): db.commit() flash("post posted postfully") return redirect(url_for('thread.view_thread',thread_id=thread_id)) + +@bp.route("/<int:thread_id>/delete_post/<int:post_id>", methods=["GET","POST"]) +def delete_post(thread_id, post_id): + return f"todo (t: {thread_id}, p: {post_id})" + +@bp.route("/<int:thread_id>/edit_post/<int:post_id>",methods=["GET","POST"]) +def edit_post(thread_id, post_id): + return f"todo (t: {thread_id}, p: {post_id})" |