From 1e41d57bd44bd503d0642c8ea20123541c146218 Mon Sep 17 00:00:00 2001 From: unclejack Date: Sat, 24 Jan 2015 08:35:03 +0200 Subject: [PATCH 1/4] docs: compress search_content.json for release Signed-off-by: Cristian Staretu Docker-DCO-1.1-Signed-off-by: unclejack (github: SvenDowideit) --- docs/release.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/release.sh b/docs/release.sh index de064706bc..4491af6247 100755 --- a/docs/release.sh +++ b/docs/release.sh @@ -72,6 +72,8 @@ setup_s3() { build_current_documentation() { mkdocs build + cd site/ + gzip -9k search_content.json } upload_current_documentation() { From a78130467a03b95d1852bb2e6d10120bd8e6a6e7 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Mon, 26 Jan 2015 16:37:03 +1000 Subject: [PATCH 2/4] Change to load the json.gz file Signed-off-by: Sven Dowideit Docker-DCO-1.1-Signed-off-by: Sven Dowideit (github: SvenDowideit) --- docs/release.sh | 3 ++- docs/theme/mkdocs/js/base.js | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/release.sh b/docs/release.sh index 4491af6247..16bd759479 100755 --- a/docs/release.sh +++ b/docs/release.sh @@ -73,7 +73,8 @@ setup_s3() { build_current_documentation() { mkdocs build cd site/ - gzip -9k search_content.json + gzip -9k -f search_content.json + cd .. } upload_current_documentation() { diff --git a/docs/theme/mkdocs/js/base.js b/docs/theme/mkdocs/js/base.js index 1406dcd177..04f0c30c70 100644 --- a/docs/theme/mkdocs/js/base.js +++ b/docs/theme/mkdocs/js/base.js @@ -1,12 +1,6 @@ $(document).ready(function () { - // Tipue Search activation - $('#tipue_search_input').tipuesearch({ - 'mode': 'json', - 'contentLocation': '/search_content.json' - }); - prettyPrint(); // Resizing @@ -51,6 +45,12 @@ $(document).ready(function () }, }); + // Tipue Search activation + $('#tipue_search_input').tipuesearch({ + 'mode': 'json', + 'contentLocation': '/search_content.json.gz' + }); + }); function resizeMenuDropdown () @@ -92,4 +92,4 @@ function getCookie(cname) { if (c.indexOf(name) == 0) return c.substring(name.length,c.length); } return ""; -} \ No newline at end of file +} From 64f67af2b2bab7c9d3b4458b194c10f7428bf257 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Mon, 26 Jan 2015 21:26:38 +1000 Subject: [PATCH 3/4] set the content-type for the search_content.json.gz Signed-off-by: Sven Dowideit Docker-DCO-1.1-Signed-off-by: Sven Dowideit (github: SvenDowideit) --- docs/release.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/release.sh b/docs/release.sh index 16bd759479..9f51e0296f 100755 --- a/docs/release.sh +++ b/docs/release.sh @@ -91,7 +91,6 @@ upload_current_documentation() { echo " to $dst" echo #s3cmd --recursive --follow-symlinks --preserve --acl-public sync "$src" "$dst" - #aws s3 cp --profile $BUCKET --cache-control "max-age=3600" --acl public-read "site/search_content.json" "$dst" # 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 @@ -103,6 +102,9 @@ upload_current_documentation() { echo "$run" echo "=======================" $run + + # Make sure the search_content.json.gz file has the right content-encoding + aws s3 cp --profile $BUCKET --cache-control "max-age=3600" --content-encoding="gzip" --acl public-read "site/search_content.json.gz" "$dst" } invalidate_cache() { From 60089ace4895d9ab9c9fe9f2fb4b0db8a0d9aeda Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Mon, 26 Jan 2015 21:44:17 +1000 Subject: [PATCH 4/4] as we're not using the search suggestion feature only load the search_content when we have a search ?q= param Signed-off-by: Sven Dowideit Docker-DCO-1.1-Signed-off-by: Sven Dowideit (github: SvenDowideit) --- docs/release.sh | 3 +-- docs/theme/mkdocs/js/base.js | 16 +++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/release.sh b/docs/release.sh index 9f51e0296f..975940f5d5 100755 --- a/docs/release.sh +++ b/docs/release.sh @@ -90,7 +90,6 @@ upload_current_documentation() { echo "Uploading $src" echo " to $dst" echo - #s3cmd --recursive --follow-symlinks --preserve --acl-public sync "$src" "$dst" # 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 @@ -104,7 +103,7 @@ upload_current_documentation() { $run # Make sure the search_content.json.gz file has the right content-encoding - aws s3 cp --profile $BUCKET --cache-control "max-age=3600" --content-encoding="gzip" --acl public-read "site/search_content.json.gz" "$dst" + aws s3 cp --profile $BUCKET --cache-control $cache --content-encoding="gzip" --acl public-read "site/search_content.json.gz" "$dst" } invalidate_cache() { diff --git a/docs/theme/mkdocs/js/base.js b/docs/theme/mkdocs/js/base.js index 04f0c30c70..b4775c837b 100644 --- a/docs/theme/mkdocs/js/base.js +++ b/docs/theme/mkdocs/js/base.js @@ -45,11 +45,17 @@ $(document).ready(function () }, }); - // Tipue Search activation - $('#tipue_search_input').tipuesearch({ - 'mode': 'json', - 'contentLocation': '/search_content.json.gz' - }); + function getURLP(name) + { + return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20')) || null; + } + if (getURLP("q")) { + // Tipue Search activation + $('#tipue_search_input').tipuesearch({ + 'mode': 'json', + 'contentLocation': '/search_content.json.gz' + }); + } });