From 036ead920a1eaae2b6788c81cc0b4dc8373d2872 Mon Sep 17 00:00:00 2001 From: drfho Date: Sat, 14 Dec 2024 18:45:20 +0800 Subject: [PATCH] Added hash to minified JS aggregate for cache refreshing --- .gitignore | 1 + Products/zms/__init__.py | 11 +++++++++++ Products/zms/_confmanager.py | 1 + Products/zms/zpt/common/zmi_html_head.zpt | 4 +++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 410739dbd..f47b661d2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.egg-info/ *.pyc Products/zms/plugins/www/zms-all.min.js +Products/zms/plugins/www/zms-all.min.js.hash Products/zms/plugins/www/i18n/*.js Products/zms/overrides.zcml .vscode/ diff --git a/Products/zms/__init__.py b/Products/zms/__init__.py index 94533f75e..0be807823 100644 --- a/Products/zms/__init__.py +++ b/Products/zms/__init__.py @@ -252,6 +252,17 @@ def initialize(context): standard.writeStdout(context, "add %s (Packed: %i -> %i Bytes)"%(fn, l0, l1)) fileobj.write(fc) fileobj.close() + # Before closing minified file finally create hash + # of packed file content and write it into separate file + min_fileobj = open(fileobj.name, 'r') + min_hash = standard.encrypt_password(min_fileobj.read(),hex=True) + min_hash_fileobj = open(fileobj.name + '.hash', 'w') + min_hash_fileobj.write(min_hash) + OFS.misc_.misc_.zms['confdict']['js_min.hash'] = min_hash + standard.writeStdout(context, "New minify hash created: %s" % min_hash_fileobj.name) + min_hash_fileobj.close() + min_fileobj.close() + # automated generation of language JavaScript from xml.dom import minidom diff --git a/Products/zms/_confmanager.py b/Products/zms/_confmanager.py index 347c0662e..90d838bac 100644 --- a/Products/zms/_confmanager.py +++ b/Products/zms/_confmanager.py @@ -471,6 +471,7 @@ def getConfPropertiesDefaults(self): {'key':'jquery.ui','title':'JQuery UI version','desc':'JQuery UI version.','datatype':'string'}, {'key':'jquery.plugin.version','title':'JQuery plugin version','desc':'JQuery plugin version','datatype':'string'}, {'key':'jquery.plugin.extensions','title':'JQuery plugin extensions','desc':'JQuery plugin extensions','datatype':'string'}, + {'key':'js_min.hash','title':'Hash value of minified ZMI-Javascript aggregate','desc':'Use hash-value of the minified ZMI-Javascript aggregate file for cache bustering','datatype':'string'}, {'key':'ZMS.blobfields.grant_public_access','title':'Grant public access to blob-fields','desc':'Blob-fields in restricted nodes are not visible. You may grant public access to blob-fields by activating this option.','datatype':'boolean'}, {'key':'ZMS.blobfields.accept_ranges','title':'Http-Header Accept-Ranges for blob-fields','desc':'Http-Header Accept-Ranges for blob-fields.','datatype':'string','default':'bytes'}, {'key':'ZMS.locale.amount.unit','title':'Currency unit for amount-types','desc':'The currency unit used for amount-types.','datatype':'string','default':'EUR'}, diff --git a/Products/zms/zpt/common/zmi_html_head.zpt b/Products/zms/zpt/common/zmi_html_head.zpt index 96cf196f4..6e4c1d197 100644 --- a/Products/zms/zpt/common/zmi_html_head.zpt +++ b/Products/zms/zpt/common/zmi_html_head.zpt @@ -27,7 +27,9 @@ + >