changeset 3784:951ed1df8ec3

move editor quickhelp out of config into parser modules that way, custom parser modules can ship their quickhelp instead of requiring the admin who enables them to put the quickhelp into the config and it cleans up the config too.
author Johannes Berg <johannes AT sipsolutions DOT net>
date Tue, 24 Jun 2008 12:38:56 +0200
parents d9431d180aff
children 17ec10ccdae2
files MoinMoin/PageEditor.py MoinMoin/config/multiconfig.py MoinMoin/i18n/__init__.py MoinMoin/parser/text_creole.py MoinMoin/parser/text_moin_wiki.py MoinMoin/parser/text_rst.py
diffstat 6 files changed, 52 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py	Tue Jun 24 12:27:59 2008 +0200
+++ b/MoinMoin/PageEditor.py	Tue Jun 24 12:38:56 2008 +0200
@@ -483,7 +483,8 @@
 
         # QuickHelp originally by Georg Mischler <schorsch@lightingwiki.com>
         markup = self.pi['format'] or request.cfg.default_markup
-        quickhelp = request.cfg.editor_quickhelp.get(markup, "")
+        parser = wikiutil.searchAndImportPlugin(self.request.cfg, "parser", markup)
+        quickhelp = getattr(parser, 'quickhelp', None)
         if quickhelp:
             request.write(request.formatter.div(1, id="editor-help"))
             request.write(_(quickhelp, wiki=True))
--- a/MoinMoin/config/multiconfig.py	Tue Jun 24 12:27:59 2008 +0200
+++ b/MoinMoin/config/multiconfig.py	Tue Jun 24 12:38:56 2008 +0200
@@ -828,49 +828,6 @@
     ('editor_force', False, "if True, force using the default editor"),
     ('editor_ui', 'freechoice', "Editor choice shown on the user interface, 'freechoice' or 'theonepreferred'"),
     ('page_license_enabled', False, 'if True, show a license hint in page editor.'),
-    ('editor_quickhelp', {
-        # editor markup hints quickhelp
-        # MUST be in wiki markup, even if the help is not for the wiki parser!
-        'wiki': _(u"""\
- Emphasis:: <<Verbatim('')>>''italics''<<Verbatim('')>>; <<Verbatim(''')>>'''bold'''<<Verbatim(''')>>; <<Verbatim(''''')>>'''''bold italics'''''<<Verbatim(''''')>>; <<Verbatim('')>>''mixed ''<<Verbatim(''')>>'''''bold'''<<Verbatim(''')>> and italics''<<Verbatim('')>>; <<Verbatim(----)>> horizontal rule.
- Headings:: = Title 1 =; == Title 2 ==; === Title 3 ===; ==== Title 4 ====; ===== Title 5 =====.
- 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([[target|linktext]])>>.
- 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: *italic* **bold** ``monospace``
-
-Headings: Heading 1  Heading 2  Heading 3
-          =========  ---------  ~~~~~~~~~
-
-Horizontal rule: ----
-
-Links: TrailingUnderscore_ `multi word with backticks`_ external_
-
-.. _external: http://external-site.example.org/foo/
-
-Lists: * bullets; 1., a. numbered items.
-}}}
-(!) For more help, see the
-[[http://docutils.sourceforge.net/docs/user/rst/quickref.html|reStructuredText Quick Reference]].
-"""),
-        'creole': _(u"""\
- Emphasis:: <<Verbatim(//)>>''italics''<<Verbatim(//)>>; <<Verbatim(**)>>'''bold'''<<Verbatim(**)>>; <<Verbatim(**//)>>'''''bold italics'''''<<Verbatim(//**)>>; <<Verbatim(//)>>''mixed ''<<Verbatim(**)>>'''''bold'''<<Verbatim(**)>> and italics''<<Verbatim(//)>>;
- Horizontal Rule:: <<Verbatim(----)>>
- Force Linebreak:: <<Verbatim(\\\\)>>
- Headings:: = Title 1 =; == Title 2 ==; === Title 3 ===; ==== Title 4 ====; ===== Title 5 =====.
- Lists:: * bullets; ** sub-bullets; # numbered items; ## numbered sub items.
- Links:: <<Verbatim([[target]])>>; <<Verbatim([[target|linktext]])>>.
- Tables:: |= header text | cell text | more cell text |;
-
-(!) For more help, see HelpOnEditing or HelpOnCreoleSyntax.
-"""),
-    },
-    "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 wiki markup."),
     ('edit_locking', 'warn 10', "Editor locking policy: `None`, `'warn <timeout in minutes>'`, or `'lock <timeout in minutes>'`"),
     ('edit_ticketing', True, None),
     ('edit_rows', 20, "Default height of the edit box"),
--- a/MoinMoin/i18n/__init__.py	Tue Jun 24 12:27:59 2008 +0200
+++ b/MoinMoin/i18n/__init__.py	Tue Jun 24 12:38:56 2008 +0200
@@ -290,7 +290,7 @@
             # do not simply return trans with str, but recursively call
             # to get english translation, maybe formatted.
             # if we don't find an english "translation", we just format it
-            # on the fly (this is needed for cfg.editor_quickhelp).
+            # on the fly (this is needed for quickhelp).
             if lang != 'en':
                 logging.debug("falling back to english, requested string not in %r translation: %r" % (lang, original))
                 translated = getText(original, request, 'en', wiki=formatted, percent=percent)
--- a/MoinMoin/parser/text_creole.py	Tue Jun 24 12:27:59 2008 +0200
+++ b/MoinMoin/parser/text_creole.py	Tue Jun 24 12:38:56 2008 +0200
@@ -30,6 +30,8 @@
 
 Dependencies = []
 
+_ = lambda x: x
+
 class Parser:
     """
     Glue the DocParser and DocEmitter with the
@@ -39,6 +41,17 @@
     # Enable caching
     caching = 1
     Dependencies = Dependencies
+    quickhelp = _(u"""\
+ Emphasis:: <<Verbatim(//)>>''italics''<<Verbatim(//)>>; <<Verbatim(**)>>'''bold'''<<Verbatim(**)>>; <<Verbatim(**//)>>'''''bold italics'''''<<Verbatim(//**)>>; <<Verbatim(//)>>''mixed ''<<Verbatim(**)>>'''''bold'''<<Verbatim(**)>> and italics''<<Verbatim(//)>>;
+ Horizontal Rule:: <<Verbatim(----)>>
+ Force Linebreak:: <<Verbatim(\\\\)>>
+ Headings:: = Title 1 =; == Title 2 ==; === Title 3 ===; ==== Title 4 ====; ===== Title 5 =====.
+ Lists:: * bullets; ** sub-bullets; # numbered items; ## numbered sub items.
+ Links:: <<Verbatim([[target]])>>; <<Verbatim([[target|linktext]])>>.
+ Tables:: |= header text | cell text | more cell text |;
+
+(!) For more help, see HelpOnEditing or HelpOnCreoleSyntax.
+""")
 
     def __init__(self, raw, request, **kw):
         """Create a minimal Parser object with required attributes."""
@@ -455,3 +468,5 @@
         # restore 'smart' formatting if it was set
         self.formatter.no_magic = magic_save
         return output
+
+del _
--- a/MoinMoin/parser/text_moin_wiki.py	Tue Jun 24 12:27:59 2008 +0200
+++ b/MoinMoin/parser/text_moin_wiki.py	Tue Jun 24 12:38:56 2008 +0200
@@ -20,6 +20,8 @@
 Dependencies = ['user'] # {{{#!wiki comment ... }}} has different output depending on the user's profile settings
 
 
+_ = lambda x: x
+
 class Parser:
     """
         Parse wiki format markup (and call the formatter to generate output).
@@ -33,6 +35,15 @@
     # allow caching
     caching = 1
     Dependencies = Dependencies
+    quickhelp = _(u"""\
+ Emphasis:: <<Verbatim('')>>''italics''<<Verbatim('')>>; <<Verbatim(''')>>'''bold'''<<Verbatim(''')>>; <<Verbatim(''''')>>'''''bold italics'''''<<Verbatim(''''')>>; <<Verbatim('')>>''mixed ''<<Verbatim(''')>>'''''bold'''<<Verbatim(''')>> and italics''<<Verbatim('')>>; <<Verbatim(----)>> horizontal rule.
+ Headings:: = Title 1 =; == Title 2 ==; === Title 3 ===; ==== Title 4 ====; ===== Title 5 =====.
+ 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([[target|linktext]])>>.
+ Tables:: || cell text |||| cell text spanning 2 columns ||;    no trailing white space allowed after tables or titles.
+
+(!) For more help, see HelpOnEditing or SyntaxReference.
+""")
 
     # some common strings
     CHILD_PREFIX = wikiutil.CHILD_PREFIX
@@ -1550,3 +1561,4 @@
         except wikiutil.PluginMissingError:
             self.parser = None
 
+del _
--- a/MoinMoin/parser/text_rst.py	Tue Jun 24 12:27:59 2008 +0200
+++ b/MoinMoin/parser/text_rst.py	Tue Jun 24 12:38:56 2008 +0200
@@ -170,9 +170,30 @@
                 setattr(self, attr, getattr(visitor, attr))
         self.output = html_escape_unicode(visitor.astext())
 
+# mark quickhelp as translatable
+_ = lambda x: x
+
 class Parser:
     caching = 1
     Dependencies = Dependencies # copy dependencies from module-scope
+    quickhelp = _("""\
+{{{
+Emphasis: *italic* **bold** ``monospace``
+
+Headings: Heading 1  Heading 2  Heading 3
+          =========  ---------  ~~~~~~~~~
+
+Horizontal rule: ----
+
+Links: TrailingUnderscore_ `multi word with backticks`_ external_
+
+.. _external: http://external-site.example.org/foo/
+
+Lists: * bullets; 1., a. numbered items.
+}}}
+(!) For more help, see the
+[[http://docutils.sourceforge.net/docs/user/rst/quickref.html|reStructuredText Quick Reference]].
+""")
 
     def __init__(self, raw, request, **kw):
         self.raw = raw
@@ -612,3 +633,4 @@
 if ErrorParser: # fixup in case of missing docutils
     Parser = ErrorParser
 
+del _