changeset 2129:5e47b9a9df08

Merge main.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Fri, 15 Jun 2007 22:13:51 +0200
parents 401d49b9f1ac (current diff) fca8ed243a88 (diff)
children 283530fa9c52 ea879bd7935d
files
diffstat 7 files changed, 116 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Fri Jun 15 22:13:25 2007 +0200
+++ b/Makefile	Fri Jun 15 22:13:51 2007 +0200
@@ -36,7 +36,7 @@
 
 # Create documentation
 epydoc: patchlevel
-	@epydoc -o ../html-1.6 -n MoinMoin -u http://moinmoin.wikiwikiweb.de MoinMoin
+	@epydoc -o ../html-1.7 --name=MoinMoin --url=http://moinmo.in/ --graph=all --graph-font=Arial MoinMoin
 
 # Create new underlay directory from MoinMaster
 # Should be used only on TW machine
--- a/MoinMoin/__init__.py	Fri Jun 15 22:13:25 2007 +0200
+++ b/MoinMoin/__init__.py	Fri Jun 15 22:13:51 2007 +0200
@@ -1,6 +1,6 @@
 # -*- coding: iso-8859-1 -*-
 """
-MoinMoin Version 1.6.0alpha eb68960b1dfb+ tip
+MoinMoin Version 1.7.0alpha 
 
 @copyright: 2000-2006 by Juergen Hermann <jh@web.de>,
             2002-2007 MoinMoin:ThomasWaldmann
--- a/MoinMoin/_tests/test_parser_text_moin_wiki.py	Fri Jun 15 22:13:25 2007 +0200
+++ b/MoinMoin/_tests/test_parser_text_moin_wiki.py	Fri Jun 15 22:13:51 2007 +0200
@@ -461,4 +461,15 @@
             self.assert_(match is not None,
                          'Expected "%(expected)s" but got "%(result)s"' % locals())
 
+    def testUrlAfterBlock(self):
+        """ parser.wiki: tests url after block element """
+        cases = ('some text {{{some block text\n}}} and a URL http://moinmo.in/',
+                 'some text {{{some block text\n}}} and a WikiName')
 
+        for case in cases:          
+            result = self.parse(case).strip()
+            match = result.endswith('</a>')
+            expected = True
+            self.assert_(match is True,
+                         'Expected "%(expected)s" but got "%(result)s"' % locals())
+
--- a/MoinMoin/_tests/test_wikiutil.py	Fri Jun 15 22:13:25 2007 +0200
+++ b/MoinMoin/_tests/test_wikiutil.py	Fri Jun 15 22:13:51 2007 +0200
@@ -61,3 +61,36 @@
                 '"%(name)s" is NOT a valid template name' % locals())
 
 
+class TestParmeterParser(unittest.TestCase):
+ 
+    def testNoWantedArguments(self):
+        args = ''
+        argParser = wikiutil.ParameterParser('')
+        self.arg_list, self.arg_dict = argParser.parse_parameters(args)
+        result = len(self.arg_dict) > 0
+        expected = False
+        self.assert_(result is expected,
+                     'Expected "%(expected)s" but got "%(result)s"' % locals())
+
+    def testWantedArguments(self):
+        test_args = ('', 
+                     'width=100',
+                     'width=100, height=200', )
+       
+        argParser = wikiutil.ParameterParser("%(width)s%(height)s")
+        for args in test_args: 
+            self.arg_list, self.arg_dict = argParser.parse_parameters(args)
+            result = len(self.arg_dict) == 2
+            expected = True
+            self.assert_(result is expected,
+                         'Expected "%(expected)s" but got "%(result)s"' % locals())
+      
+    def testTooMuchWantedArguments(self):
+        args = 'width=100, height=200, alt=Example'
+        argParser = wikiutil.ParameterParser("%(width)s%(height)s")
+        self.arg_list, self.arg_dict = argParser.parse_parameters(args)
+        result = len(self.arg_dict) == 2
+        expected = True
+        self.assert_(result is expected,
+                     'Expected "%(expected)s" but got "%(result)s"' % locals())  
+      
\ No newline at end of file
--- a/MoinMoin/logfile/__init__.py	Fri Jun 15 22:13:25 2007 +0200
+++ b/MoinMoin/logfile/__init__.py	Fri Jun 15 22:13:51 2007 +0200
@@ -455,4 +455,5 @@
             if line[-1] != '\n':
                 line += '\n'
             self._output.write(line)
-
+            self._output.close() # does this maybe help against the sporadic fedora wikis 160 \0 bytes in the edit-log?
+            del self._output # re-open the output file automagically
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/macro/Hits.py	Fri Jun 15 22:13:51 2007 +0200
@@ -0,0 +1,61 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - Hits Macro
+
+    This macro is used to show the cummulative hits of the wikipage where the Macro is called from.
+    Optional you could count how much this or all pages was changed or viewed.
+
+    [[Hits([all=(0,1)],[filter=(VIEWPAGE,SAVEPAGE)]]
+
+        all: if set to 1 then cummulative hits over all wiki pages is returned. Default is 0
+        filter: if set to SAVEPAGE then the saved pages are counted. Default is VIEWPAGE.
+    
+   @copyright: 2004-2007 MoinMoin:ReimarBauer
+               2005 BenjaminVrolijk
+   @license: GNU GPL, see COPYING for details.
+"""
+Dependencies = ['time'] # do not cache
+
+from MoinMoin import wikiutil
+from MoinMoin.logfile import eventlog
+
+class Hits:
+    def __init__(self, macro, args):
+        self.macro = macro
+        self.request = macro.request
+        self.formatter = macro.formatter
+        argParser = wikiutil.ParameterParser("%(all)s%(filter)s")
+        try:
+            self.arg_list, self.arg_dict = argParser.parse_parameters(args)
+        except ValueError:
+            # TODO Set defaults until raise in ParameterParser.parse_parameters is changed
+            self.arg_dict = {}
+            self.arg_dict["filter"] = None
+            self.arg_dict["all"] = 0
+
+        self.count = 0
+
+    def renderInText(self):
+        return self.formatter.text("%s" % (self.getHits()))
+
+    def getHits(self):
+        formatter = self.macro.formatter
+        kw = self.arg_dict
+        if not kw["filter"]: kw["filter"] = "VIEWPAGE"
+
+        event_log = eventlog.EventLog(self.request)
+        event_log.set_filter([kw["filter"]])
+        for event in event_log.reverse():
+            pagename = event[2].get('pagename', None)
+            if not kw["all"]:
+                if pagename == formatter.page.page_name:
+                   self.count += 1
+            else:
+                self.count += 1
+
+        return self.count
+
+def execute(macro, args):
+    """ Temporary glue code to use with moin current macro system """
+    return Hits(macro, args).renderInText()
+
--- a/MoinMoin/wikiutil.py	Fri Jun 15 22:13:25 2007 +0200
+++ b/MoinMoin/wikiutil.py	Fri Jun 15 22:13:51 2007 +0200
@@ -1343,6 +1343,10 @@
         i = 0
         start = 0
         named = False
+
+        if not params:
+            params = '""'
+        
         while start < len(params):
             match = re.match(self.param_re, params[start:])
             if not match:
@@ -1366,10 +1370,11 @@
                 type = 'n'
             else:
                 value = None
-
+            
             parameter_list.append(value)
             if match.group("name"):
                 if match.group("name") not in self.param_dict:
+                    # TODO we should think on inheritance of parameters
                     raise ValueError, "Unknown parameter name '%s'" % match.group("name")
                 nr = self.param_dict[match.group("name")]
                 if check_list[nr]:
@@ -1395,8 +1400,7 @@
             i += 1
 
         return parameter_list, parameter_dict
-
-
+    
 """ never used:
     def _check_type(value, type, format):
         if type == 'n' and 's' in format: # n as s