changeset 1968:df6d33520205

text_moin_wiki: inline attachments not text by EmbedObject
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 08 Apr 2007 21:58:03 +0000
parents 3bc30cdc4555
children c6359f96c0f5
files MoinMoin/parser/text_moin_wiki.py
diffstat 1 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/parser/text_moin_wiki.py	Sun Apr 08 21:21:30 2007 +0000
+++ b/MoinMoin/parser/text_moin_wiki.py	Sun Apr 08 21:58:03 2007 +0000
@@ -222,9 +222,23 @@
 
         # inline the attachment if it's major mimetype is text
         mt = wikiutil.MimeType(filename=fname)
-        if scheme == 'inline' and mt.major == 'text':
-            return self.formatter.attachment_inlined(fname, text)
-
+        if scheme == 'inline':
+            if mt.major == 'text':
+                return self.formatter.attachment_inlined(fname, text)
+            else:
+                # use EmbedObject for other mimetypes
+                from MoinMoin.macro.EmbedObject import EmbedObject
+                from MoinMoin.action import AttachFile
+                if not mt is None:
+                    # reuse class tmp from Despam to define macro
+                    from MoinMoin.action.Despam import tmp
+                    macro = tmp()
+                    macro.request = self.request
+                    macro.formatter = self.request.html_formatter
+                    pagename = self.formatter.page.page_name
+                    url = AttachFile.getAttachUrl(pagename, fname, self.request, escaped=1)
+                    return self.formatter.rawHTML(EmbedObject.embed(EmbedObject(macro, wikiutil.escape(fname)), mt, url))
+    
         return self.formatter.attachment_link(fname, text)
 
     def _u_repl(self, word):