annotate MoinMoin/action/diff.py @ 1777:ed44b93599b5

remove unneeded request param from page.send_page()
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 18 Feb 2007 21:39:36 +0100
parents 30116d7d098a
children b07b4c102d3d
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
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
5 @copyright: 2000-2004 by Jürgen Hermann <jh@web.de>,
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
6 2006 by MoinMoin:ThomasWaldmann
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
1019
6488692b1eb8 have all diff implementations at one place
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1018
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:
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
24 date = request.form['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
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:
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
33 rev1 = int(request.form.get('rev1', [-1])[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
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:
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
37 rev2 = int(request.form.get('rev2', [0])[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
38 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
39 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
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?
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
47 ignorews = int(request.form.get('ignorews', [0])[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
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)
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
53 revisions = currentpage.getRevList()
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
54 if len(revisions) < 2:
1777
ed44b93599b5 remove unneeded request param from page.send_page()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
55 currentpage.send_page(msg=_("No older revisions available!"))
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
56 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
57
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 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
59 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
60 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
61 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
62 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
63 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
64 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
65 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
66 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
67 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
68
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 # Start output
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 # This action generate content in the user language
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
71 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
72
1068
ecece5db5288 use emit_http_headers
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1019
diff changeset
73 request.emit_http_headers()
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
74 request.theme.send_title(_('Diff for "%s"') % (pagename,), pagename=pagename, allow_doubleclick=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
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 oldrev1, oldcount1 = None, 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
80 oldrev2, oldcount2 = None, 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
81
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 # get the filename of the version to compare to
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
83 edit_count = 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
84 for rev in 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
85 edit_count += 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
86 if rev <= 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
87 oldrev1, oldcount1 = rev, edit_count
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 if rev2 and rev >= rev2:
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 oldrev2, oldcount2 = rev, edit_count
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
90 if oldrev1 and oldrev2 or oldrev1 and not rev2:
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 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
92
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
93 if 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
94 oldpage = Page(request, pagename, rev=revisions[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
95 oldcount1 -= 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
96 elif 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
97 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
98 # oldcount1 is still on init value 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
99 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
100 if oldrev1:
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
101 oldpage = Page(request, pagename, rev=oldrev1)
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
102 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
103 oldpage = Page(request, "$EmptyPage$") # hack
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
104 oldpage.set_raw_body("") # avoid loading from disk
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
105 oldrev1 = 0 # XXX
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
106
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
107 if 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
108 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
109 # oldcount2 is still on init value 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
110 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
111 if oldrev2:
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
112 newpage = Page(request, pagename, rev=oldrev2)
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
113 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
114 newpage = Page(request, "$EmptyPage$") # hack
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
115 newpage.set_raw_body("") # avoid loading from disk
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 oldrev2 = 0 # XXX
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
117
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
118 edit_count = abs(oldcount1 - oldcount2)
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
119 f = request.formatter
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
120 request.write(f.div(1, id="content"))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
121 request.write(f.paragraph(1, css_class="diff-header"))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
122 request.write(f.text(_('Differences between revisions %d and %d') % (oldpage.get_real_rev(), newpage.get_real_rev())))
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
123 if edit_count > 1:
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
124 request.write(f.text(' ' + _('(spanning %d versions)') % (edit_count,)))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
125 request.write(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
126
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
127 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
128 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
129 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
130 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
131 else:
1019
6488692b1eb8 have all diff implementations at one place
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1018
diff changeset
132 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
133 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
134 if not lines:
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
135 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
136 if edit_count > 1:
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
137 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
138 '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
139 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
140 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
141 if ignorews:
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
142 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
143 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
144 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
145 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
146 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
147 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
148 qstr['rev2'] = str(rev2)
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
149 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
150 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
151 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
152
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
153 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
154 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
155 if line[0] == "@":
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
156 request.write(f.rule(1))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
157 request.write(f.text(wikiutil.escape(line)+'\n'))
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
158 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
159
1384
d1ceb31f3d02 make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1341
diff changeset
160 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
161 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
162 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
163