annotate MoinMoin/action/info.py @ 4376:eda647742453

merged moin/1.8
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 05 Oct 2008 00:38:07 +0200
parents 62177a952833 817d99d715fe
children 5ad5753ae311
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
4363
817d99d715fe remove direct usage of deprecated sha module - use hashlib, if possible
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4093
diff changeset
35 from MoinMoin.support.python_compatibility import hash_new
817d99d715fe remove direct usage of deprecated sha module - use hashlib, if possible
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4093
diff changeset
36 digest = hash_new('sha1', 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
3345
41e04736a9f1 info action: fix buglet with diff defaults
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3344
diff changeset
107 pgactioncount = 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
108 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
109 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
110 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
111 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
112 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
113 actions.append(render_action(_('view'), {'action': 'recall', 'rev': '%d' % rev}))
3345
41e04736a9f1 info action: fix buglet with diff defaults
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3344
diff changeset
114 if pgactioncount == 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
115 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
116 lchecked = ''
3345
41e04736a9f1 info action: fix buglet with diff defaults
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3344
diff changeset
117 elif pgactioncount == 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
118 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
119 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
120 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
121 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
122 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
123 if rev > 1:
dba9666479a9 info action: add 'diff to previous' link
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3343
diff changeset
124 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
125 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
126 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
127 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
128 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
129 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
130 comment = _("Renamed from '%(oldpagename)s'.") % {'oldpagename': line.extra}
3345
41e04736a9f1 info action: fix buglet with diff defaults
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3344
diff changeset
131 pgactioncount += 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
132 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
133 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
134 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
135
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 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
137 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
138 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
139 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
140 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
141 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
142 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
143 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
144 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
145 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
146 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
147
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
148 actions.append(render_action(_('get'), {'action': 'AttachFile', 'do': 'get', 'target': '%s' % filename}))
3350
7707cd079690 info: show only delete options to users with the delete right
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3345
diff changeset
149 if request.user.may.delete(pagename):
7707cd079690 info: show only delete options to users with the delete right
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3345
diff changeset
150 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
151
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 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
153 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
154 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
155 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
156 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
157 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
158 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
159 "&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
160 ))
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 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
162 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
163 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
164
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
165 # 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
166 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
167
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
168 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
169
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 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
171 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
172 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
173
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
174 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
175 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
176
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 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
178 div.append(html.INPUT(type="hidden", name="action", value="diff"))
4093
742cabb168b9 browser._format: refactored input parameter "method". The default value is changed from "GET" to None. Now it does not add a form tag to the table on default. You have to give a value of "GET" or "POST" to add a form tag using the given method.
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3907
diff changeset
179 div.append(history_table.render(method="GET"))
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
180
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
181 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
182 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
183 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
184
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
185 # 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
186 _ = 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
187 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
188 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
189
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
190 request.setContentLanguage(request.lang)
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
191 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
192
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2000
diff changeset
193 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
194 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
195 (_('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
196 {'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
197 (_('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
198 {'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
199 (_('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
200 {'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
201 ]
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
202 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
203 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
204 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
205 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
206 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
207
4201
40acd13fb3d6 Changed form access to MultiDict forms
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
208 show_hitcounts = int(request.form.get('hitcounts', 0)) != 0
40acd13fb3d6 Changed form access to MultiDict forms
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
209 show_general = int(request.form.get('general', 0)) != 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
210
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 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
212 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
213 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
214 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
215 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
216 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
217 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
218
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
219 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
220 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
221 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
222