comparison MoinMoin/macro/EmbedObject.py @ 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 e757ebc436e7
comparison
equal deleted inserted replaced
2787:1cb372eb7935 2788:e857c1c3eca1
2 """ 2 """
3 MoinMoin - EmbedObject Macro 3 MoinMoin - EmbedObject Macro
4 4
5 This macro is used to embed an object into a wiki page. Optionally, the 5 This macro is used to embed an object into a wiki page. Optionally, the
6 size of the object can get adjusted. Further keywords are dependent on 6 size of the object can get adjusted. Further keywords are dependent on
7 the kind of application. 7 the kind of application, see HelpOnMacros/EmbedObject
8 8
9 <<EmbedObject(attachment[,width=width][,height=height][,alt=Embedded mimetpye/xy])>> 9 <<EmbedObject(attachment[,width=width][,height=height][,alt=Embedded mimetpye/xy])>>
10 10
11 @copyright: 2006-2007 MoinMoin:ReimarBauer, 11 @copyright: 2006-2007 MoinMoin:ReimarBauer,
12 2006 TomSi, 12 2006 TomSi,
40 self.hidden = "false" 40 self.hidden = "false"
41 self.menu = "true" 41 self.menu = "true"
42 self.wmode = "transparent" 42 self.wmode = "transparent"
43 self.target = None 43 self.target = None
44 self.align = "middle" 44 self.align = "middle"
45 self.guess_filename = 'Probably.swf' 45 self.url_mimetype = None
46 46
47 if args: 47 if args:
48 args = args.split(',') 48 args = args.split(',')
49 args = [arg.strip() for arg in args] 49 args = [arg.strip() for arg in args]
50 else: 50 else:
183 183
184 def render(self): 184 def render(self):
185 _ = self._ 185 _ = self._
186 186
187 if not self.target: 187 if not self.target:
188 msg = _('Not enough arguments to EmbedObject macro! Try [[EmbedObject(attachment [,width=width] [,height=height] [,alt=Embedded mimetpye/xy])]]', formatted=False) 188 msg = _('Not enough arguments to EmbedObject macro! Try <<EmbedObject(attachment [,width=width] [,height=height] [,alt=Embedded mimetpye/xy])>>', formatted=False)
189 return "%s%s%s" % (self.formatter.sysmsg(1), self.formatter.text(msg), self.formatter.sysmsg(0)) 189 return "%s%s%s" % (self.formatter.sysmsg(1), self.formatter.text(msg), self.formatter.sysmsg(0))
190 190
191 if not self._is_URL(self.target): 191 if not self._is_URL(self.target):
192 pagename, fname = AttachFile.absoluteName(self.target, self.formatter.page.page_name) 192 pagename, fname = AttachFile.absoluteName(self.target, self.formatter.page.page_name)
193 193
199 linktext % {'filename': fname}) 199 linktext % {'filename': fname})
200 200
201 url = AttachFile.getAttachUrl(pagename, fname, self.request) 201 url = AttachFile.getAttachUrl(pagename, fname, self.request)
202 202
203 mt = wikiutil.MimeType(filename=fname) 203 mt = wikiutil.MimeType(filename=fname)
204 mimestr = "%s/%s" % (mt.major, mt.minor, )
205 else: 204 else:
206 mt = wikiutil.MimeType(filename=self.guess_filename) 205 if not self.url_mimetype:
207 url = wikiutil.escape(self.target) 206 return _('Not enough arguments to EmbedObject macro! Try <<EmbedObject(url, url_mimetype [,width=width] [,height=height] [,alt=Embedded mimetpye/xy])>>', formatted=False)
207 else:
208 mt = wikiutil.MimeType() # initialize dict
209 mt.major, mt.minor = self.url_mimetype.split('/')
210 url = wikiutil.escape(self.target)
208 211
209 # XXX Should better use formatter.embed if available? 212 # XXX Should better use formatter.embed if available?
210 return self.macro.formatter.rawHTML(self.embed(mt, url)) 213 return self.macro.formatter.rawHTML(self.embed(mt, url))
211 214
212 def execute(macro, args): 215 def execute(macro, args):