Commit 800fa2df authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

erp5_officejs_appstore_base: Use dedicated application redirect manifest

parent 8158b09e
<!DOCTYPE html> <!DOCTYPE html>
<html manifest="officejsredirect.appcache"> <html manifest="${application_appcache}">
<body> <body>
<SCRIPT LANGUAGE="JavaScript"> <script language="JavaScript">
document.location.href="${latest_version}/" function redirect_version() {
</SCRIPT> document.location.href="${latest_version}/"
};
window.applicationCache.addEventListener('cached',redirect_version);
window.applicationCache.addEventListener('noupdate',redirect_version);
window.applicationCache.addEventListener('updateready', function(){window.location.reload()});
// XXX This is a hack for when the network is too slow.
window.setTimeout(redirect_version, 10000);
</script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>950.60513.63859.18056</string> </value> <value> <string>951.19443.53509.7185</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -262,7 +262,7 @@ ...@@ -262,7 +262,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1462201287.71</float> <float>1463665193.7</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
portal = context.getPortalObject() portal = context.getPortalObject()
software_release = context software_release = context
# Publish Web Document
web_document_list = portal.portal_catalog( web_document_list = portal.portal_catalog(
portal_type=portal.getPortalDocumentTypeList(), portal_type=portal.getPortalDocumentTypeList(),
strict_follow_up_uid=software_release.getUid(), strict_follow_up_uid=software_release.getUid(),
validation_state="submitted", validation_state="submitted",
) )
today = DateTime().earliestTime() today = DateTime().earliestTime()
for web_document in web_document_list: for web_document in web_document_list:
web_document.setEffectiveDate(today) web_document.setEffectiveDate(today)
web_document.publish() web_document.publish()
software_product = context.getFollowUpValue(portal_type="Software Product") software_product = context.getFollowUpValue(portal_type="Software Product")
web_site = software_product.SoftwareProduct_getRelatedWebSite() web_site = software_product.SoftwareProduct_getRelatedWebSite()
# Publish Web Site, Websection and update version
today = DateTime().earliestTime() today = DateTime().earliestTime()
if web_site.getValidationState() != 'published': if web_site.getValidationState() != 'published':
web_site.setEffectiveDate(today) web_site.setEffectiveDate(today)
...@@ -33,6 +30,28 @@ web_site.edit( ...@@ -33,6 +30,28 @@ web_site.edit(
configuration_latest_version=software_release.getVersion(), configuration_latest_version=software_release.getVersion(),
) )
# Update appcache
web_manifest_reference = web_site.getId() + ".appcache"
web_manifest = portal.portal_catalog.getResultValue(
portal_type="Web Manifest",
reference=web_manifest_reference,
)
if not web_manifest:
web_manifest = portal.web_page_module.newContent(
portal_type="Web Manifest",
reference=web_manifest_reference,
title=web_site.getTitle() + " Manifest",
)
web_manifest.publishAlive()
web_manifest.setData("""CACHE MANIFEST
# generated on %s
CACHE:
NETWORK:
*""" % (DateTime().rfc822()))
# Is latest Websection what we want? # Is latest Websection what we want?
if "latest" not in web_site.objectIds(): if "latest" not in web_site.objectIds():
latest_web_section = version_web_section.Base_createCloneDocument(batch_mode=True) latest_web_section = version_web_section.Base_createCloneDocument(batch_mode=True)
...@@ -44,8 +63,3 @@ else: ...@@ -44,8 +63,3 @@ else:
latest_web_section.setCriterion('version', software_release.getVersion()) latest_web_section.setCriterion('version', software_release.getVersion())
latest_web_section.setTitle(version_web_section.getTitle()) latest_web_section.setTitle(version_web_section.getTitle())
latest_web_section.setAggregate(version_web_section.getAggregate()) latest_web_section.setAggregate(version_web_section.getAggregate())
# Archive former versions
#for web_section in web_site.objectValues(portal_type="Web Section"):
# if web_section.getId() not in ('latest', 'development', 'hateoas', version_web_section.getId()):
# web_section.setCriterion('validation_state', 'archived')
...@@ -9,4 +9,5 @@ web_section = REQUEST.get("current_web_section") ...@@ -9,4 +9,5 @@ web_section = REQUEST.get("current_web_section")
return default_web_page.WebPage_viewAsWeb(mapping_dict={ return default_web_page.WebPage_viewAsWeb(mapping_dict={
"latest_version": web_section.getLayoutProperty("configuration_latest_version", default="development"), "latest_version": web_section.getLayoutProperty("configuration_latest_version", default="development"),
"application_appcache": web_section.getId() + ".appcache",
}) })
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