Edgewall Software

Ticket #3263: wiki_timeline_event_diff_link-r3412.patch

File wiki_timeline_event_diff_link-r3412.patch, 2.3 KB (added by cboos, 6 years ago)

Implements (diff) links, added after the change comment.

  • trac/wiki/web_ui.py

     
    2828from trac.util import get_reporter_id 
    2929from trac.util.datefmt import format_datetime, pretty_timedelta 
    3030from trac.util.text import shorten_line 
    31 from trac.util.markup import html, Markup 
     31from trac.util.markup import html, Markup, Fragment 
    3232from trac.versioncontrol.diff import get_diff_options, hdf_diff 
    3333from trac.web.chrome import add_link, add_stylesheet, INavigationContributor 
    3434from trac.web import HTTPNotFound, IRequestHandler 
     
    148148            href = format == 'rss' and req.abs_href or req.href 
    149149            db = self.env.get_db_cnx() 
    150150            cursor = db.cursor() 
    151             cursor.execute("SELECT time,name,comment,author " 
     151            cursor.execute("SELECT time,name,comment,author,version " 
    152152                           "FROM wiki WHERE time>=%s AND time<=%s", 
    153153                           (start, stop)) 
    154             for t,name,comment,author in cursor: 
     154            for t,name,comment,author,version in cursor: 
    155155                title = Markup('<em>%s</em> edited by %s', 
    156156                               wiki.format_page_name(name), author) 
    157157                if format == 'rss': 
     
    160160                else: 
    161161                    comment = wiki_to_oneliner(comment, self.env, db, 
    162162                                               shorten=True) 
     163                    if version > 1: 
     164                        diff_link = html.A('diff', href=href.wiki( 
     165                            name, action='diff', version=version, 
     166                            old_version=version-1)) 
     167                        comment = Fragment(comment, ' (', diff_link, ')') 
    163168                yield 'wiki', href.wiki(name), title, t, author, comment 
    164169 
    165170            # Attachments 
  • trac/util/markup.py

     
    278278class Fragment(object): 
    279279    __slots__ = ['children'] 
    280280 
    281     def __init__(self): 
     281    def __init__(self, *args): 
    282282        self.children = [] 
     283        for arg in args: 
     284            self.append(arg) 
    283285 
    284286    def append(self, node): 
    285287        """Append an element or string as child node."""