summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app.py12
-rw-r--r--models.py4
-rw-r--r--templates/index.html15
-rw-r--r--templates/post.html8
-rw-r--r--templates/view_thread.html4
5 files changed, 27 insertions, 16 deletions
diff --git a/app.py b/app.py
index 2653dde..5256939 100644
--- a/app.py
+++ b/app.py
@@ -4,7 +4,15 @@ from urllib.parse import urlparse as url_parse
 from flask import Flask, render_template, request, redirect, url_for, flash
 from markdown import markdown, Markdown
 from config import config
-from models import Post, db, get_replies, Faccet, get_previous, get_attribed_posts
+from models import (
+    Post,
+    db,
+    get_replies,
+    Faccet,
+    get_previous,
+    get_attribed_posts,
+    get_tview,
+)
 from models import User as NewUser
 from forms import PostForm, LoginForm
 from flask_login import (
@@ -148,7 +156,7 @@ def faccets():
 @login_required
 def thread(post_id):
     thread = Post.get(Post.id == post_id)
-    pdx = get_replies(post_id)
+    pdx = get_tview(post_id)
     return render_template("view_thread.html", thread=thread, pdx=pdx)
 
 
diff --git a/models.py b/models.py
index b435a40..b476d2c 100644
--- a/models.py
+++ b/models.py
@@ -64,4 +64,8 @@ def get_attribed_posts(uid):
     return Post.select().where(Post.authour == uid).order_by(Post.created_at.asc())
 
 
+def get_tview(post_id):
+    return Post.select().where(Post.parent == post_id).order_by(Post.id.asc())
+
+
 db.create_tables([User, Post, Faccet])
diff --git a/templates/index.html b/templates/index.html
index 9a05e7a..b18ca34 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -1,11 +1,12 @@
 {% extends 'base.html' %}
 
 {% block content %}
-    <h2>Posts</h2>
-    <ul>
-        {% for post in posts %}
-            <li><a href="{{ url_for('post', post_id=post.id) }}">{{ post.title }}</a> - {{ post.created_at.strftime('%Y-%m-%d') }}</li>
-        {% endfor %}
-    </ul>
-    <a href="{{ url_for('create') }}">Create a new post</a>
+<h2>Posts</h2>
+<ul>
+    {% for post in posts %}
+    <li><a href="{{ url_for('thread', post_id=post.id) }}">{{ post.title }}</a> - {{
+        post.created_at.strftime('%Y-%m-%d') }}</li>
+    {% endfor %}
+</ul>
+<a href="{{ url_for('create') }}">Create a new post</a>
 {% endblock %}
\ No newline at end of file
diff --git a/templates/post.html b/templates/post.html
index 4d37ed9..5e14c52 100644
--- a/templates/post.html
+++ b/templates/post.html
@@ -26,13 +26,9 @@
 {% endif %}
 <h2>{{ post.title }}</h2>
 <p>{{ post.created_at.strftime('%Y-%m-%d %H:%M') }}</p>
+<p> Authour: {{post.authour.name}}</p>
+<div>{{ post.content|markdown|safe }}</div>
 
-<div class="container">
-    <div class="userbox">
-        <p> Authour: <a href="{{url_for('details', light=post.authour.name)}}"> {{post.authour.name}} </a></p>
-    </div>
-    <div class="post-content">{{ post.content|markdown|safe }}</div>
-</div>
 <div class="post-actions">
     <a href="{{ url_for('create', reply=post.id)}}"> Reply</a> ~
     <a href="{{ url_for('index') }}">Back to posts</a>
diff --git a/templates/view_thread.html b/templates/view_thread.html
index 877feb8..6696462 100644
--- a/templates/view_thread.html
+++ b/templates/view_thread.html
@@ -13,7 +13,9 @@
     </div>
     <div class="post-content">
         <p>
-        <h4> {{post.title}} </h4>
+            <a href="{{url_for('post', post_id=post.id)}}">
+                <h4> {{post.title}} </h4>
+            </a>
         </p>
         {{ post.content|markdown|safe }}
     </div>