changeset 5066:1008a0fca6a5

formatter.text_gedit: calls gedit_drawing instead of attachment_drawing.
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Mon, 31 Aug 2009 00:13:28 +0200
parents bb1df7737cf2
children fac58630b61e
files MoinMoin/action/twikidraw.py MoinMoin/formatter/text_gedit.py
diffstat 2 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/twikidraw.py	Sun Aug 30 23:26:25 2009 +0200
+++ b/MoinMoin/action/twikidraw.py	Mon Aug 31 00:13:28 2009 +0200
@@ -34,6 +34,27 @@
         logging.error("unsupported content object: %r" % content)
         raise
 
+def gedit_drawing(self, url, text, **kw):
+    # This is called for displaying a drawing image by gui editor.
+    _ = self.request.getText
+    # TODO: this 'text' argument is kind of superfluous, replace by using alt=... kw arg
+    # ToDo: make this clickable for the gui editor
+    if 'alt' not in kw or not kw['alt']:
+        kw['alt'] = text
+    # we force the title here, needed later for html>wiki converter
+    kw['title'] = "drawing:%s" % wikiutil.quoteWikinameURL(url)
+    pagename, drawing = AttachFile.absoluteName(url, self.page.page_name)
+    containername = wikiutil.taintfilename(drawing) + ".tdraw"
+    drawing_url = AttachFile.getAttachUrl(pagename, containername, self.request, drawing=drawing, upload=True)
+    ci = AttachFile.ContainerItem(self.request, pagename, containername)
+    if not ci.exists():
+        title = _('Create new drawing "%(filename)s (opens in new window)"') % {'filename': drawing}
+        img = self.icon('attachimg')  # TODO: we need a new "drawimg" in similar grey style and size
+        css = 'nonexistent'
+        return self.url(1, drawing_url, css=css, title=title) + img + self.url(0)
+    kw['src'] = ci.member_url(drawing + u'.png')
+    return self.image(**kw)
+
 def attachment_drawing(self, url, text, **kw):
     # This is called for displaying a clickable drawing image by text_html formatter.
     # XXX text arg is unused!
--- a/MoinMoin/formatter/text_gedit.py	Sun Aug 30 23:26:25 2009 +0200
+++ b/MoinMoin/formatter/text_gedit.py	Mon Aug 31 00:13:28 2009 +0200
@@ -96,11 +96,11 @@
         # Todo get it to start the drawing editor on a click
         try:
             attachment_drawing = wikiutil.importPlugin(self.request.cfg, 'action',
-                                              self.request.cfg.drawing_action, 'attachment_drawing')
+                                              self.request.cfg.drawing_action, 'gedit_drawing')
             return attachment_drawing(self, url, text, **kw)
         except (wikiutil.PluginMissingError, wikiutil.PluginAttributeError):
             return url
-        
+
     def icon(self, type):
         return self.request.theme.make_icon(type, title='smiley:%s' % type)