# HG changeset patch # User Paul Boddie # Date 1367862291 -7200 # Node ID 74d75b5146d279aa98edbd20e04b1ffa6b5c65dc # Parent 54acc965b891e3f274d3c6afad8653b0e7440401 Added update content to the feed output as encoded HTML. diff -r 54acc965b891 -r 74d75b5146d2 actions/SharedUpdates.py --- a/actions/SharedUpdates.py Mon May 06 17:16:54 2013 +0200 +++ b/actions/SharedUpdates.py Mon May 06 19:44:51 2013 +0200 @@ -2,13 +2,23 @@ """ MoinMoin - SharedUpdates Action - @copyright: 2012 by Paul Boddie + @copyright: 2012, 2013 by Paul Boddie @license: GNU GPL (v2 or later), see COPYING.txt for details. """ from MoinMoin.action import ActionBase +from MoinMoin.Page import Page from MoinMoin import wikiutil -from MoinShare import * +from MoinShare import getPreferredOutputTypes, getOutputTypes, getUpdatedTime +from MoinSupport import escattr, formatText, get_form, getFragments, \ + getMetadata, getParserClass, getPathInfo, writeHeaders, ActionSupport + +try: + from cStringIO import StringIO +except ImportError: + from StringIO import StringIO + +escape = wikiutil.escape Dependencies = ['pages'] @@ -101,6 +111,8 @@ "updated" : escape(updated), } + # Start the output. + request.write('''\ \r \r @@ -136,7 +148,26 @@ download_links.append('' % ( escattr(mimetype), escattr(specific_link))) + # Try and obtain some suitable content for the entry. # NOTE: Could potentially get a summary for the fragment. + + content = None + + if "text/html" in preferred: + parser_cls = getParserClass(request, format) + parser = parser_cls(body, request) + + if format == "html": + content = body + elif hasattr(parser, "formatForOutputType"): + s = StringIO() + parser.formatForOutputType("text/html", write=s.write) + content = s.getvalue() + else: + fmt = request.html_formatter + fmt.setPage(page) + content = formatText(body, request, fmt, parser_cls) + # NOTE: The published and updated details would need to be deduced from # NOTE: the page history. @@ -144,16 +175,22 @@ "title" : escape(summary), "fragment_link" : escape(fragment_link), "download_links" : "\r\n".join(download_links), + "content" : content and ('%s' % escape(content)) or "", } + # Write the entry output. + request.write('''\ \r %(title)s\r %(fragment_link)s\r %(download_links)s\r +%(content)s\r \r ''' % d) + # End the feed output. + request.write('\r\n') # Action function.