Mercurial > libervia-web
changeset 1127:9234f29053b0
server, pages: update to handle multi sites themes, first draft:
This first part of update handle changes in backend for multi-sites templates. Templates are now available in _t resource, followed by site name (default one is in "sat").
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 09 Sep 2018 21:12:22 +0200 |
parents | 7cd89277a129 |
children | 6414fd795df4 |
files | libervia/server/constants.py libervia/server/pages.py libervia/server/server.py |
diffstat | 3 files changed, 14 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/server/constants.py Fri Aug 31 18:08:06 2018 +0200 +++ b/libervia/server/constants.py Sun Sep 09 21:12:22 2018 +0200 @@ -34,6 +34,8 @@ CARDS_DIR = "games/cards/tarot" PAGES_DIR = u"pages" + TPL_RESOURCE = u'_t' + ERRNUM_BRIDGE_ERRBACK = 0 # FIXME ERRNUM_LIBERVIA = 0 # FIXME @@ -104,17 +106,5 @@ ## Date/Time ## HTTP_DAYS = ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun") - HTTP_MONTH = ( - "Jan", - "Feb", - "Mar", - "Apr", - "May", - "Jun", - "Jul", - "Aug", - "Sep", - "Oct", - "Nov", - "Dec", - ) + HTTP_MONTH = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", + "Nov", "Dec")
--- a/libervia/server/pages.py Fri Aug 31 18:08:06 2018 +0200 +++ b/libervia/server/pages.py Sun Sep 09 21:12:22 2018 +0200 @@ -998,7 +998,6 @@ rendered = self.host.renderer.render( template, - root_path="/templates/", error_code=code, **request.template_data ) @@ -1077,7 +1076,6 @@ return self.host.renderer.render( self.template, - root_path="/templates/", media_path="/" + C.MEDIA_DIR, cache_path=session_data.cache_dir, main_menu=LiberviaPage.main_menu, @@ -1271,7 +1269,6 @@ return self.host.renderer.render( template, - root_path="/templates/", media_path="/" + C.MEDIA_DIR, cache_path=session_data.cache_dir, main_menu=LiberviaPage.main_menu,
--- a/libervia/server/server.py Fri Aug 31 18:08:06 2018 +0200 +++ b/libervia/server/server.py Sun Sep 09 21:12:22 2018 +0200 @@ -1644,6 +1644,11 @@ def _namespacesGetEb(self, failure_): log.error(_(u"Can't get namespaces map: {msg}").format(msg=failure_)) + def _front_url_filter(self, ctx, relative_url): + template_data = ctx[u'template_data'] + return os.path.join(u'/', C.TPL_RESOURCE, template_data.site or u'sat', + C.TEMPLATE_TPL_DIR, template_data.theme, relative_url) + def backendReady(self, dummy): self.root = root = LiberviaRootResource(self.html_dir) _register = Register(self) @@ -1768,8 +1773,11 @@ ) self.site = server.Site(wrapped) self.site.sessionFactory = LiberviaSession - self.renderer = template.Renderer(self) - self.putChild("templates", ProtectedFile(self.renderer.base_dir)) + self.renderer = template.Renderer(self, self._front_url_filter) + templates_res = web_resource.Resource() + self.putChild(C.TPL_RESOURCE, templates_res) + for site_name, site_path in self.renderer.sites_paths.iteritems(): + templates_res.putChild(site_name or u'sat', ProtectedFile(site_path)) def initEb(self, failure): log.error(_(u"Init error: {msg}").format(msg=failure))