Commits

Anonymous committed 825d525

Ported [2818:2819] to 0.9-stable ''(Trac feeds are now valid RSS 2.0)''

  • Participants
  • Parent commits f5ffa9d
  • Branches 0.9-stable

Comments (0)

Files changed (8)

File templates/log_rss.cs

   <generator>Trac v<?cs var:trac.version ?></generator><?cs 
   each:item = log.items ?><?cs 
    with:change = log.changes[item.rev] ?>
-    <item>
-     <author><?cs var:change.author ?></author> 
+    <item><?cs
+     if:change.author ?><author><?cs var:change.author ?></author><?cs
+     /if ?>
      <pubDate><?cs var:change.date ?></pubDate>
      <title>Revision <?cs var:item.rev ?>: <?cs var:change.shortlog ?></title>
      <link><?cs var:base_host ?><?cs var:item.changeset_href ?></link>

File trac/Timeline.py

 # -*- coding: iso-8859-1 -*-
 #
-# Copyright (C) 2003-2005 Edgewall Software
+# Copyright (C) 2003-2006 Edgewall Software
 # Copyright (C) 2003-2005 Jonas Borgström <jonas@edgewall.com>
 # Copyright (C) 2004-2005 Christopher Lenz <cmlenz@gmx.de>
+# Copyright (C) 2005-2006 Christian Boos <cboos@neuf.fr>
 # All rights reserved.
 #
 # This software is licensed as described in the file COPYING, which
 
 from trac.core import *
 from trac.perm import IPermissionRequestor
-from trac.util import enum, format_date, format_time, http_date, Markup
+from trac.util import enum, format_date, format_time, http_date, Markup, rss_title
 from trac.web import IRequestHandler
 from trac.web.chrome import add_link, add_stylesheet, INavigationContributor
 
 
             if format == 'rss':
                 # Strip/escape HTML markup
-                if isinstance(title, Markup):
-                    event['title'] = title.striptags()
-                else:
-                    event['title'] = title
+                event['title'] = rss_title(title)
+                event['message'] = str(message)
 
                 if author:
                     # For RSS, author must be an email address

File trac/ticket/query.py

 # -*- coding: iso-8859-1 -*-
 #
-# Copyright (C) 2004-2005 Edgewall Software
+# Copyright (C) 2004-2006 Edgewall Software
 # Copyright (C) 2004-2005 Christopher Lenz <cmlenz@gmx.de>
+# Copyright (C) 2005-2006 Christian Boos <cboos@neuf.fr>
 # All rights reserved.
 #
 # This software is licensed as described in the file COPYING, which
                 result['reporter'] = ''
             if result['description']:
                 # str() cancels out the Markup() returned by wiki_to_html
-                result['description'] = str(wiki_to_html(result['description'] or '',
-                                                         self.env, req, db,
-                                                         absurls=1))
+                descr = wiki_to_html(result['description'], self.env, req, db,
+                                     absurls=True)
+                result['description'] = str(descr)
             if result['time']:
                 result['time'] = http_date(result['time'])
         req.hdf['query.results'] = results

File trac/ticket/report.py

 # -*- coding: iso-8859-1 -*-
 #
-# Copyright (C) 2003-2005 Edgewall Software
+# Copyright (C) 2003-2006 Edgewall Software
 # Copyright (C) 2003-2004 Jonas Borgström <jonas@edgewall.com>
+# Copyright (C) 2006 Christian Boos <cboos@neuf.fr>
 # All rights reserved.
 #
 # This software is licensed as described in the file COPYING, which
 
         title, description, sql = self.get_info(db, id, args)
 
-        if req.args.get('format') == 'sql':
+        format = req.args.get('format')
+        if format == 'sql':
             self._render_sql(req, id, title, description, sql)
             return
 
                         id_val = row[id_cols[0]]
                         value['ticket_href'] = self.env.href.ticket(id_val)
                 elif column == 'description':
-                    value['parsed'] = wiki_to_html(cell, self.env, req, db)
+                    descr = wiki_to_html(cell, self.env, req, db,
+                                         absurls=(format == 'rss'))
+                    value['parsed'] = format == 'rss' and str(descr) or descr
                 elif column == 'reporter' and cell.find('@') != -1:
                     value['rss'] = cell
                 elif column == 'report':
             row_idx += 1
         req.hdf['report.numrows'] = row_idx
 
-        format = req.args.get('format')
         if format == 'rss':
-            self._render_rss(req)
             return 'report_rss.cs', 'application/rss+xml'
         elif format == 'csv':
             self._render_csv(req, cols, rows)
                                        .replace('\r',' ')
             req.write(sep.join(map(sanitize, row)) + '\r\n')
 
-    def _render_rss(self, req):
-        # Escape HTML in the ticket summaries
-        item = req.hdf.getObj('report.items')
-        if item:
-            item = item.child()
-            while item:
-                for col in ('summary', 'description.parsed'):
-                    nodename = 'report.items.%s.%s' % (item.name(), col)
-                    value = req.hdf.get(nodename, '')
-                    req.hdf[nodename] = value
-                item = item.next()
-
     def _render_sql(self, req, id, title, description, sql):
         req.perm.assert_permission('REPORT_SQL_VIEW')
         req.send_response(200)

File trac/ticket/roadmap.py

                 title = Markup('Milestone <em>%s</em> completed', name)
                 if format == 'rss':
                     href = self.env.abs_href.milestone(name)
-                    message = wiki_to_html(description or '--', self.env,
-                                           req, db, absurls=True)
+                    message = wiki_to_html(description, self.env, db,
+                                           absurls=True)
                 else:
                     href = self.env.href.milestone(name)
                     message = wiki_to_oneliner(description, self.env, db,
                                                shorten=True)
-                yield 'milestone', href, title, completed, None, message
+                yield 'milestone', href, title, completed, None, message or '--'
 
     # IRequestHandler methods
 

File trac/util.py

         return text
     return text.unescape()
 
+ENTITIES = re.compile(r"&(\w+);")
+def rss_title(text):
+    if isinstance(text, Markup):
+        def replace_entity(match):
+            return match.group(1) in ('amp', 'lt', 'gt', 'apos', 'quot') \
+                   and match.group(0) or ''
+        return Markup(re.sub(ENTITIES, replace_entity,
+                             text.striptags().replace('\n', ' ')))
+    return text
+
+
+
 def to_utf8(text, charset='iso-8859-15'):
     """Convert a string to UTF-8, assuming the encoding is either UTF-8, ISO
     Latin-1, or as specified by the optional `charset` parameter."""

File trac/versioncontrol/web_ui/log.py

 # -*- coding: iso-8859-1 -*-
 #
-# Copyright (C) 2003-2005 Edgewall Software
+# Copyright (C) 2003-2006 Edgewall Software
 # Copyright (C) 2003-2005 Jonas Borgström <jonas@edgewall.com>
+# Copyright (C) 2005-2006 Christian Boos <cboos@neuf.fr>
 # All rights reserved.
 #
 # This software is licensed as described in the file COPYING, which
                 if email:
                     email_map[username] = email
             for cs in changes.values():
-                cs['shortlog'] = cs['shortlog'].replace('\n', ' ')
                 # For RSS, author must be an email address
                 author = cs['author']
                 author_email = ''

File trac/versioncontrol/web_ui/util.py

 # -*- coding: iso-8859-1 -*-
 #
-# Copyright (C) 2003-2005 Edgewall Software
+# Copyright (C) 2003-2006 Edgewall Software
 # Copyright (C) 2003-2005 Jonas Borgström <jonas@edgewall.com>
+# Copyright (C) 2005-2006 Christian Boos <cboos@neuf.fr>
 # All rights reserved.
 #
 # This software is licensed as described in the file COPYING, which
 # history and logs, available at http://projects.edgewall.com/trac/.
 #
 # Author: Jonas Borgström <jonas@edgewall.com>
+#         Christian Boos <cboos@neuf.fr>
 
 import re
 import urllib
 
 from trac.util import escape, format_datetime, pretty_timedelta, shorten_line, \
-                      TracError, Markup
+                      TracError, Markup, rss_title
 from trac.wiki import wiki_to_html, wiki_to_oneliner
 
 __all__ = ['get_changes', 'get_path_links', 'get_path_rev_line',
     for rev in revs:
         changeset = repos.get_changeset(rev)
         message = changeset.message or '--'
-        files = None
+        shortlog = wiki_to_oneliner(message, env, db, shorten=True)
         if format == 'changelog':
             files = [change[0] for change in changeset.get_changes()]
-        elif message:
-            if not full:
-                message = wiki_to_oneliner(message, env, db,
-                                           shorten=True)
-            else:
+        else:
+            files = None
+            if full:
                 message = wiki_to_html(message, env, req, db,
                                        absurls=(format == 'rss'),
                                        escape_newlines=True)
-        if not message:
-            message = '--'
+            else:
+                message = shortlog
+            if format == 'rss':
+                shortlog = rss_title(shortlog)
+                message = str(message)
         changes[rev] = {
             'date_seconds': changeset.date,
             'date': format_datetime(changeset.date),
             'age': pretty_timedelta(changeset.date),
             'author': changeset.author or 'anonymous',
             'message': message,
-            'shortlog': shorten_line(message),
+            'shortlog': shortlog,
             'files': files
         }
     return changes