Changeset 667

Show
Ignore:
Timestamp:
04/16/06 03:12:08 (3 years ago)
Author:
athomas
Message:

NavMoverPlugin:

Added ability to add custom nav items.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • navmoverplugin/navmover/navmover.py

    r666 r667  
    11from trac.core import * 
    22from trac.web.chrome import INavigationContributor, ITemplateProvider, add_stylesheet 
     3from trac.util import Markup 
    34 
    45class NavMover(Component): 
     
    2324        else: 
    2425            move_from = 'mainnav' 
     26 
    2527        # Hide the appropriate nav block 
    2628        add_stylesheet(req, 'navmover/css/hide_%s.css' % move_from) 
     
    3133            for item in contributor.get_navigation_items(req): 
    3234                if (not move_items or item[1] in move_items) and item[0] == move_from \ 
    33                         and not unicode(item[2]).startswith('logged in as'): 
     35                        and unicode(item[2]).startswith('<a '): 
    3436                    meta_items.append((move_to, item[1], item[2])) 
    3537 
     38        # Add custom items 
     39        for item, title in [o for o in self.env.config.options('navmover') 
     40                            if '.' not in o[0] and o[0] not in ('move_items', 'move_to')]: 
     41            url = self.env.config.get('navmover', '%s.url' % item) 
     42            perm = self.env.config.get('navmover', '%s.permission' % item) 
     43            if perm and not req.perm.has_permission(perm): 
     44                continue 
     45            meta_items.append((move_to, item, Markup('<a href="%s">%s</a>' % (url, title)))) 
    3646        return meta_items 
    3747