Browse Source

Page links in navigationbar added

master
Dirk Alders 3 months ago
parent
commit
a293bc9eff
1 changed files with 17 additions and 1 deletions
  1. 17
    1
      pages/context.py

+ 17
- 1
pages/context.py View File

1
 import inspect
1
 import inspect
2
 import logging
2
 import logging
3
+import os
3
 
4
 
4
 from django.utils.translation import gettext as _
5
 from django.utils.translation import gettext as _
5
 
6
 
21
 BACK_UID = 'back'
22
 BACK_UID = 'back'
22
 EDIT_UID = 'edit'
23
 EDIT_UID = 'edit'
23
 HELP_UID = 'help'
24
 HELP_UID = 'help'
25
+NAVIGATION_ENTRY_UID = 'navigation-%s'
24
 
26
 
25
 
27
 
26
 def context_adaption(context, request, **kwargs):
28
 def context_adaption(context, request, **kwargs):
40
 
42
 
41
 def navigationbar(context, request, caller_name, **kwargs):
43
 def navigationbar(context, request, caller_name, **kwargs):
42
     bar = context[context.NAVIGATIONBAR]
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
     add_back_menu(request, bar)
49
     add_back_menu(request, bar)
44
-    # TODO: Add the pages navigation, if source is pages
45
     finalise_bar(request, bar)
50
     finalise_bar(request, bar)
46
 
51
 
47
 
52
 
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
 def menubar(context, request, caller_name, **kwargs):
75
 def menubar(context, request, caller_name, **kwargs):
60
     bar = context[context.MENUBAR]
76
     bar = context[context.MENUBAR]
61
     add_help_menu(request, bar)
77
     add_help_menu(request, bar)

Loading…
Cancel
Save