changeset 3261:cbaf672bcea3

fix EmbedObject UnitArgument usage
author Johannes Berg <johannes AT sipsolutions DOT net>
date Sun, 16 Mar 2008 11:02:54 +0100
parents b971703ee4a9
children e30816db5cb5
files MoinMoin/macro/EmbedObject.py
diffstat 1 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/EmbedObject.py	Sat Mar 15 20:59:31 2008 +0100
+++ b/MoinMoin/macro/EmbedObject.py	Sun Mar 16 11:02:54 2008 +0100
@@ -21,7 +21,9 @@
 extension_type, extension_name = __name__.split('.')[-2:]
 
 def _check_object_value(param, value):
-    """ helps to ommit useless lines of object values
+    """
+    helps omit useless lines of object values
+
     @param param: definition of object param
     @param value: value of param
     """
@@ -44,14 +46,25 @@
     else:
         return ""
 
-def macro_EmbedObject(macro, target=None, pagename=None, width=wikiutil.UnitArgument('0px', float, ['px', 'em', 'mm', '%%']),
-                      height=wikiutil.UnitArgument('0px', float, ['px', 'em', 'mm', '%%']), alt=u'',
+def macro_EmbedObject(macro, target=None, pagename=None, width=wikiutil.UnitArgument('0px', float, ['px', 'em', 'mm', '%']),
+                      height=wikiutil.UnitArgument('0px', float, ['px', 'em', 'mm', '%']), alt=u'',
                       play=False, stop=True, loop=False, quality=(u'high', u'low', u'medium'),
                       op=True, repeat=False, autostart=False, align=(u'middle', u'top', u'bottom'), hidden=False,
                       menu=True, wmode='transparent', url_mimetype=None):
 
     """ This macro is used to embed an object into a wiki page """
 
+    # Join unit arguments with their units
+    if width[1] == 'px':
+        width = '%dpx' % int(width[0])
+    else:
+        width = '%f%s' % width
+
+    if height[1] == 'px':
+        height = '%dpx' % int(height[0])
+    else:
+        height = '%f%s' % height
+
     request = macro.request
     _ = macro.request.getText
     fmt = macro.formatter