Mercurial > libervia-web
changeset 1293:de3b15d68bb6
pages: expose `templates_root_url` to scripts
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 19 Jun 2020 16:47:51 +0200 |
parents | e30e96958fb7 |
children | 44da7b118b02 |
files | libervia/server/pages.py libervia/server/server.py |
diffstat | 2 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/server/pages.py Fri Jun 19 16:47:51 2020 +0200 +++ b/libervia/server/pages.py Fri Jun 19 16:47:51 2020 +0200 @@ -1388,9 +1388,14 @@ if key not in template_data: template_data[key] = value + theme = session_data.theme or self.default_theme + self.exposeToScripts( + request, + templates_root_url=str(self.vhost_root.getFrontURL(theme))) + return self.host.renderer.render( self.template, - theme=session_data.theme or self.default_theme, + theme=theme, site_themes=self.site_themes, page_url=self.getURL(), media_path=f"/{C.MEDIA_DIR}",
--- a/libervia/server/server.py Fri Jun 19 16:47:51 2020 +0200 +++ b/libervia/server/server.py Fri Jun 19 16:47:51 2020 +0200 @@ -242,6 +242,13 @@ """ return self.host.getConfig(self, key, default, value_type) + def getFrontURL(self, theme): + return Path( + '/', + C.TPL_RESOURCE, + self.site_name or C.SITE_NAME_DEFAULT, + C.TEMPLATE_TPL_DIR, + theme) def _initRedirections(self, options): url_redirections = options["url_redirections_dict"]