Re: w3cdate in flavour head
Steven Armstrong <[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <[email protected]> |
On 05/23/05 18:13, Doug Ransom wrote: > The modified element in the atom flavor is not being populated with the w3cdate. > http://ransom.dyndns.ws/doug/index.syndicate > this is the head.syndicate file, copied from the atom flavour head. > > > <?xml version="1.0"?> > <?xml-stylesheet href="http://ransom.dyndns.ws/syndicate.css" type="text/css"?> > <feed xmlns="http://purl.org/atom/ns#" xmlns:ent="http://www.purl.org/NET/ENT/1.0/" version="1.0"> > <title>$blog_title</title> > <link rel="alternate" type="text/html" href="$url" /> > <modified>$w3cdate</modified> > <!-- optional elements --> > <tagline></tagline> > <generator>$base_url</generator> > > I can’t see how this w3cdate would ever be populated, since w3cdate seems to be a story variable. Is there a trick I am missing? > > > Doug Ransom > Hi Doug I've hacked my version of w3cdate for just that reason. See attachment. You can use $lastmodified_w3cdate in your head.atom flavour. 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