Changeset 4649 for waeup/branches/ulif-layout
- Timestamp:
- 3 Jan 2010, 17:01:16 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
waeup/branches/ulif-layout/src/waeup/browser/layout.py
r4619 r4649 16 16 17 17 grok.templatedir('templates') 18 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 ] 34 19 35 class UtilityView(object): 20 36 """A view mixin with useful methods. 21 37 22 XXX: This class was copied verbatim from megrok.layout trunk. It 23 can be imported with next release of megrok.layout, so that this 24 piece can be removed. 38 The ``pnav`` attribute (a number) tells, to which primary 39 navigation tab a page declares to belong. 25 40 """ 26 41 title = u'' # What appears in the content title... 42 pnav = 0 # Primary navigation index... 27 43 28 44 def application_url(self, name=None): … … 95 111 grok.context(IWAeUPObject) 96 112 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 97 143 def isAuthenticated(self): 98 144 """Return True if the calling user is authenticated. … … 102 148 103 149 def getUserTitle(self): 150 """Return principal title of current user. 151 """ 104 152 usertitle = self.request.principal.title 105 153 if usertitle == 'Unauthenticated User': 106 154 return u'' 107 155 return usertitle 108 156 109 157 def update(self): 110 158 yui.reset_fonts_grids.need()
Note: See TracChangeset for help on using the changeset viewer.