Attachment 'PageGraphicalEditor.patch'
Download 1 --- PageGraphicalEditor-1.5b2.py 2005-11-06 06:35:56.000000000 +0900
2 +++ PageGraphicalEditor.py 2005-11-24 09:50:32.149867300 +0900
3 @@ -63,6 +63,27 @@
4 edit_lock_message = None
5 preview = kw.get('preview', None)
6 staytop = kw.get('staytop', 0)
7 +
8 + # for section editing
9 + issectionedit = kw.get('issectionedit', 1)
10 + pagetext = kw.get('pagetext', None)
11 + startline = int(form.get('startline', ['0'])[0])
12 + endline = int(form.get('endline', ['0'])[0])
13 + srev = int(form.get('srev', ['0'])[0])
14 +
15 + if startline or endline:
16 + if not startline:
17 + startline = 1
18 +
19 + if not endline:
20 + endline = -1
21 + else:
22 + issectionedit = 0
23 +
24 + if issectionedit:
25 + # need to add config
26 + self._allow_section_edit = self.cfg.allow_section_edit
27 + # self._allow_section_edit = 1
28
29 # check edit permissions
30 if not self.request.user.may.write(self.page_name):
31 @@ -94,7 +115,10 @@
32 title = _('Edit "%(pagename)s"')
33 else:
34 title = _('Preview of "%(pagename)s"')
35 - self.set_raw_body(preview, modified=1)
36 + if issectionedit and pagetext is not None:
37 + self.set_raw_body(pagetext, modified=1)
38 + else:
39 + self.set_raw_body(preview, modified=1)
40
41 # send header stuff
42 lock_timeout = self.lock.timeout / 60
43 @@ -134,9 +158,19 @@
44 # We don't show preview when in conflict
45 preview = None
46
47 + # no section-editing any more
48 + if issectionedit:
49 + conflict_msg = u'%s %s' % (conflict_msg, _('Section editing is canceled.'))
50 + issectionedit = 0
51 +
52 elif self.exists():
53 # revision of existing page
54 rev = self.current_rev()
55 +
56 + if issectionedit and preview is None:
57 + if not (srev and srev == rev):
58 + conflict_msg = u'%s %s' % (_('Section editing is canceled.'), _('Someone else updated this page. You are editing the updated revision.'))
59 + issectionedit = 0
60 else:
61 # page creation
62 rev = 0
63 @@ -193,13 +227,19 @@
64 # Generate default content for new pages
65 if not raw_body:
66 raw_body = _('Describe %s here.') % (self.page_name,)
67 -
68 + elif issectionedit:
69 + # for section editing
70 + if pagetext is not None:
71 + raw_body = preview
72 + else:
73 + raw_body = self.fetchsection(raw_body, startline, endline)
74 +
75 # send form
76 self.request.write('<form id="editor" method="post" action="%s/%s#preview">' % (
77 self.request.getScriptname(),
78 wikiutil.quoteWikinameURL(self.page_name),
79 ))
80 -
81 +
82 # yet another weird workaround for broken IE6 (it expands the text
83 # editor area to the right after you begin to type...). IE sucks...
84 # http://fplanque.net/2003/Articles/iecsstextarea/
85 @@ -210,6 +250,11 @@
86 # Send revision of the page our edit is based on
87 self.request.write('<input type="hidden" name="rev" value="%d">' % (rev,))
88
89 + # Send section startline and endline for section-editing
90 + if issectionedit:
91 + self.request.write('<input type="hidden" name="startline" value="%d">' % startline)
92 + self.request.write('<input type="hidden" name="endline" value="%d">' % endline)
93 +
94 # Save backto in a hidden input
95 backto = form.get('backto', [None])[0]
96 if backto:
97 @@ -328,9 +373,12 @@
98 })
99
100 self.request.write("</p>")
101 -
102 +
103 badwords_re = None
104 if preview is not None:
105 + if issectionedit:
106 + self.set_raw_body(preview)
107 +
108 if SpellCheck and (
109 form.has_key('button_spellcheck') or
110 form.has_key('button_newwords')):
111 @@ -345,10 +393,16 @@
112 content_id = 'previewbelow'
113 else:
114 content_id = 'preview'
115 - self.send_page(self.request, content_id=content_id, content_only=1,
116 +
117 + if issectionedit:
118 + self.send_page(self.request, content_id=content_id, content_only=1,
119 + hilite_re=badwords_re, do_cache=False)
120 + else:
121 + self.send_page(self.request, content_id=content_id, content_only=1,
122 hilite_re=badwords_re)
123
124 self.request.write(self.request.formatter.endContent()) # end content div
125 self.request.theme.emit_custom_html(self.cfg.page_footer1)
126 self.request.theme.emit_custom_html(self.cfg.page_footer2)
127
128 +
129
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.