annotate MoinMoin/action/info.py @ 3344:dba9666479a9

info action: add 'diff to previous' link
author Johannes Berg <johannes AT sipsolutions DOT net>
date Thu, 20 Mar 2008 14:26:29 +0100
parents 04548b25e042
children 41e04736a9f1
rev   line source
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 """
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 MoinMoin - info action
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 Displays page history, some general page infos and statistics.
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1914
diff changeset
7 @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
3290
abb32b0af96b revision history: enable the user to get more revisions show by using max_count=123, enable wiki admin to limit that
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3270
diff changeset
8 2006-2008 MoinMoin:ThomasWaldmann
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9 @license: GNU GPL, see COPYING for details.
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10 """
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12 from MoinMoin import config, wikiutil, action
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13 from MoinMoin.Page import Page
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
14 from MoinMoin.logfile import editlog
1129
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
15 from MoinMoin.widget import html
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17 def execute(pagename, request):
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18 """ show misc. infos about a page """
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
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: 1776
diff changeset
20 Page(request, pagename).send_page()
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21 return
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
23 def general(page, pagename, request):
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
24 _ = request.getText
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
25 f = request.formatter
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
26
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
27 request.write(f.heading(1, 1),
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
28 f.text(_('General Information')),
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
29 f.heading(0, 1))
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
31 request.write(f.paragraph(1),
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
32 f.text(_("Page size: %d") % page.size()),
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
33 f.paragraph(0))
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
34
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 import sha
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 digest = sha.new(page.get_raw_body().encode(config.charset)).hexdigest().upper()
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
37 request.write(f.paragraph(1),
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
38 f.rawHTML('%(label)s <tt>%(value)s</tt>' % {
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
39 'label': _("SHA digest of this page's content is:"),
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
40 'value': digest, }),
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
41 f.paragraph(0))
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
42
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
43 # show attachments (if allowed)
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
44 attachment_info = action.getHandler(request, 'AttachFile', 'info')
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
45 if attachment_info:
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
46 request.write(attachment_info(pagename, request))
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
47
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
48 # show subscribers
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
49 subscribers = page.getSubscribers(request, include_self=1, return_users=1)
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
50 if subscribers:
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
51 request.write(f.paragraph(1))
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
52 request.write(f.text(_('The following users subscribed to this page:')))
1870
9406e02388cf reduce usage of .keys()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1832
diff changeset
53 for lang in subscribers:
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
54 request.write(f.linebreak(), f.text('[%s] ' % lang))
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
55 for user in subscribers[lang]:
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
56 # do NOT disclose email addr, only WikiName
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
57 userhomepage = Page(request, user.name)
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
58 if userhomepage.exists():
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
59 request.write(f.rawHTML(userhomepage.link_to(request) + ' '))
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
60 else:
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
61 request.write(f.text(user.name + ' '))
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
62 request.write(f.paragraph(0))
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
63
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
64 # show links
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
65 links = page.getPageLinks(request)
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
66 if links:
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
67 request.write(f.paragraph(1))
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
68 request.write(f.text(_('This page links to the following pages:')))
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
69 request.write(f.linebreak())
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
70 for linkedpage in links:
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
71 request.write(f.rawHTML("%s%s " % (Page(request, linkedpage).link_to(request), ",."[linkedpage == links[-1]])))
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
72 request.write(f.paragraph(0))
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
73
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
74 def history(page, pagename, request):
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
75 # show history as default
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
76 _ = request.getText
3290
abb32b0af96b revision history: enable the user to get more revisions show by using max_count=123, enable wiki admin to limit that
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3270
diff changeset
77 default_count, limit_max_count = request.cfg.history_count
abb32b0af96b revision history: enable the user to get more revisions show by using max_count=123, enable wiki admin to limit that
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3270
diff changeset
78 try:
abb32b0af96b revision history: enable the user to get more revisions show by using max_count=123, enable wiki admin to limit that
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3270
diff changeset
79 max_count = int(request.form.get('max_count', [default_count])[0])
abb32b0af96b revision history: enable the user to get more revisions show by using max_count=123, enable wiki admin to limit that
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3270
diff changeset
80 except:
abb32b0af96b revision history: enable the user to get more revisions show by using max_count=123, enable wiki admin to limit that
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3270
diff changeset
81 max_count = default_count
abb32b0af96b revision history: enable the user to get more revisions show by using max_count=123, enable wiki admin to limit that
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3270
diff changeset
82 max_count = min(max_count, limit_max_count)
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
83
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
84 # open log for this page
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
85 from MoinMoin.util.dataset import TupleDataset, Column
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
86
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
87 history = TupleDataset()
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
88 history.columns = [
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
89 Column('rev', label='#', align='right'),
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
90 Column('mtime', label=_('Date'), align='right'),
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
91 Column('size', label=_('Size'), align='right'),
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
92 Column('diff', label='<input type="submit" value="%s">' % (_("Diff"))),
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
93 Column('editor', label=_('Editor'), hidden=not request.cfg.show_names),
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
94 Column('comment', label=_('Comment')),
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
95 Column('action', label=_('Action')),
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
96 ]
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
97
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
98 # generate history list
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
99
1129
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
100 def render_action(text, query, **kw):
1283
e26799c574b0 small bugfix for info action
Franz Pletz <fpletz AT franz-pletz DOT org>
parents: 1129
diff changeset
101 kw.update(dict(rel='nofollow'))
1920
b06ef2a53efa 'make pylint', fixed lots of minor stuff found by pylint (and there is still lots left to do)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1918
diff changeset
102 return page.link_to(request, text, querystr=query, **kw)
1129
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
103
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
104 # read in the complete log of this page
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
105 log = editlog.EditLog(request, rootpagename=pagename)
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
106 count = 0
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
107 for line in log.reverse():
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
108 rev = int(line.rev)
1129
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
109 actions = []
1713
1f18d08ec3ba better display of renamed pages on info/RC, show diff-link for deleted pages on RC
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1683
diff changeset
110 if line.action in ('SAVE', 'SAVENEW', 'SAVE/REVERT', 'SAVE/RENAME', ):
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
111 size = page.size(rev=rev)
3343
04548b25e042 info action: always use recall to allow sending the link
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3290
diff changeset
112 actions.append(render_action(_('view'), {'action': 'recall', 'rev': '%d' % rev}))
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
113 if count == 0:
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
114 rchecked = ' checked="checked"'
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
115 lchecked = ''
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
116 elif count == 1:
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
117 lchecked = ' checked="checked"'
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
118 rchecked = ''
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
119 else:
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
120 lchecked = rchecked = ''
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
121 diff = '<input type="radio" name="rev1" value="%d"%s><input type="radio" name="rev2" value="%d"%s>' % (rev, lchecked, rev, rchecked)
3344
dba9666479a9 info action: add 'diff to previous' link
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3343
diff changeset
122 if rev > 1:
dba9666479a9 info action: add 'diff to previous' link
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3343
diff changeset
123 diff += render_action(' ' + _('to previous'), {'action': 'diff', 'rev1': rev-1, 'rev2': rev})
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
124 comment = line.comment
1713
1f18d08ec3ba better display of renamed pages on info/RC, show diff-link for deleted pages on RC
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1683
diff changeset
125 if not comment:
1f18d08ec3ba better display of renamed pages on info/RC, show diff-link for deleted pages on RC
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1683
diff changeset
126 if '/REVERT' in line.action:
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
127 comment = _("Revert to revision %(rev)d.") % {'rev': int(line.extra)}
1713
1f18d08ec3ba better display of renamed pages on info/RC, show diff-link for deleted pages on RC
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1683
diff changeset
128 elif '/RENAME' in line.action:
1f18d08ec3ba better display of renamed pages on info/RC, show diff-link for deleted pages on RC
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1683
diff changeset
129 comment = _("Renamed from '%(oldpagename)s'.") % {'oldpagename': line.extra}
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
130 else: # ATT*
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
131 rev = '-'
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
132 diff = '-'
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
133
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
134 filename = wikiutil.url_unquote(line.extra)
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
135 comment = "%s: %s %s" % (line.action, filename, line.comment)
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
136 size = 0
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
137 if line.action != 'ATTDEL':
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
138 from MoinMoin.action import AttachFile
2000
f77a7f6bb560 info action: don't try to stat attachments that don't exist
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 1920
diff changeset
139 if AttachFile.exists(request, pagename, filename):
f77a7f6bb560 info action: don't try to stat attachments that don't exist
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 1920
diff changeset
140 size = AttachFile.size(request, pagename, filename)
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
141 if line.action == 'ATTNEW':
1129
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
142 actions.append(render_action(_('view'), {'action': 'AttachFile', 'do': 'view', 'target': '%s' % filename}))
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
143 elif line.action == 'ATTDRW':
1129
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
144 actions.append(render_action(_('edit'), {'action': 'AttachFile', 'drawing': '%s' % filename.replace(".draw", "")}))
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
145
1129
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
146 actions.append(render_action(_('get'), {'action': 'AttachFile', 'do': 'get', 'target': '%s' % filename}))
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
147 actions.append(render_action(_('del'), {'action': 'AttachFile', 'do': 'del', 'target': '%s' % filename}))
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
148
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
149 history.addRow((
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
150 rev,
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
151 request.user.getFormattedDateTime(wikiutil.version2timestamp(line.ed_time_usecs)),
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
152 str(size),
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
153 diff,
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
154 line.getEditor(request) or _("N/A"),
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
155 wikiutil.escape(comment) or '&nbsp;',
1129
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
156 "&nbsp;".join(actions),
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
157 ))
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
158 count += 1
3290
abb32b0af96b revision history: enable the user to get more revisions show by using max_count=123, enable wiki admin to limit that
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3270
diff changeset
159 if count >= max_count:
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
160 break
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
161
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
162 # print version history
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
163 from MoinMoin.widget.browser import DataBrowserWidget
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
164
1129
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
165 request.write(unicode(html.H2().append(_('Revision History'))))
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
166
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
167 if not count: # there was no entry in logfile
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
168 request.write(_('No log entries found.'))
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
169 return
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
170
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
171 history_table = DataBrowserWidget(request)
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
172 history_table.setData(history)
1129
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
173
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
174 div = html.DIV(id="page-history")
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
175 div.append(html.INPUT(type="hidden", name="action", value="diff"))
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
176 div.append(history_table.toHTML())
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
177
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
178 form = html.FORM(method="GET", action="")
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
179 form.append(div)
4d0f0ecc7880 cleaned up info action, TODO: use buttons - code there, but doesnt work
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1068
diff changeset
180 request.write(unicode(form))
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
181
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
182 # main function
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
183 _ = request.getText
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
184 page = Page(request, pagename)
1776
fc75423e26a8 remove unneeded request param from page.split_title()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1713
diff changeset
185 title = page.split_title()
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
186
1068
ecece5db5288 use emit_http_headers
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1066
diff changeset
187 request.emit_http_headers()
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
188
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: 1873
diff changeset
189 request.setContentLanguage(request.lang)
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
190 f = request.formatter
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
191
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2000
diff changeset
192 request.theme.send_title(_('Info for "%s"') % (title, ), page=page)
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
193 menu_items = [
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
194 (_('Show "%(title)s"') % {'title': _('Revision History')},
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
195 {'action': 'info'}),
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
196 (_('Show "%(title)s"') % {'title': _('General Page Infos')},
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
197 {'action': 'info', 'general': '1'}),
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
198 (_('Show "%(title)s"') % {'title': _('Page hits and edits')},
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
199 {'action': 'info', 'hitcounts': '1'}),
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
200 ]
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
201 request.write(f.div(1, id="content")) # start content div
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
202 request.write(f.paragraph(1))
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
203 for text, querystr in menu_items:
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
204 request.write("[%s] " % page.link_to(request, text=text, querystr=querystr, rel='nofollow'))
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
205 request.write(f.paragraph(0))
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
206
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
207 show_hitcounts = int(request.form.get('hitcounts', [0])[0]) != 0
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
208 show_general = int(request.form.get('general', [0])[0]) != 0
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
209
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
210 if show_hitcounts:
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
211 from MoinMoin.stats import hitcounts
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
212 request.write(hitcounts.linkto(pagename, request, 'page=' + wikiutil.url_quote_plus(pagename)))
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
213 elif show_general:
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
214 general(page, pagename, request)
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
215 else:
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
216 history(page, pagename, request)
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
217
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
218 request.write(f.div(0)) # end content div
1016
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
219 request.theme.send_footer(pagename)
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
220 request.theme.send_closing_html()
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
221