Attachment 'attachlink_rbtw.diff'

Download

   1 * looking for arch@arch.thinkmo.de--2003-archives/moin--main--1.3--patch-546 to compare with
   2 * comparing to arch@arch.thinkmo.de--2003-archives/moin--main--1.3--patch-546
   3 M  MoinMoin/parser/wiki.py
   4 
   5 * modified files
   6 
   7 --- orig/MoinMoin/parser/wiki.py
   8 +++ mod/MoinMoin/parser/wiki.py
   9 @@ -435,35 +435,72 @@
  10  
  11      def _url_bracket_repl(self, word):
  12          """Handle bracketed URLs."""
  13 -
  14          # Local extended link?
  15          if word[1] == ':':
  16              words = word[2:-1].split(':', 1)
  17 -            if len(words) == 1: words = words * 2
  18 +            if len(words) == 1:
  19 +	        words = words * 2
  20              return self._word_repl(words[0], words[1])
  21  
  22          # Traditional split on space
  23          words = word[1:-1].split(None, 1)
  24 -        if len(words) == 1: words = words * 2
  25 +        if len(words) == 1:
  26 +	    words = words * 2
  27  
  28 -        if words[0][0] == '#':
  29 -            # anchor link
  30 -            return (self.formatter.url(1, words[0]) +
  31 -                    self.formatter.text(words[1]) +
  32 -                    self.formatter.url(0))
  33 +        if words[0][0] == '#': # anchor link
  34 +            scheme = words[1].split(":", 1)[0]
  35 +            if scheme in self.attachment_schemas: # [#label attachment:img.png]
  36 +                from MoinMoin.action import AttachFile
  37 +                txt = words[1]
  38 +                try:
  39 +		    attname = txt.split(':')[1]
  40 +                except IndexError:
  41 +                    attname = 'Missing filename'
  42 +                url2 = AttachFile.getAttachUrl(self.formatter.page.page_name, attname, self.request)
  43 +                return (self.formatter.url(1, words[0]) +
  44 +                        self.formatter.image(title=attname, alt=attname, src=url2) +
  45 +                        self.formatter.url(0))
  46 +            else:
  47 +                return (self.formatter.url(1, words[0]) +
  48 +                        self.formatter.text(words[1]) +
  49 +                        self.formatter.url(0))
  50  
  51          scheme = words[0].split(":", 1)[0]
  52 -        if scheme == "wiki": return self.interwiki(words, pretty_url=1)
  53 -        if scheme in self.attachment_schemas:
  54 -            return self.attachment(words, pretty_url=1)
  55 +        if scheme == "wiki":
  56 +	    return self.interwiki(words, pretty_url=1)
  57 +        if scheme in self.attachment_schemas: # [attachment:some.png thing]
  58 +            from MoinMoin.action import AttachFile
  59 +            if len(words) == 2:
  60 +                txt = words[0]
  61 +                try:
  62 +		    attname = txt.split(':')[1]
  63 +                except IndexError:
  64 +                    attname = 'Missing filename'
  65 +                url1 = AttachFile.getAttachUrl(self.formatter.page.page_name, attname, self.request)
  66 +                scheme = words[1].split(":", 1)[0]
  67 +                if scheme in self.attachment_schemas: # [attachment:big.png attachment:small.png]
  68 +                    txt = words[1]
  69 +                    try:
  70 +		        attname = txt.split(':')[1]
  71 +                    except IndexError:
  72 +                        attname = 'Missing filename'
  73 +                    url2 = AttachFile.getAttachUrl(self.formatter.page.page_name, attname, self.request)
  74 +                    return (self.formatter.url(1, url1) +
  75 +                            self.formatter.image(title=attname, alt=attname, src=url2) +
  76 +                            self.formatter.url(0))
  77 +                else:
  78 +                    return (self.formatter.url(1, url1) +
  79 +                            self.formatter.text(words[1]) +
  80 +                            self.formatter.url(0))
  81 +            else: # can this ever happen???
  82 +                return self.attachment(words, pretty_url=1)
  83  
  84          if wikiutil.isPicture(words[1]) and re.match(self.url_rule, words[1]):
  85              return (self.formatter.url(1, words[0], 'external', unescaped=1) +
  86                      self.formatter.image(title=words[0], alt=words[0], src=words[1]) +
  87                      self.formatter.url(0))
  88          else:
  89 -            return (self.formatter.url(1, words[0], 'external',
  90 -                                       type='www', unescaped=1) +
  91 +            return (self.formatter.url(1, words[0], 'external', type='www', unescaped=1) +
  92                      self.formatter.text(words[1]) +
  93                      self.formatter.url(0))
  94  

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] (2005-01-16 18:32:56, 4.2 KB) [[attachment:attachlink_rbtw.diff]]
  • [get | view] (2004-12-22 16:42:51, 1.8 KB) [[attachment:moin.pdf]]
  • [get | view] (2004-12-22 15:59:46, 0.6 KB) [[attachment:moin.png]]
 All files | Selected Files: delete move to page copy to page

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