1.1 --- a/macros/SharedContent.py Mon May 13 20:01:29 2013 +0200
1.2 +++ b/macros/SharedContent.py Mon May 13 20:18:49 2013 +0200
1.3 @@ -75,11 +75,14 @@
1.4
1.5 # Feed retrieval.
1.6
1.7 -def getUpdates(request, feed_url, max_entries):
1.8 +def getUpdates(request, feed_url, max_entries, show_content):
1.9
1.10 """
1.11 Using the given 'request', retrieve from 'feed_url' up to the given number
1.12 - 'max_entries' of update entries.
1.13 + 'max_entries' of update entries. The 'show_content' parameter can indicate
1.14 + that a "summary" is to be obtained for each update, that the "content" of
1.15 + each update is to be obtained (falling back to a summary if no content is
1.16 + provided), or no content (indicated by a false value) is to be obtained.
1.17
1.18 A tuple of the form ((feed_type, channel_title, channel_link), updates) is
1.19 returned.
1.20 @@ -154,10 +157,14 @@
1.21 else:
1.22 channel_link = linktext(value, feed_type)
1.23
1.24 - elif feed_type == "atom" and tagname == "content":
1.25 + elif feed_type == "atom" and show_content and tagname in ("content", "summary"):
1.26 events.expandNode(value)
1.27 - if update:
1.28 - update.content_type = value.getAttribute("type")
1.29 +
1.30 + # Obtain content where requested or, failing that, a
1.31 + # summary.
1.32 +
1.33 + if update and (tagname == show_content or tagname == "summary" and not update.content):
1.34 + update.content_type = value.getAttribute("type") or "text"
1.35 if update.content_type in ("xhtml", "application/xhtml+xml", "application/xml"):
1.36 update.content = value.toxml()
1.37 else:
1.38 @@ -207,7 +214,7 @@
1.39 if arg == "url":
1.40 feed_urls.append(value)
1.41 elif arg == "show":
1.42 - show_content = value in ("true", "True", "yes")
1.43 + show_content = value.lower()
1.44 elif arg == "limit":
1.45 try:
1.46 max_entries = int(value)
1.47 @@ -230,7 +237,7 @@
1.48
1.49 for feed_url in feed_urls:
1.50 try:
1.51 - feed_info, feed_updates = getUpdates(request, feed_url, max_entries)
1.52 + feed_info, feed_updates = getUpdates(request, feed_url, max_entries, show_content)
1.53 updates += feed_updates
1.54 feeds.append((feed_url, feed_info))
1.55 except FeedMissingError: