dynamically load a /versions.html_fragment file so that all old versions get the complete dropdown list of versions to select

Docker-DCO-1.1-Signed-off-by: SvenDowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
This commit is contained in:
SvenDowideit 2014-07-21 15:51:14 +10:00
parent c550ad5900
commit 5cd0f0824d
3 changed files with 24 additions and 13 deletions

View File

@ -27,10 +27,13 @@ ADD MAINTAINERS /docs/sources/humans.txt
WORKDIR /docs
RUN VERSION=$(cat /docs/VERSION) &&\
MAJOR_MINOR="${VERSION%.*}" &&\
for i in $(seq $MAJOR_MINOR -0.1 1.0) ; do echo "<li><a class='version' href='/v$i'>Version v$i</a></li>" ; done > /docs/sources/versions.html_fragment &&\
GIT_BRANCH=$(cat /docs/GIT_BRANCH) &&\
GITCOMMIT=$(cat /docs/GITCOMMIT) &&\
AWS_S3_BUCKET=$(cat /docs/AWS_S3_BUCKET) &&\
sed -i "s/\$VERSION/$VERSION/g" /docs/theme/mkdocs/base.html &&\
sed -i "s/\$MAJOR_MINOR/v$MAJOR_MINOR/g" /docs/theme/mkdocs/base.html &&\
sed -i "s/\$GITCOMMIT/$GITCOMMIT/g" /docs/theme/mkdocs/base.html &&\
sed -i "s/\$GIT_BRANCH/$GIT_BRANCH/g" /docs/theme/mkdocs/base.html &&\
sed -i "s/\$AWS_S3_BUCKET/$AWS_S3_BUCKET/g" /docs/theme/mkdocs/base.html

View File

@ -27,6 +27,10 @@ if [ "$$AWS_S3_BUCKET" == "docs.docker.com" ]; then
fi
fi
# Remove the last version - 1.0.2-dev -> 1.0
MAJOR_MINOR="v${VERSION%.*}"
export MAJOR_MINOR
export BUCKET=$AWS_S3_BUCKET
export AWS_CONFIG_FILE=$(pwd)/awsconfig
@ -69,7 +73,8 @@ upload_current_documentation() {
# a really complicated way to send only the files we want
# if there are too many in any one set, aws s3 sync seems to fall over with 2 files to go
endings=( json html xml css js gif png JPG ttf svg woff)
# versions.html_fragment
endings=( json html xml css js gif png JPG ttf svg woff html_fragment )
for i in ${endings[@]}; do
include=""
for j in ${endings[@]}; do
@ -104,9 +109,6 @@ setup_s3
build_current_documentation
upload_current_documentation
# Remove the last version - 1.0.2-dev -> 1.0
MAJOR_MINOR="v${VERSION%.*}"
#build again with /v1.0/ prefix
sed -i "s/^site_url:.*/site_url: \/$MAJOR_MINOR\//" mkdocs.yml
build_current_documentation

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
{% set docker_version = "$VERSION" %}{% set docker_commit = "$GITCOMMIT" %}{% set docker_branch = "$GIT_BRANCH" %}{% set aws_bucket = "$AWS_S3_BUCKET" %}
{% set docker_version = "$VERSION" %}{% set major_minor = "$MAJOR_MINOR" %}{% set docker_commit = "$GITCOMMIT" %}{% set docker_branch = "$GIT_BRANCH" %}{% set aws_bucket = "$AWS_S3_BUCKET" %}
<meta name="docker_version" content="{{ docker_version }}">
<meta name="docker_git_branch" content="{{ docker_branch }}">
<meta name="docker_git_commit" content="{{ docker_commit }}">
@ -52,17 +52,13 @@
<h1 class="header2">{{ current_page.title }}</h1>
</div>
<div class="span5">
<div id="versionnav" class="span2 pull-right">
<ul class="nav version">
<div id="versionnav" class="span3 pull-right">
<ul class="nav version pull-right">
<li class="dropdown">
<a id="logged-in-header-username" class="dropdown-toggle" data-toggle="dropdown" href="#">
Latest (Version 1.3)
Latest (Version {{ major_minor }})
</a>
<ul class="dropdown-menu pull-right">
<li><a href="https://hub.docker.com/">Version 1.3</a></li>
<li><a href="https://hub.docker.com/">Version 1.2</a></li>
<li><a href="https://hub.docker.com/">Version 1.1</a></li>
<li><a href="https://hub.docker.com/">Version 1.0</a></li>
<ul id="documentation-version-list" class="dropdown-menu pull-right">
<li role="presentation" class="divider"></li>
<li> <a class="home-link3 tertiary-nav" href="https://github.com/dotcloud/docker/blob/master/docs/sources/{{ current_page.input_path }}" >Edit on GitHub</a></li>
</ul>
@ -148,6 +144,16 @@ piCId = '1482';
});
$(document).ready(function() {
$('#content').css("min-height", $(window).height() - 553 );
// load the complete versions list
$.get("/versions.html_fragment", function( data ) {
$('#documentation-version-list').prepend(data);
//remove any "/v1.1/" bits from font.
path = document.location.pathname.replace(/^\/v\d\.\d/, "");
$('#documentation-version-list a.version').each(function(i, e) {
e.href = e.href+path;
$(e).removeClass()
});
});
})
var userName = getCookie('docker_sso_username');
if (userName) {