changeset 4126:fa60d012b867

GUI editor converter: fix roundtripping of attachment links with &do=get param (q&d fix, needs to more work to be generic)
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 21 Sep 2008 21:46:05 +0200
parents 8662bba9e431
children 399c5a055ca0
files MoinMoin/converter/text_html_text_moin_wiki.py MoinMoin/formatter/text_gedit.py
diffstat 2 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/converter/text_html_text_moin_wiki.py	Sun Sep 21 21:03:09 2008 +0200
+++ b/MoinMoin/converter/text_html_text_moin_wiki.py	Sun Sep 21 21:46:05 2008 +0200
@@ -1254,10 +1254,17 @@
             # Attachments
             if title.startswith("attachment:"):
                 attname = wikiutil.url_unquote(title[len("attachment:"):])
+                if 'do=get' in href: # quick&dirty fix for not dropping &do=get param
+                    parms = '|&do=get'
+                else:
+                    parms = ''
                 if attname != desc:
-                    self.text.append('[[attachment:%s|%s]]' % (attname, desc))
+                    desc = '|%s' % desc
+                elif parms:
+                    desc = '|'
                 else:
-                    self.text.append('[[attachment:%s]]' % (attname, ))
+                    desc = ''
+                self.text.append('[[attachment:%s%s%s]]' % (attname, desc, parms))
             # wiki link
             elif href.startswith(scriptname):
                 pagename = href[len(scriptname):]
--- a/MoinMoin/formatter/text_gedit.py	Sun Sep 21 21:03:09 2008 +0200
+++ b/MoinMoin/formatter/text_gedit.py	Sun Sep 21 21:46:05 2008 +0200
@@ -68,10 +68,15 @@
             return '<span style="background-color:#ffff11">{{attachment:%s|%s}}</span>' % (url, text)
 
     def attachment_link(self, on, url=None, **kw):
+        assert on in (0, 1, False, True) # make sure we get called the new way, not like the 1.5 api was
         _ = self.request.getText
+        querystr = kw.get('querystr', {})
+        assert isinstance(querystr, dict) # new in 1.6, only support dicts
+        if 'do' not in querystr:
+            querystr['do'] = 'view'
         if on:
             pagename = self.page.page_name
-            target = AttachFile.getAttachUrl(pagename, url, self.request)
+            target = AttachFile.getAttachUrl(pagename, url, self.request, do=querystr['do'])
             return self.url(on, target, title="attachment:%s" % wikiutil.quoteWikinameURL(url))
         else:
             return self.url(on)