Re: variables
Steven Armstrong <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <[email protected]> |
On 02/25/05 20:17, Keywan Najafi Tonekaboni wrote: > Hi, > > I found on different places list with avaible variables in the flavours. > My Atom Feed isn't valid because i couldnt found a date variable for the > complete feed, which i could use in head.atom and head.rss2. > Something like a $last_modification_date which contains the date of the > newest entry would be nice. > See the attached file w3cdate.py. It's a hacked version of Ted's plugin that does what you want. It creates the following variables: head/foot templates: $lastmodified_w3cdate $lastmodified_rfc822date story templates: $w3cdate $rfc822date You'll want w3c dates for atom and rfc822 dates for rss2. > Also it would be cool to have $blog_author divided in $blog_author_name > and $blog_author_mail. > You can define your own variables in config.py to do this. Something like: py['blog_author'] = "The authors name" py['blog_email'] = "[email protected]" which are then available in templates as $blog_author resp. $blog_email > The same problem i have with the title_ $blog_title contains also the > file path. It would be nice, when $blog_title only contains the name of > the blog. An additional $blog_title_path or so contains the ": /absolute > _path" could be an alternative. > I also didn't like this behaviour. Again you can use a custom variable for this. e.g: py['blog_name'] = "This will not be changed by pyblosxom" which becomes $blog_name in templates > I know the advantage of a detailed $blog_title and also tried to use it > for <title /> . > But it is also IMHO not beatiful, that $blog_title contains > "foo : bar/hello_world.html" when i view the entry hello_world.html in > the category bar from the blog called "foo". > If it would use the $title it would be better to read. > http://bitworking.org/news/Titles_Matter_for_PyBlosxom > > This are just some ideas, hope the explanations was not too much confused. > > Regards, > > Keywan > hth cheers Steven
w3cdate.py
(text/x-python, 1.8 KB)
""" Add a 'w3cdate' key to every entry -- this contains the date in ISO8601 format WARNING: you must have PyXML installed as part of your python installation in order for this plugin to work Place this plugin early in your load_plugins list, so that the w3cdate will be available to subsequent plugins """ __author__ = "Ted Leung <[email protected]>" __version__ = "$Id:" __copyright__ = "Copyright (c) 2003 Ted Leung" __license__ = "Python" import xml.utils.iso8601 import time import rfc822 from Pyblosxom import tools def cb_prepare(args): request = args['request'] data = request.getData() try: newest_entry = data.get("entry_list", [])[0] time_tuple = newest_entry['timetuple'] if time_tuple: # /sar: in my setup this can be None tzoffset = time.timezone # if is_dst flag set, adjust for daylight savings time if time_tuple[8] == 1: tzoffset = time.altzone t = time.mktime(time_tuple) request.addData({ 'lastmodified_w3cdate': xml.utils.iso8601.tostring(t,tzoffset), 'lastmodified_rfc822date': rfc822.formatdate(t) }) except: #tools.log_exception() pass return args def cb_story(args): entry = args['entry'] time_tuple = entry['timetuple'] if time_tuple: # /sa: in my setup this can be None tzoffset = time.timezone # if is_dst flag set, adjust for daylight savings time if time_tuple[8] == 1: tzoffset = time.altzone t = time.mktime(time_tuple) entry['w3cdate'] = xml.utils.iso8601.tostring(t,tzoffset) # rfc822 date for rss feed entry['rfc822date'] = rfc822.formatdate(t) return args