annotate MoinMoin/action/CopyPage.py @ 4732:e9a2cbcf5479

action.CopyPage: added textcha feature
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Thu, 21 May 2009 16:38:16 +0200
parents e2107f4b6217
children d887cc013e76 c6fd8b7f82b4 37306fba2189
rev   line source
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
2 """
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
3 MoinMoin - CopyPage action
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
4
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
5 This action allows you to copy a page.
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
6
3057
9c58f31af69e CopyPage/RenamePage/DeletePage action: fix regex compile errors due to unescaped pagename usage, fix cosmetic bug, simplify/optimize code (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2966
diff changeset
7 @copyright: 2007 MoinMoin:ReimarBauer,
9c58f31af69e CopyPage/RenamePage/DeletePage action: fix regex compile errors due to unescaped pagename usage, fix cosmetic bug, simplify/optimize code (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2966
diff changeset
8 2007 MoinMoin:ThomasWaldmann
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
9 @license: GNU GPL, see COPYING for details.
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
10 """
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
11 import re
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
12 from MoinMoin import wikiutil
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
13 from MoinMoin.Page import Page
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
14 from MoinMoin.PageEditor import PageEditor
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
15 from MoinMoin.action import ActionBase
4732
e9a2cbcf5479 action.CopyPage: added textcha feature
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4071
diff changeset
16 from MoinMoin.security.textcha import TextCha
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
17
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
18 class CopyPage(ActionBase):
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
19 """ Copy page action
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
20
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
21 Note: the action name is the class name
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
22 """
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
23 def __init__(self, pagename, request):
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
24 ActionBase.__init__(self, pagename, request)
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
25 self.use_ticket = True
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
26 _ = self._
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
27 self.form_trigger = 'copy'
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
28 self.form_trigger_label = _('Copy Page')
3057
9c58f31af69e CopyPage/RenamePage/DeletePage action: fix regex compile errors due to unescaped pagename usage, fix cosmetic bug, simplify/optimize code (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2966
diff changeset
29 filterfn = re.compile(ur"^%s/.*$" % re.escape(pagename), re.U).match
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
30 pages = request.rootpage.getPageList(user='', exists=1, filter=filterfn)
3057
9c58f31af69e CopyPage/RenamePage/DeletePage action: fix regex compile errors due to unescaped pagename usage, fix cosmetic bug, simplify/optimize code (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2966
diff changeset
31 subpagenames = request.rootpage.getPageList(user='', exists=1, filter=filterfn)
9c58f31af69e CopyPage/RenamePage/DeletePage action: fix regex compile errors due to unescaped pagename usage, fix cosmetic bug, simplify/optimize code (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2966
diff changeset
32 self.subpages = subpagenames
9c58f31af69e CopyPage/RenamePage/DeletePage action: fix regex compile errors due to unescaped pagename usage, fix cosmetic bug, simplify/optimize code (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2966
diff changeset
33 self.users_subpages = [pagename for pagename in subpagenames if self.request.user.may.read(pagename)]
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
34
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
35 def is_allowed(self):
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
36 may = self.request.user.may
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
37 return may.read(self.pagename)
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
38
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
39 def check_condition(self):
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
40 _ = self._
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
41 if not self.page.exists():
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
42 return _('This page is already deleted or was never created!')
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
43 else:
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
44 return None
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
45
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
46 def do_action(self):
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
47 """ copy this page to "pagename" """
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
48 _ = self._
4732
e9a2cbcf5479 action.CopyPage: added textcha feature
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4071
diff changeset
49 # Currently we only check TextCha for upload (this is what spammers ususally do),
e9a2cbcf5479 action.CopyPage: added textcha feature
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4071
diff changeset
50 # but it could be extended to more/all attachment write access
e9a2cbcf5479 action.CopyPage: added textcha feature
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4071
diff changeset
51 if not TextCha(self.request).check_answer_from_form():
e9a2cbcf5479 action.CopyPage: added textcha feature
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4071
diff changeset
52 return status, _('TextCha: Wrong answer! Go back and try again...')
e9a2cbcf5479 action.CopyPage: added textcha feature
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4071
diff changeset
53
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
54 form = self.form
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
55 newpagename = form.get('newpagename', [u''])[0]
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
56 newpagename = self.request.normalizePagename(newpagename)
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
57 comment = form.get('comment', [u''])[0]
1922
f486526720c5 renamed wikiutil.clean_comment > clean_input, moved translation map to config
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1850
diff changeset
58 comment = wikiutil.clean_input(comment)
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
59
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
60 self.page = PageEditor(self.request, self.pagename)
3057
9c58f31af69e CopyPage/RenamePage/DeletePage action: fix regex compile errors due to unescaped pagename usage, fix cosmetic bug, simplify/optimize code (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2966
diff changeset
61 success, msgs = self.page.copyPage(newpagename, comment)
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
62
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
63 copy_subpages = 0
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
64 if form.has_key('copy_subpages'):
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
65 try:
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
66 copy_subpages = int(form['copy_subpages'][0])
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
67 except:
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
68 pass
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
69
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
70 if copy_subpages and self.subpages or (not self.users_subpages and self.subpages):
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
71 for name in self.subpages:
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
72 self.page = PageEditor(self.request, name)
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
73 new_subpagename = name.replace(self.pagename, newpagename, 1)
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
74 success_i, msg = self.page.copyPage(new_subpagename, comment)
3057
9c58f31af69e CopyPage/RenamePage/DeletePage action: fix regex compile errors due to unescaped pagename usage, fix cosmetic bug, simplify/optimize code (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2966
diff changeset
75 msgs = "%s %s" % (msgs, msg)
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
76
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
77 self.newpagename = newpagename # keep there for finish
3057
9c58f31af69e CopyPage/RenamePage/DeletePage action: fix regex compile errors due to unescaped pagename usage, fix cosmetic bug, simplify/optimize code (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2966
diff changeset
78 return success, msgs
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
79
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
80 def do_action_finish(self, success):
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
81 if success:
3234
a739558ca3dc Page.url() default changed to relative=False
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3057
diff changeset
82 url = Page(self.request, self.newpagename).url(self.request)
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
83 self.request.http_redirect(url)
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
84 else:
2966
ba14d391c2ba Refactor all modules to use the new add_msg interface in 1.7 (done by Frederico Lorenzi). Should not be backported to 1.6 but
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 2708
diff changeset
85 self.render_msg(self.make_form(), "dialog")
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
86
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
87 def get_form_html(self, buttons_html):
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
88 _ = self._
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
89 if self.users_subpages:
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
90 subpages = ' '.join(self.users_subpages)
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
91
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
92 d = {
4732
e9a2cbcf5479 action.CopyPage: added textcha feature
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4071
diff changeset
93 'textcha': TextCha(self.request).render(),
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
94 'subpage': subpages,
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1993
diff changeset
95 'subpages_checked': ('', 'checked')[self.request.form.get('subpages_checked', ['0'])[0] == '1'],
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
96 'subpage_label': _('Copy all /subpages too?'),
3273
9c6900a92a64 more wikiutil.escape fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
97 'pagename': wikiutil.escape(self.pagename, True),
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
98 'newname_label': _("New name"),
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
99 'comment_label': _("Optional reason for the copying"),
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
100 'buttons_html': buttons_html,
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
101 'querytext': _('Really copy this page?')
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
102 }
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
103
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
104 return '''
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
105 <strong>%(querytext)s</strong>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
106 <br>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
107 <br>
4732
e9a2cbcf5479 action.CopyPage: added textcha feature
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4071
diff changeset
108 %(textcha)s
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
109 <table>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
110 <tr>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
111 <dd>
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1993
diff changeset
112 %(subpage_label)s<input type="checkbox" name="copy_subpages" value="1" %(subpages_checked)s>
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
113 </dd>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
114 <dd>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
115 <class="label"><subpage> %(subpage)s</subpage>
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1993
diff changeset
116 </dd>
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
117 </tr>
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1993
diff changeset
118 </table>
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
119 <table>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
120 <tr>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
121 <td class="label"><label>%(newname_label)s</label></td>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
122 <td class="content">
2708
5092edd82058 bug fix for non css browsers like w3m: for input fields set size of textarea and text to cols="80"
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2286
diff changeset
123 <input type="text" name="newpagename" value="%(pagename)s" size="80">
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
124 </td>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
125 </tr>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
126 <tr>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
127 <td class="label"><label>%(comment_label)s</label></td>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
128 <td class="content">
2708
5092edd82058 bug fix for non css browsers like w3m: for input fields set size of textarea and text to cols="80"
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2286
diff changeset
129 <input type="text" name="comment" size="80" maxlength="200">
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
130 </td>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
131 </tr>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
132 <tr>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
133 <td></td>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
134 <td class="buttons">
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
135 %(buttons_html)s
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
136 </td>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
137 </tr>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
138 </table>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
139 ''' % d
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
140
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
141 else:
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
142 d = {
4732
e9a2cbcf5479 action.CopyPage: added textcha feature
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4071
diff changeset
143 'textcha': TextCha(self.request).render(),
3273
9c6900a92a64 more wikiutil.escape fixes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3234
diff changeset
144 'pagename': wikiutil.escape(self.pagename, True),
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
145 'newname_label': _("New name"),
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
146 'comment_label': _("Optional reason for the copying"),
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
147 'buttons_html': buttons_html,
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
148 }
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
149 return '''
4732
e9a2cbcf5479 action.CopyPage: added textcha feature
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 4071
diff changeset
150 %(textcha)s
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
151 <table>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
152 <tr>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
153 <td class="label"><label>%(newname_label)s</label></td>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
154 <td class="content">
2708
5092edd82058 bug fix for non css browsers like w3m: for input fields set size of textarea and text to cols="80"
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2286
diff changeset
155 <input type="text" name="newpagename" value="%(pagename)s" size="80">
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
156 </td>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
157 </tr>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
158 <tr>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
159 <td class="label"><label>%(comment_label)s</label></td>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
160 <td class="content">
2708
5092edd82058 bug fix for non css browsers like w3m: for input fields set size of textarea and text to cols="80"
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2286
diff changeset
161 <input type="text" name="comment" size="80" maxlength="200">
1850
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
162 </td>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
163 </tr>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
164 <tr>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
165 <td></td>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
166 <td class="buttons">
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
167 %(buttons_html)s
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
168 </td>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
169 </tr>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
170 </table>
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
171 ''' % d
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
172
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
173 def execute(pagename, request):
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
174 """ Glue code for actions """
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
175 CopyPage(pagename, request).render()
3d38db210672 action CopyPage added
Reimar Bauer <rb.proj AT googlemail DOT com>
parents:
diff changeset
176