From 39f8a18c3482ee32bc63ffbe7c45a1f38d37df73 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Wed, 12 Sep 2012 10:18:34 -0500 Subject: [PATCH] navbar dropdown, thanks Paolo --- VERSION | 2 +- applications/welcome/languages/it.py | 9 + applications/welcome/static/css/web2py.css | 1 + .../welcome/static/css/web2py_bootstrap.css | 2 + applications/welcome/views/layout.html | 355 +++++++++--------- gluon/tools.py | 40 +- 6 files changed, 224 insertions(+), 185 deletions(-) diff --git a/VERSION b/VERSION index cb7ce0da..68e0d9b8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.0.8 (2012-09-12 09:55:52) stable +Version 2.0.8 (2012-09-12 10:18:30) stable diff --git a/applications/welcome/languages/it.py b/applications/welcome/languages/it.py index 516852d0..ad59b34d 100644 --- a/applications/welcome/languages/it.py +++ b/applications/welcome/languages/it.py @@ -23,6 +23,7 @@ 'Cache': 'Cache', 'Cache Keys': 'Cache Keys', 'Cannot be empty': 'Non può essere vuoto', +'Change password': 'Change password', 'change password': 'Cambia password', 'Check to delete': 'Seleziona per cancellare', 'Clear CACHE?': 'Clear CACHE?', @@ -69,6 +70,7 @@ 'export as csv file': 'esporta come file CSV', 'FAQ': 'FAQ', 'First name': 'Nome', +'Forgot username?': 'Forgot username?', 'Forms and Validators': 'Forms and Validators', 'Free Applications': 'Free Applications', 'Group %(group_id)s created': 'Group %(group_id)s created', @@ -115,6 +117,7 @@ 'Modified On': 'Modified On', 'My Sites': 'My Sites', 'Name': 'Nome', +'New password': 'New password', 'New Record': 'Nuovo elemento (record)', 'new record inserted': 'nuovo record inserito', 'next 100 rows': 'prossime 100 righe', @@ -122,6 +125,7 @@ 'Non può essere vuoto': 'Non può essere vuoto', 'not authorized': 'non autorizzato', 'Object or table name': 'Object or table name', +'Old password': 'Old password', 'Online examples': 'Vedere gli esempi', 'or import from csv file': 'oppure importa da file CSV', 'Origin': 'Origine', @@ -153,10 +157,12 @@ 'Registration key': 'Chiave di Registazione', 'Registration successful': 'Registration successful', 'Remember me (for 30 days)': 'Remember me (for 30 days)', +'Request reset password': 'Request reset password', 'Reset Password key': 'Resetta chiave Password ', 'Role': 'Ruolo', 'Rows in Table': 'Righe nella tabella', 'Rows selected': 'Righe selezionate', +'Save profile': 'Save profile', 'Semantic': 'Semantic', 'Services': 'Services', 'Size of cache:': 'Size of cache:', @@ -185,6 +191,9 @@ 'Use (...)&(...) for AND, (...)|(...) for OR, and ~(...) for NOT to build more complex queries.': 'Per costruire richieste (query) più complesse si usano (...)&(...) come "e" (AND), (...)|(...) come "o" (OR), e ~(...) come negazione (NOT).', 'User %(id)s Logged-in': 'User %(id)s Logged-in', 'User %(id)s Logged-out': 'User %(id)s Logged-out', +'User %(id)s Password changed': 'User %(id)s Password changed', +'User %(id)s Password reset': 'User %(id)s Password reset', +'User %(id)s Profile updated': 'User %(id)s Profile updated', 'User %(id)s Registered': 'User %(id)s Registered', 'User ID': 'ID Utente', 'Verify Password': 'Verify Password', diff --git a/applications/welcome/static/css/web2py.css b/applications/welcome/static/css/web2py.css index be3aebf6..2a399366 100644 --- a/applications/welcome/static/css/web2py.css +++ b/applications/welcome/static/css/web2py.css @@ -107,6 +107,7 @@ div.flash { -webkit-border-radius:5px; z-index:2000; } +div.flash:hover { opacity:0.25; } div.error_wrapper {display:block} div.error { diff --git a/applications/welcome/static/css/web2py_bootstrap.css b/applications/welcome/static/css/web2py_bootstrap.css index de65e658..416cb19a 100644 --- a/applications/welcome/static/css/web2py_bootstrap.css +++ b/applications/welcome/static/css/web2py_bootstrap.css @@ -81,6 +81,8 @@ body { .ie-lte7 #navbar .auth_navbar, #navbar .auth_navbar a {color:expression(this.parentNode.currentStyle['color']); /* ie7 doesn't support inherit */} #navbar .auth_navbar a:hover {color:white;text-decoration:none;} /* this overwrite bootswatch */ +ul#navbar{padding:0;} /*reset ul padding */ +ul#navbar>.auth_navbar{display:inline-block;padding:5px;} /* set padding of span.auth_navbar inside ul*/ body { height:auto; /*to avoid vertical scroll bar*/ diff --git a/applications/welcome/views/layout.html b/applications/welcome/views/layout.html index 35532710..a0b7f584 100644 --- a/applications/welcome/views/layout.html +++ b/applications/welcome/views/layout.html @@ -1,177 +1,178 @@ - - - - - - - - - - - - - - {{=response.title or request.application}} - - - - - - - - - - - - - - - - - - {{ - response.files.append(URL('static','css/bootstrap.min.css')) - response.files.append(URL('static','css/bootstrap-responsive.min.css')) - response.files.append(URL('static','css/web2py.css')) - response.files.append(URL('static','css/web2py_bootstrap.css')) - }} - - {{include 'web2py_ajax.html'}} - - {{ - # using sidebars need to know what sidebar you want to use - left_sidebar_enabled = globals().get('left_sidebar_enabled',False) - right_sidebar_enabled = globals().get('right_sidebar_enabled',False) - middle_columns = {0:'span12',1:'span9',2:'span6'}[ - (left_sidebar_enabled and 1 or 0)+(right_sidebar_enabled and 1 or 0)] - }} - - - - {{block head}}{{end}} - - - - - - -
-
{{=response.flash or ''}}
- - - - -
-
- {{if left_sidebar_enabled:}} - - {{pass}} - -
- {{block center}} - {{include}} - {{end}} -
- - {{if right_sidebar_enabled:}} -
- {{block right_sidebar}} -

Right Sidebar

-

- {{end}} -
- {{pass}} -
-
- - -
- {{block footer}} - - {{end}} -
- -
- - - - - - {{if response.google_analytics_id:}} {{pass}} - - - + + + + + + + + + + + + + + {{=response.title or request.application}} + + + + + + + + + + + + + + + + + + {{ + response.files.append(URL('static','css/bootstrap.min.css')) + response.files.append(URL('static','css/bootstrap-responsive.min.css')) + response.files.append(URL('static','css/web2py.css')) + response.files.append(URL('static','css/web2py_bootstrap.css')) + }} + + {{include 'web2py_ajax.html'}} + + {{ + # using sidebars need to know what sidebar you want to use + left_sidebar_enabled = globals().get('left_sidebar_enabled',False) + right_sidebar_enabled = globals().get('right_sidebar_enabled',False) + middle_columns = {0:'span12',1:'span9',2:'span6'}[ + (left_sidebar_enabled and 1 or 0)+(right_sidebar_enabled and 1 or 0)] + }} + + + + {{block head}}{{end}} + + + + + + +
+
{{=response.flash or ''}}
+ + + + +
+
+ {{if left_sidebar_enabled:}} + + {{pass}} + +
+ {{block center}} + {{include}} + {{end}} +
+ + {{if right_sidebar_enabled:}} +
+ {{block right_sidebar}} +

Right Sidebar

+

+ {{end}} +
+ {{pass}} +
+
+ + +
+ {{block footer}} + + {{end}} +
+ +
+ + + + + + {{if response.google_analytics_id:}} {{pass}} + + + + diff --git a/gluon/tools.py b/gluon/tools.py index bf4503e7..cb56f25f 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -1208,16 +1208,17 @@ class Auth(object): def navbar(self, prefix='Welcome', action=None, separators=(' [ ',' | ',' ] '), user_identifier=DEFAULT, - referrer_actions=DEFAULT): + referrer_actions=DEFAULT, mode='default'): referrer_actions = [] if not referrer_actions else referrer_actions request = current.request + asdropdown = (mode == 'dropdown') T = current.T if isinstance(prefix, str): prefix = T(prefix) if prefix: prefix = prefix.strip() + ' ' if not action: - action=self.url(self.settings.function) + action = self.url(self.settings.function) s1,s2,s3 = separators if URL() == action: next = '' @@ -1244,11 +1245,19 @@ class Auth(object): profile = A(T('Profile'), _href=href('profile')) password = A(T('Password'), _href=href('change_password')) bar = SPAN(prefix, user_identifier, s1, logout, s3, _class='auth_navbar') + + if asdropdown: + logout = LI(A(I(_class='icon-off'), ' '+T('Logout'), _href='%s/logout?_next=%s' % + (action, urllib.quote(self.settings.logout_next)))) # the space before T('Logout') is intentional. It creates a gap between icon and text + profile = LI(A(I(_class='icon-user'), ' '+T('Profile'), _href=href('profile'))) + password = LI(A(I(_class='icon-lock'), ' '+T('Password'), _href=href('change_password'))) + bar = UL(logout,_class='dropdown-menu') # logout will be the last item in list + if not 'profile' in self.settings.actions_disabled: - bar.insert(-1, s2) + if not asdropdown: bar.insert(-1, s2) bar.insert(-1, profile) if not 'change_password' in self.settings.actions_disabled: - bar.insert(-1, s2) + if not asdropdown: bar.insert(-1, s2) bar.insert(-1, password) else: login = A(T('Login'), _href=href('login')) @@ -1259,17 +1268,34 @@ class Auth(object): T('Lost password?'), _href=href('request_reset_password')) bar = SPAN(s1, login, s3, _class='auth_navbar') + if asdropdown: + user_identifier = '' + login = LI(A(I(_class='icon-off'), ' '+T('Login'), _href=href('login'))) #the space before T('Login') is intentional. It creates a gap between icon and text + register = LI(A(I(_class='icon-user'), ' '+T('Register'), _href=href('register'))) + retrieve_username = LI(A(I(_class='icon-edit'), ' '+T('Forgot username?'), _href=href('retrieve_username'))) + lost_password = LI(A(I(_class='icon-lock'), ' '+T('Lost password?'), _href=href('request_reset_password'))) + bar = UL(login,_class='dropdown-menu') # login will be the last item in list + if not 'register' in self.settings.actions_disabled: - bar.insert(-1, s2) + if not asdropdown: bar.insert(-1, s2) bar.insert(-1, register) if self.settings.use_username and not 'retrieve_username' \ in self.settings.actions_disabled: - bar.insert(-1, s2) + if not asdropdown: bar.insert(-1, s2) bar.insert(-1, retrieve_username) if not 'request_reset_password' \ in self.settings.actions_disabled: - bar.insert(-1, s2) + if not asdropdown: bar.insert(-1, s2) bar.insert(-1, lost_password) + + if asdropdown: + bar.insert(-1, LI('',_class='divider')) + if self.user_id: + bar = LI(A(prefix, user_identifier, _href='#'), + bar,_class='dropdown') + else: + bar = LI(A(T('Login'), _href='#'), + bar,_class='dropdown') return bar def __get_migrate(self, tablename, migrate=True):