diff --git a/CHANGES.rst b/CHANGES.rst index 461bb18b1..416ae2c8f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -37,6 +37,7 @@ Internal changes * The GitHub Workflows now use the `step-security/harden-runner` action to monitor source code, actions, and dependency safety. All workflows now employ more constrained permissions rule sets to prevent security issues. (:pull:`1577`, :pull:`1578`, :pull:`1597`). * Updated the CONTRIBUTING.rst directions to showcase the new versioning system. (:issue:`1557`, :pull:`1573`). * The `codespell` library is now a development dependency for the `dev` installation recipe with configurations found within `pyproject.toml`. This is also now a linting step and integrated as a `pre-commit` hook. For more information, see the `codespell documentation `_ (:pull:`1576`). +* Climate indicators search page now prioritizes the "official" indicators (atmos, land, seaIce and generic), virtual submodules can be added to search through checkbox option. (:issue:`1559`, :pull:`1593`). v0.47.0 (2023-12-01) diff --git a/docs/_static/indsearch.js b/docs/_static/indsearch.js index eb7efb818..6ec3dcdd9 100644 --- a/docs/_static/indsearch.js +++ b/docs/_static/indsearch.js @@ -1,6 +1,6 @@ /* Array of indicator objects */ let indicators = []; - +let defModules = ["atmos", "generic", "land", "seaIce"]; /* MiniSearch object defining search mechanism */ let miniSearch = new MiniSearch({ fields: ['title', 'abstract', 'variables', 'keywords', 'id'], // fields to index for full-text search @@ -9,6 +9,13 @@ let miniSearch = new MiniSearch({ boost: {'title': 3, 'variables': 2}, fuzzy: 0.1, prefix: true, + boostDocument: (docID, term, storedFields) => { + if (defModules.indexOf(storedFields['module']) > -1) { + return 2; + } else { + return 1; + } + }, }, extractField: (doc, field) => { if (field === 'variables') { @@ -87,11 +94,16 @@ function indTemplate(ind) { function indFilter() { const input = document.getElementById("queryInput").value; + const incVirt = document.getElementById("incVirtMod").checked; + let opts = {}; + if (!incVirt) { + opts["filter"] = (result) => (defModules.indexOf(result.module) > -1); + } let inds = []; - if (input === "") { - inds = indicators; + if (input === "") { //Search wildcard so that boostDocument rules are applied. + inds = miniSearch.search(MiniSearch.wildcard, opts); } else { - inds = miniSearch.search(input); + inds = miniSearch.search(input, opts); } const newTable = inds.map(indTemplate).join(''); diff --git a/docs/_static/style.css b/docs/_static/style.css index 5babe9e93..5d18dca7c 100644 --- a/docs/_static/style.css +++ b/docs/_static/style.css @@ -98,3 +98,7 @@ code > .indName { margin: 5px; background-color: #ddd; } + +#incVirtModLbl { + display: inline; +} diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html index f00ef0ad7..00954b22d 100644 --- a/docs/_templates/layout.html +++ b/docs/_templates/layout.html @@ -9,7 +9,7 @@ {% block scripts %} {% if "indicators" in sourcename %} - + {% endif %} {{ super() }} diff --git a/docs/indicators.rst b/docs/indicators.rst index be46e0007..a6275f906 100644 --- a/docs/indicators.rst +++ b/docs/indicators.rst @@ -17,7 +17,7 @@ allows a simple free text search of all indicators. Click on the python names to .. raw:: html - +
diff --git a/pyproject.toml b/pyproject.toml index 267916710..4d92ec760 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -123,7 +123,7 @@ target-version = [ ] [tool.bumpversion] -current_version = "0.47.5-dev.6" +current_version = "0.47.5-dev.7" commit = true commit_args = "--no-verify" tag = false diff --git a/xclim/__init__.py b/xclim/__init__.py index 0f6130773..124572ffe 100644 --- a/xclim/__init__.py +++ b/xclim/__init__.py @@ -15,7 +15,7 @@ __author__ = """Travis Logan""" __email__ = "logan.travis@ouranos.ca" -__version__ = "0.47.5-dev.6" +__version__ = "0.47.5-dev.7" _module_data = _files("xclim.data")