1.1 --- a/macros/SharedContent.py Tue May 14 00:53:38 2013 +0200
1.2 +++ b/macros/SharedContent.py Tue May 14 01:37:22 2013 +0200
1.3 @@ -10,6 +10,7 @@
1.4 from MoinMoin.Page import Page
1.5 from MoinRemoteSupport import *
1.6 from MoinSupport import parseMacroArguments
1.7 +from MoinShare import getUpdatesFromPage, Update
1.8 from email.utils import parsedate
1.9 import xml.dom.pulldom
1.10
1.11 @@ -55,27 +56,6 @@
1.12 class FeedContentTypeError(FeedError):
1.13 pass
1.14
1.15 -# Entry/update classes.
1.16 -
1.17 -class Update:
1.18 -
1.19 - "A feed update entry."
1.20 -
1.21 - def __init__(self):
1.22 - self.title = None
1.23 - self.link = None
1.24 - self.content = None
1.25 - self.content_type = None
1.26 - self.updated = None
1.27 -
1.28 - def __cmp__(self, other):
1.29 - if self.updated is None and other.updated is not None:
1.30 - return 1
1.31 - elif self.updated is not None and other.updated is None:
1.32 - return -1
1.33 - else:
1.34 - return cmp(self.updated, other.updated)
1.35 -
1.36 # Feed retrieval.
1.37
1.38 def getUpdates(request, feed_url, max_entries, show_content):
1.39 @@ -218,12 +198,15 @@
1.40 _ = request.getText
1.41
1.42 feed_urls = []
1.43 + pagenames = []
1.44 show_content = None
1.45 max_entries = None
1.46
1.47 for arg, value in parseMacroArguments(args):
1.48 if arg == "url":
1.49 feed_urls.append(value)
1.50 + elif arg == "page":
1.51 + pagenames.append(value)
1.52 elif arg == "show":
1.53 show_content = value.lower()
1.54 elif arg == "limit":
1.55 @@ -232,8 +215,8 @@
1.56 except ValueError:
1.57 return fmt.text(_("SharedContent: limit must be set to the maximum number of entries to be shown"))
1.58
1.59 - if not feed_urls:
1.60 - return fmt.text(_("SharedContent: a feed URL must be specified"))
1.61 + if not feed_urls and not pagenames:
1.62 + return fmt.text(_("SharedContent: at least one feed URL or page must be specified"))
1.63
1.64 show_content = show_content or False
1.65 max_entries = max_entries or MAX_ENTRIES
1.66 @@ -256,6 +239,23 @@
1.67 except FeedContentTypeError:
1.68 bad_content.append(feed_url)
1.69
1.70 + # Retrieve updates from pages.
1.71 +
1.72 + for pagename in pagenames:
1.73 + page = Page(request, pagename)
1.74 + updates += getUpdatesFromPage(page, request)
1.75 +
1.76 + # Build feed-equivalent information for the update source.
1.77 +
1.78 + feeds.append((
1.79 + page.url(request), (
1.80 + "internal", _("Updates from page %s") % pagename,
1.81 + page.url(request, {"action" : "SharedUpdates", "doit" : "1"})
1.82 + )
1.83 + ))
1.84 +
1.85 + # Prepare the output.
1.86 +
1.87 output = []
1.88 append = output.append
1.89