Browse Source

Make the navbar buttons active state work

Gu1 11 years ago
parent
commit
a35e76256f
2 changed files with 8 additions and 6 deletions
  1. 7 6
      ffdnispdb/templates/layout.html
  2. 1 0
      ffdnispdb/views.py

+ 7 - 6
ffdnispdb/templates/layout.html

@@ -1,3 +1,6 @@
+{% macro menu_item(name, endpoint=None) -%}
+<li{% if request.endpoint == endpoint %} class="active"{% endif %}><a href="{{ url_for(endpoint) if endpoint else "#" }}">{{ _(name) }}</a></li>
+{% endmacro %}
 <!doctype html>
 <html lang="fr">
   <head>
@@ -30,12 +33,10 @@
           <input type="text" id="search-input" class="search-query input-medium" placeholder="{{ _("Search") }}"/>
         </form>
         <ul class="nav pull-right">
-          <li class="active">
-          <a href="/">Home</a>
-          </li>
-          <li><a href="{{ url_for('project_list') }}">Project List</a></li>
-          <li><a href="#">Schema</a></li>
-          <li><a href="#">API</a></li>
+          {{ menu_item('Home', 'home') }}
+          {{ menu_item('Project List', 'project_list') }}
+          {{ menu_item('Schema') }}
+          {{ menu_item('API') }}
           <li class="divider-vertical"></li>
         </ul>
       </div>

+ 1 - 0
ffdnispdb/views.py

@@ -140,3 +140,4 @@ def gpspart(gps, part):
         return parts[1]
     return "";
 
+