Attachment 'embedobject.diff'
Download 1 --- EmbedObject_old.py 2006-12-09 13:32:00.000000000 +0100
2 +++ EmbedObject.py 2007-02-10 18:18:00.000000000 +0100
3 @@ -8,7 +8,7 @@
4 the kind of application.
5
6 CALLING SEQUENCE:
7 - [[EmbedObject(attachment[,width=width][,height=height])]]
8 + [[EmbedObject(attachment[,width=width][,height=height][,alt=Embedded mimetpye/xy])]]
9
10 SUPPORTED MIMETYPES:
11 application/x-shockwave-flash
12 @@ -45,6 +45,7 @@
13
14 width = ""
15 height = ""
16 + alt = "Embedded mimetpye/xy"
17 type = mime_type
18 play = false
19 loop = false
20 @@ -55,22 +56,31 @@
21 menu = true
22
23
24 - All do use width, height, mime_type
25 + All do use width, height, mime_type, alt
26
27 in addition:
28 'video' do use repeat, autostart, menu, op
29 'audio' do use play, repeat, autostart, op, hidden
30 the default width is 60 and default height is 20
31 'application' do use play, menu, autostart
32 -
33 +
34 + Note: Please do provide always a sensible alt text for the embedded object which
35 + gives a short description of the visually or acoustically presented content so
36 + that visually and acoustically impaired people can at least get a clue of what's
37 + going on in this "black box". By default alt is set to "Embedded mimetpye/xy" for
38 + people that forget to set an alt. However this default alt text is not a sensible
39 + one since it does not describe the content really but only the type of content.
40 + Compare these alt texts: "Embedded application/pdf" vs. "MoinMoin Tutorial embedded
41 + as PDF file"
42
43 EXAMPLE:
44 [[EmbedObject]]
45 - [[EmbedObject(example.swf)]]
46 - [[EmbedObject(example.pdf]]
47 - [[EmbedObject(example.svg]]
48 - [[EmbedObject(example.mp3]]
49 - [[EmbedObject(example.vss]]
50 + [[EmbedObject(example.swf,alt=A flash movie showing the rotating moin logo)]]
51 + [[EmbedObject(example.mid,alt=Background sound of wikipage: oceanwaves)]]
52 + [[EmbedObject(example.pdf)]]
53 + [[EmbedObject(example.svg)]]
54 + [[EmbedObject(example.mp3)]]
55 + [[EmbedObject(example.vss)]]
56
57 [[EmbedObject(example.swf,width=637,height=392)]]
58 [[EmbedObject(SlideShow/example.swf,width=637,height=392)]]
59 @@ -88,9 +98,10 @@
60 I haven't added it by now.
61
62 Please add needed mimetypes as objects.
63 -
64 +
65 +
66 RESTRICTIONS:
67 - some mimetypes do ignore all used keywords. May be they do use different names.
68 + Some mimetypes do ignore all used keywords. May be they do use different names.
69
70
71 MODIFICATION HISTORY:
72 @@ -105,6 +116,8 @@
73 2006-10-01 RB code refactored
74 2006-10-05 RB bug fixed closing " at height added
75 2006-10-08 RB type is needed on some platforms, some more keywords added
76 + 2007-02-10 OliverSiemoneit: alt and noembed tags added for AccessibleMoin; fixed
77 + output abstraction violation.
78 """
79 import os, mimetypes
80
81 @@ -114,6 +127,7 @@
82 class EmbedObject:
83
84 def __init__(self, macro, args):
85 + self._ = macro.request.getText
86 self.macro = macro
87 self.request = macro.request
88 self.formatter = macro.formatter
89 @@ -121,6 +135,7 @@
90
91 self.width = ""
92 self.height = ""
93 + self.alt = ""
94 self.play = "false"
95 self.loop = "false"
96 self.quality = "high"
97 @@ -130,7 +145,7 @@
98 self.align = "center"
99 self.hidden = "false"
100 self.menu = "true"
101 -
102 +
103 if args:
104 args = args.split(',')
105 args = [arg.strip() for arg in args]
106 @@ -148,18 +163,25 @@
107 argc -= kw_count
108
109 if not argc:
110 - msg = 'Not enough arguments to EmbedObject macro! Try [[EmbedObject(attachment [,width=width] [,height=heigt])]]'
111 + msg = 'Not enough arguments to EmbedObject macro! Try [[EmbedObject(attachment [,width=width] [,height=height] [,alt=Embedded mimetpye/xy])]]'
112 return "%s%s%s" % (formatter.sysmsg(1), formatter.text(msg), formatter.sysmsg(0))
113 else:
114 self.target = args[0]
115
116 def embed(self, mime_type, file):
117 + _ = self._
118 mtype = mime_type.split('/')
119
120 + if self.alt == "":
121 + self.alt = "%(text)s %(mime_type)s" % { 'text': _("Embedded"), 'mime_type': mime_type, }
122 +
123 if mtype[0] == 'video':
124 return '''
125 <OBJECT>
126 <EMBED SRC="%(file)s" WIDTH="%(width)s" HEIGHT="%(height)s" REPEAT="%(repeat)s" AUTOSTART="%(autostart)s" OP="%(op)s" MENU="%(menu)s" TYPE="%(type)s"></EMBED>
127 +<NOEMBED>
128 +<p>%(alt)s</p>
129 +</NOEMBED>
130 </OBJECT>''' % {
131 "width": self.width,
132 "height": self.height,
133 @@ -169,17 +191,22 @@
134 "op": self.op,
135 "type": mime_type,
136 "menu": self.menu,
137 + "alt": self.alt,
138 }
139
140 if mtype[0] in ['image', 'chemical', 'x-world']:
141 return '''
142 <OBJECT>
143 <EMBED SRC="%(file)s" WIDTH="%(width)s" HEIGHT="%(height)s" TYPE="%(type)s"></EMBED>
144 +<NOEMBED>
145 +<p>%(alt)s</p>
146 +</NOEMBED>
147 </OBJECT>''' % {
148 "width": self.width,
149 "height": self.height,
150 "file": file,
151 "type": mime_type,
152 + "alt": self.alt,
153 }
154
155 if mtype[0] == 'audio':
156 @@ -190,22 +217,29 @@
157 return '''
158 <OBJECT>
159 <EMBED SRC="%(file)s" WIDTH="%(width)s" HEIGHT="%(height)s" REPEAT="%(repeat)s" AUTOSTART="%(autostart)s" OP="%(op)s" PLAY="%(play)s" HIDDEN="%(hidden)s" TYPE="%(type)s"></EMBED>
160 +<NOEMBED>
161 +<p>%(alt)s</p>
162 +</NOEMBED>
163 </OBJECT>''' % {
164 - "width": self.width,
165 - "height": self.height,
166 - "file": file,
167 - "play": self.play,
168 - "repeat": self.repeat,
169 - "autostart": self.autostart,
170 - "op": self.op,
171 - "hidden": self.hidden,
172 - "type": mime_type,
173 + "width": self.width,
174 + "height": self.height,
175 + "file": file,
176 + "play": self.play,
177 + "repeat": self.repeat,
178 + "autostart": self.autostart,
179 + "op": self.op,
180 + "hidden": self.hidden,
181 + "type": mime_type,
182 + "alt": self.alt,
183 }
184
185 if mtype[0] == 'application':
186 return '''
187 <OBJECT>
188 <EMBED SRC="%(file)s" WIDTH="%(width)s" HEIGHT="%(height)s" AUTOSTART="%(autostart)s" PLAY="%(play)s" LOOP="%(loop)s" MENU="%(menu)s" TYPE="%(type)s"> </EMBED>
189 +<NOEMBED>
190 +<p>%(alt)s</p>
191 +</NOEMBED>
192 </OBJECT>''' % {
193 "width": self.width,
194 "height": self.height,
195 @@ -215,10 +249,11 @@
196 "loop": self.loop,
197 "type": mime_type,
198 "menu": self.menu,
199 + "alt": self.alt,
200 }
201
202 def render(self):
203 - _ = self.request.getText
204 + _ = self._
205
206 pagename, attname = AttachFile.absoluteName(self.target, self.formatter.page.page_name)
207 attachment_fname = AttachFile.getFilename(self.request, pagename, attname)
208 @@ -259,8 +294,13 @@
209
210 "x-world/x-vrml",
211 ]:
212 -
213 - return self.embed(mime_type, url)
214 + # XXX Should better use formatter.embed if available?
215 + try:
216 + return self.macro.formatter.rawHTML(self.embed(mime_type, url))
217 + except:
218 + return "%s%s%s" % (self.macro.formatter.sysmsg(1),
219 + self.macro.formatter.text('Embedding of object by choosen formatter not possible'),
220 + self.macro.formatter.sysmsg(0))
221
222 else:
223 msg = 'Not supported mimetype %(mimetype)s ' % {"mimetype": mime_type}
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.