Commit e0d2316e authored by Roque's avatar Roque

[ERP5 Master appstore_base] Officejs appstore service worker

See merge request !1512
parents eed0e738 250fdf8a
Pipeline #18965 failed with stage
in 0 seconds
......@@ -80,6 +80,7 @@
<string>my_configuration_cache_file</string>
<string>my_configuration_webapp_manifest_url</string>
<string>my_configuration_redirect_url</string>
<string>my_configuration_precache_manifest_script</string>
</list>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_configuration_precache_manifest_script</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_reference</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Precache Manifest Script</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<!DOCTYPE html>
<html manifest="WebSection_renderOfficeJSRedirectAppCache">
<body>
<script language="JavaScript">
function redirect_version() {
document.location.replace("${latest_version}/" + document.location.hash)
};
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="officejs-redirect.js"></script>
<title>OfficeJS Redirect</title>
<script data-appconfig="latest_version" type="text/x-renderjs-configuration">${latest_version}</script>
</head>
var timeout_duration = 10000;
try {
window.applicationCache.addEventListener('cached',redirect_version);
window.applicationCache.addEventListener('noupdate',redirect_version);
window.applicationCache.addEventListener('error',redirect_version);
window.applicationCache.addEventListener('updateready', function(){window.location.reload()});
} catch (e) {
timeout_duration = 1;
}
// XXX This is a hack for when the network is too slow, or if appcache is not supported anymore
window.setTimeout(redirect_version, timeout_duration);
</script>
<body>
</body>
</html>
\ No newline at end of file
......@@ -248,7 +248,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>984.41193.2075.29252</string> </value>
<value> <string>996.46889.45254.33041</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1599639175.46</float>
<float>1639062670.98</float>
<string>UTC</string>
</tuple>
</state>
......
/*globals window, document, RSVP, rJS, navigator*/
/*jslint indent: 2, maxlen: 80, nomen: true*/
(function (window, document, RSVP, rJS, navigator) {
"use strict";
rJS(window)
.declareService(function () {
var latest_version = document.head.querySelector(
'script[data-appconfig="latest_version"]'
).textContent,
queue = new RSVP.Queue();
// Make this redirection compatible with no-service-worker browsers
if ('serviceWorker' in navigator) {
queue.push(function () {
return navigator.serviceWorker.register(
"gadget_erp5_serviceworker.js");
});
}
return queue
.push(function () {
document.location.replace(latest_version + "/" +
document.location.hash);
});
});
}(window, document, RSVP, rJS, navigator));
\ No newline at end of file
......@@ -144,6 +144,26 @@
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_latest_version</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_precache_manifest_script</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
......@@ -176,7 +196,15 @@
</item>
<item>
<key> <string>configuration_content_security_policy</string> </key>
<value> <string>default-src \'self\'; script-src \'unsafe-inline\';</string> </value>
<value> <string>default-src \'self\';</string> </value>
</item>
<item>
<key> <string>configuration_latest_version</string> </key>
<value> <string>development</string> </value>
</item>
<item>
<key> <string>configuration_precache_manifest_script</string> </key>
<value> <string>WebSection_getAppstorePrecacheManifest</string> </value>
</item>
<item>
<key> <string>configuration_x_frame_options</string> </key>
......@@ -425,7 +453,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.65259.47363.59801</string> </value>
<value> <string>996.31313.30780.31453</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -443,7 +471,7 @@
</tuple>
<state>
<tuple>
<float>1559055460.25</float>
<float>1639493797.36</float>
<string>UTC</string>
</tuple>
</state>
......
# minimum list of required files for appstore service worker
url_list = [
'./',
'rsvp.js',
'renderjs.js',
'officejs-redirect.js',
'favicon.ico'
]
return list(set(url_list))
<?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>_Cacheable__manager_id</string> </key>
<value> <string>must_revalidate_http_cache</string> </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>REQUEST=None</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Anonymous</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_getAppstorePrecacheManifest</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -33,7 +33,10 @@ if (portal_type == "Web Script"):
web_content = web_page.TextDocument_substituteTextContent(web_content, mapping_dict={
'modification_date': modification_date_string,
# Make JSLint happy for the service worker code
'required_url_list': json.dumps(web_section.WebSection_getPrecacheManifest())
'required_url_list': json.dumps(
getattr(web_section, web_section.getLayoutProperty("configuration_precache_manifest_script",
default="WebSection_getPrecacheManifest"))()
)
})
elif (portal_type == "Web Style"):
......
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