summaryrefslogtreecommitdiff
path: root/docs/docsite/.templates/banner.html
blob: 55c5b6f4b3ff8533997d3fcad4dc2e002c91815d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{% if is_eol %}
{# Creates a banner at the top of the page for EOL versions. #}
<div id='banner' class='Admonition caution'>
  <p>You are reading an unmaintained version of the Ansible documentation. Unmaintained Ansible versions can contain unfixed security vulnerabilities (CVE). Please upgrade to a maintained version. See <a href="/ansible/latest/">the latest Ansible documentation</a>.</p>
</div>
{% else %}
  <script>
    function startsWith(str, needle) {
      return str.slice(0, needle.length) == needle
    }
    function startsWithOneOf(str, needles) {
      return needles.some(function (needle) {
        return startsWith(str, needle);
      });
    }
    var banner = '';
      var extra_banner = '';
    /*use extra_banner for when marketing wants something extra, like a survey or AnsibleFest notice *
    var extra_banner =
      '<div id="latest_extra_banner_id" class="admonition important">' +
      '<br>' +
      '<p>' +
        'Immerse yourself in the automation experience October 18-19 in Chicago. ' +
      '<p>' +
        'Join us for AnsibleFest 2022. ' +
      '<pr>' +
        '<a href="https://www.ansible.com/ansiblefest?intcmp=7013a000002tuDxAAI">Register now!</a> ' +
      '</p>' +
      '<br>' +
      '</div>'; */
    // Create a banner if we're not on the official docs site
    if (location.host == "docs.testing.ansible.com") {
      document.write('<div id="testing_banner_id" class="admonition important">' +
                     '<p>This is the testing site for Ansible Documentation. Unless you are reviewing pre-production changes, please visit the <a href="https://docs.ansible.com/ansible/latest/">official documentation website</a>.</p> <p></p>' +
                     '</div>');
    }
    {% if available_versions is defined %}
      // Create a banner
      current_url_path = window.location.pathname;

      var important = false;
      var msg = '<p>';
      if (startsWith(current_url_path, "/ansible-core/")) {
        msg += 'You are reading documentation for Ansible Core, which contains no plugins except for those in ansible.builtin. For documentation of the Ansible package, go to <a href="/ansible/latest">the latest documentation</a>.';
      } else if (startsWithOneOf(current_url_path, ["/ansible/latest/", "/ansible/{{ latest_version }}/"])) {
        /* temp extra banner to advertise AnsibeFest2021 */
        banner += extra_banner;

        msg += 'You are reading the <b>latest</b> (stable) community version of the Ansible documentation. If you are a Red Hat customer, refer to the <a href="https://access.redhat.com/support/policy/updates/ansible-automation-platform">Ansible Automation Platform Life Cycle</a> page for subscription details.';
      } else if (startsWith(current_url_path, "/ansible/2.9/")) {
        msg += 'You are reading the latest Red Hat released version of the Ansible documentation. Community users can use this version, or select <b>latest</b> from the version selector to the left for the most recent community version.';
      } else if (startsWith(current_url_path, "/ansible/devel/")) {
        /* temp extra banner to advertise AnsibleFest2021 */
        banner += extra_banner;

        /* temp banner to advertise survey
        important = true;
        msg += 'Please take our <a href="https://www.surveymonkey.co.uk/r/B9V3CDY">Docs survey</a> before December 31 to help us improve Ansible documentation.';
        */

        msg += 'You are reading the <b>devel</b> version of the Ansible documentation - this version is not guaranteed stable. Use the version selection to the left if you want the <b>latest</b> (stable) released version.';
      } else {
        msg += 'You are reading an older version of the Ansible documentation. Use the version selection to the left if you want the <b>latest</b> (stable) released version.';
      }
      msg += '</p>';

      banner += '<div id="banner_id" class="admonition ';
      banner += important ? 'important' : 'caution';
      banner += '">';
      banner += important ? '<br>' : '';
      banner += msg;
      banner += important ? '<br>' : '';
      banner += '</div>';
      document.write(banner);
    {% endif %}
  </script>
{% endif %}