annotate MoinMoin/action/diff.py @ 5250:00ca621ffbc2 1.9.0rc1

updated underlay
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 03 Nov 2009 00:40:45 +0100
parents 1c8da2f463ee
children c3b6639e101a
rev   line source
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin - show diff between 2 page revisions
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT 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: 1880
diff changeset
5 @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
6 2006-2008 MoinMoin:ThomasWaldmann
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 @license: GNU GPL, see COPYING for details.
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8 """
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
10 from MoinMoin import wikiutil
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11 from MoinMoin.logfile import editlog
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12 from MoinMoin.Page import Page
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
14 def execute(pagename, request):
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15 """ Handle "action=diff"
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16 checking for either a "rev=formerrevision" parameter
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17 or rev1 and rev2 parameters
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18 """
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19 if not request.user.may.read(pagename):
1777
ed44b93599b5 remove unneeded request param from page.send_page()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
20 Page(request, pagename).send_page()
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21 return
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
23 try:
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4376
diff changeset
24 date = request.values['date']
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
25 try:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
26 date = long(date) # must be long for py 2.2.x
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
27 except StandardError:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
28 date = 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29 except KeyError:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30 date = 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32 try:
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4376
diff changeset
33 rev1 = int(request.values.get('rev1', -1))
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 except StandardError:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 rev1 = 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 try:
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4376
diff changeset
37 rev2 = int(request.values.get('rev2', 0))
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38 except StandardError:
2236
ee8beeddd28d diff action: fix UnboundLocalError caused by invalid rev2 argument
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
39 rev2 = 0
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
41 if rev1 == -1 and rev2 == 0:
1682
30116d7d098a request.rev is either revision integer (when given in form) or None
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1384
diff changeset
42 rev1 = request.rev
30116d7d098a request.rev is either revision integer (when given in form) or None
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1384
diff changeset
43 if rev1 is None:
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
44 rev1 = -1
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
45
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
46 # spacing flag?
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4376
diff changeset
47 ignorews = int(request.values.get('ignorews', 0))
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
48
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
49 _ = request.getText
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
50
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
51 # get a list of old revisions, and back out if none are available
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
52 currentpage = Page(request, pagename)
2237
4238e46245d4 fixed diff action for deleted pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2236
diff changeset
53 currentrev = currentpage.current_rev()
4238e46245d4 fixed diff action for deleted pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2236
diff changeset
54 if currentrev < 2:
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2286
diff changeset
55 request.theme.add_msg(_("No older revisions available!"), "error")
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2286
diff changeset
56 currentpage.send_page()
3202
4985657ad30a diff action: fix double http header emission error
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3175
diff changeset
57 return
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
58
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
59 if date: # this is how we get called from RecentChanges
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
60 rev1 = 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
61 log = editlog.EditLog(request, rootpagename=pagename)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
62 for line in log.reverse():
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
63 if date >= line.ed_time_usecs and int(line.rev) != 99999999:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
64 rev1 = int(line.rev)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
65 break
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
66 else:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
67 rev1 = 1
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
68 rev2 = 0
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
69
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
70 # Start output
1880
b07b4c102d3d began refactoring send_page(): processing instruction extraction, getting meta/data part of page only, fixed related problems with language detection. Removed lots of duplicate or unused code.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1777
diff changeset
71 # This action generates content in the user language
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
72 request.setContentLanguage(request.lang)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
73
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2237
diff changeset
74 request.theme.send_title(_('Diff for "%s"') % (pagename, ), pagename=pagename, allow_doubleclick=1)
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
75
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
76 if rev1 > 0 and rev2 > 0 and rev1 > rev2 or rev1 == 0 and rev2 > 0:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
77 rev1, rev2 = rev2, rev1
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
78
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
79 if rev1 == -1:
2237
4238e46245d4 fixed diff action for deleted pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2236
diff changeset
80 oldrev = currentrev - 1
4238e46245d4 fixed diff action for deleted pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2236
diff changeset
81 oldpage = Page(request, pagename, rev=oldrev)
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
82 elif rev1 == 0:
2237
4238e46245d4 fixed diff action for deleted pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2236
diff changeset
83 oldrev = currentrev
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
84 oldpage = currentpage
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
85 else:
2237
4238e46245d4 fixed diff action for deleted pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2236
diff changeset
86 oldrev = rev1
4238e46245d4 fixed diff action for deleted pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2236
diff changeset
87 oldpage = Page(request, pagename, rev=oldrev)
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
88
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
89 if rev2 == 0:
2237
4238e46245d4 fixed diff action for deleted pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2236
diff changeset
90 newrev = currentrev
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
91 newpage = currentpage
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
92 else:
2237
4238e46245d4 fixed diff action for deleted pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2236
diff changeset
93 newrev = rev2
4238e46245d4 fixed diff action for deleted pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2236
diff changeset
94 newpage = Page(request, pagename, rev=newrev)
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
95
2237
4238e46245d4 fixed diff action for deleted pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2236
diff changeset
96 edit_count = abs(newrev - oldrev)
4238e46245d4 fixed diff action for deleted pages
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2236
diff changeset
97
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
98 f = request.formatter
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
99 request.write(f.div(1, id="content"))
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
100
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
101 oldrev = oldpage.get_real_rev()
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
102 newrev = newpage.get_real_rev()
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
103
3605
d0b5d160d255 fix action=info on page that never existed
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3471
diff changeset
104 revlist = currentpage.getRevList()
d0b5d160d255 fix action=info on page that never existed
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3471
diff changeset
105
d0b5d160d255 fix action=info on page that never existed
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3471
diff changeset
106 # code below assumes that the page exists and has at least
d0b5d160d255 fix action=info on page that never existed
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3471
diff changeset
107 # one revision in the revlist, just bail out if not. Users
d0b5d160d255 fix action=info on page that never existed
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3471
diff changeset
108 # shouldn't really run into this anyway.
d0b5d160d255 fix action=info on page that never existed
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3471
diff changeset
109 if not revlist:
d0b5d160d255 fix action=info on page that never existed
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3471
diff changeset
110 request.write(f.div(0)) # end content div
d0b5d160d255 fix action=info on page that never existed
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3471
diff changeset
111 request.theme.send_footer(pagename)
d0b5d160d255 fix action=info on page that never existed
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3471
diff changeset
112 request.theme.send_closing_html()
d0b5d160d255 fix action=info on page that never existed
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3471
diff changeset
113 return
d0b5d160d255 fix action=info on page that never existed
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3471
diff changeset
114
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
115 title = _('Differences between revisions %d and %d') % (oldrev, newrev)
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
116 if edit_count > 1:
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
117 title += ' ' + _('(spanning %d versions)') % (edit_count, )
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
118 title = f.text(title)
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
119
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
120 # Revision list starts from 2...
4934
efd8087a3062 action diff: enable previous / next button only in the range of given revisions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4341
diff changeset
121 if oldrev <= min(revlist):
4341
61b60d54b591 diff action: make output valid html4.01
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3605
diff changeset
122 disable_prev = u' disabled="disabled"'
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
123 else:
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
124 disable_prev = u''
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
125
4934
efd8087a3062 action diff: enable previous / next button only in the range of given revisions
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4341
diff changeset
126 if newrev >= max(revlist):
4341
61b60d54b591 diff action: make output valid html4.01
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3605
diff changeset
127 disable_next = u' disabled="disabled"'
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
128 else:
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
129 disable_next = u''
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
130
3273
9c6900a92a64 more wikiutil.escape fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
131 page_url = wikiutil.escape(currentpage.url(request), True)
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
132
3470
e69146342ed8 action.diff: respects revert right for showing revert button
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3365
diff changeset
133 revert_html = ""
e69146342ed8 action.diff: respects revert right for showing revert button
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3365
diff changeset
134 if request.user.may.revert(pagename):
e69146342ed8 action.diff: respects revert right for showing revert button
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3365
diff changeset
135 revert_html = """
e69146342ed8 action.diff: respects revert right for showing revert button
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3365
diff changeset
136 <td style="border:0">
4341
61b60d54b591 diff action: make output valid html4.01
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3605
diff changeset
137 <form action="%s" method="get">
61b60d54b591 diff action: make output valid html4.01
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3605
diff changeset
138 <div style="text-align:center">
3470
e69146342ed8 action.diff: respects revert right for showing revert button
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3365
diff changeset
139 <input name="action" value="revert" type="hidden">
e69146342ed8 action.diff: respects revert right for showing revert button
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3365
diff changeset
140 <input name="rev" value="%d" type="hidden">
e69146342ed8 action.diff: respects revert right for showing revert button
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3365
diff changeset
141 <input value="%s" type="submit"%s>
4341
61b60d54b591 diff action: make output valid html4.01
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3605
diff changeset
142 </div>
61b60d54b591 diff action: make output valid html4.01
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3605
diff changeset
143 </form>
3470
e69146342ed8 action.diff: respects revert right for showing revert button
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3365
diff changeset
144 </td>
3471
a98d9f52813e action.diff: disabled revert on current page
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3470
diff changeset
145 """ % (page_url, rev2, _("Revert to this revision"), disable_next)
3470
e69146342ed8 action.diff: respects revert right for showing revert button
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3365
diff changeset
146
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
147 navigation_html = """
3365
e64bb042f178 action.diff: rearanged buttons and title
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3364
diff changeset
148 <span class="diff-header">%s</span>
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
149 <table class="diff">
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
150 <tr>
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
151 <td style="border:0">
4341
61b60d54b591 diff action: make output valid html4.01
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3605
diff changeset
152 <form action="%s" method="get">
61b60d54b591 diff action: make output valid html4.01
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3605
diff changeset
153 <div style="text-align:left">
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
154 <input name="action" value="diff" type="hidden">
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
155 <input name="rev1" value="%d" type="hidden">
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
156 <input name="rev2" value="%d" type="hidden">
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
157 <input value="%s" type="submit"%s>
4341
61b60d54b591 diff action: make output valid html4.01
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3605
diff changeset
158 </div>
61b60d54b591 diff action: make output valid html4.01
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3605
diff changeset
159 </form>
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
160 </td>
3470
e69146342ed8 action.diff: respects revert right for showing revert button
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3365
diff changeset
161 %s
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
162 <td style="border:0">
4341
61b60d54b591 diff action: make output valid html4.01
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3605
diff changeset
163 <form action="%s" method="get">
61b60d54b591 diff action: make output valid html4.01
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3605
diff changeset
164 <div style="text-align:right">
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
165 <input name="action" value="diff" type="hidden">
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
166 <input name="rev1" value="%d" type="hidden">
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
167 <input name="rev2" value="%d" type="hidden">
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
168 <input value="%s" type="submit"%s>
4341
61b60d54b591 diff action: make output valid html4.01
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3605
diff changeset
169 </div>
61b60d54b591 diff action: make output valid html4.01
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3605
diff changeset
170 </form>
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
171 </td>
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
172 </tr>
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
173 </table>
3365
e64bb042f178 action.diff: rearanged buttons and title
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3364
diff changeset
174 """ % (title,
e64bb042f178 action.diff: rearanged buttons and title
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3364
diff changeset
175 page_url, oldrev - 1, oldrev, _("Previous change"), disable_prev,
3470
e69146342ed8 action.diff: respects revert right for showing revert button
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3365
diff changeset
176 revert_html,
3203
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
177 page_url, newrev, newrev + 1, _("Next change"), disable_next, )
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
178
136ffd0554b9 diff action: added navigation buttons (needs css work)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3202
diff changeset
179 request.write(f.rawHTML(navigation_html))
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
180
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
181 if request.user.show_fancy_diff:
1019
6488692b1eb8 have all diff implementations at one place
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1018
diff changeset
182 from MoinMoin.util import diff_html
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
183 request.write(f.rawHTML(diff_html.diff(request, oldpage.get_raw_body(), newpage.get_raw_body())))
1777
ed44b93599b5 remove unneeded request param from page.send_page()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
184 newpage.send_page(count_hit=0, content_only=1, content_id="content-below-diff")
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
185 else:
1019
6488692b1eb8 have all diff implementations at one place
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1018
diff changeset
186 from MoinMoin.util import diff_text
6488692b1eb8 have all diff implementations at one place
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1018
diff changeset
187 lines = diff_text.diff(oldpage.getlines(), newpage.getlines())
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
188 if not lines:
3122
a1322262398a refactored _() getText calls to match new api
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3039
diff changeset
189 msg = f.text(" - " + _("No differences found!"))
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
190 if edit_count > 1:
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
191 msg = msg + f.paragraph(1) + f.text(_('The page was saved %(count)d times, though!') % {
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
192 'count': edit_count}) + f.paragraph(0)
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
193 request.write(msg)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
194 else:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
195 if ignorews:
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
196 request.write(f.text(_('(ignoring whitespace)')), f.linebreak())
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
197 else:
1341
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
198 qstr = {'action': 'diff', 'ignorews': '1', }
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
199 if rev1:
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
200 qstr['rev1'] = str(rev1)
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
201 if rev2:
f4558797325a new page.link_to_raw function, use more page.link_to(_raw) instead of lowlevel wikiutil.link_tag, use more query dicts instead of strs
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
202 qstr['rev2'] = str(rev2)
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
203 request.write(f.paragraph(1), Page(request, pagename).link_to(request,
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
204 text=_('Ignore changes in the amount of whitespace'),
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
205 querystr=qstr, rel='nofollow'), f.paragraph(0))
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
206
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
207 request.write(f.preformatted(1))
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
208 for line in lines:
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
209 if line[0] == "@":
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
210 request.write(f.rule(1))
3039
744c46c1f869 fix regular diff view, escaping before text formatting is wrong (port from 1.6)
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3006
diff changeset
211 request.write(f.text(line + '\n'))
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
212 request.write(f.preformatted(0))
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
213
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
214 request.write(f.div(0)) # end content div
1018
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
215 request.theme.send_footer(pagename)
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
216 request.theme.send_closing_html()
f5b796658f93 moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
217