Olemis Lang avatar Olemis Lang committed 9fd533a

TracMac: Right value in `href` attribute of `docknav` images

Comments (0)

Files changed (3)

tracmacos/htdocs/mac.css

   background-color: #FFFFCC;
   color: #000000;
   font-weight: bold;
+  white-space: nowrap;
 }
 

tracmacos/templates/mac_theme.html

 
     </div>
     <div id="docknav">
-      <a py:for="itm in chrome.nav['mainnav']" href="${href.wiki()}" title="${macos.util.striptags(itm.label)}">
+      <a py:for="itm in chrome.nav['mainnav']" 
+         href="${macos.util.extract_href(itm.label)}" 
+         title="${macos.util.striptags(itm.label)}">
         <img src="${href(macos.imgs.dock.get(itm.name, macos.imgs.dock_default))}" />
       </a>
     </div>

tracmacos/theme.py

 from trac.web.chrome import add_script
 from trac.web.api import IRequestFilter
 
-from genshi.builder import Markup, Element, Fragment
+from genshi.builder import Markup, Element, Fragment, tag
+from genshi.input import XML
 from genshi.util import striptags
 
 from themeengine.api import ThemeBase
             return striptags(unicode(fragment))
           else:
             return unicode(fragment)
+        def extract_href(fragment):
+          if isinstance(fragment, (Element, Fragment)):
+            stream = tag.body(fragment).generate()
+          else :
+            self.log.debug("Extracting href from %s", fragment)
+            stream = XML('<body>%s</body>' % (unicode(fragment),))
+          for x in stream.select('a[@href]') :
+            if x[0] == 'START' :
+               return x[1][1].get('href')
             
         data['macos'] = {
               'opts' : {
                   },
               'util' : {
                   'striptags' : to_text,
+                  'extract_href' : extract_href,
                   },
               'imgs' : {
                   'dock_default' : self.dock_default,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.