comparison 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
comparison
equal deleted inserted replaced
1617:e338426ed4de 1618:5d9889f14012
121 121
122 self.uri_callbacks = {} 122 self.uri_callbacks = {}
123 self.pages_redirects = {} 123 self.pages_redirects = {}
124 self.cached_urls = {} 124 self.cached_urls = {}
125 self.main_menu = None 125 self.main_menu = None
126 self.login_url = None
126 # map Libervia application names => data 127 # map Libervia application names => data
127 self.libervia_apps = {} 128 self.libervia_apps = {}
128 self.build_path = host.get_build_path(site_name) 129 self.build_path = host.get_build_path(site_name)
129 self.build_path.mkdir(parents=True, exist_ok=True) 130 self.build_path.mkdir(parents=True, exist_ok=True)
130 self.dev_build_path = host.get_build_path(site_name, dev=True) 131 self.dev_build_path = host.get_build_path(site_name, dev=True)
534 except KeyError as e: 535 except KeyError as e:
535 log_msg = _("Can'find a named page ({msg}), please check " 536 log_msg = _("Can'find a named page ({msg}), please check "
536 "menu_json in configuration.").format(msg=e.args[0]) 537 "menu_json in configuration.").format(msg=e.args[0])
537 log.error(log_msg) 538 log.error(log_msg)
538 raise exceptions.ConfigError(log_msg) 539 raise exceptions.ConfigError(log_msg)
539 main_menu.append((page_name, url)) 540
541 if page_name == "login":
542 self.login_url = url
543 continue
544 icon = C.DEFAULT_ICONS.get(page_name, "")
545
546 main_menu.append({
547 "name": page_name,
548 "url": url,
549 "icon": icon
550 })
540 self.main_menu = main_menu 551 self.main_menu = main_menu
541 552
542 def _normalize_url(self, url, lower=True): 553 def _normalize_url(self, url, lower=True):
543 """Return URL normalized for self.redirections dict 554 """Return URL normalized for self.redirections dict
544 555