# HG changeset patch # User Paul Boddie # Date 1204479105 -3600 # Node ID 6f7d92be6061a3ac6e2cc9343d146f637117d41d # Parent d8e5f57c1fc65247322740e19536945d4251a692 Removed the RSSReader macro. diff -r d8e5f57c1fc6 -r 6f7d92be6061 README.txt --- a/README.txt Sun Mar 02 18:31:09 2008 +0100 +++ b/README.txt Sun Mar 02 18:31:45 2008 +0100 @@ -31,10 +31,9 @@ sudo ./instmacros .../ep2008 -The RSSReader macro was found on the MoinMoin macro market and requires the -feedparser module (provided by the python-feedparser package on Debian/Ubuntu). -However, the FeedReader macro is preferable, at least with RSS 2.0 feeds since -it parses the titles correctly. +The FeedReader macro is used to fetch RSS 2.0 feeds and is preferable to the +RSSReader macro available elsewhere since it parses the titles of feed entries +correctly. Administering Content --------------------- diff -r d8e5f57c1fc6 -r 6f7d92be6061 macros/RSSReader.py --- a/macros/RSSReader.py Sun Mar 02 18:31:09 2008 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,166 +0,0 @@ -# -*- coding: iso-8859-1 -*- -""" - Import a RSS Feed into MoinMoin - - @copyright: 2006 by Ian Wienand (apparently assigned to the public domain) - @copyright: 2008 by Paul Boddie - @license: GNU GPL (v2 or later), see COPYING.txt for details. -""" - -# Using this macro -# [[RSSReader(url[,allow_html])]] -# where -# * url is the url of the RSS/ATOM feed to read -# * allow_html is an optional argument if you trust the feed to put -# the HTML directly into the page - -# CAUTION: this could be an attack vector, although feedparser should -# strip most "bad" HTML. - -# this tells MoinMoin not to cache the page, as we don't know when it -# changes. -Dependencies = ["time"] - -from MoinMoin import util, wikiutil, config -from MoinMoin.Page import Page - -class RSStoWiki: - def __init__(self, macro, url, allow_html, compact_list): - self.macro = macro - self.fmt = macro.formatter - self.url = url - self.allow_html = allow_html - self.compact_list = compact_list - # in debian package python-feedparser - import feedparser - self.f = feedparser.parse(url) - self.result = [] - if self.f.feed == {}: - self.result.append (self.fmt.icon('info') + \ - self.fmt.strong(1) + \ - self.fmt.text(' Unable to retrieve feed %s' % url) + \ - self.fmt.strong(0)) - self.valid = False - else: - self.valid = True - - - def get_title(self): - if not self.f.feed.has_key('title'): - return - self.result.append(self.fmt.heading(on=1, depth=1) + \ - self.fmt.text(self.f.feed.title) + \ - self.fmt.heading(on=0, depth=1)) - - def get_subtitle(self): - if not self.f.feed.has_key('subtitle'): - return - self.result.append(self.fmt.heading(on=1, depth=2) + \ - self.fmt.text(self.f.feed.subtitle) + \ - self.fmt.heading(on=0, depth=2)) - - def get_paragraph(self, text): - self.result.append(self.fmt.paragraph(on=1) + \ - self.fmt.text(text) + \ - self.fmt.paragraph(on=0)) - - def get_link(self, link): - self.result.append(self.fmt.url(on=1, href=link) + \ - self.fmt.icon('www') + \ - self.fmt.text(" "+link) + \ - self.fmt.url(on=0)) - - def get_feedlink(self): - if not self.f.feed.has_key('link'): - return - self.get_link(self.f.feed.link) - - def get_description(self): - if not self.f.feed.has_key('description'): - return - self.get_paragraph(self.f.feed.description) - - def get_rule(self): - self.result.append(self.fmt.rule(size=1)) - - def get_entry_header(self, title): - self.result.append(self.fmt.heading(on=1, depth=3) + \ - self.fmt.text(title) + \ - self.fmt.heading(on=0, depth=3)) - - def get_entry_body(self, body): - self.result.append(self.fmt.paragraph(on=1)) - if (self.allow_html): - self.result.append(self.fmt.rawHTML(body)) - else: - self.result.append(self.fmt.text(body)) - self.result.append(self.fmt.paragraph(on=0)) - - def get_entries(self): - for entry in self.f.entries: - if entry.has_key('title'): - self.get_entry_header(entry.title) - if entry.has_key('updated'): - self.get_paragraph(entry.updated) - if entry.has_key('description'): - self.get_entry_body(entry.description) - if entry.has_key('link'): - self.get_link(entry.link) - - def get_compact_title(self): - if not self.f.feed.has_key('title') or not self.f.feed.has_key('link'): - return - self.result.append(self.fmt.url(on=1, href=self.f.feed.link) + \ - self.fmt.text(self.f.feed.title) + \ - self.fmt.url(on=0) + \ - self.fmt.text(" ") + \ - self.fmt.url(on=1, href=self.url) + \ - self.fmt.icon('rss') + \ - self.fmt.url(on=0)) - - def get_compact_entry(self, entry): - if entry.has_key('link') and entry.has_key('title'): - self.result.append(self.fmt.listitem(on=1)) - #self.result.append(self.fmt.paragraph(on=1)) - self.result.append(self.fmt.url(on=1, href=entry.link) + \ - self.fmt.icon('www') + \ - self.fmt.text(" "+entry.title) + \ - self.fmt.url(on=0)) - #self.result.append(self.fmt.paragraph(on=0)) - self.result.append(self.fmt.listitem(on=0)) - - def get_compact_entries(self): - self.result.append(self.fmt.bullet_list(on=1)) - for entry in self.f.entries: - self.get_compact_entry(entry) - self.result.append(self.fmt.bullet_list(on=0)) - - def get_output(self): - if self.valid: - if self.compact_list: - self.get_compact_title() - self.get_compact_entries() - else: - self.get_title() - self.get_subtitle() - self.get_description() - self.get_feedlink() - self.get_rule() - self.get_entries() - self.get_rule() - return ''.join(self.result) - -def execute(macro, args): - macro_args = args.split(",") - allow_html = False - compact_list = False - try: - if macro_args[1].strip() == "allow_html": - allow_html = True - if macro_args[1].strip() == "compact_list": - compact_list = True - except: - pass - - rss = RSStoWiki(macro, macro_args[0], allow_html, compact_list) - return rss.get_output()