diff options
author | ubq323 <ubq323> | 2021-07-25 22:58:20 +0000 |
---|---|---|
committer | ubq323 <ubq323> | 2021-07-25 22:58:20 +0000 |
commit | a69e0cc27e41d9b71d23b94cf8bc1421dbba14df (patch) | |
tree | fc62fc7643b50b7f6c165fc3afe52d9137a206ac | |
parent | a53f2d70c880812e9a6e40dcee236d9099d10018 (diff) |
add page links nav thing
-rw-r--r-- | apioforum/forum.py | 5 | ||||
-rw-r--r-- | apioforum/templates/view_forum.html | 14 |
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"><<</a> + <a href="{{url_for('forum.view_forum',forum_id=forum.id,page=page-1)}}" aria-label="previous page"><</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">></a> + <a href="{{url_for('forum.view_forum',forum_id=forum.id,page=max_pageno)}}" aria-label="last page">>></a> + {% endif %} +</nav> + + +</nav> </main> {%endblock%} |