diff src/pages/common/blog/page_meta.py @ 1029:78b7b5ec7ca1

pages (common/blog): if background is set in user preferences, use it
author Goffi <goffi@goffi.org>
date Mon, 22 Jan 2018 08:53:06 +0100
parents 38cfee0eed48
children f5661761b1b9
line wrap: on
line diff
--- a/src/pages/common/blog/page_meta.py	Mon Jan 22 08:53:06 2018 +0100
+++ b/src/pages/common/blog/page_meta.py	Mon Jan 22 08:53:06 2018 +0100
@@ -7,7 +7,9 @@
 from libervia.server import session_iface
 from sat.core.i18n import _
 from sat.core.log import getLogger
+from sat.tools.common.template import safe
 import urllib
+import cgi
 log = getLogger('pages/common/blog')
 
 """generic blog (with service/node provided)"""
@@ -188,6 +190,14 @@
             if tag not in tags_http_uri:
                 tags_http_uri[tag] = self.host.getExtBaseURL(request, blog_view.getURL(service_s, node or '@', u'tag', tag))
     template_data[u'allow_commenting'] = data.get(u'allow_commenting', False)
+    if u'target_profile' in template_data:
+        bg_img = yield self.host.bridgeCall(u'asyncGetParamA', u'Background', u'Blog page', u'value', -1, template_data[u'target_profile'])
+        if bg_img:
+            template_data['dynamic_style'] = safe(u"""
+                :root {
+                    --bg-img: url("%s");
+                }
+                """ % cgi.escape(bg_img, True))
 
 
 @defer.inlineCallbacks