Explorar el Código

Page links in navigationbar added

master
Dirk Alders hace 3 meses
padre
commit
a293bc9eff
Se han modificado 1 ficheros con 17 adiciones y 1 borrados
  1. 17
    1
      pages/context.py

+ 17
- 1
pages/context.py Ver fichero

@@ -1,5 +1,6 @@
1 1
 import inspect
2 2
 import logging
3
+import os
3 4
 
4 5
 from django.utils.translation import gettext as _
5 6
 
@@ -21,6 +22,7 @@ ATTACHMENT_UID = 'attachment'
21 22
 BACK_UID = 'back'
22 23
 EDIT_UID = 'edit'
23 24
 HELP_UID = 'help'
25
+NAVIGATION_ENTRY_UID = 'navigation-%s'
24 26
 
25 27
 
26 28
 def context_adaption(context, request, **kwargs):
@@ -40,8 +42,11 @@ def context_adaption(context, request, **kwargs):
40 42
 
41 43
 def navigationbar(context, request, caller_name, **kwargs):
42 44
     bar = context[context.NAVIGATIONBAR]
45
+    path = kwargs.get("rel_path")
46
+    while len(path) > 0 and path != os.path.sep:
47
+        bar.append_entry(*navigation_entry_parameters(request, path))
48
+        path = os.path.dirname(path)
43 49
     add_back_menu(request, bar)
44
-    # TODO: Add the pages navigation, if source is pages
45 50
     finalise_bar(request, bar)
46 51
 
47 52
 
@@ -56,6 +61,17 @@ def add_back_menu(request, bar):
56 61
     )
57 62
 
58 63
 
64
+def navigation_entry_parameters(request, path):
65
+    return (
66
+        NAVIGATION_ENTRY_UID % os.path.basename(path),          # uid
67
+        '/' + os.path.basename(path),                           # name
68
+        None,                                                   # icon
69
+        pages.url_page(request, path),                          # url
70
+        False,                                                  # left
71
+        False                                                   # active
72
+    )
73
+
74
+
59 75
 def menubar(context, request, caller_name, **kwargs):
60 76
     bar = context[context.MENUBAR]
61 77
     add_help_menu(request, bar)

Loading…
Cancelar
Guardar