Mercurial > hg > nginx-site
comparison xslt/banner.xslt @ 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 |
comparison
equal
deleted
inserted
replaced
2845:a3aee2697d4e | 2846:fdf1464e1977 |
---|---|
1 <?xml version="1.0" encoding="utf-8"?> | |
2 <!-- | |
3 Copyright (C) Nginx, Inc. | |
4 --> | |
5 | |
6 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> | |
7 | |
8 <xsl:variable select="'/banner/banner.html'" name="BANNER"/> | |
9 | |
10 <xsl:template name="banner_link"> | |
11 <xsl:choose><xsl:when test="substring-after($DIRNAME, '/')"> | |
12 <xsl:value-of select=" concat($ROOT, $BANNER) "/> | |
13 </xsl:when><xsl:otherwise> | |
14 <xsl:value-of select=" substring-after($BANNER, '/') "/> | |
15 </xsl:otherwise></xsl:choose> | |
16 </xsl:template> | |
17 | |
18 <xsl:template name="banner"> | |
19 | |
20 <script> | |
21 window.addEventListener("load", function(e) { | |
22 fetch("<xsl:call-template name="banner_link"/>") | |
23 .then((response) => response.text()) | |
24 .then((resp) => { | |
25 document.getElementById("banner").innerHTML = resp; | |
26 }) | |
27 .catch((error) => { | |
28 console.warn(error); | |
29 }); | |
30 }); | |
31 </script> | |
32 | |
33 </xsl:template> | |
34 | |
35 </xsl:stylesheet> |