diff --git a/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/Base_downloadWithCors.py b/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/Base_downloadWithCors.py index d7c92075d26c0b437c1736a3ba1b6634b2b7c1e4..22008651372fdac02881b309aa64303bb918fd66 100644 --- a/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/Base_downloadWithCors.py +++ b/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/Base_downloadWithCors.py @@ -1,2 +1,6 @@ context.Base_prepareCorsResponse(RESPONSE=context.REQUEST.RESPONSE) +# XXX Base_download redirects to an HTML page on error ! +# So the client resend a request to the given HTML page (which is bad), +# and CORS headers won't be set (which is correct) leading to +# request failure on app.officejs ! return context.Base_download(*args, **kw) diff --git a/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/Document_downloadForOnlyOfficeApp.py b/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/Document_downloadForOnlyOfficeApp.py new file mode 100644 index 0000000000000000000000000000000000000000..77e6dd22d8a09eb5fdf2ba12fe8166abb52f3db8 --- /dev/null +++ b/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/Document_downloadForOnlyOfficeApp.py @@ -0,0 +1,9 @@ +request = context.REQUEST +response = request.RESPONSE +context.Base_prepareCorsResponse(RESPONSE=response) +content_type = context.getContentType() +if (not content_type) or content_type.startswith("application/x-asc-"): + return context.index_html(request, response, format=None, inline=inline) +if context.getExternalProcessingState() == "converted": + return context.index_html(request, response, format="html", inline=inline) +return "No Data available (maybe wrong format or not ready yet)" diff --git a/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/Document_downloadForOnlyOfficeApp.xml b/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/Document_downloadForOnlyOfficeApp.xml new file mode 100644 index 0000000000000000000000000000000000000000..bb4572d29b3f3d62ec71d251a065a6b1806e35a7 --- /dev/null +++ b/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/Document_downloadForOnlyOfficeApp.xml @@ -0,0 +1,62 @@ +<?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>_params</string> </key> + <value> <string>inline=False</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Document_downloadForOnlyOfficeApp</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/OOoDocument_viewAsJio/my_data.xml b/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/OOoDocument_viewAsJio/my_data.xml index d8514dc67c5098ff39fc94250a87b1d294941fb1..202568977db80917c7b89104b3def4efc0a405d3 100644 --- a/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/OOoDocument_viewAsJio/my_data.xml +++ b/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/OOoDocument_viewAsJio/my_data.xml @@ -294,7 +294,7 @@ <dictionary> <item> <key> <string>_text</string> </key> - <value> <string>python: not here.getContentType() or here.getContentType().startswith("application/x-asc")</string> </value> + <value> <string>python: (not here.getContentType() and (not here.getData() or here.getData()[3:7] == "Y;v2")) or (here.getContentType().startswith("application/x-asc") and (not here.getData() or here.getData()[3:7] == "Y;v2"))</string> </value> </item> </dictionary> </pickle> diff --git a/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/OOoDocument_viewAsJio/your_data.xml b/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/OOoDocument_viewAsJio/your_data.xml index d1eb65c2a11e352994a7b754b5ea1722714790cc..0ac5348bf3740394cab216eea2603eec7f15ef3b 100644 --- a/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/OOoDocument_viewAsJio/your_data.xml +++ b/bt5/erp5_officejs_connector/SkinTemplateItem/portal_skins/erp5_officejs_jio_connector/OOoDocument_viewAsJio/your_data.xml @@ -294,7 +294,7 @@ <dictionary> <item> <key> <string>_text</string> </key> - <value> <string>python: here.getContentType() and not here.getContentType().startswith("application/x-asc")</string> </value> + <value> <string>python: here.getContentType() and (not here.getContentType().startswith("application/x-asc") or (here.getData() and not here.getData()[3:7] == "Y;v2"))</string> </value> </item> </dictionary> </pickle>