changeset 923:f16cf67d3440

merge with main
author Franz Pletz <fpletz AT franz-pletz DOT org>
date Sat, 01 Jul 2006 20:18:39 +0200
parents 63e0bd0eea98 (current diff) 62a67c72ca60 (diff)
children 22f6f589162a
files
diffstat 5 files changed, 241 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/text_html_text_moin_wiki.py	Wed Jun 28 23:52:58 2006 +0200
+++ b/MoinMoin/converter/text_html_text_moin_wiki.py	Sat Jul 01 20:18:39 2006 +0200
@@ -616,7 +616,7 @@
                     self.text.append(text.replace("\n", " "))
                 elif name == 'dd':
                     self.text.append(markup)
-                    self.process_list_item(i, indent)
+                    self.process_list_item(i, indent) # XXX no dt -> indent is undefined!!!
                 else:
                     raise ConvertError("Illegal list element %s" % i.localName)
         self.depth -= 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/macro/EmbedObject.py	Sat Jul 01 20:18:39 2006 +0200
@@ -0,0 +1,199 @@
+# -*- coding: iso-8859-1 -*-
+"""
+    MoinMoin - EmbedObject Macro
+
+    PURPOSE:
+        This macro is used to embed an object into a wiki page. Optionally, the
+        size of the object can get adjusted. Further keywords are dependent on
+        the kind of application.
+
+    CALLING SEQUENCE:
+        [[EmbedObject(attachment[,width=width][,height=height])]]
+
+    SUPPORTED MIMETYPES:
+         application/x-shockwave-flash 
+         image/svg+xml
+         application/pdf
+         audio/mpeg
+         application/vnd.visio
+
+    INPUTS:
+        attachment: name of attachment
+
+    KEYWORD PARAMETERS:
+        width: width of the embedded object, default is 100% of window
+        height: height of the embedded object, default is 100% of window
+
+        application/x-shockwave-flash:
+          play: true is default
+          loop: true is default
+          quality: high is default (medium,low)
+
+    EXAMPLE:
+        [[EmbedObject]]
+        [[EmbedObject(example.swf)]]
+        [[EmbedObject(example.pdf]]
+        [[EmbedObject(example.svg]]
+        [[EmbedObject(example.mp3]]
+        [[EmbedObject(example.vss]]
+         
+        [[EmbedObject(example.swf,width=637,height=392)]]
+        [[EmbedObject(SlideShow/example.swf,width=637,height=392)]]
+        [[EmbedObject(SlideShow/example.swf,width=637,height=392,play=false)]]
+        [[EmbedObject(SlideShow/example.swf,width=637,height=392,play=false,loop=false)]]
+        [[EmbedObject(SlideShow/example.swf,width=637,height=392,play=false,loop=low)]]
+
+ 
+    PROCEDURE:
+        If the attachment file isn't uploaded yet the attachment line will be shown.
+        If you give only one size argument, e.g. width only, the other one will be calculated.
+
+        By the swftools it is possible to get the swf size returned. I don't know if it is 
+        possible to get sizes for svg, pdf and others detected too, that's the reason why 
+        I haven't added it by now.
+
+        Please add needed mimetypes as objects.
+
+
+    MODIFICATION HISTORY:
+        @copyright: 2006 by Reimar Bauer (R.Bauer@fz-juelich.de)      
+        @license: GNU GPL, see COPYING for details.
+        initial version: 1.5.0-1
+        svg was added by AndrewArmstrong
+        2006-05-04 TomSi: added mp3 support
+        2006-05-09 RB code refactored, fixed a taintfilename bug
+        2006-06-29 visio from OwenJones added but not tested,
+                   RB code reviewed, taintfile removed
+"""
+import os, mimetypes
+
+from MoinMoin import wikiutil
+from MoinMoin.action import AttachFile
+
+def execute(macro, args):
+    request = macro.request
+    _ = request.getText
+    formatter = macro.formatter
+    if args:
+        args = args.split(',')
+        args = [arg.strip() for arg in args]
+    else:
+        args = []
+
+    argc = len(args)
+    kw_count = 0
+    kw = {}
+    kw["width"] = "100%"
+    kw["height"] = "100%"
+    kw["play"] = "true"
+    kw["loop"] = "true"
+    kw["quality"] = "high"
+
+    for arg in args :
+        if '=' in arg:
+            kw_count += 1
+            key, value = arg.split('=', 1)
+            kw[str(key)] = wikiutil.escape(value, quote=1)
+    argc -= kw_count
+
+    if not argc:
+       msg = 'Not enough arguments to EmbedObject macro! Try [[EmbedObject(attachment [,width=width] [,height=heigt])]]'
+       return "%s%s%s" % (formatter.sysmsg(1), formatter.text(msg), formatter.sysmsg(0))
+    else:
+        target = args[0]
+
+    #target = wikiutil.taintfilename(target)
+    pagename, attname = AttachFile.absoluteName(target, formatter.page.page_name)
+    attachment_fname = AttachFile.getFilename(request, pagename, attname)
+
+    if not os.path.exists(attachment_fname):
+        linktext = _('Upload new attachment "%(filename)s"')
+        return wikiutil.link_tag(request,
+            ('%s?action=AttachFile&rename=%s' % (
+            wikiutil.quoteWikinameURL(pagename),
+            wikiutil.url_quote_plus(attname))),
+            linktext % {'filename': attname})
+
+    url = AttachFile.getAttachUrl(pagename, attname, request)
+    mime_type, enc = mimetypes.guess_type(attname)
+    if mime_type == "application/x-shockwave-flash":
+        return '''
+<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
+WIDTH="%(width)s"
+HEIGHT="%(height)s"
+CODEBASE="http://active.macromedia.com/flash5/cabs/swflash.cab#version=6,0,23,0">
+<PARAM NAME="MOVIE" VALUE="%(file)s">
+<PARAM NAME="PLAY" VALUE="%(play)s">
+<PARAM NAME="LOOP" VALUE="%(loop)s">
+<PARAM NAME="QUALITY" VALUE="%(quality)s">
+<EMBED SRC="%(file)s" WIDTH="%(width)s" HEIGHT="%(height)s"
+PLAY="%(play)s" ALIGN="" LOOP="%(loop)s" QUALITY="%(quality)s"
+TYPE="application/x-shockwave-flash"
+PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
+</EMBED>
+</OBJECT>''' % {
+    "width": kw["width"],
+    "height": kw["height"],
+    "play": kw["play"],
+    "loop": kw["loop"],
+    "quality": kw["quality"],
+    "file": url,
+}
+    elif mime_type == "image/svg+xml": 
+        return '''
+<OBJECT CLASSID="" 
+WIDTH="%(width)s"
+HEIGHT="%(height)s"
+CODEBASE="http://purl.org/dc/dcmitype/StillImage">
+<EMBED SRC="%(file)s" WIDTH="%(width)s" HEIGHT="%(height)s"
+TYPE="image/svg+xml">
+</EMBED>
+</OBJECT>''' % {
+    "width": kw["width"],
+    "height": kw["height"],
+    "file": url,
+}
+    elif mime_type == "application/pdf":
+        return '''
+<OBJECT CLASSID=""
+WIDTH="%(width)s"
+HEIGHT="%(height)s"
+CODEBASE="http://www.adobe.com">
+<EMBED SRC="%(file)s" WIDTH="%(width)s" HEIGHT="%(height)s"
+TYPE="application/pdf">
+</EMBED>
+</OBJECT>''' % {
+    "width": kw["width"],
+    "height": kw["height"],
+    "file": url,
+}
+    elif mime_type == "audio/mpeg":
+        return '''
+<OBJECT CLASSID=""
+WIDTH="%(width)s"
+HEIGHT="%(height)s"
+<EMBED SRC="%(file)s" HEIGHT="0" REPEAT="TRUE" AUTOSTART="TRUE" WIDTH="0" OP="TRUE"
+TYPE="audio/mpeg">
+</EMBED>
+</OBJECT>''' % {
+    "width": kw["width"],
+    "height": kw["height"],
+    "file": url,
+}
+    elif mime_type == "application/vnd.visio":
+        return  '''
+<OBJECT CLASSID="CLSID:279D6C9A-652E-4833-BEFC-312CA8887857" 
+CODEBASE="http://www.microsoft.com/technet/prodtechnol/office/visio2003/depvisvw.mspx"
+ID="viewer1" WIDTH="%(width)s" HEIGHT="%(height)s"> <PARAM NAME="CurrentPageIndex" VALUE="0"> 
+<PARAM NAME="Zoom" VALUE="-1"> <PARAM NAME = "SRC" 
+VALUE = "%(file)s">Your browser cannot display Visio</OBJECT>''' % {
+    "width": kw['width'],
+    "height": kw['height'], 
+    "file": url,
+}
+    else:
+        msg = 'Not supported mimetype %(mimetype)s ' % {"mimetype": mime_type}
+        return "%s%s%s" % (macro.formatter.sysmsg(1),
+                   macro.formatter.text(msg),
+                   macro.formatter.sysmsg(0))
+
--- a/MoinMoin/support/htmlmarkup.py	Wed Jun 28 23:52:58 2006 +0200
+++ b/MoinMoin/support/htmlmarkup.py	Sat Jul 01 20:18:39 2006 +0200
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# copied from trac.util.markup, version 2006-04-10
+# copied from trac.util.markup, revision 3446, merged on 2006-06-30
 #
 # Copyright (C) 2003-2006 Edgewall Software
 # All rights reserved.
@@ -103,7 +103,7 @@
         as is. Escaping quotes is generally only required for strings that are
         to be used in attribute values.
         """
-        if isinstance(text, cls):
+        if isinstance(text, (cls, Element)):
             return text
         text = unicode(text)
         if not text:
@@ -192,7 +192,7 @@
         'td', 'textarea', 'tfoot', 'th', 'thead', 'tr', 'tt', 'u', 'ul',
         'var'])
     safe_attrs = frozenset(['abbr', 'accept', 'accept-charset',
-        'accesskey', 'action', 'align', 'alt', 'axis', 'border',
+        'accesskey', 'action', 'align', 'alt', 'axis', 'border', 'bgcolor',
         'cellpadding', 'cellspacing', 'char', 'charoff', 'charset',
         'checked', 'cite', 'class', 'clear', 'cols', 'colspan', 'color',
         'compact', 'coords', 'datetime', 'dir', 'disabled', 'enctype',
@@ -305,14 +305,9 @@
             except TypeError:
                 self.children.append(node)
 
-    def __getitem__(self, nodes):
-        """Add child nodes to the element."""
-        if not isinstance(nodes, (basestring, Fragment)):
-            try:
-                nodes = iter(nodes)
-            except TypeError:
-                nodes = [str(nodes)]
-        self.append(nodes)
+    def __call__(self, *args):
+        for arg in args:
+            self.append(arg)
         return self
 
     def serialize(self):
@@ -327,77 +322,78 @@
         return Markup(''.join(self.serialize()))
 
     def __add__(self, other):
-        return Fragment()[self, other]
+        return Fragment()(self, other)
 
 
 class Element(Fragment):
     """Simple XHTML output generator based on the builder pattern.
-
+    
     Construct XHTML elements by passing the tag name to the constructor:
-
+    
     >>> print Element('strong')
     <strong></strong>
-
+    
     Attributes can be specified using keyword arguments. The values of the
     arguments will be converted to strings and any special XML characters
     escaped:
-
+    
     >>> print Element('textarea', rows=10, cols=60)
     <textarea rows="10" cols="60"></textarea>
     >>> print Element('span', title='1 < 2')
     <span title="1 &lt; 2"></span>
     >>> print Element('span', title='"baz"')
     <span title="&#34;baz&#34;"></span>
-
+    
     The " character is escaped using a numerical entity.
     The order in which attributes are rendered is undefined.
-
+    
     If an attribute value evaluates to `None`, that attribute is not included
     in the output:
-
+    
     >>> print Element('a', name=None)
     <a></a>
-
+    
     Attribute names that conflict with Python keywords can be specified by
     appending an underscore:
-
+    
     >>> print Element('div', class_='warning')
     <div class="warning"></div>
-
+    
     While the tag names and attributes are not restricted to the XHTML language,
     some HTML characteristics such as boolean (minimized) attributes and empty
     elements get special treatment.
-
+    
     For compatibility with HTML user agents, some XHTML elements need to be
     closed using a separate closing tag even if they are empty. For this, the
     close tag is only ommitted for a small set of elements which are known be
     be safe for use as empty elements:
-
+    
     >>> print Element('br')
     <br />
-
+    
     Trying to add nested elements to such an element will cause an
     `AssertionError`:
     
-    >>> Element('br')['Oops']
+    >>> Element('br')('Oops')
     Traceback (most recent call last):
         ...
     AssertionError: 'br' elements must not have content
-
+    
     Furthermore, boolean attributes such as "selected" or "checked" are omitted
     if the value evaluates to `False`. Otherwise, the name of the attribute is
     used for the value:
-
+    
     >>> print Element('option', value=0, selected=False)
     <option value="0"></option>
     >>> print Element('option', selected='yeah')
     <option selected="selected"></option>
-
-    Nested elements can be added to an element using item access notation.
-    The call notation can also be used for this and for adding attributes
-    using keyword arguments, as one would do in the constructor.
-
-    >>> print Element('ul')[Element('li'), Element('li')]
+    
+    
+    Nested elements can be added to an element by calling the instance using
+    positional arguments. The same technique can also be used for adding
+    attributes using keyword arguments, as one would do in the constructor:
+    
+    >>> print Element('ul')(Element('li'), Element('li'))
     <ul><li></li><li></li></ul>
     >>> print Element('a')('Label')
     <a>Label</a>
@@ -407,16 +403,16 @@
     Text nodes can be nested in an element by adding strings instead of
     elements. Any special characters in the strings are escaped automatically:
 
-    >>> print Element('em')['Hello world']
+    >>> print Element('em')('Hello world')
     <em>Hello world</em>
-    >>> print Element('em')[42]
+    >>> print Element('em')(42)
     <em>42</em>
-    >>> print Element('em')['1 < 2']
+    >>> print Element('em')('1 < 2')
     <em>1 &lt; 2</em>
 
     This technique also allows mixed content:
 
-    >>> print Element('p')['Hello ', Element('b')['world']]
+    >>> print Element('p')('Hello ', Element('b')('world'))
     <p>Hello <b>world</b></p>
 
     Elements can also be combined with other elements or strings using the
@@ -436,10 +432,8 @@
         self(**attr)
 
     def __call__(self, *args, **attr):
-        for arg in args:
-            self.append(arg)
         self.attr.update(attr)
-        return self
+        return Fragment.__call__(self, *args)
 
     def append(self, node):
         """Append an element or string as child node."""
--- a/docs/CHANGES	Wed Jun 28 23:52:58 2006 +0200
+++ b/docs/CHANGES	Sat Jul 01 20:18:39 2006 +0200
@@ -28,9 +28,6 @@
     and improving it and after having made a backup with some other, proven
     method. USE BOTH ON YOUR OWN RISK!
 
-Version 1.5.4-current:
-    * increased maxlength of some input fields from 80 to 200
-
 Branch moin-1.6-xapian:
   New Features:
     * Added Xapian (see http://xapian.org/) based indexed search code.
@@ -158,6 +155,7 @@
     * We use rel="nofollow" for some action links in the hope that some search
       engines don't fetch the targets (if they do, they will just get 403 and
       cause unnecessary traffic).
+    * Included EmbedObject macro for embedding shockwave flash, mp3, visio, ...
 
   Bugfixes:
     * on action "info" page, "revert" link will not be displayed for empty page
@@ -183,6 +181,9 @@
       compatibility issues or a wrong browser version check, please file a bug
       at FCKeditor development or browser development.
 
+Version 1.5.4-current:
+    * increased maxlength of some input fields from 80 to 200
+
 Version 1.5.current:
   Developer notes:
     * We switched to Mercurial SCM, see here for more infos:
--- a/setup.py	Wed Jun 28 23:52:58 2006 +0200
+++ b/setup.py	Sat Jul 01 20:18:39 2006 +0200
@@ -201,6 +201,7 @@
     'packages': [
         'MoinMoin',
         'MoinMoin.action',
+        'MoinMoin.auth',
         'MoinMoin.converter',
         'MoinMoin.filter',
         'MoinMoin.formatter',
@@ -209,6 +210,7 @@
         'MoinMoin.i18n.tools',
         'MoinMoin.logfile',
         'MoinMoin.macro',
+        'MoinMoin.mail',
         'MoinMoin.parser',
         'MoinMoin.request',
         'MoinMoin.script',