Attachment 'patch-RecentChanges-improved-diff-links.diff'
Download 1 diff -r da7fed3ec62f MoinMoin/macro/RecentChanges.py
2 --- a/MoinMoin/macro/RecentChanges.py Tue Sep 28 22:29:24 2010 +0200
3 +++ b/MoinMoin/macro/RecentChanges.py Sun Oct 03 16:21:57 2010 +0200
4 @@ -107,22 +107,70 @@
5
6 # print editor name or IP
7 d['editors'] = None
8 + d['editors_detailed'] = None
9 if request.cfg.show_names:
10 +
11 + # one line means only one revision
12 if len(lines) > 1:
13 counters = {}
14 - for idx in range(len(lines)):
15 - name = lines[idx].getEditor(request)
16 - if not name in counters:
17 - counters[name] = []
18 - counters[name].append(idx+1)
19 - poslist = [(v, k) for k, v in counters.items()]
20 - poslist.sort()
21 +
22 + # track the editor name and build suitable ranges
23 + current_name = None
24 + current_edit_rev = None
25 + current_idx = None
26 +
27 + # visit each line, recording the editor name, change number range
28 + # and revision number range
29 + for idx, edit_line in enumerate(lines):
30 +
31 + # get the edit details for the log line
32 + name = edit_line.getEditor(request)
33 + edit_rev = int(edit_line.rev)
34 +
35 + # record the editor and details
36 + if current_name != name:
37 + if current_name is not None:
38 + if not counters.has_key(current_name):
39 + counters[current_name] = []
40 + counters[current_name].append((range(current_idx + 1, idx + 1), (edit_rev, current_edit_rev)))
41 + current_name = name
42 + current_edit_rev = edit_rev
43 + current_idx = idx
44 +
45 + # for the final change, get a diff to the revision before
46 + else:
47 + if current_name is not None:
48 + if not counters.has_key(current_name):
49 + counters[current_name] = []
50 + counters[current_name].append((range(current_idx + 1, idx + 2), (edit_rev - 1, current_edit_rev)))
51 +
52 + # get the editors in order
53 + editors = [(v, k) for k, v in counters.items()]
54 + editors.sort()
55 +
56 + # prepare a dictionary of editor details for display
57 d['editors'] = []
58 - for positions, name in poslist:
59 + d['editors_detailed'] = []
60 +
61 + for details, name in editors:
62 +
63 + # get the combined index list
64 + all_idx_list = []
65 + for idx_list, rev_range in details:
66 + all_idx_list += idx_list
67 +
68 + # make the editor summary
69 d['editors'].append("%s [%s]" % (
70 - name, util.rangelist(positions)))
71 + name, util.rangelist(all_idx_list)))
72 +
73 + # make the editor details for display
74 + d['editors_detailed'].append((
75 + name, page, details))
76 +
77 else:
78 - d['editors'] = [line.getEditor(request)]
79 + name = line.getEditor(request)
80 + d['editors'] = [name]
81 + d['editors_detailed'] = [(name, page, None)]
82
83 comments = []
84 for idx in range(len(lines)):
85 diff -r da7fed3ec62f MoinMoin/theme/__init__.py
86 --- a/MoinMoin/theme/__init__.py Tue Sep 28 22:29:24 2010 +0200
87 +++ b/MoinMoin/theme/__init__.py Sun Oct 03 16:21:57 2010 +0200
88 @@ -14,7 +14,7 @@
89 from MoinMoin import i18n, wikiutil, config, version, caching
90 from MoinMoin.action import get_available_actions
91 from MoinMoin.Page import Page
92 -from MoinMoin.util import pysupport
93 +from MoinMoin.util import pysupport, rangelist
94
95 modules = pysupport.getPackageModules(__file__)
96
97 @@ -1437,8 +1437,39 @@
98 html.append('<td class="rcicon2">%(info_html)s</td>\n' % d)
99
100 html.append('<td class="rceditor">')
101 - if d['editors']:
102 - html.append('<br>'.join(d['editors']))
103 + if d['editors_detailed']:
104 + notfirst = 0
105 + for name, page, details in d['editors_detailed']:
106 + if notfirst:
107 + html.append('<br>')
108 +
109 + html.append(name)
110 +
111 + if details is not None:
112 + html.append(" [")
113 + notfirstlink = 0
114 +
115 + for idx_list, rev_range in details:
116 + if notfirstlink:
117 + html.append(',')
118 +
119 + # handle pages with previous content
120 + start_rev, end_rev = rev_range
121 + if start_rev > 0:
122 + html.append(
123 + page.link_to_raw(self.request, "%s" % rangelist(idx_list),
124 + querystr={'action': 'diff', 'rev1': start_rev,
125 + 'rev2': end_rev}, rel='nofollow'))
126 +
127 + # handle initial edits of pages
128 + else:
129 + html.append(
130 + page.link_to_raw(self.request, "%s" % rangelist(idx_list),
131 + rel='nofollow'))
132 + notfirstlink = 1
133 + html.append("]")
134 +
135 + notfirst = 1
136 html.append('</td>\n')
137
138 html.append('<td class="rccomment">')
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.