فهرست منبع

Merge pull request #10344 from SvenDowideit/pr_out_change_to_load_the_json_gz_file

Change to load the json.gz file
Sven Dowideit 10 سال پیش
والد
کامیت
a79d363d2d
2فایلهای تغییر یافته به همراه19 افزوده شده و 9 حذف شده
  1. 6 2
      docs/release.sh
  2. 13 7
      docs/theme/mkdocs/js/base.js

+ 6 - 2
docs/release.sh

@@ -72,6 +72,9 @@ setup_s3() {
 
 build_current_documentation() {
 	mkdocs build
+	cd site/
+	gzip -9k -f search_content.json
+	cd ..
 }
 
 upload_current_documentation() {
@@ -87,8 +90,6 @@ upload_current_documentation() {
 	echo "Uploading $src"
 	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
@@ -100,6 +101,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 $cache --content-encoding="gzip" --acl public-read "site/search_content.json.gz" "$dst"
 }
 
 invalidate_cache() {

+ 13 - 7
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,18 @@ $(document).ready(function ()
     },
   });
 
+  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'
+    });
+  }
+
 });
 
 function resizeMenuDropdown ()
@@ -92,4 +98,4 @@ function getCookie(cname) {
       if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
   }
   return "";
-}
+}