changeset 2788:e857c1c3eca1

EmbedObject: msg strings corrected for new macro syntax and external url call parameter renamed
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 31 Aug 2007 12:57:40 +0200
parents 1cb372eb7935
children 637a6c5ff74e
files MoinMoin/macro/EmbedObject.py
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/EmbedObject.py	Thu Aug 30 16:32:05 2007 +0200
+++ b/MoinMoin/macro/EmbedObject.py	Fri Aug 31 12:57:40 2007 +0200
@@ -4,7 +4,7 @@
 
     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.
+    the kind of application, see HelpOnMacros/EmbedObject
 
     <<EmbedObject(attachment[,width=width][,height=height][,alt=Embedded mimetpye/xy])>>
 
@@ -42,7 +42,7 @@
         self.wmode = "transparent"
         self.target = None
         self.align = "middle"
-        self.guess_filename = 'Probably.swf'
+        self.url_mimetype = None
 
         if args:
             args = args.split(',')
@@ -185,7 +185,7 @@
         _ = self._
 
         if not self.target:
-            msg = _('Not enough arguments to EmbedObject macro! Try [[EmbedObject(attachment [,width=width] [,height=height] [,alt=Embedded mimetpye/xy])]]', formatted=False)
+            msg = _('Not enough arguments to EmbedObject macro! Try <<EmbedObject(attachment [,width=width] [,height=height] [,alt=Embedded mimetpye/xy])>>', formatted=False)
             return "%s%s%s" % (self.formatter.sysmsg(1), self.formatter.text(msg), self.formatter.sysmsg(0))
 
         if not self._is_URL(self.target):
@@ -201,10 +201,13 @@
             url = AttachFile.getAttachUrl(pagename, fname, self.request)
 
             mt = wikiutil.MimeType(filename=fname)
-            mimestr = "%s/%s" % (mt.major, mt.minor, )
         else:
-            mt = wikiutil.MimeType(filename=self.guess_filename)
-            url = wikiutil.escape(self.target)
+            if not self.url_mimetype:
+                return _('Not enough arguments to EmbedObject macro! Try <<EmbedObject(url, url_mimetype [,width=width] [,height=height] [,alt=Embedded mimetpye/xy])>>', formatted=False)
+            else:
+                mt = wikiutil.MimeType() # initialize dict
+                mt.major, mt.minor = self.url_mimetype.split('/')
+                url = wikiutil.escape(self.target)
 
         # XXX Should better use formatter.embed if available?
         return self.macro.formatter.rawHTML(self.embed(mt, url))