changeset 4566:2eaf4b42b400

merged moin/1.8
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 10 Feb 2009 13:21:59 +0100
parents 7d8c6d279cff (current diff) 68d29223dfa9 (diff)
children 6ac8b2f4cdac
files .hgtags MoinMoin/Page.py MoinMoin/_tests/test_wikiutil.py MoinMoin/events/notification.py MoinMoin/formatter/_tests/test_formatter.py MoinMoin/formatter/text_html.py MoinMoin/i18n/MoinMoin.pot MoinMoin/i18n/ar.MoinMoin.po MoinMoin/i18n/bg.MoinMoin.po MoinMoin/i18n/ca.MoinMoin.po MoinMoin/i18n/cs.MoinMoin.po MoinMoin/i18n/da.MoinMoin.po MoinMoin/i18n/de.MoinMoin.po MoinMoin/i18n/el.MoinMoin.po MoinMoin/i18n/en.MoinMoin.po MoinMoin/i18n/es.MoinMoin.po MoinMoin/i18n/fa.MoinMoin.po MoinMoin/i18n/fi.MoinMoin.po MoinMoin/i18n/fr.MoinMoin.po MoinMoin/i18n/gl.MoinMoin.po MoinMoin/i18n/he.MoinMoin.po MoinMoin/i18n/hi.MoinMoin.po MoinMoin/i18n/hr.MoinMoin.po MoinMoin/i18n/hu.MoinMoin.po MoinMoin/i18n/id.MoinMoin.po MoinMoin/i18n/it.MoinMoin.po MoinMoin/i18n/ja.MoinMoin.po MoinMoin/i18n/ko.MoinMoin.po MoinMoin/i18n/ku.MoinMoin.po MoinMoin/i18n/lt.MoinMoin.po MoinMoin/i18n/lv.MoinMoin.po MoinMoin/i18n/mk.MoinMoin.po MoinMoin/i18n/mn.MoinMoin.po MoinMoin/i18n/nb.MoinMoin.po MoinMoin/i18n/nl.MoinMoin.po MoinMoin/i18n/pl.MoinMoin.po MoinMoin/i18n/pt-br.MoinMoin.po MoinMoin/i18n/pt.MoinMoin.po MoinMoin/i18n/ro.MoinMoin.po MoinMoin/i18n/ru.MoinMoin.po MoinMoin/i18n/sk.MoinMoin.po MoinMoin/i18n/sl.MoinMoin.po MoinMoin/i18n/sr.MoinMoin.po MoinMoin/i18n/sv.MoinMoin.po MoinMoin/i18n/tr.MoinMoin.po MoinMoin/i18n/uk.MoinMoin.po MoinMoin/i18n/vi.MoinMoin.po MoinMoin/i18n/zh-tw.MoinMoin.po MoinMoin/i18n/zh.MoinMoin.po MoinMoin/macro/__init__.py MoinMoin/parser/_tests/test_text_creole.py MoinMoin/userprefs/oid.py MoinMoin/wikiutil.py docs/CHANGES docs/INSTALL.html docs/UPDATE.html wiki/underlay.tar
diffstat 14 files changed, 83 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Feb 10 12:51:02 2009 +0100
+++ b/.hgtags	Tue Feb 10 13:21:59 2009 +0100
@@ -32,3 +32,4 @@
 4186e90ead069aad4b739f278eb8599dc00ff6a4 1.8.0rc1
 7fee549f435d119801075f0d18fc57822f78f0eb 1.8.0
 fad2936d33a7eac9370f3cdc28f0ec375518d5cf 1.8.1
+1f0db10c207f697de8d496f298167d7de76f30ac 1.8.2
--- a/MoinMoin/Page.py	Tue Feb 10 12:51:02 2009 +0100
+++ b/MoinMoin/Page.py	Tue Feb 10 13:21:59 2009 +0100
@@ -759,7 +759,10 @@
 
         # Add anchor
         if anchor:
-            url = "%s#%s" % (url, wikiutil.url_quote_plus(anchor))
+            fmt = getattr(self, 'formatter', request.html_formatter)
+            if fmt:
+                anchor = fmt.sanitize_to_id(anchor)
+            url = "%s#%s" % (url, anchor)
 
         return url
 
--- a/MoinMoin/_tests/test_wikiutil.py	Tue Feb 10 12:51:02 2009 +0100
+++ b/MoinMoin/_tests/test_wikiutil.py	Tue Feb 10 13:21:59 2009 +0100
@@ -909,9 +909,13 @@
         tests = [
             # text                    expected output
             (u'\xf6\xf6ll\xdf\xdf',   'A.2BAPYA9g-ll.2BAN8A3w-'),
-            (u'level 2',              'level2'),
+            (u'level 2',              'level_2'),
+            (u'level_2',              'level_2'),
             (u'',                     'A'),
             (u'123',                  'A123'),
+            # make sure that a valid anchor is not modified:
+            (u'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:_.-',
+             u'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789:_.-')
         ]
         for text, expected in tests:
             yield self._check, text, expected
--- a/MoinMoin/events/notification.py	Tue Feb 10 12:51:02 2009 +0100
+++ b/MoinMoin/events/notification.py	Tue Feb 10 13:21:59 2009 +0100
@@ -52,8 +52,7 @@
     @param querystr: a dict passed to wikiutil.makeQueryString
 
     """
-    query = wikiutil.makeQueryString(querystr, True)
-    return request.getQualifiedURL(page.url(request, query))
+    return request.getQualifiedURL(page.url(request, querystr))
 
 def page_change_message(msgtype, request, page, lang, **kwargs):
     """Prepare a notification text for a page change of given type
--- a/MoinMoin/formatter/_tests/test_formatter.py	Tue Feb 10 12:51:02 2009 +0100
+++ b/MoinMoin/formatter/_tests/test_formatter.py	Tue Feb 10 13:21:59 2009 +0100
@@ -14,6 +14,7 @@
 
 class TestFormatter:
     def testSyntaxReferenceDomXml(self):
+        py.test.skip("domxml <p> generation is broken")
         f_name = 'dom_xml'
         try:
             formatter = wikiutil.importPlugin(self.request.cfg, "formatter", f_name, "Formatter")
@@ -68,6 +69,7 @@
         self.request.reset()
         page = Page(self.request, pagename, formatter=formatter)
         self.request.formatter = page.formatter = formatter(self.request)
+        self.request.page = page
         #page.formatter.setPage(page)
         #page.hilite_re = None
 
--- a/MoinMoin/formatter/text_html.py	Tue Feb 10 12:51:02 2009 +0100
+++ b/MoinMoin/formatter/text_html.py	Tue Feb 10 13:21:59 2009 +0100
@@ -502,7 +502,7 @@
                     href = '%s%s%s' % (href, separator, wikiutil.makeQueryString(querystr))
                 anchor = kw.get('anchor')
                 if anchor:
-                    href = '%s#%s' % (href, anchor)
+                    href = '%s#%s' % (href, self.sanitize_to_id(anchor))
                 if wikitag_bad:
                     html_class = 'badinterwiki'
                 else:
--- a/MoinMoin/macro/SystemInfo.py	Tue Feb 10 12:51:02 2009 +0100
+++ b/MoinMoin/macro/SystemInfo.py	Tue Feb 10 13:21:59 2009 +0100
@@ -145,9 +145,7 @@
             idx = Search._xapianIndex(request)
             available = idx and idxState[0] or idxState[1]
             mtime = _('last modified: %s') % (idx and
-                request.user.getFormattedDateTime(
-                    wikiutil.version2timestamp(idx.mtime())) or
-                    _('N/A'))
+                request.user.getFormattedDateTime(idx.mtime()) or _('N/A'))
             xapRow += ', %s, %s' % (available, mtime)
 
         row(_('Xapian search'), xapRow)
--- a/MoinMoin/macro/__init__.py	Tue Feb 10 12:51:02 2009 +0100
+++ b/MoinMoin/macro/__init__.py	Tue Feb 10 13:21:59 2009 +0100
@@ -222,8 +222,9 @@
         for word in all_words:
             letter = wikiutil.getUnicodeIndexGroup(word)
             if letter != current_letter:
-                cssid = "idx" + wikiutil.quoteWikinameURL(letter).replace('%', '')
-                output.append(fmt.heading(1, 2, id=cssid)) # fmt.anchordef didn't work
+                anchor = "idx-%s" % letter
+                output.append(fmt.anchordef(anchor))
+                output.append(fmt.heading(1, 2))
                 output.append(fmt.text(letter.replace('~', 'Others')))
                 output.append(fmt.heading(0, 2))
                 current_letter = letter
@@ -249,8 +250,8 @@
         def _make_index_key(index_letters):
             index_letters.sort()
             def letter_link(ch):
-                cssid = "idx" + wikiutil.quoteWikinameURL(ch).replace('%', '')
-                return fmt.anchorlink(1, cssid) + fmt.text(ch.replace('~', 'Others')) + fmt.anchorlink(0)
+                anchor = "idx-%s" % ch
+                return fmt.anchorlink(1, anchor) + fmt.text(ch.replace('~', 'Others')) + fmt.anchorlink(0)
             links = [letter_link(letter) for letter in index_letters]
             return ' | '.join(links)
 
--- a/MoinMoin/parser/_tests/test_text_creole.py	Tue Feb 10 12:51:02 2009 +0100
+++ b/MoinMoin/parser/_tests/test_text_creole.py	Tue Feb 10 13:21:59 2009 +0100
@@ -38,6 +38,7 @@
         formatter.setPage(page)
         page.formatter = formatter
         request.formatter = formatter
+        request.page = page
         parser = CreoleParser(body, request, line_anchors=False)
         formatter.startContent('') # needed for _include_stack init
         output = request.redirectedOutput(parser.format, formatter)
@@ -396,9 +397,7 @@
 
     def testAnchor(self):
         html = self.parse("{{#anchor}}")
-        assert '<a ' in html # must create a link
-        assert 'name="anchor"' in html
-        assert '></a>' in html
+        assert 'id="anchor"' in html
 
 coverage_modules = ['MoinMoin.parser.text_creole']
 
--- a/MoinMoin/parser/text_creole.py	Tue Feb 10 12:51:02 2009 +0100
+++ b/MoinMoin/parser/text_creole.py	Tue Feb 10 13:21:59 2009 +0100
@@ -227,14 +227,10 @@
 #        return self.formatter.smiley(node.content)
 
     def header_emit(self, node):
-        from MoinMoin.support.python_compatibility import hash_new
-
-        pntt = '%s%s%d' % (self.formatter.page.page_name,
-            self.get_text(node), node.level)
-        ident = "head-%s" % hash_new('sha1', pntt.encode(config.charset)).hexdigest()
+        text = self.get_text(node)
         return ''.join([
-            self.formatter.heading(1, node.level, id=ident),
-            self.formatter.text(node.content or ''),
+            self.formatter.heading(1, node.level, id=text),
+            self.formatter.text(text),
             self.formatter.heading(0, node.level),
         ])
 
@@ -327,7 +323,7 @@
                 # inserted anchors
                 url = wikiutil.url_unquote(target, want_unicode=True)
                 if target.startswith('#'):
-                    return self.formatter.rawHTML(u'<a name="%s"></a>' % url[1:])
+                    return self.formatter.anchordef(url[1:])
                 # default to images
                 return self.formatter.attachment_image(
                     url, alt=text, html_class='image')
--- a/MoinMoin/userprefs/oid.py	Tue Feb 10 12:51:02 2009 +0100
+++ b/MoinMoin/userprefs/oid.py	Tue Feb 10 13:21:59 2009 +0100
@@ -79,9 +79,9 @@
             if oidreq is None:
                 return 'error', _("No OpenID given.") # ??
 
-            qstr = wikiutil.makeQueryString({'action': 'userprefs',
-                                             'handler': 'oid',
-                                             'oid.return': '1'})
+            qstr = {'action': 'userprefs',
+                    'handler': 'oid',
+                    'oid.return': '1'}
             return_to = request.getQualifiedURL(request.page.url(request, qstr))
             trust_root = request.url_root
             if oidreq.shouldSendRedirect():
@@ -102,9 +102,9 @@
         query = {}
         for key in request.form:
             query[key] = request.form[key]
-        qstr = wikiutil.makeQueryString({'action': 'userprefs',
-                                         'handler': 'oid',
-                                         'oid.return': '1'})
+        qstr = {'action': 'userprefs',
+                'handler': 'oid',
+                'oid.return': '1'}
         return_to = request.getQualifiedURL(request.page.url(request, qstr))
         info = oidconsumer.complete(query, return_to)
         if info.status == consumer.FAILURE:
--- a/MoinMoin/wikiutil.py	Tue Feb 10 12:51:02 2009 +0100
+++ b/MoinMoin/wikiutil.py	Tue Feb 10 13:21:59 2009 +0100
@@ -2458,11 +2458,14 @@
 
 def anchor_name_from_text(text):
     '''
-    Generate an anchor name from the given text
-    This function generates valid HTML IDs.
+    Generate an anchor name from the given text.
+    This function generates valid HTML IDs matching: [A-Za-z][A-Za-z0-9:_.-]*
+    Note: this transformation has a special feature: when you feed it with a
+          valid ID/name, it will return it without modification (identity
+          transformation).
     '''
-    quoted = urllib.quote_plus(text.encode('utf-7'))
-    res = quoted.replace('%', '.').replace('+', '').replace('_', '')
+    quoted = urllib.quote_plus(text.encode('utf-7'), safe=':')
+    res = quoted.replace('%', '.').replace('+', '_')
     if not res[:1].isalpha():
         return 'A%s' % res
     return res
--- a/docs/CHANGES	Tue Feb 10 12:51:02 2009 +0100
+++ b/docs/CHANGES	Tue Feb 10 13:21:59 2009 +0100
@@ -65,6 +65,7 @@
       * With history search enabled and in update mode, do not try to re-index
         old page revisions again.
       * With history search enabled, index page attachments only once.
+      * Fix last modified time of xapian index (shown on SystemInfo page).
     * Make logging handlers defined in logging.handlers work (e.g.
       class=handlers.RotatingFileHandler)
     * Jabber notifications:
@@ -72,6 +73,23 @@
       * Fix user creation notifications.
     * OpenID: Compatibility fix for python-openid 2.x.x (also works with
       1.x.x), fixes crash when trying to associate moin user to OpenID.
+    * Have a wikiserverconfig.py in wiki/server/ so setup.py copies it.
+    * Fixed inconsistent handling of fragments / anchor IDs:
+      * Fixed creole and wiki parser, other parsers might need similar fixes.
+      * IDs with blanks, non-ASCII chars etc. are now sanitized in the same way
+        for links as well as for link targets, so the user editing a page won't
+        have to bother with it.
+        E.g. [[#123 foo bar]] will link to:
+        * <<Anchor(123 foo bar)>> (moin) or {{#123 foo bar}} (creole)
+        * headline = 123 foo bar = (moin / creole)
+        Simple rule: if the link and the target are consistent, it should work.
+      * The creole wiki parser created non-human-readable sha1 heading IDs
+        before 1.8.2, now it creates same (sometimes readable) heading IDs as
+        the moin wiki parser.
+      * TitleIndex/WordIndex now also use IDs sanitized in that way internally.
+      HINT: if you manually worked around the inconsistencies/bugs before, you
+            likely have to remove those workarounds now. Same thing if you used
+            creole's sha1 heading IDs or IDs on TitleIndex/WordIndex.
 
   Other changes:
     * Updated FCKeditor to 2.6.4 (== many bug fixes in the GUI editor).
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wiki/server/wikiserverconfig.py	Tue Feb 10 13:21:59 2009 +0100
@@ -0,0 +1,26 @@
+"""
+    Standalone server configuration, you can either use this file or
+    commandline options to configure server options.
+"""
+
+from MoinMoin.script.server.standalone import DefaultConfig
+
+class Config(DefaultConfig):
+    port = 8080 # if you use port < 1024, you need to start as root
+
+    # if you start the server as root, the standalone server can change
+    # to this user and group, e.g. 'www-data'
+    #user = ''
+    #group = ''
+
+    # use '' for all interface or "1.2.3.4" for some specific IP
+    #interface = 'localhost'
+
+    # where the static data is served from:
+    #docs = "/usr/share/moin/htdocs"
+
+    # tuning options:
+    #serverClass = 'ThreadPoolServer'
+    #threadLimit = 10
+    #requestQueueSize = 50
+