Browse code

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)

SvenDowideit authored on 2014/07/21 14:51:14
Showing 3 changed files
... ...
@@ -27,10 +27,13 @@ ADD	MAINTAINERS /docs/sources/humans.txt
27 27
 WORKDIR	/docs
28 28
 
29 29
 RUN	VERSION=$(cat /docs/VERSION)								&&\
30
+        MAJOR_MINOR="${VERSION%.*}"								&&\
31
+	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 &&\
30 32
 	GIT_BRANCH=$(cat /docs/GIT_BRANCH)							&&\
31 33
 	GITCOMMIT=$(cat /docs/GITCOMMIT)							&&\
32 34
 	AWS_S3_BUCKET=$(cat /docs/AWS_S3_BUCKET)						&&\
33 35
 	sed -i "s/\$VERSION/$VERSION/g" /docs/theme/mkdocs/base.html				&&\
36
+	sed -i "s/\$MAJOR_MINOR/v$MAJOR_MINOR/g" /docs/theme/mkdocs/base.html			&&\
34 37
 	sed -i "s/\$GITCOMMIT/$GITCOMMIT/g" /docs/theme/mkdocs/base.html			&&\
35 38
 	sed -i "s/\$GIT_BRANCH/$GIT_BRANCH/g" /docs/theme/mkdocs/base.html			&&\
36 39
 	sed -i "s/\$AWS_S3_BUCKET/$AWS_S3_BUCKET/g" /docs/theme/mkdocs/base.html
... ...
@@ -27,6 +27,10 @@ if [ "$$AWS_S3_BUCKET" == "docs.docker.com" ]; then
27 27
 	fi
28 28
 fi
29 29
 
30
+# Remove the last version - 1.0.2-dev -> 1.0
31
+MAJOR_MINOR="v${VERSION%.*}"
32
+export MAJOR_MINOR
33
+
30 34
 export BUCKET=$AWS_S3_BUCKET
31 35
 
32 36
 export AWS_CONFIG_FILE=$(pwd)/awsconfig
... ...
@@ -69,7 +73,8 @@ upload_current_documentation() {
69 69
 
70 70
 	# a really complicated way to send only the files we want
71 71
 	# if there are too many in any one set, aws s3 sync seems to fall over with 2 files to go
72
-	endings=( json html xml css js gif png JPG ttf svg woff)
72
+	#  versions.html_fragment
73
+	endings=( json html xml css js gif png JPG ttf svg woff html_fragment )
73 74
 	for i in ${endings[@]}; do
74 75
 		include=""
75 76
 		for j in ${endings[@]}; do
... ...
@@ -104,9 +109,6 @@ setup_s3
104 104
 build_current_documentation
105 105
 upload_current_documentation
106 106
 
107
-# Remove the last version - 1.0.2-dev -> 1.0
108
-MAJOR_MINOR="v${VERSION%.*}"
109
-
110 107
 #build again with /v1.0/ prefix
111 108
 sed -i "s/^site_url:.*/site_url: \/$MAJOR_MINOR\//" mkdocs.yml
112 109
 build_current_documentation
... ...
@@ -4,7 +4,7 @@
4 4
   <meta charset="utf-8">
5 5
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
6 6
   <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
7
-{% set docker_version = "$VERSION" %}{% set docker_commit = "$GITCOMMIT" %}{% set docker_branch = "$GIT_BRANCH" %}{% set aws_bucket = "$AWS_S3_BUCKET" %}
7
+  {% set docker_version = "$VERSION" %}{% set major_minor = "$MAJOR_MINOR" %}{% set docker_commit = "$GITCOMMIT" %}{% set docker_branch = "$GIT_BRANCH" %}{% set aws_bucket = "$AWS_S3_BUCKET" %}
8 8
   <meta name="docker_version" content="{{ docker_version }}">
9 9
   <meta name="docker_git_branch" content="{{ docker_branch }}">
10 10
   <meta name="docker_git_commit" content="{{ docker_commit }}">
... ...
@@ -52,17 +52,13 @@
52 52
         <h1 class="header2">{{ current_page.title }}</h1>
53 53
       </div>
54 54
       <div class="span5">
55
-        <div id="versionnav" class="span2 pull-right">
56
-          <ul class="nav version">
55
+        <div id="versionnav" class="span3 pull-right">
56
+          <ul class="nav version pull-right">
57 57
             <li class="dropdown">
58 58
               <a id="logged-in-header-username" class="dropdown-toggle" data-toggle="dropdown" href="#">
59
-  	  	  Latest (Version 1.3)
59
+		      Latest (Version {{ major_minor }})
60 60
               </a>
61
-              <ul class="dropdown-menu pull-right">
62
-                <li><a href="https://hub.docker.com/">Version 1.3</a></li>
63
-                <li><a href="https://hub.docker.com/">Version 1.2</a></li>
64
-                <li><a href="https://hub.docker.com/">Version 1.1</a></li>
65
-                <li><a href="https://hub.docker.com/">Version 1.0</a></li>
61
+              <ul id="documentation-version-list" class="dropdown-menu pull-right">
66 62
 		<li role="presentation" class="divider"></li>
67 63
 		<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>
68 64
               </ul>
... ...
@@ -148,6 +144,16 @@ piCId = '1482';
148 148
   });
149 149
   $(document).ready(function() {
150 150
     $('#content').css("min-height", $(window).height() - 553 );
151
+    // load the complete versions list
152
+    $.get("/versions.html_fragment", function( data ) {
153
+    	$('#documentation-version-list').prepend(data);
154
+	//remove any "/v1.1/" bits from font.
155
+	path = document.location.pathname.replace(/^\/v\d\.\d/, "");
156
+	$('#documentation-version-list a.version').each(function(i, e) {
157
+		e.href = e.href+path;
158
+		$(e).removeClass()
159
+	});
160
+    });
151 161
   })
152 162
   var userName = getCookie('docker_sso_username');
153 163
   if (userName) {