summaryrefslogtreecommitdiff
path: root/src/hydrilla/proxy/policies
diff options
context:
space:
mode:
Diffstat (limited to 'src/hydrilla/proxy/policies')
-rw-r--r--src/hydrilla/proxy/policies/js_templates/page_init_script.js.jinja3
-rw-r--r--src/hydrilla/proxy/policies/payload_resource.py7
2 files changed, 9 insertions, 1 deletions
diff --git a/src/hydrilla/proxy/policies/js_templates/page_init_script.js.jinja b/src/hydrilla/proxy/policies/js_templates/page_init_script.js.jinja
index 3a8382c..629b008 100644
--- a/src/hydrilla/proxy/policies/js_templates/page_init_script.js.jinja
+++ b/src/hydrilla/proxy/policies/js_templates/page_init_script.js.jinja
@@ -65,6 +65,9 @@ code in a proprietary program, I am not going to enforce this in court.
}
const unique_token = decode_jinja("{{ unique_token_encoded }}");
const assets_base_url = decode_jinja("{{ assets_base_url_encoded }}");
+ window.haketilo_version = JSON.parse(
+ decode_jinja("{{ haketilo_version }}")
+ );
/* Make it possible to serialize an Error object. */
function error_data_jsonifiable(error) {
diff --git a/src/hydrilla/proxy/policies/payload_resource.py b/src/hydrilla/proxy/policies/payload_resource.py
index cda19ba..70844e6 100644
--- a/src/hydrilla/proxy/policies/payload_resource.py
+++ b/src/hydrilla/proxy/policies/payload_resource.py
@@ -64,11 +64,13 @@ import json
from threading import Lock
from base64 import b64encode
from urllib.parse import quote, parse_qs, urlparse, urlencode, urljoin
+from itertools import takewhile
import jinja2
from ...translations import smart_gettext as _
from ...url_patterns import ParsedUrl
+from ..._version import version_tuple
from .. import state
from .. import http_messages
from . import base
@@ -279,9 +281,12 @@ class PayloadResourcePolicy(PayloadAwarePolicy):
template = jinja_env.get_template('page_init_script.js.jinja')
token = self.payload_data.unique_token
base_url = self.assets_base_url(request_info.url)
+ ver = [*takewhile(lambda i: isinstance(i, int), version_tuple)]
+ ver_str = json.dumps(ver)
js = template.render(
unique_token_encoded = encode_string_for_js(token),
- assets_base_url_encoded = encode_string_for_js(base_url)
+ assets_base_url_encoded = encode_string_for_js(base_url),
+ haketilo_version = encode_string_for_js(ver_str)
)
return http_messages.ProducedResponse(