[WIP] Add dropdown version selection to docsite (#55655)

* docs: Add way to select version for documentation
pull/57713/head
Sandra McCann 5 years ago committed by Alicia Cozine
parent 8b6c6cf302
commit f3720c90e0

@ -0,0 +1,29 @@
<!--- Based on https://github.com/rtfd/sphinx_rtd_theme/pull/438/files -->
{# Creates dropdown version selection in the top-left navigation. #}
<div class="version">
{% if not READTHEDOCS %}
<div class="version-dropdown">
<select class="version-list" id="version-list" onchange="javascript:location.href = this.value;">
<script> x = document.getElementById("version-list"); </script>
{% for slug in available_versions %}
<script>
current_url = window.location.href;
option = document.createElement("option");
option.text = "{{ slug }}";
if ( "{{ slug }}" == "{{ current_version }}" ) {
option.selected = true;
}
if (current_url.search("{{ current_version }}") > -1) {
option.value = current_url.replace("{{ current_version }}","{{ slug }}");
} else {
option.value = current_url.replace("latest","{{ slug }}");
}
x.add(option);
</script>
{% endfor %}
</select>
</div>
{% else %}
{{ nav_version }}
{% endif %}
</div>

@ -17,7 +17,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript" src="//www.redhat.com/dtm.js"></script> <script type="text/javascript" src="//www.redhat.com/dtm.js"></script>
<meta class="swiftype" name="published_at" data-type="date" content="2017-12-13" /> <meta class="swiftype" name="published_at" data-type="date" content="2017-12-13" />
<meta class="swiftype" name="version" data-type="string" content="3.2.2"> <meta class="swiftype" name="version" data-type="string" content="3.2.2">
<!-- Google Tag Manager Data Layer --> <!-- Google Tag Manager Data Layer -->
@ -113,7 +113,7 @@
</head> </head>
<body class="wy-body-for-nav"> <body class="wy-body-for-nav">
<!-- Google Tag Manager --> <!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-PSB293" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-PSB293" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
@ -131,7 +131,7 @@
</div> </div>
<a class="DocSite-nav" href="/" style="padding-bottom: 30px;"> <a class="DocSite-nav" href="/" style="padding-bottom: 30px;">
<img class="DocSiteNav-logo" <img class="DocSiteNav-logo"
src="{{ pathto('_static/', 1) }}images/logo_invert.png" src="{{ pathto('_static/', 1) }}images/logo_invert.png"
alt="Ansible Logo"> alt="Ansible Logo">
@ -145,32 +145,28 @@
{# SIDE NAV, TOGGLES ON MOBILE #} {# SIDE NAV, TOGGLES ON MOBILE #}
<nav data-toggle="wy-nav-shift" class="wy-nav-side"> <nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll"> <div class="wy-side-scroll">
<div class="wy-side-nav-search"> <div class="wy-side-nav-search">
{% block sidebartitle %} {% block sidebartitle %}
<div style="background-color:#5bbdbf;height=80px;margin:'auto auto auto auto'"> <div style="background-color:#5bbdbf;height=80px;margin:'auto auto auto auto'">
<a class="DocSiteProduct-header DocSiteProduct-header--core" href="/"> <a class="DocSiteProduct-header DocSiteProduct-header--core" href="/">
<div class="DocSiteProduct-productName"> <div class="DocSiteProduct-productName">
<div class="DocSiteProduct-logoText"> <div class="DocSiteProduct-logoText">
Ansible Ansible
<div class="DocSiteProduct-CurrentVersion" align="right"> <div class="DocSiteProduct-CurrentVersion" align="right">{{ current_version }}</div>
devel
</div>
</div> </div>
</div> </div>
</a> </a>
</div>
<div class="DocSiteProduct-CheckVersionPara">For previous versions, see the <a class="DocSiteProduct-versionheader" href="/#coreversionselect">documentation archive.</a></div> {% include "ansible_versions.html" %}
</div>
<div class="wy-side-nav-search" style="background-color#5bbdbf;height=80px;margin:'auto auto auto auto'"> <div class="wy-side-nav-search" style="background-color#5bbdbf;height=80px;margin:'auto auto auto auto'">
<!-- <a href="{{ pathto(master_doc) }}" class="icon icon-home"> {{ project }}</a> --> {% include "searchbox.html" %}
{% include "searchbox.html" %} </div>
</div>
{% endblock %} {% endblock %}
</div> </div>
@ -194,19 +190,18 @@
{% endif %} {% endif %}
{% endblock %} {% endblock %}
</div> </div>
<!-- changeable widget --> <!-- changeable widget -->
<div id="sideBanner">
<br/> <div id="sideBanner">
<a href="https://www.ansible.com/docs-left?utm_source=docs"> <br/>
<img style="border-width:0px;" src="https://cdn2.hubspot.net/hubfs/330046/docs-graphics/ASB-docs-left-rail.png" /> <a href="https://www.ansible.com/docs-left?utm_source=docs">
</a> <img style="border-width:0px;" src="https://cdn2.hubspot.net/hubfs/330046/docs-graphics/ASB-docs-left-rail.png" />
</div> </a>
<br/><br/><br/>
</div>
</div> </div>
&nbsp;
</nav> </nav>
</div> </div>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
@ -248,7 +243,6 @@
</section> </section>
</div> </div>
{% include "versions.html" %}
{% if not embedded %} {% if not embedded %}

@ -34,4 +34,3 @@
</div> </div>
</div> </div>
{% endif %} {% endif %}

@ -34,7 +34,7 @@ sys.path.append(os.path.abspath(os.path.join('..', '_extensions')))
# the repository version needs to be the one that is loaded: # the repository version needs to be the one that is loaded:
sys.path.insert(0, os.path.abspath(os.path.join('..', '..', '..', 'lib'))) sys.path.insert(0, os.path.abspath(os.path.join('..', '..', '..', 'lib')))
VERSION = '2.8' VERSION = 'devel'
AUTHOR = 'Ansible, Inc' AUTHOR = 'Ansible, Inc'
@ -263,3 +263,9 @@ autoclass_content = 'both'
intersphinx_mapping = {'python': ('https://docs.python.org/2/', (None, '../python2-2.7.13.inv')), intersphinx_mapping = {'python': ('https://docs.python.org/2/', (None, '../python2-2.7.13.inv')),
'python3': ('https://docs.python.org/3/', (None, '../python3-3.6.2.inv')), 'python3': ('https://docs.python.org/3/', (None, '../python3-3.6.2.inv')),
'jinja2': ('http://jinja.pocoo.org/docs/', (None, '../jinja2-2.9.7.inv'))} 'jinja2': ('http://jinja.pocoo.org/docs/', (None, '../jinja2-2.9.7.inv'))}
# list specifically out of order to make latest work
html_context = {
'current_version': version,
'available_versions': ('latest', '2.7', '2.6', 'devel')
}

Loading…
Cancel
Save