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
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.
It's simple: put editor_quickhelp = { 'wiki': """<help for wiki markup>""", 'rst': """<help for rst markup>""", } into multiconfig.py (see where all the other defaults are). You can override it in your cfg as you can override any other default value. And in the editor, just determine what markup you have (pi_format maybe) and use request.cfg.editor_quickhelp.get(format, "") for getting the help string.
Lastly, is it OK to do this against the 1.5 tla branch? Sure, moin--main--1.5 is the current stuff.
Thank you, the multiconfig.py stuff now makes sense. But I'm having trouble detecting the current page's markup. It looks to me like self.pi_format is only set during the call to send_page(). Is there another way to get at it that I'm missing? Reasonable choices seem to be: just use cfg.default_markup, or refactor the #format FOO detection so it is its own method and can be called without sending the page. - SF
I committed it to main branch. Not perfect yet, but better than nothing.
Fantastic If you have specific ideas for improvements, let me know.
- This is indeed a nice feature - I see it in V1.5.4. However, it works only for the configured default markup syntax of a Wiki. I guess this happens because in
markup = self.pi_format or self.request.cfg.default_markup
the term self.pi_format is always None. This is because it is only set by MoinMoin.Page.send_page() which has not been called at this stage. -- StefanMerten 2006-08-27 19:55:46
- This is indeed a nice feature - I see it in V1.5.4. However, it works only for the configured default markup syntax of a Wiki. I guess this happens because in