Allow customization of the markup hint that appears on the edit page

We use rst as the default markup for our wikis. When users edit pages, they see markup hints that are only appropriate for the wiki markup. It is very confusing for new users. I propose a new option editor_quickhelp be added that allows customization of the markup hint.

Here is the proposed documentation:

Variable name

Default

Description

editor_quickhelp

{'wiki':"...", 'rst':"..."}

Quickhelp provided at the bottom of edit pages. To customize, specify a dictionary with key matching default_markup (e.g. 'wiki') and give a string value containing HTML markup

Here is a patch that allows the option editor_quickhelp to be specified in wikiconfig.py as a dictionary mapping markup names (e.g. 'wiki' or 'rst') to the quickhelp that should be provided. The patch includes a default for 'rst'.

* looking for arch@arch.thinkmo.de--2003-archives/moin--main--1.5--patch-523 to compare with
* comparing to arch@arch.thinkmo.de--2003-archives/moin--main--1.5--patch-523
M  MoinMoin/PageEditor.py
M  MoinMoin/multiconfig.py

* modified files

--- orig/MoinMoin/PageEditor.py
+++ mod/MoinMoin/PageEditor.py
@@ -408,16 +408,12 @@
         self.request.write("</form>")
         
         # QuickHelp originally by Georg Mischler <schorsch@lightingwiki.com>
-        self.request.write(self.request.formatter.div(1, id="editor-help"))
-        self.request.write(_(""" Emphasis:: [[Verbatim('')]]''italics''[[Verbatim('')]]; [[Verbatim(''')]]'''bold'''[[Verbatim(''')]]; [[Verbatim(''''')]]'''''bold italics'''''[[Verbatim(''''')]]; [[Verbatim('')]]''mixed ''[[Verbatim(''')]]'''''bold'''[[Verbatim(''')]] and italics''[[Verbatim('')]]; [[Verbatim(----)]] horizontal rule.
- Headings:: [[Verbatim(=)]] Title 1 [[Verbatim(=)]]; [[Verbatim(==)]] Title 2 [[Verbatim(==)]]; [[Verbatim(===)]] Title 3 [[Verbatim(===)]];   [[Verbatim(====)]] Title 4 [[Verbatim(====)]]; [[Verbatim(=====)]] Title 5 [[Verbatim(=====)]].
- Lists:: space and one of: * bullets; 1., a., A., i., I. numbered items; 1.#n start numbering at n; space alone indents.
- Links:: [[Verbatim(JoinCapitalizedWords)]]; [[Verbatim(["brackets and double quotes"])]]; url; [url]; [url label].
- Tables:: || cell text |||| cell text spanning 2 columns ||;    no trailing white space allowed after tables or titles.
-
-(!) For more help, see HelpOnEditing or SyntaxReference.
-"""))
-        self.request.write(self.request.formatter.div(0))
+        markup = self.pi_format or self.request.cfg.default_markup
+        quickhelp = self.request.cfg.editor_quickhelp.get(markup, "")
+        if quickhelp:
+            self.request.write(self.request.formatter.div(1, id="editor-help"))
+            self.request.write(_(quickhelp))
+            self.request.write(self.request.formatter.div(0))
 
         if preview is not None:
             if staytop:


--- orig/MoinMoin/multiconfig.py
+++ mod/MoinMoin/multiconfig.py
@@ -207,6 +207,33 @@
     editor_default = 'text' # which editor is called when nothing is specified
     editor_ui = 'freechoice' # which editor links are shown on user interface
     editor_force = False
+    editor_quickhelp = { # editor markup hints quickhelp 
+        'wiki':""" Emphasis:: [[Verbatim('')]]''italics''[[Verbatim('')]]; [[Verbatim(''')]]'''bold'''[[Verbatim(''')]]; [[Verbatim(''''')]]'''''bold italics'''''[[Verbatim(''''')]]; [[Verbatim('')]]''mixed ''[[Verbatim(''')]]'''''bold'''[[Verbatim(''')]] and italics''[[Verbatim('')]]; [[Verbatim(----)]] horizontal rule.
+ Headings:: [[Verbatim(=)]] Title 1 [[Verbatim(=)]]; [[Verbatim(==)]] Title 2 [[Verbatim(==)]]; [[Verbatim(===)]] Title 3 [[Verbatim(===)]];   [[Verbatim(====)]] Title 4 [[Verbatim(====)]]; [[Verbatim(=====)]] Title 5 [[Verbatim(=====)]].
+ Lists:: space and one of: * bullets; 1., a., A., i., I. numbered items; 1.#n start numbering at n; space alone indents.
+ Links:: [[Verbatim(JoinCapitalizedWords)]]; [[Verbatim(["brackets and double quotes"])]]; url; [url]; [url label].
+ Tables:: || cell text |||| cell text spanning 2 columns ||;    no trailing white space allowed after tables or titles.
+
+(!) For more help, see HelpOnEditing or SyntaxReference.
+""",
+        'rst':"""Emphasis: <i>*italic*</i> <b>**bold**</b> ``monospace``<br/>
+<br/><pre>
+Headings: Heading 1  Heading 2  Heading 3
+          =========  ---------  ~~~~~~~~~
+
+Horizontal rule: ---- 
+Links: TrailingUnderscore_ `multi word with backticks`_ external_ 
+
+.. _external: http://external-site.net/foo/
+
+Lists: * bullets; 1., a. numered items.
+</pre>
+<br/>
+(!) For more help, see 
+<a href="http://docutils.sourceforge.net/docs/user/rst/quickref.html">
+reStructuredText Quick Reference
+</a>
+"""}
     edit_locking = 'warn 10' # None, 'warn <timeout mins>', 'lock <timeout mins>'
     edit_rows = 20                                                                                     

SethFalcon

If you do more work on this, like docs, multiconfig.py stuff (default) and using the page markup as an index into a dictionary key markup, value help, I'll consider applying the patch.


I would be willing to polish it. Can you give me a little more detail on what you'd like to see for hint dictionary? Not sure I follow. I think you want code in multiconfig.py so that by default you get an edit hint based on a markup name lookup into said dictionary. But would it still be possible for users to override? Anyhow, if you'd be willing to sketch out a few more specifics, I will give a shot at polishing.

Lastly, is it OK to do this against the 1.5 tla branch? Sure, moin--main--1.5 is the current stuff.

I committed it to main branch. Not perfect yet, but better than nothing. :)


CategoryFeatureImplemented

MoinMoin: FeatureRequests/AllowCustomMarkupHint (last edited 2007-10-29 19:11:00 by localhost)