annotate MoinMoin/action/diff.py @ 1018:f5b796658f93

moved edit and diff code to own files, strange: needs a http_headers() call at end of edit.py - why?
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 24 Jul 2006 00:19:55 +0200
parents
children 6488692b1eb8
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
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
10 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
11 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
12
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 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
14 """ 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
15 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
16 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
17 """
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 if not request.user.may.read(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
19 Page(request, pagename).send_page(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
20 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
21
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 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
23 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
24 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
25 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
26 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
27 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
28 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
29 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
30
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 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
32 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
33 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
34 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
35 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
36 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
37 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
38 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
39
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 if rev1 == -1 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
41 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
42 rev1 = int(request.form.get('rev', [-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
43 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
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:
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
55 currentpage.send_page(request, msg=_("No older revisions 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
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
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 request.http_headers()
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)
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
119
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
120 # this should use the formatter, but there is none?
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
121 request.write('<div id="content">\n') # start content div
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
122 request.write('<p class="diff-header">')
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 request.write(_('Differences between revisions %d and %d') % (oldpage.get_real_rev(), newpage.get_real_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
124 if 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
125 request.write(' ' + _('(spanning %d versions)') % (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
126 request.write('</p>')
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
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
128 if request.user.show_fancy_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
129 from MoinMoin.util.diff import 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
130 request.write(diff(request, oldpage.get_raw_body(), newpage.get_raw_body()))
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 newpage.send_page(request, count_hit=0, content_only=1, content_id="content-below-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
132 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
133 lines = wikiutil.linediff(oldpage.getlines(), newpage.getlines())
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:
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
135 msg = _("No differences found!")
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:
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
137 msg = msg + '<p>' + _('The page was saved %(count)d times, though!') % {
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
138 'count': 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
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:
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
142 request.write(_('(ignoring whitespace)') + '<br>')
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:
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
144 qstr = 'action=diff&ignorews=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
145 if rev1: qstr = '%s&rev1=%s' % (qstr, 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
146 if rev2: qstr = '%s&rev2=%s' % (qstr, 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
147 request.write(Page(request, pagename).link_to(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
148 text=_('Ignore changes in the amount of whitespace'),
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
149 querystr=qstr, rel='nofollow') + '<p>')
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
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
151 request.write('<pre>')
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 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
153 if line[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
154 request.write('<hr>')
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 request.write(wikiutil.escape(line)+'\n')
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
156 request.write('</pre>')
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
157
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
158 request.write('</div>\n') # end content div
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 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
160 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
161