# -*- encoding: iso-8859-1 -*- """ MoinMoin - Inline RSS generator Copyright (c) 2003 by Conectiva, Inc. Copyright (c) 2005 by Canonical, Ltd. Copyright (c) 2000-2002 by J?rgen Hermann All rights reserved, see COPYING for details. Written by Gustavo Niemeyer , based on code from RecentChanges. This macro allows one to use a moin page as an RSS feed. To define an RSS feed, enclose the items you want to provide in the comment tags "##irss start" and "##irss stop", like this: ---- This won't be considered ##irss start == Newest item == This will be the newest RSS item. == Older item == This is another RSS item. ##irss stop This won't be considered as well. ---- Then, you can link to that feed in from any moin page using [[IRSS([PageName])]]. If linking from the same page, the pagename parameter is optional. You can also have more than one feed in the same page. To do that, use "##irss start yourfeedname", and link to it with [[IRSS([PageName], yourfeedname)]] (you can use an empty first parameter, if the feed is in the same page). Using the feedname in the stop tag, like "##irss stop yourfeedname", is optional and necessary only if you want to have one feed "contained" inside another one. The following tags can also be used between the start and stop tags to configure the feed. ##irss topic This will set the "title" of the whole RSS feed. Only the first topic found is considered. The default topic is the page name. ##irss descr This will set the "description" of the whole RSS feed. Only the first description found is considered. The default description is "News from ". ##irss reverse The default behavior is to have the newer items at the top of the list. If used, this tag will reverse this behavior. ##irss link This tag should be used just after a Moin title, and will make the RSS item title link to that URL. The default behavior is to link the RSS item title to the Moin title in the page where the feed is defined. """ import re, string, sys, cStringIO, new, sha from MoinMoin import config, util, wikiutil, wikimacro from MoinMoin.Page import Page from MoinMoin.wikixml.util import RssGenerator from MoinMoin.parser.wiki import Parser from MoinMoin.formatter.text_html import Formatter def execute(macro, args, **kwargs): if args: args = [x.strip() for x in args.split(",")] else: args = [] pagename = macro.formatter.page.page_name rssname = "" if len(args) > 0 and args[0]: pagename = args[0] if len(args) > 1: import urllib rssname = "&name=" + urllib.quote(args[1]) img = macro.request.theme.make_icon("rss") url = wikiutil.quoteWikinameURL(pagename)+"?action=irss"+rssname return wikiutil.link_tag(macro.request, url, img, unescaped=1) # vim:ts=4:sw=4:et