Commit 85f5ef66 authored by Sven Franck's avatar Sven Franck

erp5_web_renderjs_ui: add compatibility with other bt5 by calling same method names

parent 443df1d5
......@@ -75,7 +75,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/WebManifest_viewAsWeb</string> </value>
<value> <string>string:${object_url}/WebPage_viewAsWeb</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -75,7 +75,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/WebScript_viewAsWeb</string> </value>
<value> <string>string:${object_url}/WebPage_viewAsWeb</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -75,7 +75,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/WebStyle_viewAsWeb</string> </value>
<value> <string>string:${object_url}/WebPage_viewAsWeb</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
if REQUEST is None:\n
REQUEST = context.REQUEST\n
if response is None:\n
response = REQUEST.RESPONSE\n
\n
web_script = context\n
\n
modified_header = REQUEST.getHeader(\'If-Modified-Since\', \'\')\n
\n
if (modified_header != "") and (web_script.getModificationDate().rfc822() == DateTime(modified_header).rfc822()):\n
response.setStatus(304)\n
return ""\n
\n
js_content = web_script.getTextContent()\n
\n
response.setHeader(\'Content-Type\', \'text/cache-manifest\')\n
return js_content\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None, response=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebManifest_viewAsWeb</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -55,23 +55,36 @@
if response is None:\n
response = REQUEST.RESPONSE\n
\n
web_script = context\n
web_page = context\n
\n
if REQUEST.getHeader(\'If-Modified-Since\', \'\') == web_script.getModificationDate().rfc822():\n
if REQUEST.getHeader(\'If-Modified-Since\', \'\') == web_page.getModificationDate().rfc822():\n
response.setStatus(304)\n
return ""\n
\n
js_content = web_script.getTextContent()\n
portal_type = web_page.getPortalType()\n
web_content = web_page.getTextContent()\n
\n
# Do not allow to put inside an iframe\n
response.setHeader("X-Frame-Options", "SAMEORIGIN")\n
response.setHeader("X-Content-Type-Options", "nosniff")\n
# set headers depending on type of script\n
if (portal_type == "Web Script"):\n
response.setHeader(\'Content-Type\', \'application/javascript\')\n
\n
# Only fetch code (html, js, css, image) and data from this ERP5, to prevent any data leak as the web site do not control the gadget\'s code\n
response.setHeader("Content-Security-Policy", "default-src \'none\'; img-src \'self\' data:; media-src \'self\'; connect-src \'self\'; script-src \'self\' \'unsafe-eval\'; font-src netdna.bootstrapcdn.com; style-src \'self\' netdna.bootstrapcdn.com \'unsafe-inline\' data:; frame-src \'self\' data:")\n
elif (portal_type == "Web Style"):\n
response.setHeader(\'Content-Type\', \'text/css\')\n
\n
response.setHeader(\'Content-Type\', \'text/html\')\n
return js_content\n
elif (portal_type == "Web Manifest"):\n
response.setHeader(\'Content-Type\', \'text/cache-manifest\')\n
\n
else:\n
# Do not allow to put inside an iframe\n
response.setHeader("X-Frame-Options", "SAMEORIGIN")\n
response.setHeader("X-Content-Type-Options", "nosniff")\n
\n
# Only fetch code (html, js, css, image) and data from this ERP5, to prevent any data leak as the web site do not control the gadget\'s code\n
response.setHeader("Content-Security-Policy", "default-src \'none\'; img-src \'self\' data:; media-src \'self\'; connect-src \'self\'; script-src \'self\' \'unsafe-eval\'; font-src netdna.bootstrapcdn.com; style-src \'self\' netdna.bootstrapcdn.com \'unsafe-inline\' data:; frame-src \'self\' data:")\n
\n
response.setHeader(\'Content-Type\', \'text/html\')\n
\n
return web_content\n
</string> </value>
</item>
<item>
......@@ -80,7 +93,7 @@ return js_content\n
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebPage_viewAsGadget</string> </value>
<value> <string>WebPage_viewAsWeb</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from DateTime import DateTime\n
if REQUEST is None:\n
REQUEST = context.REQUEST\n
if response is None:\n
response = REQUEST.RESPONSE\n
\n
web_script = context\n
\n
modified_header = REQUEST.getHeader(\'If-Modified-Since\', \'\')\n
\n
if (modified_header != "") and (web_script.getModificationDate().rfc822() == DateTime(modified_header).rfc822()):\n
response.setStatus(304)\n
return ""\n
\n
js_content = web_script.getTextContent()\n
\n
response.setHeader(\'Content-Type\', \'application/javascript\')\n
return js_content\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None, response=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebScript_viewAsWeb</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -58,7 +58,7 @@ if response is None:\n
web_section = context\n
default_web_page = web_section.getDefaultDocumentValue()\n
\n
return default_web_page.WebPage_viewAsGadget()\n
return default_web_page.WebPage_viewAsWeb()\n
</string> </value>
</item>
<item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>if REQUEST is None:\n
REQUEST = context.REQUEST\n
if response is None:\n
response = REQUEST.RESPONSE\n
\n
web_script = context\n
\n
modified_header = REQUEST.getHeader(\'If-Modified-Since\', \'\')\n
\n
if (modified_header != "") and (web_script.getModificationDate().rfc822() == DateTime(modified_header).rfc822()):\n
response.setStatus(304)\n
return ""\n
\n
js_content = web_script.getTextContent()\n
\n
response.setHeader(\'Content-Type\', \'text/css\')\n
return js_content\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>REQUEST=None, response=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebStyle_viewAsWeb</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment