# HG changeset patch # User Paul Boddie # Date 1368469129 -7200 # Node ID d446dfd062c875d46008dbe004d86c4138adfebb # Parent feb90c7c4432acee53091e9ca75cb62e07115907 Changed the "show" parameter to indicate whether summary or content information is preferred, retrieving full content only if "content" is indicated. Made sure that "text" is the default content type where the "type" attribute is not specified on "summary" or "content" elements. diff -r feb90c7c4432 -r d446dfd062c8 macros/SharedContent.py --- a/macros/SharedContent.py Mon May 13 20:01:29 2013 +0200 +++ b/macros/SharedContent.py Mon May 13 20:18:49 2013 +0200 @@ -75,11 +75,14 @@ # Feed retrieval. -def getUpdates(request, feed_url, max_entries): +def getUpdates(request, feed_url, max_entries, show_content): """ Using the given 'request', retrieve from 'feed_url' up to the given number - 'max_entries' of update entries. + 'max_entries' of update entries. The 'show_content' parameter can indicate + that a "summary" is to be obtained for each update, that the "content" of + each update is to be obtained (falling back to a summary if no content is + provided), or no content (indicated by a false value) is to be obtained. A tuple of the form ((feed_type, channel_title, channel_link), updates) is returned. @@ -154,10 +157,14 @@ else: channel_link = linktext(value, feed_type) - elif feed_type == "atom" and tagname == "content": + elif feed_type == "atom" and show_content and tagname in ("content", "summary"): events.expandNode(value) - if update: - update.content_type = value.getAttribute("type") + + # 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() else: @@ -207,7 +214,7 @@ if arg == "url": feed_urls.append(value) elif arg == "show": - show_content = value in ("true", "True", "yes") + show_content = value.lower() elif arg == "limit": try: max_entries = int(value) @@ -230,7 +237,7 @@ for feed_url in feed_urls: try: - feed_info, feed_updates = getUpdates(request, feed_url, max_entries) + feed_info, feed_updates = getUpdates(request, feed_url, max_entries, show_content) updates += feed_updates feeds.append((feed_url, feed_info)) except FeedMissingError: