1.1 --- a/actions/SharedUpdates.py Tue May 07 23:44:34 2013 +0200
1.2 +++ b/actions/SharedUpdates.py Sat May 11 00:35:03 2013 +0200
1.3 @@ -9,14 +9,9 @@
1.4 from MoinMoin.action import ActionBase
1.5 from MoinMoin.Page import Page
1.6 from MoinMoin import wikiutil
1.7 -from MoinShare import getPreferredOutputTypes, getOutputTypes, getUpdatedTime
1.8 -from MoinSupport import escattr, formatText, get_form, getFragments, \
1.9 - getMetadata, getParserClass, getPathInfo, writeHeaders, ActionSupport
1.10 -
1.11 -try:
1.12 - from cStringIO import StringIO
1.13 -except ImportError:
1.14 - from StringIO import StringIO
1.15 +from MoinShare import getUpdatedTime, getUpdateFragmentsFromPage
1.16 +from MoinSupport import escattr, get_form, getMetadata, getPathInfo, \
1.17 + writeHeaders, ActionSupport
1.18
1.19 escape = wikiutil.escape
1.20
1.21 @@ -122,24 +117,13 @@
1.22 <updated>%(updated)s</updated>\r
1.23 ''' % d)
1.24
1.25 - # Get the fragment regions for the page.
1.26 -
1.27 - for n, (format, attributes, body) in enumerate(getFragments(page.get_raw_body())):
1.28 -
1.29 - # Produce a fragment identifier.
1.30 - # NOTE: Choose a more robust identifier where none is explicitly given.
1.31 -
1.32 - fragment = attributes.get("fragment", str(n))
1.33 - summary = attributes.get("summary", "Update #%d" % n)
1.34 + for fragment, summary, preferred, content, updated in \
1.35 + getUpdateFragmentsFromPage(page, request):
1.36
1.37 # Get the URL that yields only the fragment.
1.38
1.39 fragment_link = "%s?action=SharedUpdate&fragment=%s" % (link, fragment)
1.40
1.41 - # Get the preferred content types available for the fragment.
1.42 -
1.43 - preferred = getPreferredOutputTypes(request, getOutputTypes(request, format))
1.44 -
1.45 download_links = []
1.46
1.47 for mimetype in preferred:
1.48 @@ -148,29 +132,6 @@
1.49 download_links.append('<link rel="alternate" type="%s" href="%s"/>' % (
1.50 escattr(mimetype), escattr(specific_link)))
1.51
1.52 - # Try and obtain some suitable content for the entry.
1.53 - # NOTE: Could potentially get a summary for the fragment.
1.54 -
1.55 - content = None
1.56 -
1.57 - if "text/html" in preferred:
1.58 - parser_cls = getParserClass(request, format)
1.59 - parser = parser_cls(body, request)
1.60 -
1.61 - if format == "html":
1.62 - content = body
1.63 - elif hasattr(parser, "formatForOutputType"):
1.64 - s = StringIO()
1.65 - parser.formatForOutputType("text/html", write=s.write)
1.66 - content = s.getvalue()
1.67 - else:
1.68 - fmt = request.html_formatter
1.69 - fmt.setPage(page)
1.70 - content = formatText(body, request, fmt, parser_cls)
1.71 -
1.72 - # NOTE: The published and updated details would need to be deduced from
1.73 - # NOTE: the page history instead of being taken for the page as a whole.
1.74 -
1.75 d = {
1.76 "title" : escape(summary),
1.77 "fragment_link" : escape(fragment_link),