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

updated underlay
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 03 Nov 2009 00:40:45 +0100
parents 61ce73eb13a0
children b23b1d2b1391
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
5102
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
16 from MoinMoin.action import AttachFile
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
17
8b196cdb11e8 move info 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 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
19 """ 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
20 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
21 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
22 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
23
8b196cdb11e8 move info 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 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
25 _ = request.getText
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
26 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
27
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
28 request.write(f.heading(1, 1),
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
29 f.text(_('General Information')),
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
30 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
31
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
32 request.write(f.paragraph(1),
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
33 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
34 f.paragraph(0))
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
35
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
36 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
37 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
38 request.write(f.paragraph(1),
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
39 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
40 '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
41 'value': digest, }),
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
42 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
43
8b196cdb11e8 move info 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 # show attachments (if allowed)
5168
61ce73eb13a0 action.getHandler(): make it moin 1.8 compatible again
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5102
diff changeset
45 attachment_info = action.getHandler(request, 'AttachFile', 'info')
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
46 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
47 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
48
8b196cdb11e8 move info 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 # 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
50 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
51 if subscribers:
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
52 request.write(f.paragraph(1))
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
53 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
54 for lang in subscribers:
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
55 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
56 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
57 # 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
58 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
59 if userhomepage.exists():
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
60 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
61 else:
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
62 request.write(f.text(user.name + ' '))
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
63 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
64
8b196cdb11e8 move info 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 # 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
66 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
67 if links:
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
68 request.write(f.paragraph(1))
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
69 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
70 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
71 for linkedpage in links:
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
72 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
73 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
74
8b196cdb11e8 move info 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 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
76 # 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
77 _ = 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
78 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
79 try:
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4376
diff changeset
80 max_count = int(request.values.get('max_count', default_count))
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
81 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
82 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
83 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
84
8b196cdb11e8 move info 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 # 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
86 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
87
8b196cdb11e8 move info 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 = 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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96 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
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
8b196cdb11e8 move info 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 # 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
100
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
101 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
102 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
103 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
104
5102
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
105 def render_file_action(text, pagename, filename, request, do):
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
106 url = AttachFile.getAttachUrl(pagename, filename, request, do=do)
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
107 if url:
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
108 f = request.formatter
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
109 link = f.url(1, url) + f.text(text) + f.url(0)
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
110 return link
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
111
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
112 may_write = request.user.may.write(pagename)
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
113 may_delete = request.user.may.delete(pagename)
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
114
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 # 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
116 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
117 count = 0
3345
41e04736a9f1 info action: fix buglet with diff defaults
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3344
diff changeset
118 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
119 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
120 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
121 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
122 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
123 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
124 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
125 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
126 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
127 lchecked = ''
3345
41e04736a9f1 info action: fix buglet with diff defaults
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3344
diff changeset
128 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
129 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
130 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
131 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
132 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
133 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
134 if rev > 1:
dba9666479a9 info action: add 'diff to previous' link
Johannes Berg <johannes AT sipsolutions DOT net>
parents: 3343
diff changeset
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142 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
143 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
144 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
145 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
146
8b196cdb11e8 move info 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 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
148 comment = "%s: %s %s" % (line.action, filename, line.comment)
5102
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
149 if AttachFile.exists(request, pagename, filename):
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
150 size = AttachFile.size(request, pagename, filename)
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
151 actions.append(render_file_action(_('view'), pagename, filename, request, do='view'))
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
152 actions.append(render_file_action(_('get'), pagename, filename, request, do='get'))
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
153 if may_delete:
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
154 actions.append(render_file_action(_('del'), pagename, filename, request, do='del'))
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
155 if may_write:
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
156 actions.append(render_file_action(_('edit'), pagename, filename, request, do='modify'))
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
157 else:
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
158 size = 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
159
8b196cdb11e8 move info 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 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
161 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
162 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
163 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
164 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
165 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
166 wikiutil.escape(comment) or '&nbsp;',
5102
9ae242080889 drawings/attachments: made editing support more generic (details see below)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5090
diff changeset
167 "&nbsp;".join(a for a in actions if a),
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
168 ))
8b196cdb11e8 move info 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 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
170 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
171 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
172
8b196cdb11e8 move info 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 # 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
174 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
175
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 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
177
8b196cdb11e8 move info action code to own file, fix some links by using page.link_to
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
178 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
179 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
180 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
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 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
183 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
184
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
185 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
186 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
187 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
188
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
189 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
190 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
191 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
192
8b196cdb11e8 move info 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 # 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
194 _ = 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
195 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
196 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
197
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
198 request.setContentLanguage(request.lang)
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
199 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
200
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2000
diff changeset
201 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
202 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
203 (_('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
204 {'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
205 (_('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
206 {'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
207 (_('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
208 {'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
209 ]
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
210 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
211 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
212 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
213 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
214 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
215
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4376
diff changeset
216 show_hitcounts = int(request.values.get('hitcounts', 0)) != 0
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4376
diff changeset
217 show_general = int(request.values.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
218
8b196cdb11e8 move info 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 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
220 from MoinMoin.stats import hitcounts
4660
f4e386e03434 fix quoting for pagehits stats (info action) - was not working for pagenames with blanks
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4363
diff changeset
221 request.write(hitcounts.linkto(pagename, request, 'page=' + wikiutil.url_quote(pagename)))
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
222 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
223 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
224 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
225 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
226
1383
fdb726f0f34f make more use of formatter
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1347
diff changeset
227 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
228 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
229 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
230