annotate MoinMoin/util/diff_html.py @ 6100:e9ef58bdad15

use difflib from stdlib
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 06 Sep 2016 00:20:17 +0200
parents a02d87f66ce7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 MoinMoin - Side by side diffs
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1866
diff changeset
5 @copyright: 2002 Juergen Hermann <jh@web.de>,
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1866
diff changeset
6 2002 Scott Moonen <smoonen@andstuff.org>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
7 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
8 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
9
6100
e9ef58bdad15 use difflib from stdlib
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5620
diff changeset
10 import difflib
e9ef58bdad15 use difflib from stdlib
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5620
diff changeset
11
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
12 from MoinMoin.wikiutil import escape
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
13
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
14 def indent(line):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15 eol = ''
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16 while line and line[0] == '\n':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
17 eol += '\n'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
18 line = line[1:]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19 stripped = line.lstrip()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
20 if len(line) - len(stripped):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
21 line = "&nbsp;" * (len(line) - len(stripped)) + stripped
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
22 #return "%d / %d / %s" % (len(line), len(stripped), line)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
23 return eol + line
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
25
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
26 # This code originally by Scott Moonen, used with permission.
5412
9baa4e79b813 Some visual cleanup (CSS, styles) of revision information presentation in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5410
diff changeset
27 def diff(request, old, new, old_top='', new_top='', old_bottom='', new_bottom='', old_top_class='', new_top_class='', old_bottom_class='', new_bottom_class=''):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
28 """ Find changes between old and new and return
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
29 HTML markup visualising them.
5410
dac434907110 Information about revisions (number, timestamp, editor, size) in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 3123
diff changeset
30
dac434907110 Information about revisions (number, timestamp, editor, size) in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 3123
diff changeset
31 @param old: old text [unicode]
dac434907110 Information about revisions (number, timestamp, editor, size) in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 3123
diff changeset
32 @param new: new text [unicode]
dac434907110 Information about revisions (number, timestamp, editor, size) in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 3123
diff changeset
33 @param old_top: Custom html for adding ontop of old revision column (optional)
dac434907110 Information about revisions (number, timestamp, editor, size) in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 3123
diff changeset
34 @param old_bottom: Custom html for adding at bottom of old revision column (optional)
dac434907110 Information about revisions (number, timestamp, editor, size) in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 3123
diff changeset
35 @param new_top: Custom html for adding ontop of new revision column (optional)
dac434907110 Information about revisions (number, timestamp, editor, size) in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 3123
diff changeset
36 @param new_bottom: Custom html for adding at bottom of new revision column (optional)
5412
9baa4e79b813 Some visual cleanup (CSS, styles) of revision information presentation in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5410
diff changeset
37 @param old_top_class: Custom class for <td> with old_top content (optional)
9baa4e79b813 Some visual cleanup (CSS, styles) of revision information presentation in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5410
diff changeset
38 @param new_top_class: Custom class for <td> with new_top content (optional)
9baa4e79b813 Some visual cleanup (CSS, styles) of revision information presentation in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5410
diff changeset
39 @param old_bottom_class: Custom class for <td> with old_bottom content (optional)
9baa4e79b813 Some visual cleanup (CSS, styles) of revision information presentation in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5410
diff changeset
40 @param new_bottom_class: Custom class for <td> with new_bottom content (optional)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
41 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
42 _ = request.getText
32
5153d7c2b1c1 diffs with hrefs into the full text, TODO: extend formatter to support that
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
43 t_line = _("Line") + " %d"
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
44
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
45 seq1 = old.splitlines()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
46 seq2 = new.splitlines()
32
5153d7c2b1c1 diffs with hrefs into the full text, TODO: extend formatter to support that
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
47
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
48 seqobj = difflib.SequenceMatcher(None, seq1, seq2)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
49 linematch = seqobj.get_matching_blocks()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
50
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
51 result = """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
52 <table class="diff">
5410
dac434907110 Information about revisions (number, timestamp, editor, size) in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 3123
diff changeset
53 """
dac434907110 Information about revisions (number, timestamp, editor, size) in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 3123
diff changeset
54
dac434907110 Information about revisions (number, timestamp, editor, size) in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 3123
diff changeset
55 if old_top or new_top:
5412
9baa4e79b813 Some visual cleanup (CSS, styles) of revision information presentation in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5410
diff changeset
56 result += '<tr><td class="%s">%s</td><td class="%s">%s</td></tr>' % (old_top_class, old_top, new_top_class, new_top)
5410
dac434907110 Information about revisions (number, timestamp, editor, size) in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 3123
diff changeset
57
5445
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
58 if len(seq1) == len(seq2) and linematch[0] == (0, 0, len(seq1)):
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
59 # No differences.
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
60 result += '<tr><td class="diff-same" colspan="2">' + _("No differences found!") + '</td></tr>'
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
61 else:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
62 result += """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
63 <tr>
5620
a02d87f66ce7 util/diff_html.py: Fixed whitespace in generated diff view table so white-space: pre can be used (and whitespace in diffs preserved).
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5445
diff changeset
64 <td class="diff-removed"><span>%s</span></td>
a02d87f66ce7 util/diff_html.py: Fixed whitespace in generated diff view table so white-space: pre can be used (and whitespace in diffs preserved).
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5445
diff changeset
65 <td class="diff-added"><span>%s</span></td>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
66 </tr>
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
67 """ % (_('Deletions are marked like this.'), _('Additions are marked like this.'), )
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
68
5445
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
69 lastmatch = (0, 0)
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
70
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
71 # Print all differences
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
72 for match in linematch:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
73 # Starts of pages identical?
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
74 if lastmatch == match[0:2]:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
75 lastmatch = (match[0] + match[2], match[1] + match[2])
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
76 continue
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
77 llineno, rlineno = lastmatch[0]+1, lastmatch[1]+1
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
78 result += """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
79 <tr class="diff-title">
5620
a02d87f66ce7 util/diff_html.py: Fixed whitespace in generated diff view table so white-space: pre can be used (and whitespace in diffs preserved).
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5445
diff changeset
80 <td>%s:</td>
a02d87f66ce7 util/diff_html.py: Fixed whitespace in generated diff view table so white-space: pre can be used (and whitespace in diffs preserved).
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5445
diff changeset
81 <td>%s:</td>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
82 </tr>
1004
7828d27399d4 whitespace-only cleanup and minor style changes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 874
diff changeset
83 """ % (request.formatter.line_anchorlink(1, llineno) + request.formatter.text(t_line % llineno) + request.formatter.line_anchorlink(0),
5445
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
84 request.formatter.line_anchorlink(1, rlineno) + request.formatter.text(t_line % rlineno) + request.formatter.line_anchorlink(0))
32
5153d7c2b1c1 diffs with hrefs into the full text, TODO: extend formatter to support that
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
85
5445
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
86 leftpane = ''
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
87 rightpane = ''
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
88 linecount = max(match[0] - lastmatch[0], match[1] - lastmatch[1])
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
89 for line in range(linecount):
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
90 if line < match[0] - lastmatch[0]:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
91 if line > 0:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
92 leftpane += '\n'
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
93 leftpane += seq1[lastmatch[0] + line]
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
94 if line < match[1] - lastmatch[1]:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
95 if line > 0:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
96 rightpane += '\n'
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
97 rightpane += seq2[lastmatch[1] + line]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
98
5445
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
99 charobj = difflib.SequenceMatcher(None, leftpane, rightpane)
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
100 charmatch = charobj.get_matching_blocks()
32
5153d7c2b1c1 diffs with hrefs into the full text, TODO: extend formatter to support that
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
101
5445
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
102 if charobj.ratio() < 0.5:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
103 # Insufficient similarity.
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
104 if leftpane:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
105 leftresult = """<span>%s</span>""" % indent(escape(leftpane))
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
106 else:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
107 leftresult = ''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
108
5445
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
109 if rightpane:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
110 rightresult = """<span>%s</span>""" % indent(escape(rightpane))
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
111 else:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
112 rightresult = ''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
113 else:
5445
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
114 # Some similarities; markup changes.
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
115 charlast = (0, 0)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
116
5445
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
117 leftresult = ''
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
118 rightresult = ''
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
119 for thismatch in charmatch:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
120 if thismatch[0] - charlast[0] != 0:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
121 leftresult += """<span>%s</span>""" % indent(
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
122 escape(leftpane[charlast[0]:thismatch[0]]))
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
123 if thismatch[1] - charlast[1] != 0:
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
124 rightresult += """<span>%s</span>""" % indent(
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
125 escape(rightpane[charlast[1]:thismatch[1]]))
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
126 leftresult += escape(leftpane[thismatch[0]:thismatch[0] + thismatch[2]])
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
127 rightresult += escape(rightpane[thismatch[1]:thismatch[1] + thismatch[2]])
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
128 charlast = (thismatch[0] + thismatch[2], thismatch[1] + thismatch[2])
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
129
5620
a02d87f66ce7 util/diff_html.py: Fixed whitespace in generated diff view table so white-space: pre can be used (and whitespace in diffs preserved).
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5445
diff changeset
130 leftpane = '<br>'.join([indent(x) for x in leftresult.splitlines()])
a02d87f66ce7 util/diff_html.py: Fixed whitespace in generated diff view table so white-space: pre can be used (and whitespace in diffs preserved).
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5445
diff changeset
131 rightpane = '<br>'.join([indent(x) for x in rightresult.splitlines()])
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
132
5445
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
133 # removed width="50%%"
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
134 result += """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
135 <tr>
5620
a02d87f66ce7 util/diff_html.py: Fixed whitespace in generated diff view table so white-space: pre can be used (and whitespace in diffs preserved).
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5445
diff changeset
136 <td class="diff-removed">%s</td>
a02d87f66ce7 util/diff_html.py: Fixed whitespace in generated diff view table so white-space: pre can be used (and whitespace in diffs preserved).
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5445
diff changeset
137 <td class="diff-added">%s</td>
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
138 </tr>
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
139 """ % (leftpane, rightpane)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
140
5445
2b641be7728c action/diff.py: Added navigation links to change revision in left/right pane separately.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5412
diff changeset
141 lastmatch = (match[0] + match[2], match[1] + match[2])
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
142
5410
dac434907110 Information about revisions (number, timestamp, editor, size) in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 3123
diff changeset
143 if old_bottom or new_bottom:
5412
9baa4e79b813 Some visual cleanup (CSS, styles) of revision information presentation in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 5410
diff changeset
144 result += '<tr><td class="%s">%s</td><td class="%s">%s</td></tr>' % (old_top_class, old_top, new_top_class, new_top)
5410
dac434907110 Information about revisions (number, timestamp, editor, size) in diff viewer.
Eugene Syromyatnikov <evgsyr@gmail.com>
parents: 3123
diff changeset
145
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
146 result += '</table>\n'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
147 return result
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
148