diff xsls/banner.xsls @ 2846:fdf1464e1977

Moved banner to the external file to make partial rollout possible. An idea is to have several banners and show them with different probability specified by split directive in the nginx.conf
author Sergey Budnevitch <sb@waeme.net>
date Tue, 10 May 2022 18:07:27 +0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xsls/banner.xsls	Tue May 10 18:07:27 2022 +0400
@@ -0,0 +1,34 @@
+<!--
+  Copyright (C) Nginx, Inc.
+  -->
+
+X:stylesheet {
+
+X:var BANNER = "'/banner/banner.html'";
+
+X:template banner_link () {
+    X:if "substring-after($DIRNAME, '/')" {
+        !{ concat($ROOT, $BANNER) }
+    } else {
+        !{ substring-after($BANNER, '/') }
+    }
+}
+
+X:template banner () {
+
+    <script>
+        window.addEventListener("load", function(e) \{
+            fetch("!banner_link ()")
+                .then((response) => response.text())
+                .then((resp) => \{
+                    document.getElementById("banner").innerHTML = resp;
+                \})
+                .catch((error) => \{
+                    console.warn(error);
+                \});
+        \});
+    </script>
+
+}
+
+}