diff MoinMoin/theme/__init__.py @ 2728:59b3d8b8971f

remove (un)quoteName, new functions split_interwiki() and resolve_interwiki(), cleanup interwiki mess, fix some link markup
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 13 Aug 2007 03:04:22 +0200
parents 388204baf00f
children b185b5b80d1b
line wrap: on
line diff
--- a/MoinMoin/theme/__init__.py	Mon Aug 13 01:06:37 2007 +0200
+++ b/MoinMoin/theme/__init__.py	Mon Aug 13 03:04:22 2007 +0200
@@ -298,7 +298,7 @@
         """ Split navibar links into pagename, link to page
 
         Admin or user might want to use shorter navibar items by using
-        the [page title] or [url title] syntax. In this case, we don't
+        the [[page|title]] or [[url|title]] syntax. In this case, we don't
         use localization, and the links goes to page or to the url, not
         the localized version of page.
 
@@ -307,7 +307,7 @@
             * WikiName:PageName
             * wiki:WikiName:PageName
             * url
-            * all targets as seen above with title: [target title]
+            * all targets as seen above with title: [[target|title]]
 
         @param text: the text used in config or user preferences
         @rtype: tuple
@@ -317,16 +317,17 @@
         fmt = request.formatter
         title = None
 
-        # Handle [pagename title] or [url title] formats
-        if text.startswith('[') and text.endswith(']'):
-            text = text[1:-1].strip()
+        # Handle [[pagename|title]] or [[url|title]] formats
+        if text.startswith('[[') and text.endswith(']]'):
+            text = text[2:-2]
             try:
-                pagename, title = text.split(' ', 1)
-                title = title.lstrip()
+                pagename, title = text.split('|', 1)
+                pagename = pagename.strip()
+                title = title.strip()
                 localize = 0
             except (ValueError, TypeError):
                 # Just use the text as is.
-                pagename = text
+                pagename = text.strip()
         else:
             pagename = text
 
@@ -344,9 +345,9 @@
 
         # try handling interwiki links
         try:
-            interwiki, page = pagename.split(':', 1)
+            interwiki, page = wikiutil.split_interwiki(pagename)
             thiswiki = request.cfg.interwikiname
-            if interwiki == thiswiki:
+            if interwiki == thiswiki or interwiki == 'Self':
                 pagename = page
             else:
                 if not title:
@@ -587,8 +588,8 @@
                 items = []
                 for pagename in trail:
                     try:
-                        interwiki, page = pagename.split(":", 1)
-                        if request.cfg.interwikiname != interwiki:
+                        interwiki, page = wikiutil.split_interwiki(pagename)
+                        if interwiki != request.cfg.interwikiname and interwiki != 'Self':
                             link = (self.request.formatter.interwikilink(True, interwiki, page) +
                                     self.shortenPagename(page) +
                                     self.request.formatter.interwikilink(False, interwiki, page))