changeset 1722:366650d8772b

ImageLink gui formatter/converter roundtrip: fixed width/height/alt bugs
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 08 Jan 2007 00:53:08 +0100
parents 65bf1618c196
children 4916528e1cd7
files MoinMoin/converter/text_html_text_moin_wiki.py MoinMoin/formatter/text_gedit.py
diffstat 2 files changed, 22 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/text_html_text_moin_wiki.py	Sun Jan 07 23:08:59 2007 +0100
+++ b/MoinMoin/converter/text_html_text_moin_wiki.py	Mon Jan 08 00:53:08 2007 +0100
@@ -1192,7 +1192,7 @@
         # Attachment image
         if (title and title.startswith("attachment:") and
             wikiutil.isPicture(wikiutil.url_unquote(title[len("attachment:"):]))):
-            if height is None and width is None:
+            if height is None and width is None and target is None:
                 self.text.extend([self.white_space,
                                   wikiutil.url_unquote(title),
                                   self.white_space])
@@ -1205,7 +1205,7 @@
                     il_parms += ",width=%s" % width
                 if height is not None:
                     il_parms += ",height=%s" % height
-                if alt is not None:
+                if alt:
                     il_parms += ",alt=%s" % alt
                 self.text.extend([self.white_space, "[[ImageLink(%s)]]" % il_parms, self.white_space])
 
--- a/MoinMoin/formatter/text_gedit.py	Sun Jan 07 23:08:59 2007 +0100
+++ b/MoinMoin/formatter/text_gedit.py	Mon Jan 08 00:53:08 2007 +0100
@@ -97,32 +97,30 @@
         if name == "ImageLink" and args is not None:
             pagename = self.page.page_name
             if args:
-                args = args.split(',')
-                args = [arg.strip() for arg in args]
+                args = [arg.strip() for arg in args.split(',')]
             else:
                 args = []
-            argc = len(args)
-            url = args[0]
-            keywords = {}
-            width = None
-            height = None
-            alt = None
+            url = None
+            kw = {}
+            pos = 0
             for arg in args:
-                if arg.find('=') > -1:
+                if '=' in arg:
                     key, value = arg.split('=')
-                    if key == 'width':
-                        width = value
-                    elif key == 'height':
-                        height = value
-                    elif key == 'alt':
-                        alt = value
-            target = None
-            if argc >= 2 and args[1]:
-                target = args[1]
-
-            return self.image(
-                    title="attachment:%s" % wikiutil.quoteWikinameURL(url),
-                    src=AttachFile.getAttachUrl(pagename, url, self.request, addts=1), width=width, height=height, alt=alt, target=target)
+                    if key == 'width' and value:
+                        kw['width'] = value
+                    elif key == 'height' and value:
+                        kw['height'] = value
+                    elif key == 'alt' and value:
+                        kw['alt'] = value
+                else:
+                    if pos == 0 and arg:
+                        url = arg
+                        kw['title'] = "attachment:%s" % wikiutil.quoteWikinameURL(url)
+                    elif pos == 1 and arg:
+                        kw['target'] = arg
+                    pos += 1
+            kw['src'] = AttachFile.getAttachUrl(pagename, url, self.request, addts=1)              
+            return self.image(**kw)
 
         elif args is not None:
             result = "[[%s(%s)]]" % (name, args)