changeset 1708:ac830832ca26

ImageLink conversion: optimized code
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 06 Jan 2007 21:18:05 +0100
parents dd2bdae20379
children 2f7793521ccd 1f18d08ec3ba
files MoinMoin/converter/text_html_text_moin_wiki.py
diffstat 1 files changed, 8 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/text_html_text_moin_wiki.py	Sat Jan 06 17:34:09 2007 +0100
+++ b/MoinMoin/converter/text_html_text_moin_wiki.py	Sat Jan 06 21:18:05 2007 +0100
@@ -1197,35 +1197,14 @@
                                   wikiutil.url_unquote(title),
                                   self.white_space])
             else:
-                #use ImageLink for resized images
-                if target is None:
-                    if not alt:
-                        cmd = "[[ImageLink(%(file)s,width=%(width)s,height=%(height)s)]]" % {
-                                    "file": wikiutil.url_unquote(title[len("attachment:"):]),
-                                    "width": width,
-                                    "height": height, }
-                    else:
-                        cmd = "[[ImageLink(%(file)s,width=%(width)s,height=%(height)s,alt=%(alt)s)]]" % {
-                                    "file": wikiutil.url_unquote(title[len("attachment:"):]),
-                                    "width": width,
-                                    "height": height,
-                                    "alt": alt, }
-                else:
-                    if not alt:
-                        cmd = "[[ImageLink(%(file)s,%(target)s,width=%(width)s,height=%(height)s)]]" % {
-                                    "file": wikiutil.url_unquote(title[len("attachment:"):]),
-                                    "target": target,
-                                    "width": width,
-                                    "height": height, }
-                    else:
-                        cmd = "[[ImageLink(%(file)s,%(target)s,width=%(width)s,height=%(height)s,alt=%(alt)s)]]" % {
-                                    "file": wikiutil.url_unquote(title[len("attachment:"):]),
-                                    "target": target,
-                                    "width": width,
-                                    "height": height,
-                                    "alt": alt, }
-
-                self.text.extend([self.white_space, cmd, self.white_space])
+                # use ImageLink for resized images
+                il_parms = "%s" % wikiutil.url_unquote(title[len("attachment:"):])
+                if target is not None:
+                    il_parms += ",%s" % target
+                il_kws = "width=%s,height=%s" % (width, height)
+                if alt:
+                    il_kws += ",alt=%s" % alt
+                self.text.extend([self.white_space, "[[ImageLink(%s,%s)]]" % (il_parms, il_kws), self.white_space])
 
         # Drawing image
         elif title and title.startswith("drawing:"):