bygdis.fi

git clone https://git.tarina.org/bygdis.fi
Log | Files | Refs | README

commit 3715147a0639a8c230396b8e4d13d195982c4e46
parent 883ac5bdc5452cb2c988dd2378140d5f1cf4bb3b
Author: rbckman <rob@tarina.org>
Date:   Tue, 13 Oct 2020 09:25:31 +0300

next prev bug

Diffstat:
Mpublic_html/html/bild.html | 7++++++-
Mpublic_html/html/bilder.html | 2++
Mserver.py | 12++++++++----
3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/public_html/html/bild.html b/public_html/html/bild.html @@ -2,7 +2,12 @@ $def with (b, imghash, personer, kform, comments, user, user_likes, likes, user_ $ imglink = imghash + '.jpeg' <div id="album"> <br> -<a href="/bilder#$imghash"><-- tibaks</a> <a href="/bild/$back_next.next"><-- föra</a> <a href="/bild/$back_next.prev">nästa --></a> <a href="/static/bilder/$imglink">full storlek</a> +<a href="/bilder#$imghash"><-- tibaks</a> +$if back_next.prev != None: + <a href="/bild/$back_next.prev"><-- föra</a> +$if back_next.next != None: + <a href="/bild/$back_next.next">nästa --></a> +<a href="/static/bilder/$imglink">full storlek</a> <br> <h2>$b.titel</h2> <a href="/bilder#$imghash"><img id="bild" src="/static/bilder/web/$imglink"></a><br> diff --git a/public_html/html/bilder.html b/public_html/html/bilder.html @@ -4,6 +4,8 @@ $ displayname = db.query("SELECT displayname FROM bildadmin WHERE name='"+namn+" <p>inloggad som <b><a href="/tuning">$displayname.displayname</a></b> ❃ | <a href="/logout">Logga ut</a> 🗝</p> <h1>Byyns eji fotoalbum</h1> <h4><a href="/upload">lägg opp ny bild</a> 💾 <a href="/senaste">senast häändi</a> 🔥</h4> +$if totbilder == 0: + inga bilder $if search == '': <p>bilder totalt: $totbilder</p> $else: diff --git a/server.py b/server.py @@ -558,9 +558,13 @@ class bilder(): def GET(self): bildpersida = 100 i = web.input() - bilder_totalt = db.query("SELECT COUNT(*) AS bilder FROM bilder")[0] - tot = int(bilder_totalt.bilder) - print('bilder alltsomallt: ' + str(tot)) + try: + bilder_totalt = db.query("SELECT COUNT(*) AS bilder FROM bilder")[0] + tot = int(bilder_totalt.bilder) + print('bilder alltsomallt: ' + str(tot)) + except: + print("inga bilder") + tot = 0 print('session search: ' + session.search) try: if i.search == '': @@ -793,7 +797,7 @@ class bild(): personer = b.personer.replace(', ', ',').split(',') except: personer = '' - back_next = db.query('SELECT prev, next from (SELECT id, LAG(filename) OVER (ORDER BY id) AS prev, filename, LEAD(filename) OVER (ORDER BY id) AS next FROM bilder) AS t WHERE filename="'+imghash+'";')[0] + back_next = db.query('SELECT prev, next from (SELECT id, LAG(filename) OVER (ORDER BY id) AS next, filename, LEAD(filename) OVER (ORDER BY id) AS prev FROM bilder) AS t WHERE filename="'+imghash+'";')[0] print(back_next) return render.bild(b, imghash, personer, kform, comments, session.user, user_likes, likes, user_hates, hates, back_next, text, getdisplayname) else: