Mercurial > libervia-web
comparison libervia/web/server/pages.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 | 97ea776df74c |
children |
comparison
equal
deleted
inserted
replaced
1617:e338426ed4de | 1618:5d9889f14012 |
---|---|
265 @property | 265 @property |
266 def main_menu(self): | 266 def main_menu(self): |
267 return self.vhost_root.main_menu | 267 return self.vhost_root.main_menu |
268 | 268 |
269 @property | 269 @property |
270 def login_url(self): | |
271 return self.vhost_root.login_url | |
272 | |
273 @property | |
270 def default_theme(self): | 274 def default_theme(self): |
271 return self.vhost_root.default_theme | 275 return self.vhost_root.default_theme |
272 | 276 |
273 | 277 |
274 @property | 278 @property |
1419 self.expose_to_scripts(request, own_jid=session_data.jid.full()) | 1423 self.expose_to_scripts(request, own_jid=session_data.jid.full()) |
1420 | 1424 |
1421 uri = request.uri.decode() | 1425 uri = request.uri.decode() |
1422 try: | 1426 try: |
1423 template_data["current_page"] = next( | 1427 template_data["current_page"] = next( |
1424 m[0] for m in self.main_menu if uri.startswith(m[1]) | 1428 m["name"] for m in self.main_menu if uri.startswith(m["url"]) |
1425 ) | 1429 ) |
1426 except StopIteration: | 1430 except StopIteration: |
1427 pass | 1431 pass |
1428 | 1432 |
1429 return self.host.renderer.render( | 1433 return self.host.renderer.render( |
1685 # it's important to not add CSRF token and session uuid if service profile | 1689 # it's important to not add CSRF token and session uuid if service profile |
1686 # is used because the page may be cached, and the token then leaked | 1690 # is used because the page may be cached, and the token then leaked |
1687 "csrf_token": "" if profile is None else session_data.csrf_token, | 1691 "csrf_token": "" if profile is None else session_data.csrf_token, |
1688 "session_uuid": "public" if profile is None else session_data.uuid, | 1692 "session_uuid": "public" if profile is None else session_data.uuid, |
1689 "breadcrumbs": [], | 1693 "breadcrumbs": [], |
1690 "tz_name": time.tzname[0] | 1694 "tz_name": time.tzname[0], |
1695 "login_url": self.login_url | |
1691 } | 1696 } |
1692 | 1697 |
1693 # XXX: here is the code which need to be executed once | 1698 # XXX: here is the code which need to be executed once |
1694 # at the beginning of the request hanling | 1699 # at the beginning of the request hanling |
1695 if request.postpath and not request.postpath[-1]: | 1700 if request.postpath and not request.postpath[-1]: |