浏览代码

Update Algolia DocSearch integration with new application and correct versioning setup

Thibaud Colas 2 年之前
父节点
当前提交
d5e4ac5590
共有 7 个文件被更改,包括 19 次插入9 次删除
  1. 3 0
      CHANGELOG.txt
  2. 11 7
      docs/_templates/layout.html
  3. 1 0
      docs/releases/4.1.3.md
  4. 1 0
      docs/releases/4.2.1.md
  5. 1 0
      docs/releases/5.0.md
  6. 1 1
      docs/requirements.txt
  7. 1 1
      setup.py

+ 3 - 0
CHANGELOG.txt

@@ -66,6 +66,7 @@ Changelog
  * Maintenance: Move models and forms for `wagtailsearch.Query` to `wagtail.contrib.search_promotions` (Karl Hobley)
  * Maintenance: Migrate `initErrorDetection` (tabs error counts) to a Stimulus Controller `w-count` (Aman Pandey)
  * Maintenance: Migrate `window.addMessage` behaviour to a global event listener & Stimulus Controller approach with `w-messages` (Aman Pandey)
+ * Maintenance: Update Algolia DocSearch to use new application and correct versioning setup (Thibaud Colas)
 
 
 4.2.1 (xx.xx.xxxx) - IN DEVELOPMENT
@@ -81,6 +82,7 @@ Changelog
  * Fix: Fix dialog component's message to have rounded corners at the top side (Sam)
  * Fix: Prevent matches from unrelated models from leaking into SQLite FTS searches (Matt Westcott)
  * Fix: Prevent duplicate addition of StreamField blocks with the new block picker (Deepam Priyadarshi)
+ * Maintenance: Update Algolia DocSearch to use new application and correct versioning setup (Thibaud Colas)
 
 
 4.2 (06.02.2023)
@@ -246,6 +248,7 @@ Changelog
  * Fix: Add missing log information for `wagtail.schedule.cancel` (Stefan Hammer)
  * Fix: Fix timezone activation leaking into subsequent requests in `require_admin_access()` (Stefan Hammer)
  * Fix: Prevent matches from unrelated models from leaking into SQLite FTS searches (Matt Westcott)
+ * Maintenance: Update Algolia DocSearch to use new application and correct versioning setup (Thibaud Colas)
 
 
 4.1.2 (06.02.2023)

+ 11 - 7
docs/_templates/layout.html

@@ -4,6 +4,8 @@
 {% set docsearch_base = 'https://cdn.jsdelivr.net/npm/docsearch.js@' ~ docsearch_version ~ '/dist/cdn/' %}
 
 {% block extrahead %}
+    <meta name="docsearch:version" content="{% if READTHEDOCS and current_version %}{{ current_version }}{% else %}unknown{% endif %}" />
+
     <link rel="stylesheet" href="{{ docsearch_base ~ 'docsearch.min.css' }}"/>
     <link rel="stylesheet" href="{{ pathto('_static/css/docsearch.overrides.css', 1) }}" />
     <link rel="stylesheet" href="{{ pathto('_static/css/pagination.css', 1) }}" />
@@ -18,13 +20,14 @@
          * Get version of the currently served docs.
          *
          * PR builds have their version set to the PR ID (for example "6753").
-         * If the docs are built for a PR, use the "latest" search index.
-         * Otherwise, use the search index for the current version.
+         * If the docs are built for a PR or local development, use the "latest" facet filter.
+         * Otherwise, use the facet filter for the current version.
          */
         function getReadTheDocsVersion() {
-            const rtd_version = (window.READTHEDOCS_DATA || {}).version || 'latest'
-            const version = rtd_version.match(/^\d+$/) ? 'latest' : rtd_version
-            return version
+            const meta = document.querySelector('meta[name="docsearch:version"]');
+            const rtd_version = meta ? meta.content : 'latest';
+            const version = rtd_version.match(/^(\d+|unknown)$/) ? 'latest' : rtd_version;
+            return version;
         }
 
         function getVersionFacetFilter() {
@@ -54,10 +57,11 @@
         function docSearchReady() {
             /**
              * Configure Algolia DocSearch.
-             * See https://github.com/algolia/docsearch-configs/blob/master/configs/wagtail.json for index configuration.
+             * See https://github.com/wagtail/wagtail/wiki/Documentation-search for index configuration.
              */
             const search = docsearch({
-                apiKey: '8325c57d16798633e29d211c26c7b6f9',
+                appId: 'XSYGEO7KMJ',
+                apiKey: 'd50a485660ed9280079aada4e09454b2',
                 indexName: 'wagtail',
                 inputSelector: '#searchbox [name="q"]',
                 algoliaOptions: {

+ 1 - 0
docs/releases/4.1.3.md

@@ -22,3 +22,4 @@ depth: 1
  * Add missing log information for `wagtail.schedule.cancel` (Stefan Hammer)
  * Fix timezone activation leaking into subsequent requests in `require_admin_access()` (Stefan Hammer)
  * Prevent matches from unrelated models from leaking into SQLite FTS searches (Matt Westcott)
+ * Update Algolia DocSearch to use new application and correct versioning setup (Thibaud Colas)

+ 1 - 0
docs/releases/4.2.1.md

@@ -23,3 +23,4 @@ depth: 1
  * Fix dialog component's message to have rounded corners at the top side (Sam)
  * Prevent matches from unrelated models from leaking into SQLite FTS searches (Matt Westcott)
  * Prevent duplicate addition of StreamField blocks with the new block picker (Deepam Priyadarshi)
+ * Update Algolia DocSearch to use new application and correct versioning setup (Thibaud Colas)

+ 1 - 0
docs/releases/5.0.md

@@ -87,6 +87,7 @@ Support for adding custom validation logic to StreamField blocks has been formal
  * Move models and forms for `wagtailsearch.Query` to `wagtail.contrib.search_promotions` (Karl Hobley)
  * Migrate `initErrorDetection` (tabs error counts) to a Stimulus Controller `w-count` (Aman Pandey)
  * Migrate `window.addMessage` behaviour to a global event listener & Stimulus Controller approach with `w-messages` (Aman Pandey)
+ * Update Algolia DocSearch to use new application and correct versioning setup (Thibaud Colas)
 
 ## Upgrade considerations
 

+ 1 - 1
docs/requirements.txt

@@ -1,3 +1,3 @@
 myst_parser==0.18.1
-sphinx-wagtail-theme==5.3.2
+sphinx-wagtail-theme==6.0.0
 sphinx-copybutton>=0.5,<1.0

+ 1 - 1
setup.py

@@ -78,7 +78,7 @@ documentation_extras = [
     "sphinxcontrib-spelling>=5.4.0,<6",
     "Sphinx>=1.5.2",
     "sphinx-autobuild>=0.6.0",
-    "sphinx-wagtail-theme==5.3.2",
+    "sphinx-wagtail-theme==6.0.0",
     "myst_parser==0.18.1",
     "sphinx_copybutton>=0.5,<1.0",
 ]