def makeCommentHeading(self, page, subject, username, time, message_id=None,in_reply_to=None): heading = '\n\n' if message_id: # use the message id for linking, but strip the <> # and leave it unquoted, browsers can handle it heading += '<a class="visualNoPrint" name="msg%s"></a>\n' % \ re.sub(r'^<(.*)>$',r'\1',message_id) if page.inCMF(): heading += \ '<img src="discussionitem_icon.gif" style="border:none; margin:0" />' heading += '<b>%s</b> --' % (subject or '...') #more robust if username: heading = heading + '%s, ' % (username) if message_id: heading += ' <a href="%s#msg%s">%s</a>' % \ (page.pageUrl(), re.sub(r'^<(.*)>$',r'\1',message_id), html_quote(time or '')) inreplytobit = '&in_reply_to='+quote(message_id) else: heading += html_quote(time or '') inreplytobit = '' #heading += ( (' <a href="%s?subject=%s%s#bottom">' # % (page.pageUrl(),quote(subject or ''),inreplytobit)) + # + _("reply") + '</a>' ) heading += ' <a class="visualNoPrint" href="%s?subject=%s%s#bottom">reply</a>'\ % (page.pageUrl(),quote(subject or ''),inreplytobit) heading += '<br />\n' return heading
def makeCommentHeading(self, page, subject, username, time, message_id=None, in_reply_to=None): heading = '\n\n' time = page.tounicode(time) if message_id: # use the message id for linking, but strip the <> # and leave it unquoted, browsers can handle it heading += '<a class="visualNoPrint" name="msg%s"></a>\n' % \ re.sub(r'^<(.*)>$',r'\1',message_id) if page.inCMF(): heading += \ '<img src="discussionitem_icon.gif" style="border:none; margin:0" />' heading += '<b>%s</b> --' % (page.tounicode(subject) or '...' ) #more robust if username: heading = heading + '%s, ' % (page.tounicode(username)) if message_id: heading += ' <a href="%s#msg%s">%s</a>' % \ (page.pageUrl(), re.sub(r'^<(.*)>$',r'\1',message_id), html_quote(time or '')) inreplytobit = '&in_reply_to=' + quote(message_id) else: heading += html_quote(time or '') inreplytobit = '' #heading += ( (' <a href="%s?subject=%s%s#bottom">' # % (page.pageUrl(),quote(subject or ''),inreplytobit)) + # + _("reply") + '</a>' ) heading += ' <a class="visualNoPrint" href="%s?subject=%s%s#bottom">reply</a>'\ % (page.pageUrl(),quote(subject or ''),inreplytobit) heading += '<br />\n' return heading
def edits_rss(self, num=10, REQUEST=None): """Provide an RSS feed listing this wiki's N most recently edited pages. May be useful for monitoring, as a (less detailed) alternative to an all edits mail subscription. """ self.ensureCatalog() return self.rssForPages(self.pages(sort_on='last_edit_time', sort_order='reverse', sort_limit=num, isBoring=0), lambda p: '[%s] %s' % (self.toencoded(self.title_quote(p.Title)), self.toencoded(self.title_quote(p.last_log))), lambda p: p.lastEditTime(), lambda p: html_quote(p.textDiff()), ' changed pages', REQUEST=REQUEST)
def rssForPages(self, pages, titlefunc, datefunc, descriptionfunc, title_suffix='', REQUEST=None): """Generate an RSS feed from the given page brains and title/date/description functions. titlefunc should take a page brain and return an item title string. datefunc should take a page object and return a DateTime object. descriptionfunc should take a page object and return a html-quoted string. """ if len(pages) > 0: last_mod = datefunc(pages[0].getObject()) else: last_mod = DateTime() if self.handle_modified_headers(last_mod=last_mod, REQUEST=REQUEST): return '' feedtitle = self.folder().title_or_id() + title_suffix feeddescription = feedtitle feedlanguage = 'en' feeddate = self.folder().bobobase_modification_time().rfc822() wikiurl = self.wikiUrl() if REQUEST: REQUEST.RESPONSE.setHeader('Content-Type', 'text/xml; charset=utf-8') t = """\ <rss version="2.0"> <channel> <title>%(feedtitle)s</title> <link>%(feedurl)s</link> <description>%(feeddescription)s</description> <language>%(feedlanguage)s</language> <pubDate>%(feeddate)s</pubDate> """ % { 'feedtitle': self.toencoded(self.title_quote(feedtitle)), 'feeddescription': self.toencoded(html_quote(feeddescription)), 'feedurl': wikiurl, 'feedlanguage': feedlanguage, 'feeddate': feeddate, } for p in pages: pobj = p.getObject() t += """\ <item> <title>%(title)s</title> <link>%(wikiurl)s/%(id)s</link> <guid>%(wikiurl)s/%(id)s</guid> <description>%(description)s</description> <pubDate>%(date)s</pubDate> </item> """ % { 'title': titlefunc(p), 'wikiurl': wikiurl, 'id': p.id, 'description': self.toencoded(descriptionfunc(pobj)), 'date': datefunc(pobj).rfc822(), # be robust here } t += """\ </channel> </rss> """ return t
def pageContentForFeed(p): return toencoded( html_quote(p.render(bare=1, show_subtopics=0, show_issueproperties=0)))