Attachment 'moinmoin-1.3.4-editor-insert-patch.diff'
Download 1 Patch to MoinMoin 1.3.4 to provide a special character insert bar in
2 the page editor.
3 By Deron E. Meranda <http://deron.meranda.us/> April 2005
4 Released under the GNU General License (GPL) version 2 or later.
5 Portions of this code (Javascript portion) are derived from GPL'ed
6 code from to the Wikimedia project.
7
8 --- MoinMoin/config.py.orig 2005-03-12 16:26:16.000000000 -0500
9 +++ MoinMoin/config.py 2005-04-04 00:39:36.375259942 -0400
10 @@ -96,6 +96,172 @@
11 "{o}": (15, 15, 0, "star_off.png"),
12 }
13
14 +# Inserters for page edit.
15 +#
16 +# A list of tuples, each describing one insert selector. Each
17 +# tuple consists of five string, of the form:
18 +# (open, close, sample_body, label, description)
19 +# The open and close strings define the character(s) to insert before
20 +# and after the cursor. The sample_body will be placed between the
21 +# open and close, unless a region is currently selected in which case
22 +# the selected region is left alone. The label is what's shown in
23 +# the insert bar area, and the description is the tool-tip title.
24 +#
25 +# These strings are output as raw HTML, so be sure to use proper
26 +# escaping. Also escape single-quotes with backslashes as in \\' and
27 +# double-quotes as ". The label and description are optional,
28 +# and if missing will be constructed from the open, close, and body
29 +# values.
30 +#
31 +# You can supply simple strings rather than tuples in the list to add
32 +# nonselectable text between inserters (again escape appropriately).
33 +# An empty value or '\n' will result in a forced line break.
34 +editor_insert_tags = [
35 + ('À','','','','Latin capital A with grave'),
36 + ('à','','','','Latin small a with grave'),
37 + ('È','','','','Latin capital E with grave'),
38 + ('è','','','','Latin small e with grave'),
39 + ('Ì','','','','Latin capital I with grave'),
40 + ('ì','','','','Latin small i with grave'),
41 + ('Ò','','','','Latin capital O with grave'),
42 + ('ò','','','','Latin small o with grave'),
43 + ('Ù','','','','Latin capital U with grave'),
44 + ('ù','','','','Latin small u with grave'),
45 + ' ',
46 + ('Á','','','','Latin capital A with acute'),
47 + ('á','','','','Latin small a with acute'),
48 + ('É','','','','Latin capital E with acute'),
49 + ('é','','','','Latin small e with acute'),
50 + ('Í','','','','Latin capital I with acute'),
51 + ('í','','','','Latin small i with acute'),
52 + ('Ó','','','','Latin capital O with acute'),
53 + ('ó','','','','Latin small o with acute'),
54 + ('Ú','','','','Latin capital U with acute'),
55 + ('ú','','','','Latin small u with acute'),
56 + ('Ý','','','','Latin capital Y with acute'),
57 + ('ý','','','','Latin small y with acute'),
58 + ' ',
59 + ('Â','','','','Latin capital A with circumflex'),
60 + ('â','','','','Latin small a with circumflex'),
61 + ('Ê','','','','Latin capital E with circumflex'),
62 + ('ê','','','','Latin small e with circumflex'),
63 + ('Î','','','','Latin capital I with circumflex'),
64 + ('î','','','','Latin small i with circumflex'),
65 + ('Ô','','','','Latin capital O with circumflex'),
66 + ('ô','','','','Latin small o with circumflex'),
67 + ('Û','','','','Latin capital U with circumflex'),
68 + ('û','','','','Latin small u with circumflex'),
69 + ' ',
70 + ('Ä','','','','Latin capital A with dieresis'),
71 + ('ä','','','','Latin small a with dieresis'),
72 + ('Ë','','','','Latin capital E with dieresis'),
73 + ('ë','','','','Latin small e with dieresis'),
74 + ('Ï','','','','Latin capital I with dieresis'),
75 + ('ï','','','','Latin small i with dieresis'),
76 + ('Ö','','','','Latin capital O with dieresis'),
77 + ('ö','','','','Latin small o with dieresis'),
78 + ('Ü','','','','Latin capital U with dieresis'),
79 + ('ü','','','','Latin small u with dieresis'),
80 + ('Ÿ','','','','Latin capital Y with dieresis'),
81 + ('ÿ','','','','Latin small y with dieresis'),
82 + ' ',
83 + ('Ã','','','','Latin capital A with tilde'),
84 + ('ã','','','','Latin small a with tilde'),
85 + ('Ñ','','','','Latin capital N with tilde'),
86 + ('ñ','','','','Latin small n with tilde'),
87 + ('Õ','','','','Latin capital O with tilde'),
88 + ('õ','','','','Latin small o with tilde'),
89 + ' ',
90 + ('ç','','','','Latin small c with cedilla'),
91 + ('Ç','','','','Latin capital C with cedilla'),
92 + ' ',
93 + ('ß','','','','Latin small sharp s'),
94 + ('Ø','','','','Latin capital O with stroke'),
95 + ('ø','','','','Latin small o with stroke'),
96 + ('Ð','','','','Latin capital letter eth'),
97 + ('ð','','','','Latin small letter Eth'),
98 + ('Þ','','','','Latin capital letter Thorn'),
99 + ('þ','','','','Latin small letter thorn'),
100 + ' ',
101 + ('Å','','','','Latin capital A with ring above'),
102 + ('å','','','','Latin small a with ring above'),
103 + ' ',
104 + ('Æ','','','','Latin capital ligature AE'),
105 + ('æ','','','','Latin small ligature ae'),
106 + ('Œ','','','','Latin capital ligature OE'),
107 + ('œ','','','','Latin small ligature oe'),
108 + ('ff','','','','Latin small ligature ff'),
109 + ('fi','','','','Latin small ligature fi'),
110 + ('fl','','','','Latin small ligature fl'),
111 + None,
112 + 'Pairs: ',
113 + ('“','”','text','“ ” ','double-quoted text'),
114 + ' ',
115 + ('‘','’','text','‘ ’ ','single-quoted text'),
116 + ' ',
117 + ('«','»','text','« » ','guillemot-quoted text'),
118 + ' ',
119 + ('[',']','text','[ ] ','square-bracketed text'),
120 + ('{','}','text','{ } ','braced text'),
121 + ('<','>','text','< > ','angle-bracketed text'),
122 + ' Punctuation: ',
123 + ('¡','','','','Inverted exclamation mark'),
124 + ('¿','','','','Inverted question mark'),
125 + ('¢','','','','Cent sign'),
126 + ('£','','','','Pound sign'),
127 + ('¥','','','','Yen sign'),
128 + ('€','','','','Euro sign'),
129 + ' ',
130 + ('–','','','','en-dash'),
131 + ('—','','','','em-dash'),
132 + ' ',
133 + (' ','','','⎕','non-breaking space'),
134 + ' ',
135 + ('…','','','','horizontal elipsis'),
136 + ('•','','','','bullet'),
137 + ('©','','','','copyright sign'),
138 + ('®','','','','registered trademark sign'),
139 + ('™','','','','trademark sign'),
140 + ('†','','','','dagger'),
141 + ('‡','','','','double dagger'),
142 + ('§','','','','section sign'),
143 + ' Math: ',
144 + ('×','','','','multiplication sign'),
145 + ('÷','','','','division sign'),
146 + ('+','','','','plus sign'),
147 + ('−','','','','minus sign'),
148 + ('±','','','','plus-or-minus sign'),
149 + ('=','','','','equal to'),
150 + ('≠','','','','not equal to'),
151 + ('≤','','','','less than or equal to'),
152 + ('≥','','','','greater than or equal to'),
153 + ('¼','','','','vulgar fraction one-quarter'),
154 + ('½','','','','vulgar fraction one-half'),
155 + ('¾','','','','vulgar fraction three-quarters'),
156 + ('²','','','','superscript digit two, squared'),
157 + ('³','','','','superscript digit three, cubed'),
158 + ('µ','','','','micro sign, 1/1000000th'),
159 + ('°','','','','degree sign'),
160 + None,
161 + ' Formatting: ',
162 + ("\\'\\'","\\'\\'",'italic','<i>italic</i> ','italics text'),
163 + ("\\'\\'\\'","\\'\\'\\'",'bold','<b>bold</b> ','boldface text'),
164 + ("__","__",'underline','<u>underline</u> ','underlined text'),
165 + #("^","^",'superscript','<sup>super</sup>','superscript text'),
166 + #(",,",",,",'subscript','<sub>sub</sub>','subscript text'),
167 + ("{{{","}}}",'monospace','<tt>monospace</tt> ','monospace text'),
168 + ' ',
169 + ('[',']','http://example.com/','<u>URL</u> ','URL hyperlink'),
170 + ' ',
171 + ('["','"]','Example page','<u>WikiName</u> ','A quoted-stye Wiki Name'),
172 + ' ',
173 + ('= ',' =','heading','<b>H1</b> ','heading level 1'),
174 + ('== ',' ==','heading','<b>H2</b> ','heading level 2'),
175 + ('=== ',' ===','heading','<b>H3</b> ','heading level 3'),
176 + ('[[BR]]\\n','','','linebreak','force a new line'),
177 +]
178 +
179 +
180 # unicode: set the char types (upper, lower, digits, spaces)
181 from MoinMoin.util.chartypes import _chartypes
182 for key, val in _chartypes.items():
183 --- MoinMoin/multiconfig.py.orig 2005-03-12 16:26:14.000000000 -0500
184 +++ MoinMoin/multiconfig.py 2005-04-04 00:38:45.423848494 -0400
185 @@ -180,6 +180,7 @@
186 datetime_fmt = '%Y-%m-%d %H:%M:%S'
187 default_lang = 'en'
188 default_markup = 'wiki'
189 + edit_insert_tags_enabled = 1
190 edit_locking = 'warn 10' # None, 'warn <timeout mins>', 'lock <timeout mins>'
191 edit_rows = 30
192 hosts_deny = []
193 --- MoinMoin/PageEditor.py.orig 2005-02-27 13:25:11.000000000 -0500
194 +++ MoinMoin/PageEditor.py 2005-04-04 00:37:50.781200814 -0400
195 @@ -75,6 +75,89 @@
196 </script>
197 """
198
199 +# This javascript was derived from GPL code from the Wikimedia project.
200 +_insert_tags_js = """
201 +<script type="text/javascript">
202 +var clientPC = navigator.userAgent.toLowerCase(); // Get client info
203 +var is_gecko = ((clientPC.indexOf('gecko')!=-1) && (clientPC.indexOf('spoofer')==-1)
204 + && (clientPC.indexOf('khtml') == -1) && (clientPC.indexOf('netscape/7.0')==-1));
205 +var is_safari = ((clientPC.indexOf('AppleWebKit')!=-1) && (clientPC.indexOf('spoofer')==-1));
206 +var is_khtml = (navigator.vendor == 'KDE' || ( document.childNodes && !document.all && !navigator.taintEnabled ));
207 +if (clientPC.indexOf('opera')!=-1) {
208 + var is_opera = true;
209 + var is_opera_preseven = (window.opera && !document.childNodes);
210 + var is_opera_seven = (window.opera && document.childNodes);
211 +}
212 +// apply tagOpen/tagClose to selection in textarea,
213 +// use sampleText instead of selection if there is none
214 +// copied and adapted from phpBB
215 +function insertTags(tagOpen, tagClose, sampleText) {
216 + var txtarea = document.getElementById('editor-textarea');
217 + // var txtarea = document.editform.wpTextbox1;
218 + if( ! txtarea ) {
219 + alert('Can not locate text area control');
220 + }
221 + else if(document.selection && !is_gecko) {
222 + // IE
223 + var theSelection = document.selection.createRange().text;
224 + if(!theSelection) { theSelection=sampleText;}
225 + txtarea.focus();
226 + if(theSelection.charAt(theSelection.length - 1) == " "){// exclude ending space char, if any
227 + theSelection = theSelection.substring(0, theSelection.length - 1);
228 + document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
229 + } else {
230 + document.selection.createRange().text = tagOpen + theSelection + tagClose;
231 + }
232 + } else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
233 + // Mozilla
234 + var startPos = txtarea.selectionStart;
235 + var endPos = txtarea.selectionEnd;
236 + var scrollTop=txtarea.scrollTop;
237 + var myText = (txtarea.value).substring(startPos, endPos);
238 + if(!myText) { myText=sampleText;}
239 + if(myText.charAt(myText.length - 1) == " "){ // exclude ending space char, if any
240 + subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
241 + } else {
242 + subst = tagOpen + myText + tagClose;
243 + }
244 + txtarea.value = txtarea.value.substring(0, startPos) + subst +
245 + txtarea.value.substring(endPos, txtarea.value.length);
246 + txtarea.focus();
247 +
248 + var cPos=startPos+(tagOpen.length+myText.length+tagClose.length);
249 + txtarea.selectionStart=cPos;
250 + txtarea.selectionEnd=cPos;
251 + txtarea.scrollTop=scrollTop;
252 + } else {
253 + // All others
254 + var copy_alertText=alertText;
255 + var re1=new RegExp("\\$1","g");
256 + var re2=new RegExp("\\$2","g");
257 + copy_alertText=copy_alertText.replace(re1,sampleText);
258 + copy_alertText=copy_alertText.replace(re2,tagOpen+sampleText+tagClose);
259 + var text;
260 + if (sampleText) {
261 + text=prompt(copy_alertText);
262 + } else {
263 + text="";
264 + }
265 + if(!text) { text=sampleText;}
266 + text=tagOpen+text+tagClose;
267 + document.infoform.infobox.value=text;
268 + // in Safari this causes scrolling
269 + if(!is_safari) {
270 + txtarea.focus();
271 + }
272 + noOverwrite=true;
273 + }
274 + // reposition cursor if possible
275 + if (txtarea && txtarea.createTextRange) {
276 + txtarea.caretPos = document.selection.createRange().duplicate();
277 + }
278 +}
279 +</script>
280 +"""
281 +
282
283 #############################################################################
284 ### PageEditor - Edit pages
285 @@ -268,19 +351,23 @@
286 status = [msg for msg in status if msg]
287 status = ' '.join(status)
288 status = Status(self.request, content=status)
289 -
290 - wikiutil.send_title(self.request,
291 - title % {'pagename': self.split_title(self.request),},
292 - page=self,
293 - pagename=self.page_name, msg=status,
294 - body_onload=self.lock.locktype and 'countdown()' or '', # broken / bug in Mozilla 1.5, when using #preview
295 - html_head=self.lock.locktype and (
296 +
297 + html_head = self.lock.locktype and (
298 _countdown_js % {
299 'lock_timeout': lock_timeout,
300 'lock_expire': lock_expire,
301 'lock_mins': lock_mins,
302 'lock_secs': lock_secs,
303 }) or ''
304 + if self.request.cfg.edit_insert_tags_enabled:
305 + html_head += _insert_tags_js
306 +
307 + wikiutil.send_title(self.request,
308 + title % {'pagename': self.split_title(self.request),},
309 + page=self,
310 + pagename=self.page_name, msg=status,
311 + body_onload=self.lock.locktype and 'countdown()' or '', # broken / bug in Mozilla 1.5, when using #preview
312 + html_head=html_head
313 )
314
315 self.request.write(self.request.formatter.startContent("content"))
316 @@ -364,6 +451,30 @@
317
318 self.request.write('</p>')
319
320 + # Character tags insert selection box
321 + if self.request.cfg.edit_insert_tags_enabled:
322 + self.request.write('<div id="editor-insert-tags">')
323 + self.request.write(_("Insert: "))
324 + for tag in config.editor_insert_tags:
325 + if not tag or tag=='\n':
326 + self.request.write('<br />')
327 + continue
328 + elif tag==' ':
329 + self.request.write(' ')
330 + continue
331 + elif type(tag) is type(' ') or type(tag) is type(u' '):
332 + self.request.write(tag)
333 + continue
334 + tag_open, tag_close, tag_body, tag_name, tag_description = tag
335 + if not tag_name:
336 + tag_name = tag_open + ' ' + tag_close
337 + if not tag_description:
338 + tag_description = tag_name
339 + self.request.write("<a href=\"javascript:insertTags('%s','%s','%s')\" title=\"%s\">%s</a>" \
340 + % (tag_open,tag_close,tag_body,tag_description,tag_name) )
341 + self.request.write('</div>')
342 +
343 + # Change description
344 self.request.write("<p>", _("Optional comment about this change"),
345 '<br><input id="editor-comment" type="text" name="comment" value="%s" maxlength="80"></p>' % (
346 wikiutil.escape(kw.get('comment', ''), 1), ))
347 --- wiki/htdocs/classic/css/screen.css.orig 2005-01-09 13:48:07.000000000 -0500
348 +++ wiki/htdocs/classic/css/screen.css 2005-04-04 00:47:15.688677652 -0400
349 @@ -261,6 +261,21 @@
350 background-color: white;
351 }
352
353 +div#editor-insert-tags {
354 + border: 2px solid #c0c0c0;
355 + padding-left: 4pt; padding-right: 4pt;
356 + background-color: #e5e5e5; color: black;
357 + font-size: 9pt;
358 +}
359 +#editor-insert-tags a {
360 + text-decoration: none;
361 + padding-left: 0.2pt; padding-right: 0.2pt;
362 +}
363 +#editor-insert-tags a:hover {
364 + background-color: yellow; color: black;
365 + text-decoration: underline;
366 +}
367 +
368 /* We use here dumb css1 ids becuase of IE suckiness */
369 #editor-textarea, #editor-comment {
370 width: 100%;
371 --- wiki/htdocs/modern/css/screen.css.orig 2005-02-15 04:06:20.000000000 -0500
372 +++ wiki/htdocs/modern/css/screen.css 2005-04-04 00:46:48.942249672 -0400
373 @@ -276,6 +276,21 @@
374 padding: 10px 30px 20px 30px;
375 }
376
377 +div#editor-insert-tags {
378 + border: 1px solid #5588bb;
379 + padding-left: 4pt; padding-right: 4pt;
380 + background-color: #f0f8ff; color: black;
381 + font-size: 9pt;
382 +}
383 +#editor-insert-tags a {
384 + text-decoration: none;
385 + padding-left: 0.2pt; padding-right: 0.2pt;
386 +}
387 +#editor-insert-tags a:hover {
388 + background-color: yellow; color: black;
389 + text-decoration: underline;
390 +}
391 +
392 /* We use here dumb css1 ids because of IE suckiness */
393 #editor-textarea, #editor-comment {
394 width: 100%;
395 --- wiki/htdocs/rightsidebar/css/screen.css.orig 2005-02-15 04:06:20.000000000 -0500
396 +++ wiki/htdocs/rightsidebar/css/screen.css 2005-04-04 00:47:47.332084514 -0400
397 @@ -220,6 +220,21 @@
398 width: 100%;
399 }
400
401 +div#editor-insert-tags {
402 + border: 1px solid #9c9c9c;
403 + padding-left: 4pt; padding-right: 4pt;
404 + background-color: #F0ECE6; color: black;
405 + font-size: 9pt;
406 +}
407 +#editor-insert-tags a {
408 + text-decoration: none;
409 + padding-left: 0.2pt; padding-right: 0.2pt;
410 +}
411 +#editor-insert-tags a:hover {
412 + background-color: yellow; color: black;
413 + text-decoration: underline;
414 +}
415 +
416 /* We use here dumb css1 ids becuase of IE suckiness */
417 #editor-textarea, #editor-comment {
418 width: 100%;
419 --- wiki/underlay/pages/HelpOnConfiguration/revisions/00000001.orig 2005-03-12 18:29:00.000000000 -0500
420 +++ wiki/underlay/pages/HelpOnConfiguration/revisions/00000001 2005-04-04 00:51:56.405148977 -0400
421 @@ -184,6 +184,7 @@
422 || datetime_fmt || '%Y-%m-%d %H:%M:%S' || Default format for dates and times (when the user has no preferences or chose the "default" date format) ||
423 || default_lang || 'en' || Default language for user interface and page content, see HelpOnLanguages!||
424 || default_markup || 'wiki' || Default page parser / format (name of module in `MoinMoin.parser`) ||
425 +|| edit_insert_tags_enabled || 1 || Show a special character insert helper in the page editor (requires Javascript) ||
426 || edit_locking || 'warn 10' || Editor locking policy: `None`, `'warn <timeout in minutes>'`, or `'lock <timeout in minutes>'` ||
427 || edit_rows || 30 || Default height of the edit box ||
428 || hosts_deny || `[]` || List of denied IPs; if an IP ends with a dot, it denies a whole subnet (class A, B or C) ||
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.