Improved main menu, showing categories on demand with a drop down of panels. Showing only first panel if that category only have one child.

This commit is contained in:
Felipe Martin 2013-11-26 20:29:46 +01:00
parent 8877e2e66a
commit 7dd32c88aa
3 changed files with 16 additions and 7 deletions

View File

@ -39,7 +39,7 @@ def category_list():
@server.context_processor
def current_section():
# Empty so jinja can stop yelling at me
return dict(current=dict())
return dict(current=dict(category=None, panel=None, section=None))
#

View File

@ -27,9 +27,9 @@ class GUIController(object):
# Category handling
category = slugify(ins.category)
if ins.category not in self._categories:
if category not in self._categories:
self._categories[category] = []
self._categories[category].append(slug)
self._categories[category].append(ins)
def load_from_library(self, library):
"""
@ -43,9 +43,9 @@ class GUIController(object):
)
try:
import_module(gui_module)
except ImportError as error:
except ImportError:
# Plugin with no GUI module.
print(error)
print("Plugin {} gui module not found.".format(k))
def load_panel(self, panel_id):
"""

View File

@ -20,8 +20,17 @@
</a>
<ul class="nav navbar-nav">
{% for category in categories %}
<li {% if current.category == category %}class="active"{% endif %}>
<a href="/{{ category }}">{{ category|title }}</a>
<li class="{% if current.category == category %}active{% endif %} dropdown">
{% if categories[category]|length == 1 %}
<a href="/{{ category }}/{{ categories[category] }}">{{ categories[category][0].name }}</a>
{% else %}
<a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ category|title }} <i class="caret"></i></a>
<ul class="dropdown-menu">
{% for panel in categories[category] %}
<li {% if current.panel.id == panel.id %}class="active"{% endif %}><a href="/{{ category }}/{{ panel.id }}/">{{ panel.name }}</a></li>
{% endfor %}
</ul>
{% endif %}
</li>
{% endfor %}
</ul>