changeset 150:d3deda1731fb

configure navi_bar using tuples saves us from first having to parse to stuff - faster it is also more flexible as one can easily link to any endpoint with any params move the global views from item_views to default navi_bar remove now wrong navi_bar docs
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 20 Mar 2011 22:06:11 +0100
parents 601b8be0ced6
children 704a9b888fe9
files MoinMoin/config/default.py MoinMoin/themes/__init__.py docs/admin/upgrade.rst docs/examples/config/wikiconfig.py
diffstat 4 files changed, 11 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/config/default.py	Sun Mar 20 20:32:30 2011 +0100
+++ b/MoinMoin/config/default.py	Sun Mar 20 22:06:11 2011 +0100
@@ -109,10 +109,6 @@
         # internal dict for plugin `modules' lists
         self._site_plugin_lists = {}
 
-        # we replace any string placeholders with config values
-        # e.g u'%(item_root)s' % self
-        self.navi_bar = [elem % self for elem in self.navi_bar]
-
         # check if mail is possible and set flag:
         self.mail_enabled = (self.mail_smarthost is not None or self.mail_sendmail is not None) and self.mail_from
         self.mail_enabled = self.mail_enabled and True or False
@@ -195,7 +191,7 @@
 """
 
         decode_names = (
-            'sitename', 'interwikiname', 'user_homewiki', 'navi_bar',
+            'sitename', 'interwikiname', 'user_homewiki',
             'interwiki_preferred',
             'item_root', 'item_license', 'mail_from',
             'item_dict_regex', 'item_group_regex',
@@ -334,8 +330,14 @@
      "Short description of your wiki site, displayed below the logo on each page, and used in RSS documents as the channel title [Unicode]"),
     ('interwikiname', None, "unique and stable InterWiki name (prefix, moniker) of the site [Unicode], or None"),
     ('html_pagetitle', None, "Allows you to set a specific HTML page title (if None, it defaults to the value of `sitename`) [Unicode]"),
-    ('navi_bar', [u'FindPage', u'HelpContents', ],
-     'Most important page names. Users can add more names in their quick links in user preferences. To link to URL, use `u"[[url|link title]]"`, to use a shortened name for long page name, use `u"[[LongLongPageName|title]]"`. [list of Unicode]'),
+    ('navi_bar', [
+        ('wikilink', 'frontend.show_root', dict(), L_('Home'), L_('Home Page')),
+        ('wikilink', 'frontend.global_history', dict(), L_('History'), L_('Global History')),
+        ('wikilink', 'frontend.global_index', dict(), L_('Index'), L_('Global Index')),
+        ('wikilink', 'frontend.global_tags', dict(), L_('Tags'), L_('Global Tags Index')),
+        ('wikilink', 'admin.index', dict(), L_('More'), L_('Administration & Docs')),
+     ],
+     'Data to create the navi_bar from. Users can add more items in their quick links in user preferences. You need to configure a list of tuples (css_class, endpoint, args, label, title). Use L_() for translating. [list of tuples]'),
 
     ('theme_default', u'modernized', "Default theme."),
 
@@ -375,12 +377,6 @@
         ('frontend.rename_item', L_('Rename'), True, ),
         ('frontend.delete_item', L_('Delete'), True, ),
         ('frontend.destroy_item', L_('Destroy'), True, ),
-        ('special.delimiter', None, None, ),
-        ('frontend.global_history', L_('Global History'), False, ),
-        ('frontend.global_index', L_('Global Items Index'), False, ),
-        ('frontend.global_tags', L_('Global Tags Index'), False, ),
-        ('special.delimiter', None, None, ),
-        ('admin.index', L_('Administration & Docs'), False, ),
      ],
      'list of edit bar entries (list of tuples (endpoint, label))'),
     ('history_count', (100, 200), "number of revisions shown for info/history action (default_count_shown, max_count_shown)"),
--- a/MoinMoin/themes/__init__.py	Sun Mar 20 20:32:30 2011 +0100
+++ b/MoinMoin/themes/__init__.py	Sun Mar 20 22:06:11 2011 +0100
@@ -204,13 +204,10 @@
         :returns: list of tuples (css_class, url, link_text, title)
         """
         flaskg.clock.start('navibar')
-        items = []  # navibar items
         current = item_name
-
         # Process config navi_bar
-        for text in self.cfg.navi_bar:
-            url, link_text, title = self.split_navilink(text)
-            items.append(('wikilink', url, link_text, title))
+        items = [(cls, url_for(endpoint, **args), link_text, title)
+                 for cls, endpoint, args, link_text, title in self.cfg.navi_bar]
 
         # Add user links to wiki links.
         userlinks = self.user.getQuickLinks()
--- a/docs/admin/upgrade.rst	Sun Mar 20 20:32:30 2011 +0100
+++ b/docs/admin/upgrade.rst	Sun Mar 20 22:06:11 2011 +0100
@@ -58,7 +58,6 @@
     interwikiname = ... # critical, make sure it is same as in 1.9!
     sitename = ... # same as in 1.9
     item_root = ... # see page_front_page in 1.9
-    navi_bar = ... # similar as in 1.9
     theme_default = ... # (only supported value is "modernized")
     language_default = ...
     mail_smarthost = ...
--- a/docs/examples/config/wikiconfig.py	Sun Mar 20 20:32:30 2011 +0100
+++ b/docs/examples/config/wikiconfig.py	Sun Mar 20 22:06:11 2011 +0100
@@ -92,17 +92,6 @@
 
     # User interface ----------------------------------------------------
 
-    # Add your wikis important pages at the end. It is not recommended to
-    # remove the default links.  Leave room for user links - don't use
-    # more than 6 short items.
-    # You MUST use Unicode strings here, but you need not use localized
-    # page names for system and help pages, those will be used automatically
-    # according to the user selected language. [Unicode]
-    navi_bar = [
-        # If you want to show your item_root here:
-        #u'%(item_root)s',
-    ]
-
     # The default theme anonymous or new users get
     theme_default = u'modernized'