diff libervia/web/server/resources.py @ 1618:5d9889f14012 default tip @

server: start major redesign - Add icons to menu items - Switch menu items representation from tuple to dictionary for future extensibility: - Include icon information - Prepare for additional data - Remove "login" from main menu, add login page URL to template data, as it is now a separate right-aligned item
author Goffi <goffi@goffi.org>
date Sat, 26 Oct 2024 23:07:01 +0200
parents f3305832f3f6
children
line wrap: on
line diff
--- a/libervia/web/server/resources.py	Wed Aug 07 00:02:40 2024 +0200
+++ b/libervia/web/server/resources.py	Sat Oct 26 23:07:01 2024 +0200
@@ -123,6 +123,7 @@
         self.pages_redirects = {}
         self.cached_urls = {}
         self.main_menu = None
+        self.login_url = None
         # map Libervia application names => data
         self.libervia_apps = {}
         self.build_path = host.get_build_path(site_name)
@@ -536,7 +537,17 @@
                                 "menu_json in configuration.").format(msg=e.args[0])
                     log.error(log_msg)
                     raise exceptions.ConfigError(log_msg)
-            main_menu.append((page_name, url))
+
+            if page_name == "login":
+                self.login_url = url
+                continue
+            icon = C.DEFAULT_ICONS.get(page_name, "")
+
+            main_menu.append({
+                "name": page_name,
+                "url": url,
+                "icon": icon
+            })
         self.main_menu = main_menu
 
     def _normalize_url(self, url, lower=True):