Attachment 'resizing_imagelink_from_gui_20061222_patch.txt'

Download

   1 # HG changeset patch
   2 # User ReimarBauer <R.Bauer@fz-juelich.de>
   3 # Date 1166811596 -3600
   4 # Node ID 52ef8cfb5055dce2314c6377536bfee585bb710f
   5 # Parent  e7987ee5ae5441fdea4fd7988c4754206810988b
   6 resizing of images from gui using ImageLink
   7 
   8 diff -r e7987ee5ae54 -r 52ef8cfb5055 MoinMoin/converter/text_html_text_moin_wiki.py
   9 --- a/MoinMoin/converter/text_html_text_moin_wiki.py	Fri Dec 22 18:23:50 2006 +0100
  10 +++ b/MoinMoin/converter/text_html_text_moin_wiki.py	Fri Dec 22 19:19:56 2006 +0100
  11 @@ -1185,6 +1185,10 @@ class convert_tree(visitor):
  12          height = None
  13          if node.attributes.has_key("height"):
  14              height = node.attributes.get("height").nodeValue
  15 +        target = None
  16 +        if node.attributes.has_key("target"):
  17 +            target = node.attributes.get("target").nodeValue
  18 +
  19          # Attachment image
  20          if (title and title.startswith("attachment:") and
  21              wikiutil.isPicture(wikiutil.url_unquote(title[len("attachment:"):]))):
  22 @@ -1193,9 +1197,39 @@ class convert_tree(visitor):
  23                                    wikiutil.url_unquote(title),
  24                                    self.white_space])
  25              else:
  26 -                self.text.extend([self.white_space,
  27 -                                  "[[Image(%(file)s,width=%(width)s,height=%(height)s,alt=%(alt)s)]]" % {
  28 +                if target == None:
  29 +                    if alt == None or alt == '':
  30 +                        self.text.extend([self.white_space,
  31 +                                  "[[ImageLink(%(file)s,width=%(width)s,height=%(height)s)]]" % {
  32                                      "file": wikiutil.url_unquote(title[len("attachment:"):]),
  33 +                                    "width": width,
  34 +                                    "height": height,
  35 +                                    },
  36 +                                  self.white_space])
  37 +                    else:
  38 +                        self.text.extend([self.white_space,
  39 +                                  "[[ImageLink(%(file)s,width=%(width)s,height=%(height)s,alt=%(alt)s)]]" % {
  40 +                                    "file": wikiutil.url_unquote(title[len("attachment:"):]),
  41 +                                    "width": width,
  42 +                                    "height": height,
  43 +                                    "alt": alt,
  44 +                                    },
  45 +                                  self.white_space])
  46 +                else:
  47 +                    if alt == None or alt == '':
  48 +                        self.text.extend([self.white_space,
  49 +                                  "[[ImageLink(%(file)s,%(target)s,width=%(width)s,height=%(height)s)]]" % {
  50 +                                    "file": wikiutil.url_unquote(title[len("attachment:"):]),
  51 +                                    "target": target,
  52 +                                    "width": width,
  53 +                                    "height": height,
  54 +                                    },
  55 +                                  self.white_space])
  56 +                    else:
  57 +                          self.text.extend([self.white_space,
  58 +                                  "[[ImageLink(%(file)s,%(target)s,width=%(width)s,height=%(height)s,alt=%(alt)s)]]" % {
  59 +                                    "file": wikiutil.url_unquote(title[len("attachment:"):]),
  60 +                                    "target": target,
  61                                      "width": width,
  62                                      "height": height,
  63                                      "alt": alt,
  64 diff -r e7987ee5ae54 -r 52ef8cfb5055 MoinMoin/formatter/text_gedit.py
  65 --- a/MoinMoin/formatter/text_gedit.py	Fri Dec 22 18:23:50 2006 +0100
  66 +++ b/MoinMoin/formatter/text_gedit.py	Fri Dec 22 19:19:56 2006 +0100
  67 @@ -93,13 +93,14 @@ class Formatter(text_html.Formatter):
  68      # Dynamic stuff / Plugins ############################################
  69  
  70      def macro(self, macro_obj, name, args):
  71 -        if name == "Image" and args is not None:
  72 +        if name == "ImageLink" and args is not None:
  73              pagename = self.page.page_name
  74              if args:
  75                  args = args.split(',')
  76                  args = [arg.strip() for arg in args]
  77              else:
  78                  args = []
  79 +            argc = len(args)
  80              url = args[0]
  81              keywords = {}
  82              width = None
  83 @@ -114,11 +115,14 @@ class Formatter(text_html.Formatter):
  84                          height = value
  85                      if key == 'alt':
  86                          alt = value
  87 -            if alt == None:
  88 -                alt = url
  89 +            target = None
  90 +            if argc >= 2 and args[1]:
  91 +                target = args[1]
  92 +
  93              return self.image(
  94 -            title="attachment:%s" % wikiutil.quoteWikinameURL(url),
  95 -            src=AttachFile.getAttachUrl(pagename, url, self.request, addts=1), width=width, height=height, alt=alt)
  96 +                    title = "attachment:%s" % wikiutil.quoteWikinameURL(url),
  97 +                    src=AttachFile.getAttachUrl(pagename, url, self.request, addts=1), width=width, height=height, alt=alt, target=target)
  98 +
  99          elif args is not None:
 100              result = "[[%s(%s)]]" % (name, args)
 101          else:

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.
  • [get | view] (2006-12-22 13:34:46, 7.3 KB) [[attachment:resizing_image_from_gui_20061222_patch.txt]]
  • [get | view] (2006-12-22 18:20:12, 5.1 KB) [[attachment:resizing_imagelink_from_gui_20061222_patch.txt]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.