Mark Paschal has written a very nice detector which generates static RSS feeds from roundup issue changes:
http://markpasc.org/code/rsswriter/
There are a couple of advantages to this approach over TemplateBasedFeedGeneration:
- The file is static so you can host it from a normal web server, so you could have a public feed and a private tracker, or more commonly, the static feed could withstand the battering of thousands of badly behaved news readers. (This would be a good spot to rant on about people who set their news reader to poll sites every five minutes.)
- A detector is told what has changed (and can be made to only look at specific events), so it can produce a good summary of the changes.
There are also a couple of disadvantages:
- Since the feed is statically generated from a pre-defined set of criteria you can't add more custom feeds without editing the script generating the feeds. This means that it's harder for users to get ad-hoc feeds on particular issues.
- The feed is only generated when the issue is changed, so if you want the feed to include information from other items it will only be a snapshot of that information. This might not suit users in situations where the issues themselves link to a lot of relevant information (of course you can just hook in to the other item's change events).
If you get::
- File "/home/roundup/trackers/support/detectors/rsswriter.py", line 141, in writeRss
- from nosyreaction import determineNewMessages
ImportError: No module named nosyreaction
just copy the function determineNewMessages() from nosyreaction.py to rsswriter.py and comment out the line::
- from nosyreaction import determineNewMessages
The original source link seems to have disappeared, so I am putting my copy that I think is the original contents here.
# # RSS writer Roundup reactor # Mark Paschal <markpasc@markpasc.org> # # The filename of a tracker's RSS feed. Tracker config variables are placed # with the standard '%' operator syntax. FILENAME = "%(TEMPLATES)s/rss.xml" # i.e., roundup.cgi/projects/_file/rss.xml # FILENAME = "/home/markpasc/public_html/%(TRACKER_NAME)s.xml" # How many <item>s to have in the feed, at most. MAX_ITEMS = 30 # # Module metadata # __author__ = "Mark Paschal <markpasc@markpasc.org>" __copyright__ = "Copyright 2003 Mark Paschal" __version__ = "1.2" __changes__ = """ 1.1 29 Aug 2003 Produces valid pubDates. Produces pubDates and authors for change notes. Consolidates a message and change note into one item. Uses TRACKER_NAME in filename to produce one feed per tracker. Keeps to MAX_ITEMS limit more efficiently. 1.2 5 Sep 2003 Fixes bug with programmatically submitted issues having messages without summaries (?!). """ __license__ = 'MIT' # # Copyright 2003 Mark Paschal # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # # The strftime format to use for <pubDate>s. RSS20_DATE_FORMAT = '%a, %d %b %Y %H:%M:%S %Z' def newRss(title, link, description): """Returns an XML Document containing an RSS 2.0 feed with no items.""" import xml.dom.minidom rss = xml.dom.minidom.Document() root = rss.appendChild(rss.createElement("rss")) root.setAttribute("version", "2.0") channel = root.appendChild(rss.createElement("channel")) addEl = lambda tag,value: channel.appendChild(rss.createElement(tag)).appendChild(rss.createTextNode(value)) addEl("title", title) addEl("link", link) addEl("description", description) return rss # has no items def writeRss(db, cl, nodeid, olddata): """ Reacts to a created or changed issue. Puts new messages and the change note in items in the RSS feed, as determined by the rsswriter.py FILENAME setting. If no RSS feed exists where FILENAME specifies, a new feed is created with rsswriter.newRss. """ filename = FILENAME % db.config.__dict__ # open the RSS import xml.dom.minidom try: rss = xml.dom.minidom.parse(filename) except IOError, e: if 2 <> e.errno: raise # File not found rss = newRss( "%s tracker" % (db.config.TRACKER_NAME,), db.config.TRACKER_WEB, "Recent changes to the %s Roundup issue tracker" % (db.config.TRACKER_NAME,) ) channel = rss.documentElement.getElementsByTagName('channel')[0] addEl = lambda parent,tag,value: parent.appendChild(rss.createElement(tag)).appendChild(rss.createTextNode(value)) issuelink = '%sissue%s' % (db.config.TRACKER_WEB, nodeid) if olddata: chg = cl.generateChangeNote(nodeid, olddata) else: chg = cl.generateCreateNote(nodeid) def addItem(desc, date, userid): """ Adds an RSS item to the RSS document. The title, link, and comments link are those of the current issue. desc: the description text to use date: an appropriately formatted string for pubDate userid: a Roundup user ID to use as author """ item = rss.createElement('item') addEl(item, 'title', db.issue.get(nodeid, 'title')) addEl(item, 'link', issuelink) addEl(item, 'comments', issuelink) addEl(item, 'description', desc.replace('&','&').replace('<','<').replace('\n', '<br>\n')) addEl(item, 'pubDate', date) addEl(item, 'author', '%s (%s)' % ( db.user.get(userid, 'address'), db.user.get(userid, 'username') ) ) channel.appendChild(item) from nosyreaction import determineNewMessages for msgid in determineNewMessages(cl, nodeid, olddata): desc = db.msg.get(msgid, 'content') if desc and chg: desc += chg elif chg: desc = chg chg = None addItem(desc or '', db.msg.get(msgid, 'date').pretty(RSS20_DATE_FORMAT), db.msg.get(msgid, 'author')) if chg: from time import strftime addItem(chg.replace('\n----------\n', ''), strftime(RSS20_DATE_FORMAT), db.getuid()) for c in channel.getElementsByTagName('item')[0:-MAX_ITEMS]: # leaves at most MAX_ITEMS at the end channel.removeChild(c) # write the RSS out = file(filename, 'w') out.write(rss.toxml()) out.close() def init(db): db.issue.react('create', writeRss) db.issue.react('set', writeRss)