Edgewall Software

Ticket #7418 (new defect)

Opened 5 months ago

Last modified 6 weeks ago

Active navigation items are broken in Clearsilver templates

Reported by: anonymous Owned by:
Priority: low Milestone: 0.11-retriage
Component: general Version: 0.11-stable
Severity: normal Keywords: clearsilver navigation
Cc:

Description

It looks like changes made to move templates away from Clearsilver have introduced a regression where active navigation items are not highlighted properly.

To reproduce, use a plugin that returns a Clearsilver template from its process_request() method. You will see that the "mainnav" navigation bar does not render the active item highlighted.

The bug is that the CSS class "active" is not assigned to the list element in the navigation bar.

The fix is to change trac/web/chrome.py:

class Chrome(component)
...
    def populate_hdf(self, req):
    ...
        for category, items in req.chrome['nav'].items():
+           req.hdf['chrome.nav.%s' % category] = items
-           for item in items:
-               prefix = 'chrome.nav.%s.%s' % (category, item['name'])
-               req.hdf[prefix] = item['label']

And then change trac/templates/header.cs:

<?cs def:nav(items) ?><?cs
 if:len(items) ?><ul><?cs
  set:idx = 0 ?><?cs
  set:max = len(items) - 1 ?><?cs
  each:item = items ?><?cs
   set:first = idx == 0 ?><?cs
   set:last = idx == max ?><li<?cs
   if:first || last || item.active ?> class="<?cs
    if:item.active ?>active<?cs /if ?><?cs
    if:item.active && (first || last) ?> <?cs /if ?><?cs
    if:first ?>first<?cs /if ?><?cs
    if:(item.active || first) && last ?> <?cs /if ?><?cs
    if:last ?>last<?cs /if ?>"<?cs
+  /if ?>><?cs var:item.label ?></li><?cs
-  /if ?>><?cs var:item?></li><?cs
   set:idx = idx + 1 ?><?cs
  /each ?></ul><?cs
 /if ?><?cs
/def ?>

Attachments

Change History

Changed 2 months ago by anonymous

  • milestone set to 0.11.2

Changed 6 weeks ago by cboos

  • keywords clearsilver navigation added
  • priority changed from normal to low
  • milestone changed from 0.11.2 to 0.11.3

Thanks for reminding us how ugly the ClearSilver templates were, sort of mitigates all the trouble we had with Genshi :P)

If anyone can make a clean patch (see TracDev/SubmittingPatches) and test the patch, we could eventually apply it.

Add/Change #7418 (Active navigation items are broken in Clearsilver templates)

Author



Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change from (none). Next status will be 'new'
The owner will change from (none) to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.