comparison libervia/web/server/pages.py @ 1580:08342aca8c1e

pages: make `tz_data` always available as template data and exposed to scripts
author Goffi <goffi@goffi.org>
date Tue, 28 Nov 2023 17:52:09 +0100
parents 66c1a90da1bc
children 291a7026cb2b
comparison
equal deleted inserted replaced
1579:5db55d01ce05 1580:08342aca8c1e
1404 theme = session_data.theme or self.default_theme 1404 theme = session_data.theme or self.default_theme
1405 self.expose_to_scripts( 1405 self.expose_to_scripts(
1406 request, 1406 request,
1407 cache_path=session_data.cache_dir, 1407 cache_path=session_data.cache_dir,
1408 templates_root_url=str(self.vhost_root.get_front_url(theme)), 1408 templates_root_url=str(self.vhost_root.get_front_url(theme)),
1409 profile=session_data.profile) 1409 profile=session_data.profile,
1410 tz_name=template_data["tz_name"]
1411 )
1410 1412
1411 uri = request.uri.decode() 1413 uri = request.uri.decode()
1412 try: 1414 try:
1413 template_data["current_page"] = next( 1415 template_data["current_page"] = next(
1414 m[0] for m in self.main_menu if uri.startswith(m[1]) 1416 m[0] for m in self.main_menu if uri.startswith(m[1])
1674 "profile": profile, 1676 "profile": profile,
1675 # it's important to not add CSRF token and session uuid if service profile 1677 # it's important to not add CSRF token and session uuid if service profile
1676 # is used because the page may be cached, and the token then leaked 1678 # is used because the page may be cached, and the token then leaked
1677 "csrf_token": "" if profile is None else session_data.csrf_token, 1679 "csrf_token": "" if profile is None else session_data.csrf_token,
1678 "session_uuid": "public" if profile is None else session_data.uuid, 1680 "session_uuid": "public" if profile is None else session_data.uuid,
1679 "breadcrumbs": [] 1681 "breadcrumbs": [],
1682 "tz_name": time.tzname[0]
1680 } 1683 }
1681 1684
1682 # XXX: here is the code which need to be executed once 1685 # XXX: here is the code which need to be executed once
1683 # at the beginning of the request hanling 1686 # at the beginning of the request hanling
1684 if request.postpath and not request.postpath[-1]: 1687 if request.postpath and not request.postpath[-1]: