From 4452fcda986c418874073444c31147077ad592d9 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Mar 2016 22:48:29 -0500 Subject: [PATCH 01/14] Properly note when 0.5.0 features were released [ci skip] --- docs/checks-examples.md | 2 ++ docs/deployment/dockerfiles.md | 4 +++- docs/dokku-storage.md | 4 ++-- docs/nginx.md | 2 ++ docs/proxy.md | 2 ++ 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/checks-examples.md b/docs/checks-examples.md index bb95f8513..5e90c1ef5 100644 --- a/docs/checks-examples.md +++ b/docs/checks-examples.md @@ -1,5 +1,7 @@ # Zero Downtime Deploys +> Plugin management is New as of 0.5.0 + ``` checks Show zero-downtime status checks:disable Disable zero-downtime checks diff --git a/docs/deployment/dockerfiles.md b/docs/deployment/dockerfiles.md index fe9c9eb0b..ab990c1bc 100644 --- a/docs/deployment/dockerfiles.md +++ b/docs/deployment/dockerfiles.md @@ -42,13 +42,15 @@ Setting `$DOKKU_DOCKERFILE_CACHE_BUILD` to `true` or `false` will enable or disa ### Procfiles and Multiple Processes +> New as of 0.5.0 + You can also customize the run command using a `Procfile`, much like you would on Heroku or with a buildpack deployed app. The `Procfile` should contain one or more lines defining [process types and associated commands](https://devcenter.heroku.com/articles/procfile#declaring-process-types). When you deploy your app a Docker image will be built, the `Procfile` will be extracted from the image (it must be in the folder defined in your `Dockerfile` as `WORKDIR` or `/app`) and the commands in it will be passed to `docker run` to start your process(es). Here's an example `Procfile`: - + ``` web: bin/run-prod.sh worker: bin/run-worker.sh diff --git a/docs/dokku-storage.md b/docs/dokku-storage.md index 5793bbbe8..a133b22d3 100644 --- a/docs/dokku-storage.md +++ b/docs/dokku-storage.md @@ -1,8 +1,8 @@ # Dokku Core Storage Plugin -> Spanking New as of 0.5.0 +> New as of 0.5.0 -As of Dokku 0.5.0, the preferred method to mount external containers to a dokku managed container, is to use the dokku storage plugin. +The preferred method to mount external containers to a dokku managed container, is to use the dokku storage plugin. ```shell diff --git a/docs/nginx.md b/docs/nginx.md index eb4809271..920076d79 100644 --- a/docs/nginx.md +++ b/docs/nginx.md @@ -10,6 +10,8 @@ nginx:error-logs [-t] ## Customizing the nginx configuration +> New as of 0.5.0 + Dokku uses a templating library by the name of [sigil](https://github.com/gliderlabs/sigil) to generate nginx configuration for each app. If you'd like to provide a custom template for your application, there are a couple options: - Copy the following example template to a file named `nginx.conf.sigil` and either: diff --git a/docs/proxy.md b/docs/proxy.md index 646a860ea..ae3763734 100644 --- a/docs/proxy.md +++ b/docs/proxy.md @@ -1,5 +1,7 @@ # Proxy plugin +> New as of 0.5.0 + As of dokku 0.5.0, the proxy functionality has been decoupled from the nginx-vhosts plugin into the proxy plugin. In the future this will allow other proxy software (HAproxy for example) to be used instead of nginx. ``` From b721661e2ca4b17459314c896b98b2e03929c1be Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Mar 2016 22:48:54 -0500 Subject: [PATCH 02/14] Fix formatting in dokku-storage [ci skip] --- docs/dokku-storage.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/dokku-storage.md b/docs/dokku-storage.md index a133b22d3..ee7412efc 100644 --- a/docs/dokku-storage.md +++ b/docs/dokku-storage.md @@ -6,16 +6,17 @@ The preferred method to mount external containers to a dokku managed container, ```shell -$ dokku storage:help - storage:list , List bind mounts for app's container(s) (host:container) - storage:mount , Create a new bind mount - storage:unmount , Remove an existing bind mount +storage:list , List bind mounts for app's container(s) (host:container) +storage:mount , Create a new bind mount +storage:unmount , Remove an existing bind mount ``` ## Ideology and Background + The storage plugin requires explicit paths on the host side. This is intentional to ensure that new users avoid running into unexpected results with implicit paths that may not exist (a feature deprecate in [Docker 1.9.0](https://github.com/docker/docker/releases/tag/v1.9.0])). The container directory is created for the mount point in the container. Any existing directory contents are not accessible after a mount is added to the container. Dokku creates a new directory `/var/lib/dokku/data/storage` during installation, it's the general consensus that new users should use this directory. Mounts are only available at run and deploy times, you must redeploy (restart) an app to mount or unmount to an existing app's container. ## Usage + This example demonstrates how to mount the recommended directory to `/storage` inside the container: ``` $ dokku storage:mount app-name /var/lib/dokku/data/storage:/storage @@ -24,19 +25,19 @@ Dokku will then mount the shared contents of`/var/lib/dokku/storage` to `/storag ## Use Cases -##### Persistent storage +### Persistent storage Dokku is powered by Docker containers, which recommends in their [best practices](https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#containers-should-be-ephemeral) that containers be treated as ephemeral. In order to manage persistent storage for web applications, like user uploads or large binary assets like images, a directory outside the container should be mounted. -##### Shared storage between containers +### Shared storage between containers When scaling your app, you may require a common location to access shared assets between containers, a storage mount can be used in this situation. -##### Shared storage across environments +### Shared storage across environments Your app may be used in a cluster that requires containers or resources not running on the same host access your data. Mounting a shared file service (like S3FS or EFS) inside your container will give you great flexibility. -##### Backing up +### Backing up Your app may have services that are running in memory and need to be backed up locally (like a key store). Mount a non ephemeral storage mount will allow backups that are not lost when the app is shut down. From ede399e95c1dbfe312011dfaad2450a0a1a787f4 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Mar 2016 22:49:09 -0500 Subject: [PATCH 03/14] Add link to disabling nginx [ci skip] --- docs/nginx.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/nginx.md b/docs/nginx.md index 920076d79..7aaad3b7e 100644 --- a/docs/nginx.md +++ b/docs/nginx.md @@ -195,3 +195,7 @@ See the [HSTS documentation](/dokku/deployment/ssl-configuration/#hsts-header). ## SSL Configuration See the [ssl documentation](/dokku/deployment/ssl-configuration/). + +## Disabling Nginx + +See the [proxy documentation](/dokku/deployment/proxy/). From 60cd04c36a6f8f58acf57bde182e93248d56d75d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Mar 2016 22:49:30 -0500 Subject: [PATCH 04/14] Add reference to cron to one-off-processes doc [ci skip] --- docs/deployment/one-off-processes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/deployment/one-off-processes.md b/docs/deployment/one-off-processes.md index cfd0dd14a..5e591353e 100644 --- a/docs/deployment/one-off-processes.md +++ b/docs/deployment/one-off-processes.md @@ -1,4 +1,4 @@ -# One-off Processes +# One-off Processes and Cron Sometimes you need to either inspect running containers or run a one-off command under an application. In those cases, Dokku makes it easy to either connect to a running container or run a fresh container. From d8c5b7f4845ad8ccb5f20c5e02abfd7e44ebdf5d Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Mar 2016 22:52:27 -0500 Subject: [PATCH 05/14] Update sidebar links - Refer to checks plugin in zero-downtime deploy link - Refer to cron in one off processes link - Add an "Advanced Usage" section - Add links to proxy management and deployment tasks - Move container options and persistent storage to advanced usage [ci skip] --- docs/template.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/template.html b/docs/template.html index 8fdaf1d8a..c8629791e 100644 --- a/docs/template.html +++ b/docs/template.html @@ -70,9 +70,9 @@ Dockerfile Deployment Image Tagging Remote Commands - One Off Processes + One Off Processes/Cron Scaling Apps - Zero Downtime Deploys + Zero Downtime Deploy Checks Configuration @@ -80,10 +80,15 @@ DNS Configuration Nginx Configuration SSL Configuration - Docker Container Options - Storage Plugin Dokku Event Logs + + Advanced Usage + Backup and Recovery + Deployment Tasks + Docker Container Options + Persistent Storage + Proxy Management Community Contributions From 6eaa06f61309637fe8a05d8f8bab862a537ee46e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Mar 2016 22:58:05 -0500 Subject: [PATCH 06/14] Note the location of the CHECKS file for dockerfile deploys. Closes #1962 [ci skip] --- docs/checks-examples.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/checks-examples.md b/docs/checks-examples.md index 5e90c1ef5..9177243a4 100644 --- a/docs/checks-examples.md +++ b/docs/checks-examples.md @@ -41,6 +41,8 @@ To specify checks, add a `CHECKS` file to the root of your project directory. Th * Comments (lines starting with #) * Empty lines +> For dockerfile-based deploys, the file *must* be in `/app/CHECKS` within the container. `/app` is used by default as the root container directory for buildpack-based deploys. + ### Check Instructions The format of a check instruction is a path or relative URL, optionally followed by the expected content: From 40e169043a6ef0781b87af2ccfc6f204e805d302 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Mar 2016 23:10:05 -0500 Subject: [PATCH 07/14] Add link to 0.5.x migration guide [ci skip] --- docs/appendices/0.5.0-migration-guide.md | 2 ++ docs/template.html | 2 +- docs/upgrading.md | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/appendices/0.5.0-migration-guide.md b/docs/appendices/0.5.0-migration-guide.md index 3719582bb..587345ded 100644 --- a/docs/appendices/0.5.0-migration-guide.md +++ b/docs/appendices/0.5.0-migration-guide.md @@ -1,5 +1,7 @@ # 0.5.0 Migration Guide + ## nginx-vhosts + - The nginx-vhosts template language is now [sigil](https://github.com/gliderlabs/sigil) - No need to escape literal `$` characters (or other "bash-isms") - Template variables are represented as {{ .VARIABLE_NAME }} diff --git a/docs/template.html b/docs/template.html index c8629791e..d0cc7d147 100644 --- a/docs/template.html +++ b/docs/template.html @@ -59,7 +59,7 @@
Getting Started Getting Started with Dokku - Upgrading + Upgrading Dokku Troubleshooting Getting Help diff --git a/docs/upgrading.md b/docs/upgrading.md index 99d6677e9..fb5381f99 100644 --- a/docs/upgrading.md +++ b/docs/upgrading.md @@ -6,6 +6,14 @@ This document covers upgrades for the 0.3.0 series and up. If upgrading from old ## Dokku +### Migration Guides + +Migration guides contain information regarding the new features introduced in each version and the migration path between versions. + +- [0.5 Migration Guide](/dokku/appendices/0.5.0-migration-guide/) + +### General Information + If dokku was installed via a debian package, you can upgrade dokku via the following command: ```shell From 37bfdbbbe0c94d8cdc08d556851ed21fa44f676c Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Mar 2016 23:16:55 -0500 Subject: [PATCH 08/14] Note that deployment tasks are new as of 0.5.0 [ci skip] --- docs/deployment/deployment-tasks.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/deployment/deployment-tasks.md b/docs/deployment/deployment-tasks.md index c5ff3fe69..c5685100b 100644 --- a/docs/deployment/deployment-tasks.md +++ b/docs/deployment/deployment-tasks.md @@ -1,5 +1,7 @@ # Deployment Tasks +> New as of 0.5.0 + Sometimes you need to run a command on at deployment time, but before an app is completely deployed. Common use cases include: From 45c180368f08b90018f4d8d8d2033da1cd4ca4ad Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Wed, 2 Mar 2016 23:38:06 -0500 Subject: [PATCH 09/14] Update issue template - Add application name and contents of Procfile as required debug info - Capitalize a few things [ci skip] --- ISSUE_TEMPLATE.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 46cb87b9a..104dc208a 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -16,9 +16,11 @@ Output of the following commands - `cat /home/dokku//nginx.conf` (if applicable): - Link to the exact repository being deployed (if possible/applicable): - If a deploy is failing: - - the type of application being deployed (node, php, python, ruby, etc.) - - whether or not you have a `Dockerfile` in the root of your repository - - if using buildpacks, which custom buildpacks are in use + - Application name + - The type of application being deployed (node, php, python, ruby, etc.) + - Whether or not you have a `Dockerfile` in the root of your repository + - If using buildpacks, which custom buildpacks are in use + - If it exists, the contents of your `Procfile`. - Output of failing dokku commands after running `dokku trace on` (BEWARE: `trace on` will print environment variables for some commands, be sure you're not exposing any sensitive information when posting issues. You may replace these values with XXXXXXX): From 173a87a53ed021b2e3c984301171b7e96e22f025 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 3 Mar 2016 04:36:53 -0500 Subject: [PATCH 10/14] Add link to slack group to readme [ci skip] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c5c791c25..b6d56242a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Dokku [![Build Status](https://img.shields.io/circleci/project/dokku/dokku/master.svg?style=flat-square "Build Status")](https://circleci.com/gh/dokku/dokku/tree/master) [![Ubuntu Package](https://img.shields.io/badge/package-ubuntu-brightgreen.svg?style=flat-square "Ubuntu Package")](https://packagecloud.io/dokku/dokku) [![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg?style=flat-square "IRC Freenode")](https://webchat.freenode.net/?channels=dokku) [![Documentation](https://img.shields.io/badge/docs-viewdocs-blue.svg?style=flat-square "Viewdocs")](http://dokku.viewdocs.io/dokku/) [![Gratipay](https://img.shields.io/gratipay/dokku.svg?style=flat-square)](https://gratipay.com/dokku/) +# Dokku [![Build Status](https://img.shields.io/circleci/project/dokku/dokku/master.svg?style=flat-square "Build Status")](https://circleci.com/gh/dokku/dokku/tree/master) [![Ubuntu Package](https://img.shields.io/badge/package-ubuntu-brightgreen.svg?style=flat-square "Ubuntu Package")](https://packagecloud.io/dokku/dokku) [![IRC Network](https://img.shields.io/badge/irc-freenode-blue.svg?style=flat-square "IRC Freenode")](https://webchat.freenode.net/?channels=dokku) [![Slack Group](https://img.shields.io/badge/irc-slack-blue.svg?style=flat-square "Slack Group")](https://glider-slackin.herokuapp.com/) [![Documentation](https://img.shields.io/badge/docs-viewdocs-blue.svg?style=flat-square "Viewdocs")](http://dokku.viewdocs.io/dokku/) [![Gratipay](https://img.shields.io/gratipay/dokku.svg?style=flat-square)](https://gratipay.com/dokku/) Docker powered mini-Heroku. The smallest PaaS implementation you've ever seen. Sponsored by our friends at [Deis](http://deis.io/). From 8bf666f56de6e98ac5a916eb8abbb20b2f770fcc Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Thu, 3 Mar 2016 04:41:51 -0500 Subject: [PATCH 11/14] Add dynamic version menu This will allow a user to browse the documentation as it was at any point in time. In doing so, this allows us to more easily deprecate/remove features without worrying about having to duplicate old documentation in the future. [ci skip] --- docs/assets/style.css | 45 +++++++ docs/assets/versions.raw | 6 + docs/development/release-process.md | 1 + docs/template.html | 176 +++++++++++++++++++++++++++- 4 files changed, 227 insertions(+), 1 deletion(-) create mode 100644 docs/assets/versions.raw diff --git a/docs/assets/style.css b/docs/assets/style.css index b2e3a8477..001b5c387 100644 --- a/docs/assets/style.css +++ b/docs/assets/style.css @@ -256,3 +256,48 @@ blockquote.new-as-of { margin-top: 120px; } } + +.rst-versions.rst-badge {display: block;} +.rst-other-versions {text-align: left;} +.rst-other-versions a {border: 0;} +.rst-other-versions dl {margin: 0;} + +.bookmark-added-msg {display: none;} +.bookmark-active {display: none;} +.bookmark-inactive {display: none;} + +.fa:before{-webkit-font-smoothing:antialiased} +.clearfix{*zoom:1} +.clearfix:before,.clearfix:after{display:table;content:""} +.clearfix:after{clear:both} +a .fa{display:inline-block;text-decoration:inherit} +li .fa{display:inline-block} +li .fa-large:before,li .fa-large:before{width:1.875em} +ul.fas{list-style-type:none;margin-left:2em;text-indent:-0.8em} +ul.fas li .fa{width:0.8em} +ul.fas li .fa-large:before,ul.fas li .fa-large:before{vertical-align:baseline} +.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;border-top:solid 10px #343131;font-family:"Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;font-size:13px;z-index:400} +.rst-versions a{color:#2980B9;text-decoration:none} +.rst-versions .rst-badge-small{display:none} +.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27AE60;*zoom:1} +.rst-versions .rst-current-version:before,.rst-versions .rst-current-version:after{display:table;content:""} +.rst-versions .rst-current-version:after{clear:both} +.rst-versions .rst-current-version .fa{color:#fcfcfc} +.rst-versions .rst-current-version .fa-book{float:left; line-height: 30px} +.rst-versions .rst-current-version .icon-book{float:left} +.rst-versions .rst-current-version.rst-out-of-date{background-color:#E74C3C;color:#fff} +.rst-versions .rst-current-version.rst-active-old-version{background-color:#F1C40F;color:#000} +.rst-versions.shift-up .rst-other-versions{display:block} +.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:gray;display:none} +.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:solid 1px #413d3d} +.rst-versions .rst-other-versions dd{display:inline-block;margin:0} +.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc} +.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px} +.rst-versions.rst-badge .icon-book{float:none} +.rst-versions.rst-badge .fa-book{float:none} +.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right} +.rst-versions.rst-badge.shift-up .rst-current-version .fa-book{float:left} +.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left} +.rst-versions.rst-badge .rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center} +@media screen and (max-width: 768px){.rst-versions{width:85%;display:none} +.rst-versions.shift{display:block}img{width:100%;height:auto}} diff --git a/docs/assets/versions.raw b/docs/assets/versions.raw new file mode 100644 index 000000000..4964ec5d8 --- /dev/null +++ b/docs/assets/versions.raw @@ -0,0 +1,6 @@ +{ + "max-versions": [ + "0.3.26", + "0.4.14" + ] +} diff --git a/docs/development/release-process.md b/docs/development/release-process.md index dd814ee0d..5a7fd3d78 100644 --- a/docs/development/release-process.md +++ b/docs/development/release-process.md @@ -18,6 +18,7 @@ To propose a release, the following tasks need to be performed: - The versioned links should be updated in the `docs/home.html` file. - The versioned links should be updated in the `docs/template.html` file. - The versioned links should be updated in the `docs/template.html` file. +- The versioned links should be updated or added to the `docs/assets/versions.raw` file. - A list of changes must be made in the `HISTORY.md`. - A tag must be created locally with your release version - Debian packages *must* be created via `vagrant up build` diff --git a/docs/template.html b/docs/template.html index d0cc7d147..c1303c225 100644 --- a/docs/template.html +++ b/docs/template.html @@ -34,7 +34,52 @@ + @@ -106,6 +151,46 @@
+
+
+ +   + v: {{REF}} + + +
+
+
Versions
+
+ +
+
On GitHub
+
+ View +
+
+ Edit +
+
+ +
+ + Free document hosting provided by Viewdocs. +
+
+
+ From f385efbbfc2570150b71d3879e51177c0430f7e0 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 8 Mar 2016 21:03:08 -0500 Subject: [PATCH 12/14] Request a json file and set the proper cache-control header [ci skip] --- docs/assets/{versions.raw => versions.json} | 0 docs/template.html | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) rename docs/assets/{versions.raw => versions.json} (100%) diff --git a/docs/assets/versions.raw b/docs/assets/versions.json similarity index 100% rename from docs/assets/versions.raw rename to docs/assets/versions.json diff --git a/docs/template.html b/docs/template.html index c1303c225..394e2b49b 100644 --- a/docs/template.html +++ b/docs/template.html @@ -287,7 +287,8 @@ }; var request = new XMLHttpRequest(); - request.open('GET', '/dokku/assets/versions.raw/', true); + request.open('GET', '/dokku/assets/versions.json', true); + request.setRequestHeader("Cache-Control", "no-cache, no-store"); request.onload = function() { if (request.status >= 200 && request.status < 400) { From ec2a21c766deffecf78499aff6f01e106810c499 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 8 Mar 2016 21:21:04 -0500 Subject: [PATCH 13/14] Better styling on menu item --- docs/template.html | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/docs/template.html b/docs/template.html index 394e2b49b..e63615734 100644 --- a/docs/template.html +++ b/docs/template.html @@ -55,10 +55,10 @@ ul.fas{list-style-type:none;margin-left:2em;text-indent:-0.8em} ul.fas li .fa{width:0.8em} ul.fas li .fa-large:before,ul.fas li .fa-large:before{vertical-align:baseline} - .rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;border-top:solid 10px #343131;font-family:"Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;font-size:13px;z-index:400} - .rst-versions a{color:#2980B9;text-decoration:none} + .rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#15518d;border-top:solid 10px #343131;font-family:"Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;font-size:13px;z-index:400} + .rst-versions a{color:#7c8e98;text-decoration:none} .rst-versions .rst-badge-small{display:none} - .rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27AE60;*zoom:1} + .rst-versions .rst-current-version{padding:12px;background-color:#2475c3;display:block;text-align:right;font-size:90%;cursor:pointer;color:#d8edf8;*zoom:1} .rst-versions .rst-current-version:before,.rst-versions .rst-current-version:after{display:table;content:""} .rst-versions .rst-current-version:after{clear:both} .rst-versions .rst-current-version .fa{color:#fcfcfc} @@ -67,8 +67,8 @@ .rst-versions .rst-current-version.rst-out-of-date{background-color:#E74C3C;color:#fff} .rst-versions .rst-current-version.rst-active-old-version{background-color:#F1C40F;color:#000} .rst-versions.shift-up .rst-other-versions{display:block} - .rst-versions .rst-other-versions{font-size:90%;padding:12px;color:gray;display:none} - .rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:solid 1px #413d3d} + .rst-versions .rst-other-versions{font-size:90%;padding:12px;color:light-gray;display:none} + .rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:solid 1px #d6edf9} .rst-versions .rst-other-versions dd{display:inline-block;margin:0} .rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc} .rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px} @@ -153,13 +153,13 @@
- +   v: {{REF}}
-
+
Versions
@@ -206,7 +206,8 @@ var tables = document.querySelectorAll('table'), blockquotes = document.querySelectorAll('blockquote'), versionList = document.querySelectorAll('.rst-other-versions dl')[0], - versionToggle = document.querySelectorAll('.rst-current-version')[0], + currentVersionEl = document.querySelectorAll('.rst-current-version')[0], + currentVersion = currentVersionEl.getAttribute('data-ref'), versionContainer = document.querySelectorAll('.rst-versions.rst-badge')[0], classNames = ['table', 'table-striped', 'table-hover', 'table-condensed'], localPath = location.pathname.split('/').splice(2).join("/"), @@ -243,7 +244,7 @@ }); }); - versionToggle.addEventListener('click', function() { + currentVersionEl.addEventListener('click', function() { if (hasClass(versionContainer, 'shift-up')) { removeClass(versionContainer, 'shift-up'); } else { @@ -279,10 +280,17 @@ ref = 'dokku'; versionName = 'master'; } + console.log(currentVersion, versionName); a.setAttribute('href', "/" + ref + "/" + localPath); a.appendChild(document.createTextNode(versionName)); - dd.appendChild(a); + if (versionName == currentVersion) { + var strong = document.createElement('strong'); + strong.appendChild(a); + dd.appendChild(strong); + } else { + dd.appendChild(a); + } versionList.appendChild(dd); }; From cf77ee1d2ade0ecdeea70dca084a21423766968f Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 8 Mar 2016 21:35:56 -0500 Subject: [PATCH 14/14] Cache the versions response in local storage to reduce network activity [ci-skip] --- docs/template.html | 71 +++++++++++++++++++++++++++++++--------------- 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/docs/template.html b/docs/template.html index e63615734..3fdcbf24f 100644 --- a/docs/template.html +++ b/docs/template.html @@ -233,6 +233,21 @@ } }; + var ls2 = { + save : function(key, jsonData, expirationMS) { + if (typeof (Storage) == "undefined") { return false; } + var record = {value: JSON.stringify(jsonData), timestamp: new Date().getTime()/1000 + expirationMS} + localStorage.setItem(key, JSON.stringify(record)); + return jsonData; + }, + load : function(key) { + if (typeof (Storage) == "undefined") { return false; } + var record = JSON.parse(localStorage.getItem(key)); + if (!record){return false;} + return (new Date().getTime()/1000 < record.timestamp && JSON.parse(record.value)); + } + }; + Array.prototype.forEach.call(blockquotes, function (el, i) { if (el.innerHTML.indexOf('New as of') !== -1) { addClass(el, 'new-as-of'); @@ -280,7 +295,6 @@ ref = 'dokku'; versionName = 'master'; } - console.log(currentVersion, versionName); a.setAttribute('href', "/" + ref + "/" + localPath); a.appendChild(document.createTextNode(versionName)); @@ -294,34 +308,45 @@ versionList.appendChild(dd); }; - var request = new XMLHttpRequest(); - request.open('GET', '/dokku/assets/versions.json', true); - request.setRequestHeader("Cache-Control", "no-cache, no-store"); - - request.onload = function() { - if (request.status >= 200 && request.status < 400) { - versions = [] - var data = JSON.parse(request.responseText); - for (var key in data['max-versions']) { - if (!data['max-versions'].hasOwnProperty(key)) { - continue; - } - - versions = parseVersions(data['max-versions'][key], versions); + var processVersions = function(data) { + var versions = []; + for (var key in data['max-versions']) { + if (!data['max-versions'].hasOwnProperty(key)) { + continue; } - addVersionLink('master'); - Array.prototype.forEach.call(versions, function (version, i) { - addVersionLink(version); - }); + versions = parseVersions(data['max-versions'][key], versions); } + + addVersionLink('master'); + Array.prototype.forEach.call(versions, function (version, i) { + addVersionLink(version); + }); }; - request.onerror = function() { - // There was a connection error of some sort - }; + data = ls2.load('max-versions'); + if (!data) { + var request = new XMLHttpRequest(); + request.open('GET', '/dokku/assets/versions.json', true); + request.setRequestHeader("Cache-Control", "no-cache, no-store"); - request.send(); + request.onload = function() { + if (request.status >= 200 && request.status < 400) { + var data = JSON.parse(request.responseText); + // store for 1 day + ls2.save('max-versions', data, 86400); + processVersions(data); + } + }; + + request.onerror = function() { + // There was a connection error of some sort + }; + + request.send(); + } else { + processVersions(data); + } });