changeset 826:8e880418d736

remove all underscore <-> blank magic
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 10 Jun 2006 20:42:47 +0200
parents 2438f386293f
children 1faf38d5c3cb
files MoinMoin/converter/text_html_text_moin_wiki.py MoinMoin/request/__init__.py MoinMoin/search.py MoinMoin/theme/__init__.py MoinMoin/user.py MoinMoin/userform.py MoinMoin/wikiutil.py docs/CHANGES
diffstat 8 files changed, 9 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/text_html_text_moin_wiki.py	Sat Jun 10 16:52:04 2006 +0200
+++ b/MoinMoin/converter/text_html_text_moin_wiki.py	Sat Jun 10 20:42:47 2006 +0200
@@ -1122,7 +1122,7 @@
                     self.text.extend([self.white_space, title, self.white_space])
             # wiki link
             elif href.startswith(scriptname):
-                pagename = href[len(scriptname):].replace('_', ' ')
+                pagename = href[len(scriptname):]
                 pagename = pagename.lstrip('/')    # XXX temp fix for generated pagenames starting with /
                 if text == pagename:
                     self.text.append(wikiutil.pagelinkmarkup(pagename))
--- a/MoinMoin/request/__init__.py	Sat Jun 10 16:52:04 2006 +0200
+++ b/MoinMoin/request/__init__.py	Sat Jun 10 20:42:47 2006 +0200
@@ -803,9 +803,6 @@
     def normalizePagename(self, name):
         """ Normalize page name 
 
-        Convert '_' to spaces - allows using nice URLs with spaces, with no
-        need to quote.
-
         Prevent creating page names with invisible characters or funny
         whitespace that might confuse the users or abuse the wiki, or
         just does not make sense.
@@ -816,9 +813,6 @@
         @rtype: unicode
         @return: decoded and sanitized page name
         """
-        # Replace underscores with spaces
-        name = name.replace(u'_', u' ')
-
         # Strip invalid characters
         name = config.page_invalid_chars_regex.sub(u'', name)
 
--- a/MoinMoin/search.py	Sat Jun 10 16:52:04 2006 +0200
+++ b/MoinMoin/search.py	Sat Jun 10 20:42:47 2006 +0200
@@ -393,7 +393,6 @@
         @param use_re: treat pattern as re of plain text, bool
         @param case: do case sensitive search, bool 
         """
-        pattern = pattern.replace("_", " ")
         # used for search in links
         self._pattern = pattern
         # used for search in text
--- a/MoinMoin/theme/__init__.py	Sat Jun 10 16:52:04 2006 +0200
+++ b/MoinMoin/theme/__init__.py	Sat Jun 10 20:42:47 2006 +0200
@@ -347,10 +347,6 @@
         except ValueError:
             pass
                   
-        # Normalize page names, replace '_' with ' '. Usually
-        # all names use spaces internally, but for
-        # [name_with_spaces label] we must save the underscores
-        # until this point.
         pagename = request.normalizePagename(pagename)
         link = Page(request, pagename).link_to(request, title)
 
@@ -555,9 +551,6 @@
                 for pagename in trail:
                     try:
                         interwiki, page = pagename.split(":", 1)
-                        # Items in trail are saved as valid interwiki
-                        # links, using _ for spaces.
-                        page = page.replace('_', ' ')
                         if request.cfg.interwikiname != interwiki:
                             link = (self.request.formatter.interwikilink(True, interwiki, page) +
                                     self.shortenPagename(page) +
--- a/MoinMoin/user.py	Sat Jun 10 16:52:04 2006 +0200
+++ b/MoinMoin/user.py	Sat Jun 10 20:42:47 2006 +0200
@@ -136,9 +136,9 @@
     @rtype: unicode
     @return: user name that can be used in acl lines
     """
-    name = name.replace('_', ' ') # we treat _ as a blank
-    username_allowedchars = "'@.-" # ' for names like O'Brian or email addresses.
-                                   # "," and ":" must not be allowed (ACL delimiters).
+    username_allowedchars = "'@.-_" # ' for names like O'Brian or email addresses.
+                                    # "," and ":" must not be allowed (ACL delimiters).
+                                    # We also allow _ in usernames for nicer URLs.
     # Strip non alpha numeric characters (except username_allowedchars), keep white space
     name = ''.join([c for c in name if c.isalnum() or c.isspace() or c in username_allowedchars])
 
@@ -155,7 +155,6 @@
     @param name: user name, unicode
     """
     normalized = normalizeName(name)
-    name = name.replace('_', ' ') # we treat _ as a blank
     return (name == normalized) and not wikiutil.isGroupPage(request, name)
 
 
@@ -812,8 +811,6 @@
         if not self._cfg.interwikiname:
             return None
             
-        # Interwiki links must use _ e.g Wiki:Main_Page
-        pagename = pagename.replace(" ", "_")
         return "%s:%s" % (self._cfg.interwikiname, pagename)
 
     # -----------------------------------------------------------------
@@ -936,7 +933,7 @@
             else:
                 markup = pagename
         else:
-            markup = '%s:%s' % (wikiname, pagename.replace(" ","_")) 
+            markup = '%s:%s' % (wikiname, pagename) 
         return markup
 
     def mailAccountData(self, cleartext_passwd=None):
--- a/MoinMoin/userform.py	Sat Jun 10 16:52:04 2006 +0200
+++ b/MoinMoin/userform.py	Sat Jun 10 20:42:47 2006 +0200
@@ -38,10 +38,6 @@
 
         Each line is a page name, empty lines ignored.
 
-        Items can use '_' as spaces, needed by [name_with_spaces label]
-        format used in quicklinks. We do not touch those names here, the
-        underscores are handled later by the theme code.
-
         @param key: the form key to get
         @rtype: list of unicode strings
         @return: list of normalized names
@@ -53,10 +49,6 @@
             item = item.strip()
             if not item:
                 continue
-            # Normalize names - except [name_with_spaces label]
-            # Commented out to allow URLs
-            #if not (item.startswith('[') and item.endswith(']')):
-            #    item = self.request.normalizePagename(item)
             items.append(item)
         return items
 
@@ -408,7 +400,7 @@
         options = []
         users = user.getUserList(self.request)
         for uid in users:
-            name = user.User(self.request, id=uid).name # + '_' + uid # for debugging
+            name = user.User(self.request, id=uid).name # + '/' + uid # for debugging
             options.append((name, name))
         options.sort()
 
--- a/MoinMoin/wikiutil.py	Sat Jun 10 16:52:04 2006 +0200
+++ b/MoinMoin/wikiutil.py	Sat Jun 10 20:42:47 2006 +0200
@@ -208,7 +208,6 @@
     @rtype: string
     @return: the quoted filename, all unsafe characters encoded
     """
-    pagename = pagename.replace(u' ', u'_')
     pagename = pagename.encode(charset)
     return urllib.quote(pagename)
 
@@ -295,7 +294,6 @@
     @rtype: string
     @return: quoted name, safe for any file system
     """
-    wikiname = wikiname.replace(u' ', u'_') # " " -> "_"
     filename = wikiname.encode(charset)
     
     quoted = []    
@@ -376,7 +374,6 @@
     #    raise InvalidFileNameError(filename)
     
     wikiname = decodeUserInput(wikiname, charsets)
-    wikiname = wikiname.replace(u'_', u' ') # "_" -> " "
     return wikiname
 
 # time scaling
--- a/docs/CHANGES	Sat Jun 10 16:52:04 2006 +0200
+++ b/docs/CHANGES	Sat Jun 10 20:42:47 2006 +0200
@@ -107,6 +107,9 @@
       'item', it will use a cache directory per item (== per page).
       Creating a CacheEntry without explicit scope is DEPRECATED.
     * smileys moved from MoinMoin.config to MoinMoin.theme
+    * removed all _ magic in URLs and filenames
+      TODO: write mig script for data_dir
+      TODO: make blanks in interwiki pagelinks possible
 
   New Features: