diff options
author | Ctibor <ctibor@brancik.cz> | 2017-03-23 08:12:29 +0100 |
---|---|---|
committer | Ctibor <ctibor@brancik.cz> | 2017-03-23 08:12:29 +0100 |
commit | 6ce10a6b046cbe57d9a1660dba4b91da961f055c (patch) | |
tree | 4be90cb6ea0172568d6398c7fea39e77b22eff97 /cgi-bin | |
parent | 325b213b41d4e45eb6ae2ad7110efd53c9d7268f (diff) | |
download | hnizdo-6ce10a6b046cbe57d9a1660dba4b91da961f055c.tar.gz hnizdo-6ce10a6b046cbe57d9a1660dba4b91da961f055c.tar.bz2 |
Display caption with date stamp under the image.
Diffstat (limited to 'cgi-bin')
-rw-r--r-- | cgi-bin/display.py | 8 | ||||
-rw-r--r-- | cgi-bin/link.py | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/cgi-bin/display.py b/cgi-bin/display.py index d3a9e2d..826f1f1 100644 --- a/cgi-bin/display.py +++ b/cgi-bin/display.py @@ -1,5 +1,6 @@ # -*- coding: utf8 -*- import link, os, config +from datetime import datetime class Body: def __init__(self, site): @@ -28,12 +29,15 @@ class Body: print ("</header>") print ("<article id=\"prev\">") print (self.a.imglink(self.a.delta('+m'),'prev')) + print ("<p>"+self.a.caption(self.a.delta('+m'))+"</p>") print ("</article>") print ("<article id=\"now\">") print (self.a.imglink(self.a.img, 'now')) + print ("<p>"+self.a.caption(self.a.img)+"</p>") print ("</article>") print ("<article id=\"next\">") print (self.a.imglink(self.a.delta('-m'), 'next')) + print ("<p>"+self.a.caption(self.a.delta('-m'))+"</p>") print ("</article>") print ("<footer>") print ("<a href=\"?f=index\" title=\"všechny fotky\">vše</a>") @@ -59,7 +63,3 @@ class Body: self.index() else: self.articles() - - - - diff --git a/cgi-bin/link.py b/cgi-bin/link.py index b0e6560..d6f3251 100644 --- a/cgi-bin/link.py +++ b/cgi-bin/link.py @@ -27,6 +27,13 @@ class Link: return "<a href=\""+self.href(target)+"\"><img src=\""+self.src(target)+"\" class=\""+order+"\"/></a>" else: return "<img src=\""+self.src(target)+"\" class=\""+order+"\"/>" + + def caption(self, figure): + if self.detect(figure): + date=datetime.datetime.strftime(datetime.datetime.strptime(figure[: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) |