summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--apioforum/__init__.py3
-rw-r--r--apioforum/auth.py4
-rw-r--r--apioforum/forum.py2
-rw-r--r--apioforum/templates/auth/login.html (renamed from apioforum/templates/auth/login.html.j2)2
-rw-r--r--apioforum/templates/auth/register.html (renamed from apioforum/templates/auth/register.html.j2)2
-rw-r--r--apioforum/templates/base.html (renamed from apioforum/templates/base.html.j2)0
-rw-r--r--apioforum/templates/view_forum.html (renamed from apioforum/templates/view_forum.html.j2)4
-rw-r--r--apioforum/templates/view_thread.html18
-rw-r--r--apioforum/thread.py19
9 files changed, 47 insertions, 7 deletions
diff --git a/apioforum/__init__.py b/apioforum/__init__.py
index 2eacd67..df7185b 100644
--- a/apioforum/__init__.py
+++ b/apioforum/__init__.py
@@ -26,6 +26,9 @@ def create_app():
from . import forum
app.register_blueprint(forum.bp)
+ from . import thread
+ app.register_blueprint(thread.bp)
+
@app.route("/")
def main():
return "the"
diff --git a/apioforum/auth.py b/apioforum/auth.py
index f558025..fe03264 100644
--- a/apioforum/auth.py
+++ b/apioforum/auth.py
@@ -32,7 +32,7 @@ def login():
flash(err)
- return render_template("auth/login.html.j2")
+ return render_template("auth/login.html")
@bp.route("/register", methods=("GET","POST"))
def register():
@@ -62,7 +62,7 @@ def register():
flash(err)
- return render_template("auth/register.html.j2")
+ return render_template("auth/register.html")
@bp.route("/logout")
def logout():
diff --git a/apioforum/forum.py b/apioforum/forum.py
index 7fb1e57..c09b0e8 100644
--- a/apioforum/forum.py
+++ b/apioforum/forum.py
@@ -12,4 +12,4 @@ bp = Blueprint("forum", __name__, url_prefix="/")
def view_forum():
db = get_db()
threads = db.execute("SELECT * FROM threads ORDER BY updated DESC LIMIT 10;").fetchall()
- return render_template("view_forum.html.j2",threads=threads)
+ return render_template("view_forum.html",threads=threads)
diff --git a/apioforum/templates/auth/login.html.j2 b/apioforum/templates/auth/login.html
index c8c67b4..c0a2eed 100644
--- a/apioforum/templates/auth/login.html.j2
+++ b/apioforum/templates/auth/login.html
@@ -1,4 +1,4 @@
-{% extends "base.html.j2" %}
+{% extends "base.html" %}
{% block header %}
<h1>{% block title %}login{% endblock %}</h1>
{% endblock %}
diff --git a/apioforum/templates/auth/register.html.j2 b/apioforum/templates/auth/register.html
index f7eab81..716fa1d 100644
--- a/apioforum/templates/auth/register.html.j2
+++ b/apioforum/templates/auth/register.html
@@ -1,4 +1,4 @@
-{% extends "base.html.j2" %}
+{% extends "base.html" %}
{% block header %}
<h1>{% block title %}register{% endblock %}</h1>
{% endblock %}
diff --git a/apioforum/templates/base.html.j2 b/apioforum/templates/base.html
index 6660686..6660686 100644
--- a/apioforum/templates/base.html.j2
+++ b/apioforum/templates/base.html
diff --git a/apioforum/templates/view_forum.html.j2 b/apioforum/templates/view_forum.html
index fe14652..2140c7a 100644
--- a/apioforum/templates/view_forum.html.j2
+++ b/apioforum/templates/view_forum.html
@@ -1,4 +1,4 @@
-{% extends 'base.html.j2' %}
+{% extends 'base.html' %}
{% block header %}<h1>{% block title %}apio forum george etc{%endblock%}</h1>{%endblock%}
{%block content%}
<p>the</p>
@@ -13,7 +13,7 @@
{%for thread in threads%}
<tr>
<td>#{{thread.id}}</td>
- <td><a href="#">{{thread.title}}</a></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>
diff --git a/apioforum/templates/view_thread.html b/apioforum/templates/view_thread.html
new file mode 100644
index 0000000..34faeea
--- /dev/null
+++ b/apioforum/templates/view_thread.html
@@ -0,0 +1,18 @@
+{% extends 'base.html' %}
+{% block header %}
+<h1>{%block title %}thread{% endblock %}</h1>
+{% endblock %}
+
+{%block content%}
+<h2>{{thread.title}}</h2>
+<p>by {{thread.creator}}</p>
+<dl>
+{% for post in posts %}
+<dt>{{post.author}}</dt>
+<dd>{{post.content}}</dd>
+{% else %}
+<dt>there weren't</dt>
+<dd>any posts</dd>
+{% endfor %}
+</dl>
+{% endblock %}
diff --git a/apioforum/thread.py b/apioforum/thread.py
new file mode 100644
index 0000000..24b7766
--- /dev/null
+++ b/apioforum/thread.py
@@ -0,0 +1,19 @@
+# view posts in thread
+
+from flask import (
+ Blueprint, render_template
+)
+from .db import get_db
+
+bp = Blueprint("thread", __name__, url_prefix="/thread")
+
+@bp.route("/view/<int:thread_id>")
+def view_thread(thread_id):
+ db = get_db()
+ thread = db.execute("SELECT * FROM threads WHERE id = ?;",(thread_id,)).fetchone()
+ if thread is None:
+ abort(404)
+ else:
+ posts = db.execute("SELECT * FROM posts WHERE thread = ? ORDER BY idx;",(thread_id,)).fetchall()
+ return render_template("view_thread.html",posts=posts,thread=thread)
+