annotate MoinMoin/PageGraphicalEditor.py @ 5646:e45e3ae9e540

scrolling the text editor to the double clicked line If you have edit_on_doubleclick enabled (either by configuration default or by user preferences), double clicking into the wiki page text will enter edit mode and (for the text editor) position the cursor near the place where you clicked (for some browsers it will be the correct line, for others it will be just near). Also, if you are doing a preview of your edit, you can also click into the preview to scroll the editor to a position near to the line where you clicked. See cfg.checkbox_defaults' 'edit_on_doubleclick' member for modifying the default. Thanks to Radomir Dopieralski and Roger D. Haase for implementing and testing this.
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 04 Apr 2010 13:31:54 +0200
parents 268004c7b206
children 5b04b7edee94
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._
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
54
199
4e9b5e9610da fixed editor preview throwing away page content for new pages
Thomas Waldmann <tw@waldmann-edv.de>
parents: 194
diff changeset
55 raw_body = ''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
56 msg = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
57 conflict_msg = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
58 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
59 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
60 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
61
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
62 # 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
63 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
64 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
65 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
66 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
67 elif self.rev:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
68 # 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
69 # 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
70 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
71 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
72 # 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
73 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
74 if not ok:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
75 # 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
76 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
77 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
78 ) + "<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
79 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
80 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
81
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
82 # 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
83 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
84 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
85 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
86 return
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
87
4444
b757ecd984fb Fix headers already sent exception in GUI editor code when using e.g. edit LOCKing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3629
diff changeset
88 # Emit http_headers after checks (send_page)
b757ecd984fb Fix headers already sent exception in GUI editor code when using e.g. edit LOCKing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3629
diff changeset
89 request.disableHttpCaching(level=2)
b757ecd984fb Fix headers already sent exception in GUI editor code when using e.g. edit LOCKing
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3629
diff changeset
90
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
91 # 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
92 use_draft = None
1868
64507f46beb2 reduce usage of has_key()
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1832
diff changeset
93 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
94 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
95 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
96 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
97 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
98 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
99 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
100 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
101
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
102 # 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
103 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
104 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
105 # 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
106 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
107 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
108 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
109 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
110 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
111 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
112 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
113 # 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
114 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
115 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
116
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
117 # send header stuff
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
118 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
119 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
120 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
121 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
122 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
123
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
124 # get request parameters
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
125 try:
4237
162002d5b148 Replaced some references to request.form with MultiDict-compatible semantics
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4235
diff changeset
126 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
127 except StandardError:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
128 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
129 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
130 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
131
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
132 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
133 # 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
134 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
135 # 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
136 if 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 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
138 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
139 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
140 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
141 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
142 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
143 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
144 if conflict_msg:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
145 # 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
146 preview = None
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
147
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
148 elif self.exists():
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
149 # 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
150 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
151 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
152 # page creation
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
153 rev = 0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
154
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
155 self.setConflict(bool(conflict_msg))
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
156
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
157 # 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
158 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
159
1640
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
160 # 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
161 # 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
162 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
163 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
164 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
165 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
166 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
167 # 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
168 # 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
169 raw_body = self.get_raw_body()
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4326
diff changeset
170 elif 'template' in request.values:
3490
af3460a4cb79 fix some typos in messages / comments
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3390
diff changeset
171 # If the page does not exist, we try to get the content from the template parameter.
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4326
diff changeset
172 template_page = wikiutil.unquoteWikiname(request.values['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
173 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
174 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
175 if raw_body:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
176 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
177 else:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
178 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
179 else:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
180 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
181
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
182 # 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
183 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
184 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
185
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
186 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
187 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
188 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
189 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
190 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
191 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
192 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
193 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
194 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
195 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
196 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
197
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
198 # 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
199 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
200 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
201 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
202 status = Status(request, content=status)
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
203
3037
c0d62e7f4fbc PageGraphicalEditor: fixed deprecation of send_page(msg=)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 3035
diff changeset
204 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
205 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
206 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
207 page=self,
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
208 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
209 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
210 '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
211 '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
212 '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
213 '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
214 '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
215 }) or '',
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
216 editor_mode=1,
5646
e45e3ae9e540 scrolling the text editor to the double clicked line
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4649
diff changeset
217 allow_doubleclick=1,
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
218 )
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
219
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
220 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
221
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
222 # 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
223 if not raw_body:
2286
01f05e74aa9c Big PEP8 and whitespace cleanup
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1961
diff changeset
224 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
225
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
226 # 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
227 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
228 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
229 ))
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
230
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
231 # 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
232 # 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
233 # 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
234 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
235
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
236 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
237
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
238 # 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
239 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
240
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
241 # 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
242 # 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
243 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
244
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
245 # 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
246 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
247
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
248 # Save backto in a hidden input
4424
5ad5753ae311 pre-1.9: request.form has qs args and post data, 1.9: .form only post data, .args only qs args, .values both
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4326
diff changeset
249 backto = request.values.get('backto')
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
250 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
251 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
252
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
253 # 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
254 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
255
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
256 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
257 cancel_button_text = _('Cancel')
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
258
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
259 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
260 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
261 """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
262 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
263 '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
264 '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
265 '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
266 }, '</em></p>')
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
267
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
268 request.write('''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
269 <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
270 <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
271 <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
272 ''' % (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
273
6478c7744221 new per page drafts functionality, replaces old /MoinEditorBackup method
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1580
diff changeset
274 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
275 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
276 <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
277 <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
278 <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
279 ''' % (_('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
280
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
281 request.write('''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
282 %s
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
283 <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
284 <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
285 ''' % (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
286 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
287 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
288 <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
289 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
290 {
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 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
292 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
293 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
294 }
b545446562a0 fix for MoinMoinBugs/TrivialChangeEasyAccess (thanks to Ninnu) (ported from 1.6)
Reimar Bauer <rb.proj AT googlemail DOT com>
parents: 2983
diff changeset
295 </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
296 &nbsp;
3168
0b0b756908c1 fix using unique IDs for 'trivial change' checkboxes
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 3143
diff changeset
297 <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
298 <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
299 ''' % {
4237
162002d5b148 Replaced some references to request.form with MultiDict-compatible semantics
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4235
diff changeset
300 '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
301 '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
302 })
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
303
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
304 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
305 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
306
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
307 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
308
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
309 # 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
310 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
311 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
312 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
313 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
314 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
315 wikipage = wikiutil.quoteWikinameURL(self.page_name)
4645
641b595ce675 use url_prefix_fckeditor if you don't want to use the builtin FCKeditor of moin, but a separate one at some specific url
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4445
diff changeset
316 fckbasepath = request.cfg.url_prefix_fckeditor
4579
87d97510de79 getScriptname() -> script_root, getBaseURL() -> url_root (for werkzeug API)
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 4472
diff changeset
317 wikiurl = request.script_root + '/'
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
318 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
319 smileypath = themepath + '/img'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
320 # 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
321 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
322 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
323
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
324 request.write("""
0
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" 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
326 <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
327 <!--
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
328 var oFCKeditor = new FCKeditor( 'savetext', '100%%', %(editor_size)s, 'MoinDefault' ) ;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
329 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
330 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
331 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
332 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
333 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
334 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
335 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
336 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
337 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
338 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
339 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
340 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
341 oFCKeditor.Value= """ % locals())
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
342
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
343 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
344 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
345 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
346 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
347 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
348 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
349 output = output[1:]
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
350 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
351 request.write(""" ;
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
352 oFCKeditor.Create() ;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
353 //-->
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
354 </script>
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
355 """)
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
356 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
357 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
358 ' <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
359 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
360 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
361
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
362 # 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
363 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
364 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
365 cat_pages.sort()
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
366 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
367 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
368 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
369 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
370 '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
371 })
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
372 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
373 request.write('''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
374 &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
375 <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
376 <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
377 '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
378 'label': _("Trivial change"),
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
379 })
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
380
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
381 request.write('''
0
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
382 &nbsp;
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
383 <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
384 <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
385 </p> ''' % {
4237
162002d5b148 Replaced some references to request.form with MultiDict-compatible semantics
Florian Krupicka <florian.krupicka@googlemail.com>
parents: 4235
diff changeset
386 '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
387 '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
388 })
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
389
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
390 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
391
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
392 badwords_re = None
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
393 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
394 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
395 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
396 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
397 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
398 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
399
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
400 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
401 if staytop:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
402 content_id = 'previewbelow'
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
403 else:
77665d8e2254 tag of nonpublic@localhost--archive/moin--enterprise--1.5--base-0
Thomas Waldmann <tw-public@gmx.de>
parents:
diff changeset
404 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
405 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
406
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
407 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
408 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
409 request.theme.send_closing_html()
1577
c2457afd322d cosmetic changes, mostly whitespace
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 1573
diff changeset
410