annotate MoinMoin/PageGraphicalEditor.py @ 4326:07862b0663fd

merge moin/1.8 repo
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Fri, 22 Aug 2008 22:58:18 +0200
parents 162002d5b148 c1bddba80ebd
children 5ad5753ae311
rev   line source
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
1 # -*- coding: iso-8859-1 -*-
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
2 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
3 MoinMoin - Call the GUI editor (FCKeditor)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
4
1909
be140a589f11 improved some module docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1908
diff changeset
5 Same as PageEditor, but we use the HTML based GUI editor here.
be140a589f11 improved some module docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1908
diff changeset
6
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
7 TODO:
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
8 * see PageEditor.py
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
9
1918
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1909
diff changeset
10 @copyright: 2006 Bastian Blank, Florian Festi,
bb2e053067fb fixing copyright headers: remove umlauts (encoding troubles), make epydoc compatible, reformat
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1909
diff changeset
11 2006-2007 MoinMoin:ThomasWaldmann
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
12 @license: GNU GPL, see COPYING for details.
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
13 """
1791
6dd2e29acffe Eclipse PyDev Check: fixed lots of its errors and warnings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1784
diff changeset
14 import re
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
15
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
16 from MoinMoin import PageEditor
1793
2a4caa295346 Eclipse PyDev Check: fixed lots of its errors and warnings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1791
diff changeset
17 from MoinMoin import wikiutil
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
18 from MoinMoin.Page import Page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
19 from MoinMoin.widget import html
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
20 from MoinMoin.widget.dialog import Status
1791
6dd2e29acffe Eclipse PyDev Check: fixed lots of its errors and warnings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1784
diff changeset
21 from MoinMoin.util import web
1908
8bd4b581cc60 make converter pluggable, dynamically load correct converter, move loading of parser to send_page_content
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1880
diff changeset
22 from MoinMoin.parser.text_moin_wiki import Parser as WikiParser
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
23
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
24 def execute(pagename, request):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
25 if not request.user.may.write(pagename):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
26 _ = request.getText
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: 2754
diff changeset
27 request.theme.add_msg_('You are not allowed to edit this page.', "error")
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: 2754
diff changeset
28 Page(request, pagename).send_page()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
29 return
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
30
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
31 PageGraphicalEditor(request, pagename).sendEditor()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
32
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
33
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
34 class PageGraphicalEditor(PageEditor.PageEditor):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
35 """ Same as PageEditor, but use the GUI editor (FCKeditor) """
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
36 def word_rule(self):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
37 regex = re.compile(r"\(\?<![^)]*?\)")
3390
f1ba94b7913d GUI editor: fixed javascript error by using a simpler word_rule_js regex
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3269
diff changeset
38 word_rule = regex.sub("", WikiParser.word_rule_js)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
39 return repr(word_rule)[1:]
199
4e9b5e9610da fixed editor preview throwing away page content for new pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 194
diff changeset
40
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
41 def sendEditor(self, **kw):
1961
4e528d291fc0 Page*.py: improve docstrings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1920
diff changeset
42 """ Send the editor form page.
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
43
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
44 @keyword preview: if given, show this text in preview mode
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
45 @keyword staytop: don't go to #preview
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
46 @keyword comment: comment field (when preview is true)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
47 """
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
48 from MoinMoin import i18n
3629
bf72cc397f76 fix some ImportError handlers: SpellCheck is builtin. Don't hide import errors in wikiserverconfig.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3573
diff changeset
49 from MoinMoin.action import SpellCheck
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
50
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
51 request = self.request
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
52 form = request.form
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
53 _ = self._
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
54 request.disableHttpCaching(level=2)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
55
199
4e9b5e9610da fixed editor preview throwing away page content for new pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 194
diff changeset
56 raw_body = ''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
57 msg = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
58 conflict_msg = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
59 edit_lock_message = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
60 preview = kw.get('preview', None)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
61 staytop = kw.get('staytop', 0)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
62
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
63 # check edit permissions
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
64 if not request.user.may.write(self.page_name):
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
65 msg = _('You are not allowed to edit this page.')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
66 elif not self.isWritable():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
67 msg = _('Page is immutable!')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
68 elif self.rev:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
69 # Trying to edit an old version, this is not possible via
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
70 # the web interface, but catch it just in case...
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
71 msg = _('Cannot edit old revisions!')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
72 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
73 # try to acquire edit lock
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
74 ok, edit_lock_message = self.lock.acquire()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
75 if not ok:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
76 # failed to get the lock
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
77 if preview is not None:
36
eb3b18ffb28b fixed some english strings, better converter debugging msgs, move lineno anchors to formatter
Thomas Waldmann <tw@waldmann-edv.de>
parents: 18
diff changeset
78 edit_lock_message = _('The lock you held timed out. Be prepared for editing conflicts!'
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
79 ) + "<br>" + edit_lock_message
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
80 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
81 msg = edit_lock_message
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
82
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
83 # Did one of the prechecks fail?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
84 if msg:
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: 2754
diff changeset
85 request.theme.add_msg(msg, "error")
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: 2754
diff changeset
86 self.send_page()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
87 return
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
88
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
89 # check if we want to load a draft
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
90 use_draft = None
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1832
diff changeset
91 if 'button_load_draft' in form:
4237
162002d5b148 Replaced some references to request.form with MultiDict-compatible semantics
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4235
diff changeset
92 wanted_draft_timestamp = int(form.get('draft_ts', '0'))
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
93 if wanted_draft_timestamp:
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
94 draft = self._load_draft()
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
95 if draft is not None:
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
96 draft_timestamp, draft_rev, draft_text = draft
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
97 if draft_timestamp == wanted_draft_timestamp:
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
98 use_draft = draft_text
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
99
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
100 # Check for draft / normal / preview submit
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
101 if use_draft is not None:
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
102 title = _('Draft of "%(pagename)s"')
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
103 # Propagate original revision
4237
162002d5b148 Replaced some references to request.form with MultiDict-compatible semantics
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4235
diff changeset
104 rev = int(form['draft_rev'])
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
105 self.set_raw_body(use_draft, modified=1)
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
106 preview = use_draft
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
107 elif preview is None:
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
108 title = _('Edit "%(pagename)s"')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
109 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
110 title = _('Preview of "%(pagename)s"')
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
111 # Propagate original revision
1682
30116d7d098a request.rev is either revision integer (when given in form) or None
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1656
diff changeset
112 rev = request.rev
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
113 self.set_raw_body(preview, modified=1)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
114
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
115 # send header stuff
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
116 lock_timeout = self.lock.timeout / 60
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
117 lock_page = wikiutil.escape(self.page_name, quote=1)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
118 lock_expire = _("Your edit lock on %(lock_page)s has expired!") % {'lock_page': lock_page}
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
119 lock_mins = _("Your edit lock on %(lock_page)s will expire in # minutes.") % {'lock_page': lock_page}
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
120 lock_secs = _("Your edit lock on %(lock_page)s will expire in # seconds.") % {'lock_page': lock_page}
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
121
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
122 # get request parameters
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
123 try:
4237
162002d5b148 Replaced some references to request.form with MultiDict-compatible semantics
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4235
diff changeset
124 text_rows = int(form['rows'])
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
125 except StandardError:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
126 text_rows = self.cfg.edit_rows
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
127 if request.user.valid:
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
128 text_rows = int(request.user.edit_rows)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
129
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
130 if preview is not None:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
131 # Check for editing conflicts
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
132 if not self.exists():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
133 # page does not exist, are we creating it?
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
134 if rev:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
135 conflict_msg = _('Someone else deleted this page while you were editing!')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
136 elif rev != self.current_rev():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
137 conflict_msg = _('Someone else changed this page while you were editing!')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
138 if self.mergeEditConflict(rev):
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
139 conflict_msg = _("""Someone else saved this page while you were editing!
785
f3c1ea6ef86e Refactored conflict messages, removed link to diff because it is not necessary for a 3-way merge.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 779
diff changeset
140 Please review the page and save then. Do not save this page as it is!""")
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
141 rev = self.current_rev()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
142 if conflict_msg:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
143 # We don't show preview when in conflict
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
144 preview = None
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
145
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
146 elif self.exists():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
147 # revision of existing page
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
148 rev = self.current_rev()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
149 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
150 # page creation
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
151 rev = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
152
779
9834dda36973 Added conflict icon in RecentChanges, refactored conflict handling in the code. Translators, esp. german translators!, there seems to be an outdated string. You will see it on the editing conflict.
Alexander Schremmer <alex AT alexanderweb DOT de>
parents: 657
diff changeset
153 self.setConflict(bool(conflict_msg))
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
154
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
155 # Page editing is done using user language
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
156 request.setContentLanguage(request.lang)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
157
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
158 # Get the text body for the editor field.
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
159 # TODO: what about deleted pages? show the text of the last revision or use the template?
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
160 if preview is not None:
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
161 raw_body = self.get_raw_body()
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
162 if use_draft:
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
163 request.write(_("[Content loaded from draft]"), '<br>')
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
164 elif self.exists():
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
165 # If the page exists, we get the text from the page.
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
166 # TODO: maybe warn if template argument was ignored because the page exists?
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
167 raw_body = self.get_raw_body()
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1832
diff changeset
168 elif 'template' in form:
3490
af3460a4cb79 fix some typos in messages / comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
169 # If the page does not exist, we try to get the content from the template parameter.
4237
162002d5b148 Replaced some references to request.form with MultiDict-compatible semantics
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4235
diff changeset
170 template_page = wikiutil.unquoteWikiname(form['template'])
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
171 if request.user.may.read(template_page):
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
172 raw_body = Page(request, template_page).get_raw_body()
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
173 if raw_body:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
174 request.write(_("[Content of new page loaded from %s]") % (template_page, ), '<br>')
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
175 else:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
176 request.write(_("[Template %s not found]") % (template_page, ), '<br>')
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
177 else:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
178 request.write(_("[You may not read %s]") % (template_page, ), '<br>')
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
179
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
180 # Make backup on previews - but not for new empty pages
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
181 if not use_draft and preview and raw_body:
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
182 self._save_draft(raw_body, rev)
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
183
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
184 draft_message = None
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
185 loadable_draft = False
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
186 if preview is None:
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
187 draft = self._load_draft()
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
188 if draft is not None:
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
189 draft_timestamp, draft_rev, draft_text = draft
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
190 if draft_text != raw_body:
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
191 loadable_draft = True
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
192 page_rev = rev
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
193 draft_timestamp_str = request.user.getFormattedDateTime(draft_timestamp)
3123
5cb80bd604b4 refactored _() getText calls to match new api
Radomir Dopieralski <moindev@sheep.art.pl>
parents: 3037
diff changeset
194 draft_message = _(u"'''<<BR>>Your draft based on revision %(draft_rev)d (saved %(draft_timestamp_str)s) can be loaded instead of the current revision %(page_rev)d by using the load draft button - in case you lost your last edit somehow without saving it.''' A draft gets saved for you when you do a preview, cancel an edit or unsuccessfully save.", wiki=True, percent=True) % locals()
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
195
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
196 # Setup status message
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
197 status = [kw.get('msg', ''), conflict_msg, edit_lock_message, draft_message]
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
198 status = [msg for msg in status if msg]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
199 status = ' '.join(status)
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
200 status = Status(request, content=status)
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
201
3037
c0d62e7f4fbc PageGraphicalEditor: fixed deprecation of send_page(msg=)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3035
diff changeset
202 request.theme.add_msg(status, "error")
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
203 request.theme.send_title(
1776
fc75423e26a8 remove unneeded request param from page.split_title()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1695
diff changeset
204 title % {'pagename': self.split_title(), },
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
205 page=self,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
206 html_head=self.lock.locktype and (
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
207 PageEditor._countdown_js % {
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
208 'countdown_script': request.theme.externalScript('countdown'),
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
209 'lock_timeout': lock_timeout,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
210 'lock_expire': lock_expire,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
211 'lock_mins': lock_mins,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
212 'lock_secs': lock_secs,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
213 }) or '',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
214 editor_mode=1,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
215 )
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
216
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
217 request.write(request.formatter.startContent("content"))
191
e5ca7fa46f2e fixed Page(Graphical)Editor so that template param doesnt destroy existing pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 131
diff changeset
218
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
219 # Generate default content for new pages
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
220 if not raw_body:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
221 raw_body = _('Describe %s here.') % (self.page_name, )
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
222
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
223 # send form
4235
a6c315ff8d66 Make more use of werkzeugs Href object for URL-generation in MoinMoin
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
224 request.write('<form id="editor" method="post" action="%s#preview">' % (
a6c315ff8d66 Make more use of werkzeugs Href object for URL-generation in MoinMoin
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4176
diff changeset
225 request.href(self.page_name)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
226 ))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
227
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
228 # yet another weird workaround for broken IE6 (it expands the text
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
229 # editor area to the right after you begin to type...). IE sucks...
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
230 # http://fplanque.net/2003/Articles/iecsstextarea/
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
231 request.write('<fieldset style="border:none;padding:0;">')
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
232
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
233 request.write(unicode(html.INPUT(type="hidden", name="action", value="edit")))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
234
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
235 # Send revision of the page our edit is based on
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
236 request.write('<input type="hidden" name="rev" value="%d">' % (rev, ))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
237
1908
8bd4b581cc60 make converter pluggable, dynamically load correct converter, move loading of parser to send_page_content
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1880
diff changeset
238 # Add src format (e.g. 'wiki') into a hidden form field, so that
8bd4b581cc60 make converter pluggable, dynamically load correct converter, move loading of parser to send_page_content
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1880
diff changeset
239 # we can load the correct converter after POSTing.
8bd4b581cc60 make converter pluggable, dynamically load correct converter, move loading of parser to send_page_content
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1880
diff changeset
240 request.write('<input type="hidden" name="format" value="%s">' % self.pi['format'])
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
241
1573
1453513eaa7e use tickets for editing, cfg.edit_ticketing, make tickets more safe, invalidate old tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1549
diff changeset
242 # Create and send a ticket, so we can check the POST
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
243 request.write('<input type="hidden" name="ticket" value="%s">' % wikiutil.createTicket(request))
1573
1453513eaa7e use tickets for editing, cfg.edit_ticketing, make tickets more safe, invalidate old tickets
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1549
diff changeset
244
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
245 # Save backto in a hidden input
4237
162002d5b148 Replaced some references to request.form with MultiDict-compatible semantics
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4235
diff changeset
246 backto = form.get('backto')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
247 if backto:
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
248 request.write(unicode(html.INPUT(type="hidden", name="backto", value=backto)))
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
249
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
250 # button bar
3629
bf72cc397f76 fix some ImportError handlers: SpellCheck is builtin. Don't hide import errors in wikiserverconfig.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3573
diff changeset
251 button_spellcheck = '<input class="button" type="submit" name="button_spellcheck" value="%s">' % _('Check Spelling')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
252
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
253 save_button_text = _('Save Changes')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
254 cancel_button_text = _('Cancel')
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
255
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
256 if self.cfg.page_license_enabled:
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
257 request.write('<p><em>', _(
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
258 """By hitting '''%(save_button_text)s''' you put your changes under the %(license_link)s.
3269
398ab9187a50 getText calls: fix some percent=... args
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3168
diff changeset
259 If you don't want that, hit '''%(cancel_button_text)s''' to cancel your changes.""", wiki=True) % {
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
260 'save_button_text': save_button_text,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
261 'cancel_button_text': cancel_button_text,
1784
2668d470091f wikiutil.getSysPage renamed to getLocalizedPage
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1779
diff changeset
262 'license_link': wikiutil.getLocalizedPage(request, self.cfg.page_license_page).link_to(request),
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
263 }, '</em></p>')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
264
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
265 request.write('''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
266 <input class="button" type="submit" name="button_save" value="%s">
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
267 <input class="button" type="submit" name="button_preview" value="%s">
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
268 <input class="button" type="submit" name="button_switch" value="%s">
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
269 ''' % (save_button_text, _('Preview'), _('Text mode'), ))
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
270
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
271 if loadable_draft:
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
272 request.write('''
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
273 <input class="button" type="submit" name="button_load_draft" value="%s" onClick="flgChange = false;">
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
274 <input type="hidden" name="draft_ts" value="%d">
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
275 <input type="hidden" name="draft_rev" value="%d">
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
276 ''' % (_('Load Draft'), draft_timestamp, draft_rev))
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
277
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
278 request.write('''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
279 %s
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
280 <input class="button" type="submit" name="button_cancel" value="%s">
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
281 <input type="hidden" name="editor" value="gui">
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
282 ''' % (button_spellcheck, cancel_button_text, ))
3035
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
283 if self.cfg.mail_enabled:
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
284 request.write('''
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
285 <script type="text/javascript">
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
286 function toggle_trivial(CheckedBox)
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
287 {
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
288 TrivialBoxes = document.getElementsByName("trivial");
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
289 for (var i = 0; i < TrivialBoxes.length; i++)
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
290 TrivialBoxes[i].checked = CheckedBox.checked;
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
291 }
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
292 </script>
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
293 &nbsp;
3168
0b0b756908c1 fix using unique IDs for 'trivial change' checkboxes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
294 <input type="checkbox" name="trivial" id="chktrivialtop" value="1" %(checked)s onclick="toggle_trivial(this)">
0b0b756908c1 fix using unique IDs for 'trivial change' checkboxes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
295 <label for="chktrivialtop">%(label)s</label>
3035
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
296 ''' % {
4237
162002d5b148 Replaced some references to request.form with MultiDict-compatible semantics
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4235
diff changeset
297 'checked': ('', 'checked')[form.get('trivial', '0') == '1'],
3123
5cb80bd604b4 refactored _() getText calls to match new api
Radomir Dopieralski <moindev@sheep.art.pl>
parents: 3037
diff changeset
298 'label': _("Trivial change"),
3035
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
299 })
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
300
2983
7b0aadb97d01 new antispam stuff: textchas (text CAPTCHAs), cleanup AttachFile handler (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2966
diff changeset
301 from MoinMoin.security.textcha import TextCha
7b0aadb97d01 new antispam stuff: textchas (text CAPTCHAs), cleanup AttachFile handler (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2966
diff changeset
302 request.write(TextCha(request).render())
7b0aadb97d01 new antispam stuff: textchas (text CAPTCHAs), cleanup AttachFile handler (port from 1.6)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 2966
diff changeset
303
542
2f495a1be4c7 confirm leaving JS added to gui editor, TODO: add flgChange update JS code
Thomas Waldmann <tw@waldmann-edv.de>
parents: 476
diff changeset
304 self.sendconfirmleaving() # TODO update state of flgChange to make this work, see PageEditor
2f495a1be4c7 confirm leaving JS added to gui editor, TODO: add flgChange update JS code
Thomas Waldmann <tw@waldmann-edv.de>
parents: 476
diff changeset
305
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
306 # Add textarea with page text
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: 1868
diff changeset
307 lang = self.pi.get('language', request.cfg.language_default)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
308 contentlangdirection = i18n.getDirection(lang) # 'ltr' or 'rtl'
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
309 uilanguage = request.lang
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
310 url_prefix_static = request.cfg.url_prefix_static
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
311 url_prefix_local = request.cfg.url_prefix_local
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
312 wikipage = wikiutil.quoteWikinameURL(self.page_name)
1654
2a1f570ea6d4 cfg.url_prefix_local for stuff that needs to be loaded from same-site to work correctly (e.g. FCKeditor - ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1640
diff changeset
313 fckbasepath = url_prefix_local + '/applets/FCKeditor'
4168
2edbd96f3179 Replaced request.getScriptname() with a werkzeug property
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 3629
diff changeset
314 wikiurl = request.script_root
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
315 if not wikiurl or wikiurl[-1] != '/':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
316 wikiurl += '/'
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
317 themepath = '%s/%s' % (url_prefix_static, request.theme.name)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
318 smileypath = themepath + '/img'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
319 # auto-generating a list for SmileyImages does NOT work from here!
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
320 editor_size = int(request.user.edit_rows) * 22 # 22 height_pixels/line
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
321 word_rule = self.word_rule()
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
322
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
323 request.write("""
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
324 <script type="text/javascript" src="%(fckbasepath)s/fckeditor.js"></script>
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
325 <script type="text/javascript">
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
326 <!--
3951
c1bddba80ebd solve javascript alert error
Byeongweon [tasyblue@gmail.com]
parents: 3950
diff changeset
327 var oFCKeditor = new FCKeditor( 'savetext', '100%%', %(editor_size)s, 'MoinDefault' ) ;
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
328 oFCKeditor.BasePath= '%(fckbasepath)s/' ;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
329 oFCKeditor.Config['WikiBasePath'] = '%(wikiurl)s' ;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
330 oFCKeditor.Config['WikiPage'] = '%(wikipage)s' ;
1654
2a1f570ea6d4 cfg.url_prefix_local for stuff that needs to be loaded from same-site to work correctly (e.g. FCKeditor - ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1640
diff changeset
331 oFCKeditor.Config['PluginsPath'] = '%(url_prefix_local)s/applets/moinFCKplugins/' ;
2a1f570ea6d4 cfg.url_prefix_local for stuff that needs to be loaded from same-site to work correctly (e.g. FCKeditor - ported from 1.5)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1640
diff changeset
332 oFCKeditor.Config['CustomConfigurationsPath'] = '%(url_prefix_local)s/applets/moinfckconfig.js' ;
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
333 oFCKeditor.Config['WordRule'] = %(word_rule)s ;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
334 oFCKeditor.Config['SmileyPath'] = '%(smileypath)s/' ;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
335 oFCKeditor.Config['EditorAreaCSS'] = '%(themepath)s/css/common.css' ;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
336 oFCKeditor.Config['SkinPath'] = '%(fckbasepath)s/editor/skins/silver/' ;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
337 oFCKeditor.Config['AutoDetectLanguage'] = false ;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
338 oFCKeditor.Config['DefaultLanguage'] = '%(uilanguage)s' ;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
339 oFCKeditor.Config['ContentLangDirection'] = '%(contentlangdirection)s' ;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
340 oFCKeditor.Value= """ % locals())
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
341
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
342 from MoinMoin.formatter.text_gedit import Formatter
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
343 self.formatter = Formatter(request)
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
344 self.formatter.page = self
1908
8bd4b581cc60 make converter pluggable, dynamically load correct converter, move loading of parser to send_page_content
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1880
diff changeset
345 output = request.redirectedOutput(self.send_page_content, request, raw_body, format=self.pi['format'], do_cache=False)
68
0bbc39b09f95 optimize backup by sorting, refactor some easy stuff to use redirectedOutput
Thomas Waldmann <tw@waldmann-edv.de>
parents: 36
diff changeset
346 output = repr(output)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
347 if output[0] == 'u':
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
348 output = output[1:]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
349 request.write(output)
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
350 request.write(""" ;
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
351 oFCKeditor.Create() ;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
352 //-->
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
353 </script>
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
354 """)
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
355 request.write("<p>")
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
356 request.write(_("Comment:"),
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
357 ' <input id="editor-comment" type="text" name="comment" value="%s" size="80" maxlength="200">' % (
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
358 wikiutil.escape(kw.get('comment', ''), 1), ))
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
359 request.write("</p>")
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
360
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
361 # Category selection
3573
124d0ef138aa change page_*_regex processing, see docs/CHANGES (fixes Xapian category search for non-english)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3490
diff changeset
362 filterfn = self.cfg.cache.page_category_regexact.search
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
363 cat_pages = request.rootpage.getPageList(filter=filterfn)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
364 cat_pages.sort()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
365 cat_pages = [wikiutil.pagelinkmarkup(p) for p in cat_pages]
3143
16ae95df840a i18n.getText: fixed some callers that had still 'formatted=' kw args
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3123
diff changeset
366 cat_pages.insert(0, ('', _('<No addition>')))
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
367 request.write("<p>")
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
368 request.write(_('Add to: %(category)s') % {
1791
6dd2e29acffe Eclipse PyDev Check: fixed lots of its errors and warnings
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1784
diff changeset
369 'category': unicode(web.makeSelection('category', cat_pages)),
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
370 })
18
316340dd9a7f remove subscribe icon in classic when no mail is enabled. fix check for sendmail.
Thomas Waldmann <tw@waldmann-edv.de>
parents: 0
diff changeset
371 if self.cfg.mail_enabled:
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
372 request.write('''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
373 &nbsp;
3035
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
374 <input type="checkbox" name="trivial" id="chktrivial" value="1" %(checked)s onclick="toggle_trivial(this)">
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
375 <label for="chktrivial">%(label)s</label> ''' % {
4237
162002d5b148 Replaced some references to request.form with MultiDict-compatible semantics
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4235
diff changeset
376 'checked': ('', 'checked')[form.get('trivial', '0') == '1'],
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
377 'label': _("Trivial change"),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
378 })
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
379
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
380 request.write('''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
381 &nbsp;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
382 <input type="checkbox" name="rstrip" id="chkrstrip" value="1" %(checked)s>
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
383 <label for="chkrstrip">%(label)s</label>
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
384 </p> ''' % {
4237
162002d5b148 Replaced some references to request.form with MultiDict-compatible semantics
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4235
diff changeset
385 'checked': ('', 'checked')[form.get('rstrip', '0') == '1'],
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
386 'label': _('Remove trailing whitespace from each line')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
387 })
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
388
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
389 request.write("</p>")
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
390
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
391 badwords_re = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
392 if preview is not None:
3629
bf72cc397f76 fix some ImportError handlers: SpellCheck is builtin. Don't hide import errors in wikiserverconfig.
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3573
diff changeset
393 if 'button_spellcheck' in form or 'button_newwords' in form:
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
394 badwords, badwords_re, msg = SpellCheck.checkSpelling(self, request, own_form=0)
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
395 request.write("<p>%s</p>" % msg)
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
396 request.write('</fieldset>')
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
397 request.write("</form>")
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
398
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
399 if preview is not None:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
400 if staytop:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
401 content_id = 'previewbelow'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
402 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
403 content_id = 'preview'
1777
ed44b93599b5 remove unneeded request param from page.send_page()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1776
diff changeset
404 self.send_page(content_id=content_id, content_only=1, hilite_re=badwords_re)
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
405
1695
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
406 request.write(request.formatter.endContent()) # end content div
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
407 request.theme.send_footer(self.page_name)
9ae9f564380e fix backtrace on editor preview, refactor code to use 'request', not 'self.request'
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1682
diff changeset
408 request.theme.send_closing_html()
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
409