changeset 32:5153d7c2b1c1

diffs with hrefs into the full text, TODO: extend formatter to support that imported from: moin--main--1.5--patch-33
author Thomas Waldmann <tw@waldmann-edv.de>
date Sun, 25 Sep 2005 10:37:48 +0000
parents d8ee677f6ae5
children 55ff4feb0f59
files MoinMoin/parser/wiki.py MoinMoin/util/diff.py docs/CHANGES
diffstat 3 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/parser/wiki.py	Sat Sep 24 19:32:17 2005 +0000
+++ b/MoinMoin/parser/wiki.py	Sun Sep 25 10:37:48 2005 +0000
@@ -932,6 +932,7 @@
         # Main loop
         for line in self.lines:
             self.lineno += 1
+            self.request.write('<a id="line-%d"></a>' % self.lineno) # TODO move to formatter
             self.table_rowstart = 1
             self.line_was_empty = self.line_is_empty
             self.line_is_empty = 0
--- a/MoinMoin/util/diff.py	Sat Sep 24 19:32:17 2005 +0000
+++ b/MoinMoin/util/diff.py	Sun Sep 25 10:37:48 2005 +0000
@@ -28,11 +28,12 @@
         HTML markup visualising them.
     """
     _ = request.getText
-    t_line = _("Line") + " "
+    t_line = _("Line") + " %d"
+    target = '#line-%d'
 
     seq1 = old.splitlines()
     seq2 = new.splitlines()
-    
+
     seqobj = difflib.SequenceMatcher(None, seq1, seq2)
     linematch = seqobj.get_matching_blocks()
 
@@ -64,19 +65,18 @@
         if lastmatch == match[0:2]:
             lastmatch = (match[0] + match[2], match[1] + match[2])
             continue
-
+        llineno, rlineno = lastmatch[0]+1, lastmatch[1]+1
         result += """
 <tr class="diff-title">
 <td>
-%s %s:
+<a href="%s">%s</a>:
 </td>
 <td>
-%s %s:
+<a href="%s">%s</a>:
 </td>
 </tr>
-""" % ( t_line, str(lastmatch[0] + 1),
-        t_line, str(lastmatch[1] + 1),)
-        
+""" % ( target % llineno, t_line % llineno, target % rlineno, t_line % rlineno)
+
         leftpane  = ''
         rightpane = ''
         linecount = max(match[0] - lastmatch[0], match[1] - lastmatch[1])
@@ -92,7 +92,7 @@
 
         charobj   = difflib.SequenceMatcher(None, leftpane, rightpane)
         charmatch = charobj.get_matching_blocks()
-        
+
         if charobj.ratio() < 0.5:
             # Insufficient similarity.
             if leftpane:
--- a/docs/CHANGES	Sat Sep 24 19:32:17 2005 +0000
+++ b/docs/CHANGES	Sun Sep 25 10:37:48 2005 +0000
@@ -134,6 +134,7 @@
     * added a "Despam" action to make de-spamming a wiki easy (mass revert
       bad changes done by a single author or bot). You need to be in
       cfg.superuser to use it.
+    * Better diffs with links to anchors to the changed places
     * Enhanced table support in the DocBook formatter.
     * Added 'moin' daemon script, that let you run moin standalone
       server as daemon and control the server with simple command line