# HG changeset patch # User Paul Boddie # Date 1368485618 -7200 # Node ID 4967a73df0a59a840ea378548dfef7f1f5bc487f # Parent d446dfd062c875d46008dbe004d86c4138adfebb Added support for getting content from RSS 2.0 feed entries. diff -r d446dfd062c8 -r 4967a73df0a5 macros/SharedContent.py --- a/macros/SharedContent.py Mon May 13 20:18:49 2013 +0200 +++ b/macros/SharedContent.py Tue May 14 00:53:38 2013 +0200 @@ -41,6 +41,9 @@ else: return element.getAttribute("href") +def need_content(show_content, tagname): + return show_content in ("content", "description") and tagname in ("content", "description") + # Error classes. class FeedError(Exception): @@ -157,21 +160,29 @@ else: channel_link = linktext(value, feed_type) - elif feed_type == "atom" and show_content and tagname in ("content", "summary"): + elif show_content and ( + feed_type == "atom" and tagname in ("content", "summary") or + feed_type == "rss" and tagname == "description"): + events.expandNode(value) # Obtain content where requested or, failing that, a # summary. - if update and (tagname == show_content or tagname == "summary" and not update.content): - update.content_type = value.getAttribute("type") or "text" - if update.content_type in ("xhtml", "application/xhtml+xml", "application/xml"): - update.content = value.toxml() + if update and (need_content(show_content, tagname) or tagname == "summary" and not update.content): + if feed_type == "atom": + update.content_type = value.getAttribute("type") or "text" + if update.content_type in ("xhtml", "application/xhtml+xml", "application/xml"): + update.content = value.toxml() + else: + update.content = text(value) else: + update.content_type = "html" update.content = text(value) elif feed_type == "atom" and tagname == "updated" or \ feed_type == "rss" and tagname == "pubDate": + events.expandNode(value) if update: