Permalink
Browse files

Menu now active the right page

  • Loading branch information...
1 parent e1e7621 commit 2b8c27928665003a3474bb3aa58cee4f5fa9025e @rhaamo committed Jan 12, 2014
Showing with 29 additions and 11 deletions.
  1. +15 −4 codular/templates/layout.jinja2
  2. +2 −1 codular/views/home.py
  3. +12 −6 codular/views/users.py
@@ -38,10 +38,21 @@
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav side-nav">
- <li class="active"><a href="{{'home'|route_url}}"><i class="fa fa-home"></i> Home</a></li>
- <li><a href="{{'new_user'|route_url}}"><i class="fa fa-wrench"></i> Register</a></li>
- <li><a href="{{'home'|route_url}}"><i class="fa fa-user"></i> Login</a></li>
- <li><a href="{{'home'|route_url}}"><i class="fa fa-question"></i> About</a></li>
+ <li class="{{ 'active' if menu_active == 'home' else 'inactive' }}">
+ <a href="{{'home'|route_url}}"><i class="fa fa-home"></i> Home</a>
+ </li>
+
+ <li class="{{ 'active' if menu_active == 'new_user' else 'inactive' }}">
+ <a href="{{'new_user'|route_url}}"><i class="fa fa-wrench"></i> Register</a>
+ </li>
+
+ <li class="{{ 'active' if menu_active == 'login' else 'inactive' }}">
+ <a href="{{'home'|route_url}}"><i class="fa fa-user"></i> Login</a>
+ </li>
+
+ <li class="{{ 'active' if menu_active == 'about' else 'inactive' }}">
+ <a href="{{'home'|route_url}}"><i class="fa fa-question"></i> About</a>
+ </li>
</ul>
<ul class="nav navbar-nav navbar-right navbar-user">
View
@@ -21,4 +21,5 @@ def __init__(self, request):
@view_config(route_name='home', renderer='home/home.jinja2')
def home_get(self):
- return {'one': "the one", 'project': 'codular'}
+ template_vars = {'menu_active': 'home', 'one': "the one", 'project': 'codular'}
+ return template_vars
View
@@ -26,24 +26,30 @@ def __init__(self, request):
@view_config(route_name='users', renderer='json')
def users(self):
- return "users"
+ template_vars = {'menu_active': 'users'}
+ return template_vars
@view_config(route_name='user', renderer='json')
def user(self):
- return "user"
+ template_vars = {'menu_active': 'user'}
+ return template_vars
@view_config(route_name='update_user', renderer='json')
def update_user(self):
- return "update_user"
+ template_vars = {'menu_active': 'update_user'}
+ return template_vars
@view_config(route_name='delete_user', renderer='json')
def delete_user(self):
- return "delete_user"
+ template_vars = {'menu_active': 'delete_user'}
+ return template_vars
@view_config(route_name='new_user', renderer='users/new.jinja2')
def new_user(self):
- return {'one': "the one", 'project': 'codular'}
+ template_vars = {'menu_active': 'new_user'}
+ return template_vars
@view_config(route_name='edit_user', renderer='json')
def edit_user(self):
- return "edit_user"
+ template_vars = {'menu_active': 'edit_user'}
+ return template_vars

0 comments on commit 2b8c279

Please sign in to comment.