diff --git a/suchwow/app.py b/suchwow/app.py index c31c2b8..8a7ba73 100644 --- a/suchwow/app.py +++ b/suchwow/app.py @@ -1,5 +1,6 @@ import json import click +from math import ceil from datetime import datetime, timedelta from random import choice from os import makedirs, path, remove @@ -30,7 +31,7 @@ app.register_blueprint(api.bp) @app.route("/") def index(): - itp = 20 + itp = 15 page = request.args.get("page", 1) submitter = request.args.get("submitter", None) try: @@ -42,9 +43,15 @@ def index(): posts = Post.select().where(Post.approved==True).order_by(Post.timestamp.desc()) if submitter: posts = posts.where(Post.submitter == submitter) - posts = posts.paginate(page, itp) - total_pages = Post.select().count() / itp - return render_template("index.html", posts=posts, page=page, total_pages=total_pages) + + paginated_posts = posts.paginate(page, itp) + total_pages = ceil(posts.count() / itp) + return render_template( + "index.html", + posts=paginated_posts, + page=page, + total_pages=total_pages + ) @app.route("/mod") @moderator_required diff --git a/suchwow/static/css/wow.css b/suchwow/static/css/wow.css index e4efe68..53c7e2e 100755 --- a/suchwow/static/css/wow.css +++ b/suchwow/static/css/wow.css @@ -791,3 +791,7 @@ ul.b { .navbar-nav { flex-direction: row; } + +.current-page-btn { + font-size: 1.5em; +} diff --git a/suchwow/templates/index.html b/suchwow/templates/index.html index 0369739..b7bf868 100644 --- a/suchwow/templates/index.html +++ b/suchwow/templates/index.html @@ -40,16 +40,11 @@
No posts yet!
{% endif %} - -{% if page %} - {% if page > 1 %} - Back - {% endif %} - - {% if page < total_pages and total_pages > 0 %} - Next - {% endif %} -{% endif %} +