Changeset 4692 for waeup


Ignore:
Timestamp:
6 Jan 2010, 03:52:36 (15 years ago)
Author:
uli
Message:

Primary navigation is now handled by a viewlet. Remove static stuff
here.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • waeup/branches/ulif-layout/src/waeup/browser/layout.py

    r4649 r4692  
    1616
    1717grok.templatedir('templates')
    18 
    19 # The list of primary navigation tabs.
    20 # Each entry is a tuple
    21 #
    22 #   (<id_number>, <order_number>, <text_to_render>, <link_target>)
    23 #
    24 # where id number is the number pages can use as their pnav attribute,
    25 # order number determines the order in which the primary tabs are
    26 # rendered, text_to_render gives the text displayed and link_target
    27 # says, what url (relative to application URL) the tab should link to.
    28 #
    29 PRIMARY_NAV = [
    30     (0, 0, u'Home', ''),
    31     (1, 1, u'Faculties', '/faculties'),
    32     (2, 2, u'Search', '/search'),
    33     ]
    3418
    3519class UtilityView(object):
     
    11195    grok.context(IWAeUPObject)
    11296
    113     def getPrimaryNav(self, view):
    114         """Get an ordered list of primary navigation entries.
    115 
    116         Each is a dict with keys
    117 
    118           'url': <link-target>
    119           'active' : <value for HTML class attribute: 'active' or ''
    120           'title': <text to be rendered in menu tab>
    121           'order': <num indicating order num of this entry>
    122 
    123         Pages attatched to this layout can provide an attribute 'pnav'
    124         to indicate, to which tab they belong. This tab will then be
    125         rendered 'active'.
    126         """
    127         result = []
    128         app_url = view.application_url()
    129         for item in PRIMARY_NAV:
    130             active = ''
    131             pnav = getattr(view, 'pnav', 0)
    132             if pnav == item[0]:
    133                 active = 'active'
    134             url =  app_url + item[3]
    135             result.append(
    136                 dict(title=item[2],
    137                      url=url,
    138                      order=item[1],
    139                      active=active)
    140                 )
    141         return sorted(result, key=lambda x: x['order'])
    142    
    14397    def isAuthenticated(self):
    14498        """Return True if the calling user is authenticated.
Note: See TracChangeset for help on using the changeset viewer.