=== modified file 'lava_server/context_processors.py'
@@ -19,12 +19,28 @@
import versiontools
import lava_server
-from lava_server.extension import loader
+from lava_server.extension import Menu, loader
+from django.core.urlresolvers import reverse
def lava(request):
+ menu_list = [
+ Menu("LAVA", reverse('lava.home')),
+ ]
+ for extension in loader.extensions:
+ menu = extension.get_menu()
+ if menu:
+ menu_list.append(menu)
+ menu_list.extend([
+ Menu("Documentation", "http://lava.rtfd.org/"),
+ Menu("API", reverse("lava.api_help"), [
+ Menu("Available Methods", reverse("lava.api_help")),
+ Menu("Authentication Tokens", reverse("linaro_django_xmlrpc.views.tokens")),
+ ])
+ ])
return {
'lava': {
+ 'menu_list': menu_list,
'extension_list': loader.extensions,
'version': versiontools.format_version(
lava_server.__version__, hint=lava_server)}}
=== modified file 'lava_server/extension.py'
@@ -92,6 +92,23 @@
Absolute URL of the main view
"""
+ @abstractmethod
+ def get_menu(self):
+ """
+ Return a Menu object
+ """
+
+
+class Menu(object):
+ """
+ Menu (for navigation)
+ """
+
+ def __init__(self, label, url, sub_menu=None):
+ self.label = label
+ self.url = url
+ self.sub_menu = sub_menu or []
+
class LavaServerExtension(ILavaServerExtension):
"""
@@ -115,6 +132,10 @@
Name of the main view
"""
+ def get_menu(self):
+ from django.core.urlresolvers import reverse
+ return Menu(self.name, reverse(self.main_view_name))
+
@property
def front_page_template(self):
return None