summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--apioforum/forum.py5
-rw-r--r--apioforum/templates/view_forum.html14
2 files changed, 17 insertions, 2 deletions
diff --git a/apioforum/forum.py b/apioforum/forum.py
index 69a05c5..3a5dbe3 100644
--- a/apioforum/forum.py
+++ b/apioforum/forum.py
@@ -75,8 +75,7 @@ def view_forum(forum_id,page=1):
# XXX: update this when thread filtering happens
num_threads = db.execute("SELECT count(*) AS count FROM threads WHERE threads.forum = ?",(forum_id,)).fetchone()['count']
- num_pages = math.ceil(num_threads/THREADS_PER_PAGE)
-
+ max_pageno = math.ceil(num_threads/THREADS_PER_PAGE)
thread_tags = {}
thread_polls = {}
@@ -137,6 +136,8 @@ def view_forum(forum_id,page=1):
thread_tags=thread_tags,
thread_polls=thread_polls,
avail_tags=avail_tags,
+ max_pageno=max_pageno,
+ page=page,
)
@bp.route("/<int:forum_id>/create_thread",methods=("GET","POST"))
diff --git a/apioforum/templates/view_forum.html b/apioforum/templates/view_forum.html
index 475fdc2..9c3c2c5 100644
--- a/apioforum/templates/view_forum.html
+++ b/apioforum/templates/view_forum.html
@@ -92,5 +92,19 @@ please log in to create a new thread
</div>
{%endfor%}
</div>
+<nav id="pages">
+ {% if page > 1 %}
+ <a href="{{url_for('forum.view_forum',forum_id=forum.id)}}" aria-label="first page">&lt;&lt;</a>
+ <a href="{{url_for('forum.view_forum',forum_id=forum.id,page=page-1)}}" aria-label="previous page">&lt;</a>
+ {% endif %}
+ page {{page}} of {{max_pageno}}
+ {% if page < max_pageno %} {# > #}
+ <a href="{{url_for('forum.view_forum',forum_id=forum.id,page=page+1)}}" aria-label="next page">&gt;</a>
+ <a href="{{url_for('forum.view_forum',forum_id=forum.id,page=max_pageno)}}" aria-label="last page">&gt;&gt;</a>
+ {% endif %}
+</nav>
+
+
+</nav>
</main>
{%endblock%}