From 7d9464c11122b512c77768d79be55f5830f9eea5 Mon Sep 17 00:00:00 2001 From: Ctibor Date: Thu, 23 Mar 2017 13:51:09 +0100 Subject: Add pagination to the bottom of index --- cgi-bin/display.py | 48 +++++++++++++++++++++++++++--------------------- cgi-bin/link.py | 34 +++++++++++++++++----------------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/cgi-bin/display.py b/cgi-bin/display.py index 944706d..990158a 100644 --- a/cgi-bin/display.py +++ b/cgi-bin/display.py @@ -49,36 +49,42 @@ class Body: remove=("latest.jpeg", "notfound.jpeg") for r in remove: index.remove(r) - index.sort() - count=len(index) - pnum=count/config.pagination+1 - if int(page) > int(pnum): - page=pnum-1 - #print pnum - rngend=(int(page)+1)*config.pagination-1 - #print rngend - rngstart=rngend-(config.pagination-1) - #print rngstart - print ("
") + index.sort() + count=len(index) + pnum=count/config.pagination+1 + if int(page) > int(pnum): + page=pnum-1 + #print pnum + rngend=(int(page)+1)*config.pagination-1 + #print rngend + rngstart=rngend-(config.pagination-1) + #print rngstart + print ("
") print ("

Hnízdo - Index

") print ("
") print ("") + a = 0 + while a < pnum: + print(""+str(a+1)+"") + a = a + 1 + print ("") print ("") - print ("") + f = f + 1 + print ("") + print ("") + print ("") def page(self): if self.site == "index": diff --git a/cgi-bin/link.py b/cgi-bin/link.py index 2fe8973..a8e9bc4 100644 --- a/cgi-bin/link.py +++ b/cgi-bin/link.py @@ -23,21 +23,21 @@ class Link: return os.path.relpath(self.src_datadir + "notfound.jpeg") def imglink(self, target, order=""): - if order: - cssclass="class=\""+order+"\"" - else: - cssclass="" + if order: + cssclass="class=\""+order+"\"" + else: + cssclass="" if self.detect(target): return "" else: return "" - def timestamp(self, date): - if self.detect(date): - date=datetime.datetime.strftime(datetime.datetime.strptime(date[:12], "%Y%m%d%H%M"), "%Y-%m-%d %H:%M") - return date - else: - return "" + def timestamp(self, date): + if self.detect(date): + date=datetime.datetime.strftime(datetime.datetime.strptime(date[:12], "%Y%m%d%H%M"), "%Y-%m-%d %H:%M") + return date + else: + return "" def href(self, target): ##print os.path.realpath(root+target) @@ -55,13 +55,13 @@ class Link: #print os.path.realpath(filename) return False - def first(self): - index=os.listdir(os.path.realpath(self.datadir)) - remove=('latest.jpeg', 'notfound.jpeg') - for r in remove: - index.remove(r) - index.sort() - return index[0] + def first(self): + index=os.listdir(os.path.realpath(self.datadir)) + remove=('latest.jpeg', 'notfound.jpeg') + for r in remove: + index.remove(r) + index.sort() + return index[0] def link(self, target, link): #print target -- cgit v1.2.3