changeset 515:1b9f0d6b9f48

fixed double CSS class attribute for nonexistent links, removed ugly formatter.url attrs keyword handling code imported from: moin--main--1.5--patch-519
author Thomas Waldmann <tw@waldmann-edv.de>
date Tue, 28 Mar 2006 21:52:01 +0000
parents fc74944187ad
children ec330d9ec20b
files ChangeLog MoinMoin/formatter/text_html.py MoinMoin/macro/MonthCalendar.py MoinMoin/theme/__init__.py MoinMoin/wikiutil.py docs/CHANGES
diffstat 6 files changed, 60 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Mar 28 19:47:18 2006 +0000
+++ b/ChangeLog	Tue Mar 28 21:52:01 2006 +0000
@@ -2,6 +2,22 @@
 # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5
 #
 
+2006-03-28 22:52:01 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-519
+
+    Summary:
+      fixed double CSS class attribute for nonexistent links, removed ugly formatter.url attrs keyword handling code
+    Revision:
+      moin--main--1.5--patch-519
+
+    fixed double CSS class attribute for nonexistent links, removed ugly formatter.url attrs keyword handling code
+    
+
+    modified files:
+     ChangeLog MoinMoin/formatter/text_html.py
+     MoinMoin/macro/MonthCalendar.py MoinMoin/theme/__init__.py
+     MoinMoin/wikiutil.py docs/CHANGES
+
+
 2006-03-28 20:47:18 GMT	Thomas Waldmann <tw@waldmann-edv.de>	patch-518
 
     Summary:
--- a/MoinMoin/formatter/text_html.py	Tue Mar 28 19:47:18 2006 +0000
+++ b/MoinMoin/formatter/text_html.py	Tue Mar 28 21:52:01 2006 +0000
@@ -539,48 +539,32 @@
                      all escaping and quoting is the caller's responsibility.
 
         Note that the 'attrs' keyword argument is for backwards compatibility
-        only.  It should not be used for new code--instead just pass
+        only.  It should not be used for new code -- instead just pass
         any attributes in as separate keyword arguments.
-        """
-        if not on:
-            return self._close('a')
-        attrs = self._langAttr()
-
-        # Handle the URL mapping
-        if url is None and kw.has_key('href'):
-            url = kw['href']
-            del kw['href']
-        if url is not None:
-            url = wikiutil.mapURL(self.request, url)
-            
-            # TODO just calling url_quote does not work, as it will also quote "http:" to "http%xx" X)
-            if 0: # do_escape: # protocol and server part must not get quoted, path should get quoted
-                url = wikiutil.url_quote(url)
-            
-            attrs['href'] = url
 
-        if css:
-            attrs['class'] = css
-        
-        if kw.has_key('attrs'):
-            # for backwards compatibility, raw pre-formated attribute string
-            extra_attrs = kw['attrs']
-            del kw['attrs']
-        else:
-            extra_attrs = None
+        1.5.3: removed ugly "attrs" keyword argument handling code
+        """
+        if on:
+            attrs = self._langAttr()
 
-        # create link
-        if on:
-            str = self._open('a', attr=attrs, **kw)
-            if extra_attrs:
-                # insert this into the tag verbatim (messy)
-                if str[-2:] == '/>':
-                    str = '%s %s />' % (str[:-2], extra_attrs)
-                else:
-                    str = '%s %s>' % (str[:-1], extra_attrs)
+            # Handle the URL mapping
+            if url is None and kw.has_key('href'):
+                url = kw['href']
+                del kw['href']
+            if url is not None:
+                url = wikiutil.mapURL(self.request, url)
+                # TODO just calling url_quote does not work, as it will also quote "http:" to "http%xx" X)
+                if 0: # do_escape: # protocol and server part must not get quoted, path should get quoted
+                    url = wikiutil.url_quote(url)
+                attrs['href'] = url
+
+            if css:
+                attrs['class'] = css
+            
+            markup = self._open('a', attr=attrs, **kw)
         else:
-            str = self._close('a')
-        return str
+            markup = self._close('a')
+        return markup
 
     def anchordef(self, id):
         """Inserts an invisible element used as a link target.
@@ -733,7 +717,7 @@
                                      edit_link,
                                      self.image(alt=url,
                                                 src=AttachFile.getAttachUrl(pagename, filename, self.request, addts=1), css="drawing"),
-                                     attrs='title="%s"' % (_('Edit drawing %(filename)s') % {'filename': self.text(fname)}))
+                                     title="%s" % (_('Edit drawing %(filename)s') % {'filename': self.text(fname)}))
         
     
     # def attachment_inlined(self, url, text, **kw):
--- a/MoinMoin/macro/MonthCalendar.py	Tue Mar 28 19:47:18 2006 +0000
+++ b/MoinMoin/macro/MonthCalendar.py	Tue Mar 28 21:52:01 2006 +0000
@@ -405,7 +405,8 @@
                     tiptitle = link
                     tiptext = '<br>'.join(titletext)
                     maketip_js.append("maketip('%s','%s','%s');" % (tipname, tiptitle, tiptext))
-                    onmouse = '''onMouseOver="tip('%s')" onMouseOut="untip()"''' % tipname
+                    onmouse = {'onMouseOver': "tip('%s')" % tipname,
+                               'onMouseOut':  "untip()"}
                 else:
                     csslink = "cal-emptyday"
                     if parmtemplate:
@@ -415,7 +416,7 @@
                     r, g, b, u = (255, 255, 255, 0)
                     if wkday in wkend:
                         csslink = "cal-weekend"
-                    onmouse = ''
+                    onmouse = {}
                 for otherpage in parmpagename[1:]:
                     otherlink = "%s/%4d-%02d-%02d" % (otherpage, year, month, day)
                     otherdaypage = Page(request, otherlink)
@@ -427,7 +428,7 @@
                             r, g, b = (r, g+colorstep, b)
                 r, g, b = cliprgb(r, g, b)
                 style = 'background-color:#%02x%02x%02x' % (r, g, b)
-                fmtlink = formatter.url(1, daypage.url(request, query), csslink, attrs=onmouse) + str(day) + formatter.url(0)
+                fmtlink = formatter.url(1, daypage.url(request, query), csslink, **onmouse) + str(day) + formatter.url(0)
                 if day == currentday and month == currentmonth and year == currentyear:
                     cssday = "cal-today"
                     fmtlink = "<b>%s</b>" % fmtlink # for browser with CSS probs
--- a/MoinMoin/theme/__init__.py	Tue Mar 28 19:47:18 2006 +0000
+++ b/MoinMoin/theme/__init__.py	Tue Mar 28 21:52:01 2006 +0000
@@ -467,7 +467,7 @@
         d['title'] = title % d
         d['i18ntitle'] = self.request.getText(d['title'], formatted=False)
         img_src = self.make_icon(icon, d)
-        return wikiutil.link_tag(self.request, page_params % d, img_src, attrs='title="%(i18ntitle)s"' % d)
+        return wikiutil.link_tag(self.request, page_params % d, img_src, title="%(i18ntitle)s" % d)
 
     def msg(self, d):
         """ Assemble the msg display
@@ -1089,18 +1089,18 @@
         if self.showBothEditLinks() and guiworks:
             text = _('Edit (Text)', formatted=False)
             params = params + 'text'
-            attrs = 'name="texteditlink"'
+            attrs = {'name': "texteditlink"}
         else:
             text = _('Edit', formatted=False)
             if guiworks:
                 # 'textonly' will be upgraded dynamically to 'guipossible' by JS
                 params = params + 'textonly'
-                attrs = 'name="editlink"'
+                attrs = {'name': "editlink"}
             else:
                 params = params + 'text'
-                attrs = 'name="texteditlink"'
+                attrs = {'name': "texteditlink"}
         
-        return wikiutil.link_tag(self.request, params, text, attrs=attrs)
+        return wikiutil.link_tag(self.request, params, text, **attrs)
 
     def showBothEditLinks(self):
         """ Return True if both edit links should be displayed """
--- a/MoinMoin/wikiutil.py	Tue Mar 28 19:47:18 2006 +0000
+++ b/MoinMoin/wikiutil.py	Tue Mar 28 21:52:01 2006 +0000
@@ -1080,11 +1080,15 @@
                  escaped, so you can give HTML here and it will be used verbatim
     @param formatter: the formatter object to use
     @param on: opening/closing tag only
-    @keyword attrs: additional attrs (HTMLified string)
+    @keyword attrs: additional attrs (HTMLified string) (removed in 1.5.3)
     @rtype: string
     @return: formatted link tag
     """
-    css_class = kw.get('css_class', None)
+    if kw.has_key('css_class'):
+        css_class = kw['css_class']
+        del kw['css_class'] # one time is enough
+    else:
+        css_class = None
     id = kw.get('id', None)
     if text is None:
         text = params # default
@@ -1099,8 +1103,6 @@
         return '</a>'
     
     attrs = ''
-    if kw.has_key('attrs'):
-        attrs += ' ' + kw['attrs']
     if css_class:
         attrs += ' class="%s"' % css_class
     if id:
--- a/docs/CHANGES	Tue Mar 28 19:47:18 2006 +0000
+++ b/docs/CHANGES	Tue Mar 28 21:52:01 2006 +0000
@@ -36,12 +36,17 @@
 Version 1.5.3-current:
   New Features:
     * modified SystemInfo macro to give human readable units and disk usage
+
+  Bugfixes:
+    * fixed double class attribute for nonexistent links
   
   Other changes:
     * moved back UserPreferences action link from menu to top of page (renaming
       it to "Preferences"), added "Cancel" button to make it possible to return
       to the previous page without saving preferences.
-
+    * removed formatter.url "attrs" keyword arg that took premade html, we use
+      separate kw args per attribute now.
+ 
 Version 1.5.3-rc1:
 
   New features: