X-Git-Url: https://git.llucax.com/software/blitiri.git/blobdiff_plain/05c7cdc940c7db22df3bcd0ff475cc950eae8b2e..e3c7d198b1679ff33fc1e4fc800aa61f22a5ab31:/blitiri.cgi diff --git a/blitiri.cgi b/blitiri.cgi index 3c904b7..15c820e 100755 --- a/blitiri.cgi +++ b/blitiri.cgi @@ -66,15 +66,16 @@ templates_path = os.path.realpath(templates_path) # Default template -default_main_header = """ - +default_main_header = """\ + + - + - + %(title)s @@ -248,29 +249,7 @@ class Templates (object): def get_article_header(self, article): avars = self.vars.copy() - avars.update( { - 'arttitle': article.title, - 'author': article.author, - 'date': article.created.isoformat(' '), - 'uuid': article.uuid, - 'created': article.created.isoformat(' '), - 'updated': article.updated.isoformat(' '), - 'tags': article.get_tags_links(), - - 'cyear': article.created.year, - 'cmonth': article.created.month, - 'cday': article.created.day, - 'chour': article.created.hour, - 'cminute': article.created.minute, - 'csecond': article.created.second, - - 'uyear': article.updated.year, - 'umonth': article.updated.month, - 'uday': article.updated.day, - 'uhour': article.updated.hour, - 'uminute': article.updated.minute, - 'usecond': article.updated.second, - } ) + avars.update(article.to_vars()) p = self.tpath + '/art_header.html' if os.path.isfile(p): @@ -279,29 +258,7 @@ class Templates (object): def get_article_footer(self, article): avars = self.vars.copy() - avars.update( { - 'arttitle': article.title, - 'author': article.author, - 'date': article.created.isoformat(' '), - 'uuid': article.uuid, - 'created': article.created.isoformat(' '), - 'updated': article.updated.isoformat(' '), - 'tags': article.get_tags_links(), - - 'cyear': article.created.year, - 'cmonth': article.created.month, - 'cday': article.created.day, - 'chour': article.created.hour, - 'cminute': article.created.minute, - 'csecond': article.created.second, - - 'uyear': article.updated.year, - 'umonth': article.updated.month, - 'uday': article.updated.day, - 'uhour': article.updated.hour, - 'uminute': article.updated.minute, - 'usecond': article.updated.second, - } ) + avars.update(article.to_vars()) p = self.tpath + '/art_footer.html' if os.path.isfile(p): @@ -406,6 +363,33 @@ class Article (object): writer_name = "html") return parts['body'].encode('utf8') + def to_vars(self): + return { + 'arttitle': self.title, + 'author': self.author, + 'date': self.created.isoformat(' '), + 'uuid': self.uuid, + 'tags': self.get_tags_links(), + + 'created': self.created.isoformat(' '), + 'ciso': self.created.isoformat(), + 'cyear': self.created.year, + 'cmonth': self.created.month, + 'cday': self.created.day, + 'chour': self.created.hour, + 'cminute': self.created.minute, + 'csecond': self.created.second, + + 'updated': self.updated.isoformat(' '), + 'uiso': self.updated.isoformat(), + 'uyear': self.updated.year, + 'umonth': self.updated.month, + 'uday': self.updated.day, + 'uhour': self.updated.hour, + 'uminute': self.updated.minute, + 'usecond': self.updated.second, + } + def get_tags_links(self): l = [] tags = list(self.tags) @@ -548,6 +532,11 @@ def render_atom(articles): } for a in articles: + vars = a.to_vars() + vars.update( { + 'url': full_url, + 'contents': a.to_html(), + } ) print """ %(arttitle)s @@ -555,24 +544,15 @@ def render_atom(articles): %(url)s/post/%(uuid)s %(arttitle)s - %(created)sZ - %(updated)sZ + %(ciso)sZ + %(uiso)sZ

%(contents)s

- """ % { - 'arttitle': a.title, - 'author': a.author, - 'uuid': a.uuid, - 'url': full_url, - 'created': a.created.isoformat(), - 'updated': a.updated.isoformat(), - 'contents': a.to_html(), - } - + """ % vars print ""