diff --git a/php/layout.php b/php/layout.php
index 1e24b25..ecac3f4 100644
--- a/php/layout.php
+++ b/php/layout.php
@@ -17,8 +17,14 @@
* $nonce string CSP nonce from SecurityHeadersMiddleware::getNonce()
* $currentUser array ['username', 'name', 'is_admin', 'groups']
* $pageTitle string Page
suffix
- * $activeNav string Which nav link is active ('dashboard','tickets',etc.)
+ * $activeNav string Which nav key is active — must match a $navLinks entry
* $config array From config/config.php
+ * $navLinks array Navigation items:
+ * [['href' => '/path', 'key' => 'mykey', 'label' => 'My Page'], ...]
+ * Nested (dropdown):
+ * ['label' => 'Admin', 'key' => 'admin', 'adminOnly' => true, 'children' => [
+ * ['href' => '/admin/users', 'label' => 'Users'],
+ * ]]
*/
// Defensive defaults
@@ -27,6 +33,7 @@ $currentUser = $currentUser ?? [];
$pageTitle = $pageTitle ?? 'Dashboard';
$activeNav = $activeNav ?? '';
$config = $config ?? [];
+$navLinks = $navLinks ?? [];
$isAdmin = $currentUser['is_admin'] ?? false;
?>
@@ -40,7 +47,7 @@ $isAdmin = $currentUser['is_admin'] ?? false;
-
+
@@ -67,25 +74,31 @@ $isAdmin = $currentUser['is_admin'] ?? false;
@@ -130,6 +143,8 @@ $isAdmin = $currentUser['is_admin'] ?? false;
username: ,
isAdmin: ,
};
+ // App-specific config: set window.APP_CONFIG in your app's own
@@ -137,7 +152,7 @@ $isAdmin = $currentUser['is_admin'] ?? false;
diff --git a/python/base.html b/python/base.html
index 252a68f..91d33da 100644
--- a/python/base.html
+++ b/python/base.html
@@ -17,7 +17,8 @@
Required Flask setup (app.py):
- Pass `nonce` into every render_template() call via a context processor
- Pass `user` dict from _get_user() helper
- - Pass `config` dict with APP_NAME, etc.
+ - Pass `config` dict with APP_NAME, APP_SUBTITLE, etc.
+ - Pass `nav_links` list of dicts defining navigation
Context processor example:
@app.context_processor
@@ -25,6 +26,16 @@
import base64, os
nonce = base64.b64encode(os.urandom(16)).decode()
return dict(nonce=nonce, user=_get_user(), config=_config())
+
+ nav_links format (pass from route or context processor):
+ nav_links = [
+ {'href': url_for('index'), 'key': 'dashboard', 'label': 'Dashboard'},
+ {'href': url_for('settings'), 'key': 'settings', 'label': 'Settings'},
+ # Admin-only dropdown:
+ {'label': 'Admin', 'key': 'admin', 'admin_only': True, 'children': [
+ {'href': url_for('admin_users'), 'label': 'Users'},
+ ]},
+ ]
#}
@@ -64,24 +75,28 @@
@@ -107,17 +122,16 @@
All
@@ -136,6 +150,6 @@
{% block active_nav %}dashboard{% endblock %}
- Values: dashboard | links | inspector | suppressions
+ Value must match a 'key' in your nav_links list.
--------------------------------------------------------------- #}
{% block active_nav %}{% endblock %}