From 15b1d3999ab34d0e6b0fd3104eacf0d248ea97e8 Mon Sep 17 00:00:00 2001 From: Rupus Reinefjord Date: Fri, 12 Jan 2018 00:19:34 +0100 Subject: [PATCH] page nav for photo gallery --- app.py | 11 +++++++++-- static/css/style.css | 9 +++++++++ templates/photography.html | 9 +++++++++ templates/view_photo.html | 1 + 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index d961c3a..342df40 100644 --- a/app.py +++ b/app.py @@ -141,8 +141,15 @@ def index(): @app.route('/photo/', defaults={'page': 1}) @app.route('/photo/page/') def photography(page): - photos = Photo.select().order_by(Photo.timestamp.desc()).paginate(page, 9) - return flask.render_template('photography.html', photos=photos) + query = Photo.select().order_by(Photo.timestamp.desc()) + + photos = query.paginate(page, 9) or flask.abort(404) + has_next = bool(query.paginate(page+1, 9)) + + return flask.render_template('photography.html', + photos=photos, + page=page, + has_next=has_next) @app.route('/photo/') diff --git a/static/css/style.css b/static/css/style.css index d82e348..ac6b837 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -95,6 +95,15 @@ nav ul { .view-image nav { align-self: center; +} + +.photo-grid + nav { + margin-left: auto; + margin-right: auto; +} + +.view-image nav, +.photo-grid + nav { margin-top: 2rem; max-width: 24rem; width: 100%; diff --git a/templates/photography.html b/templates/photography.html index be3897d..73dc098 100644 --- a/templates/photography.html +++ b/templates/photography.html @@ -16,5 +16,14 @@ {% endfor %} + + {% endblock %} diff --git a/templates/view_photo.html b/templates/view_photo.html index be473d6..35ee210 100644 --- a/templates/view_photo.html +++ b/templates/view_photo.html @@ -28,5 +28,6 @@ {% endif %} {% endif %} + {% endblock %}