comparison libervia/web/server/server.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 ebd538cb26cb
children
comparison
equal deleted inserted replaced
1617:e338426ed4de 1618:5d9889f14012
303 template_data = ctx['template_data'] 303 template_data = ctx['template_data']
304 return os.path.join( 304 return os.path.join(
305 '/', C.TPL_RESOURCE, template_data.site or C.SITE_NAME_DEFAULT, 305 '/', C.TPL_RESOURCE, template_data.site or C.SITE_NAME_DEFAULT,
306 C.TEMPLATE_TPL_DIR, template_data.theme, relative_url) 306 C.TEMPLATE_TPL_DIR, template_data.theme, relative_url)
307 307
308 def _move_first_level_to_dict(self, options, key, keys_to_keep): 308 def _move_first_level_to_dict(
309 """Read a config option and put value at first level into u'' dict 309 self, options: dict, key: str, keys_to_keep: list[str]
310 ) -> None:
311 """Read a config option and put value at first level into '' dict
310 312
311 This is useful to put values for Libervia official site directly in dictionary, 313 This is useful to put values for Libervia official site directly in dictionary,
312 and to use site_name as keys when external sites are used. 314 and to use site_name as keys when external sites are used.
313 options will be modified in place 315 options will be modified in place
314 @param options(dict): options to modify 316 @param options: Dictionary of options to modify in place.
315 @param key(unicode): setting key to modify 317 @param key: The key in the options dictionary to process.
316 @param keys_to_keep(list(unicode)): keys allowed in first level 318 @param keys_to_keep: List of keys that are allowed to remain at the first level.
317 """ 319 """
318 try: 320 try:
319 conf = options[key] 321 conf = options[key]
320 except KeyError: 322 except KeyError:
321 return 323 return
474 self._move_first_level_to_dict(self.options, "menu_extra_json", sites_names) 476 self._move_first_level_to_dict(self.options, "menu_extra_json", sites_names)
475 menu = self.options["menu_json"] 477 menu = self.options["menu_json"]
476 if not '' in menu: 478 if not '' in menu:
477 menu[''] = C.DEFAULT_MENU 479 menu[''] = C.DEFAULT_MENU
478 for site, value in self.options["menu_extra_json"].items(): 480 for site, value in self.options["menu_extra_json"].items():
479 menu[site].extend(value) 481 try:
482 menu[site].extend(value)
483 except KeyError:
484 log.warning(
485 "Configuration error: the key {site!r} is missing from \"menu_json\"."
486 )
480 487
481 # service profile 488 # service profile
482 if not self.options['build-only']: 489 if not self.options['build-only']:
483 await self.check_and_connect_service_profile() 490 await self.check_and_connect_service_profile()
484 491