From a3e6722ebeb72bde447180d0e9a6a42460c978c1 Mon Sep 17 00:00:00 2001 From: Basha MEGA Date: Sat, 8 Mar 2025 07:31:01 +0000 Subject: [PATCH 01/18] feat: integrate search --- Makefile | 1 + assets/css/search.css | 26 +++++++++ assets/js/search.js | 123 ++++++++++++++++++++++++++++++++++++++++++ config.yaml | 2 +- 4 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 assets/css/search.css create mode 100644 assets/js/search.js diff --git a/Makefile b/Makefile index 954a3491..c15042de 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ .DEFAULT_GOAL := help SHELL:=/bin/bash +SEARCH = (echo "Installing \`pagefind\` and generating search index..." && npx --yes pagefind --site public) # Add help text after each target name starting with '\#\#' help: ## show this help diff --git a/assets/css/search.css b/assets/css/search.css new file mode 100644 index 00000000..2b1b5264 --- /dev/null +++ b/assets/css/search.css @@ -0,0 +1,26 @@ +.search-button { + border-radius: 20px; + padding: 8px; + margin-right: 15px; + cursor: pointer; +} +.search-dialog { + padding: 15px; + width: 80%; + border-radius: 1rem; +} +.search-dialog::backdrop { + background-color: rgb(0, 0, 0, 0.5); + backdrop-filter: blur(3px); +} +.search-dialog input { + padding: 10px 15px; + color: #333; +} +.pagefind-ui button { + border: none; +} +/* unset a pagefind color setting to make results more legible in dark mode */ +.pagefind-ui__result-title > .pagefind-ui__result-link { + color: unset !important; +} \ No newline at end of file diff --git a/assets/js/search.js b/assets/js/search.js new file mode 100644 index 00000000..b0d11f5a --- /dev/null +++ b/assets/js/search.js @@ -0,0 +1,123 @@ +// This file is attributed to the Scientific Python Developers +// Source: https://github.com/scientific-python/scientific-python-hugo-theme/pull/615/files + +// BSD 3-Clause License + +// Copyright (c) 2021--2023, Scientific Python Developers +// All rights reserved. + +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: + +// 1. Redistributions of source code must retain the above copyright notice, this +// list of conditions and the following disclaimer. + +// 2. Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. + +// 3. Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. + +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// ---- + +// Adapted from the Hugo Fresh theme, which has the following license: + +// MIT License + +// Copyright (c) 2019 Stefan M. + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +"use strict"; + +window.addEventListener("DOMContentLoaded", () => { + let searchDialog = document.querySelector(".search-dialog"); + let searchButton = document.getElementById("search-button"); + + // Do nothing here if search is not enabled. + if (!searchDialog || !searchButton) return; + + const isMac = /(Mac|iPhone|iPod|iPad)/i.test(navigator.userAgent); + searchButton.title = `Search (${isMac ? "⌘" : "Ctrl"} + K)`; + + new PagefindUI({ + element: ".search-dialog", + autofocus: true, + resetStyles: false, + showSubResults: true, + }); + + let showSearch = () => searchDialog.showModal(); + let hideSearch = () => searchDialog.close(); + + let toggleSearch = () => { + if (!searchDialog.open) { + showSearch(); + } else { + hideSearch(); + } + }; + + let isClickOutside = (elem, clickEvt) => { + const elemDims = elem.getBoundingClientRect(); + return ( + clickEvt.clientX < elemDims.left || + clickEvt.clientX > elemDims.right || + clickEvt.clientY < elemDims.top || + clickEvt.clientY > elemDims.bottom + ); + }; + + // Close the search dialog if user clicks outside of it when it is open. + // This feels like functionality that should really be natively supported + // by the dialog element already. + // https://blog.webdevsimplified.com/2023-04/html-dialog/ + searchDialog.addEventListener("click", (evt) => { + if (searchDialog.open && isClickOutside(searchDialog, evt)) { + hideSearch(); + } + }); + + window.addEventListener("keydown", (evt) => { + if ( + ((isMac && evt.metaKey) || (!isMac && evt.ctrlKey)) && + evt.key === "k" + ) { + evt.preventDefault(); // prevents default browser behaviour + toggleSearch(); + } + }); + + document + .querySelector(".search-button") + .addEventListener("click", showSearch); +}); diff --git a/config.yaml b/config.yaml index 6d6b35e0..55c812cc 100644 --- a/config.yaml +++ b/config.yaml @@ -20,7 +20,7 @@ params: author: name: Scientific Python team description: Community developed and owned ecosystem for scientific computing - + search: true fonts: - name: "Lato" weights: [400, 900] From 43fcafd8c86c5940a74b6b112147150ffe938e4e Mon Sep 17 00:00:00 2001 From: Basha MEGA Date: Sat, 8 Mar 2025 07:33:55 +0000 Subject: [PATCH 02/18] feat: netlify --- netlify.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index 4fc74cc6..6635eab5 100644 --- a/netlify.toml +++ b/netlify.toml @@ -13,7 +13,10 @@ tar -xf ${DART_SASS_TARBALL} && \ rm ${DART_SASS_TARBALL} && \ export PATH=/opt/build/repo/dart-sass:$PATH && \ - make html \ + python3 -m pip install nox && \ + nox -s themes && \ + nox -s html && \ + nox -s search """ [[plugins]] From cda79c46bdb678c4c1300da1f0e2957853cd80a2 Mon Sep 17 00:00:00 2001 From: Basha MEGA Date: Sat, 8 Mar 2025 07:34:56 +0000 Subject: [PATCH 03/18] patch: node version --- netlify.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/netlify.toml b/netlify.toml index 6635eab5..7325909c 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,6 +1,7 @@ [build.environment] PYTHON_VERSION = "3.13" HUGO_VERSION = "0.141.0" + NODE_VERSION = "20" DART_SASS_VERSION = "1.83.4" DART_SASS_URL = "https://github.com/sass/dart-sass/releases/download/" From 455a721971a324708276a18ad247f62e3afd1e9f Mon Sep 17 00:00:00 2001 From: Basha MEGA Date: Sat, 8 Mar 2025 07:41:33 +0000 Subject: [PATCH 04/18] patch: remove my netlify configurations --- netlify.toml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/netlify.toml b/netlify.toml index 7325909c..4fc74cc6 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,7 +1,6 @@ [build.environment] PYTHON_VERSION = "3.13" HUGO_VERSION = "0.141.0" - NODE_VERSION = "20" DART_SASS_VERSION = "1.83.4" DART_SASS_URL = "https://github.com/sass/dart-sass/releases/download/" @@ -14,10 +13,7 @@ tar -xf ${DART_SASS_TARBALL} && \ rm ${DART_SASS_TARBALL} && \ export PATH=/opt/build/repo/dart-sass:$PATH && \ - python3 -m pip install nox && \ - nox -s themes && \ - nox -s html && \ - nox -s search + make html \ """ [[plugins]] From 6c7061b635b981bd638cbe8ed1e6fc3ca3ae23e2 Mon Sep 17 00:00:00 2001 From: Basha MEGA Date: Sat, 8 Mar 2025 07:47:03 +0000 Subject: [PATCH 05/18] patch: install missing package --- netlify.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/netlify.toml b/netlify.toml index 4fc74cc6..a4ab67f9 100644 --- a/netlify.toml +++ b/netlify.toml @@ -13,6 +13,7 @@ tar -xf ${DART_SASS_TARBALL} && \ rm ${DART_SASS_TARBALL} && \ export PATH=/opt/build/repo/dart-sass:$PATH && \ + npx --yes pagefind --site public make html \ """ From cf7d2d1e79fb4bd9bf18ba6daf5edfa76308c879 Mon Sep 17 00:00:00 2001 From: Basha MEGA Date: Sat, 8 Mar 2025 08:41:26 +0000 Subject: [PATCH 06/18] fix: command --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index a4ab67f9..99a98212 100644 --- a/netlify.toml +++ b/netlify.toml @@ -13,7 +13,7 @@ tar -xf ${DART_SASS_TARBALL} && \ rm ${DART_SASS_TARBALL} && \ export PATH=/opt/build/repo/dart-sass:$PATH && \ - npx --yes pagefind --site public + npx --yes pagefind --site public && \ make html \ """ From 2fb5a88e64d0721be69b8aa853567816e0ca9b7a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 8 Mar 2025 08:43:30 +0000 Subject: [PATCH 07/18] =?UTF-8?q?[pre-commit.ci=20=F0=9F=A4=96]=20Apply=20?= =?UTF-8?q?code=20format=20tools=20to=20PR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/css/search.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/css/search.css b/assets/css/search.css index 2b1b5264..9e66566b 100644 --- a/assets/css/search.css +++ b/assets/css/search.css @@ -23,4 +23,4 @@ /* unset a pagefind color setting to make results more legible in dark mode */ .pagefind-ui__result-title > .pagefind-ui__result-link { color: unset !important; -} \ No newline at end of file +} From 3c50e97cfc1940fc505946da65050ab9667d2504 Mon Sep 17 00:00:00 2001 From: Basha MEGA Date: Sat, 8 Mar 2025 08:49:37 +0000 Subject: [PATCH 08/18] fix: environment --- netlify.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/netlify.toml b/netlify.toml index 99a98212..552fbcd2 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,6 +1,7 @@ [build.environment] PYTHON_VERSION = "3.13" HUGO_VERSION = "0.141.0" + NODE_VERSION = "20" DART_SASS_VERSION = "1.83.4" DART_SASS_URL = "https://github.com/sass/dart-sass/releases/download/" From 079bc44ea0023de0d8cc698d2ea6f3584b9db376 Mon Sep 17 00:00:00 2001 From: Basha MEGA Date: Sat, 8 Mar 2025 08:58:45 +0000 Subject: [PATCH 09/18] Fix --- netlify.toml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index 552fbcd2..d07cba46 100644 --- a/netlify.toml +++ b/netlify.toml @@ -14,11 +14,18 @@ tar -xf ${DART_SASS_TARBALL} && \ rm ${DART_SASS_TARBALL} && \ export PATH=/opt/build/repo/dart-sass:$PATH && \ + if ! command -v make &> /dev/null; then apt-get update && apt-get install -y make; fi && \ npx --yes pagefind --site public && \ make html \ """ [[plugins]] package = "netlify-plugin-checklinks" + [plugins.inputs] - skipPatterns = ['*bot*', 'https://fonts.gstatic.com', 'https://fonts.googleapis.com', 'https://cdn.jsdelivr.net'] + skipPatterns = [ + '*bot*', + 'https://fonts.gstatic.com', + 'https://fonts.googleapis.com', + 'https://cdn.jsdelivr.net' + ] From c8b4bb00e38dee086b04f390278e95c31c3279e9 Mon Sep 17 00:00:00 2001 From: Basha MEGA Date: Sun, 9 Mar 2025 10:05:55 +0000 Subject: [PATCH 10/18] fix the makefile and netlify deployment --- Makefile | 6 ++++-- netlify.toml | 11 +---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index c15042de..153eaf7e 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,6 @@ .DEFAULT_GOAL := help SHELL:=/bin/bash -SEARCH = (echo "Installing \`pagefind\` and generating search index..." && npx --yes pagefind --site public) - # Add help text after each target name starting with '\#\#' help: ## show this help @echo -e "Help for this makefile\n" @@ -31,6 +29,7 @@ SPEC_DIR = content/specs/steering-committee TEAMS = community-managers community-leaders emeritus-community-leaders SPEC_TEAMS = spec-steering-committee emeritus-spec-steering-committee TEAMS_QUERY = python themes/scientific-python-hugo-theme/tools/team_query.py +SEARCH = (echo "Installing \`pagefind\` and generating search index..." && npx --yes pagefind --site public) $(TEAMS_DIR)/%.toml: $(TEAMS_QUERY) --org scientific-python --team "$*" > $(TEAMS_DIR)/$*.toml @@ -56,12 +55,15 @@ content/specs/core-projects/core-projects.json: content/specs/core-projects/[^_] @python tools/md-header-to-json.py $? > $@ html: prepare calendars core-project-json ## build the website in ./public + $(SEARCH) @hugo serve: prepare calendars core-project-json ## serve the website + $(SEARCH) @hugo --printI18nWarnings server serve-dev: prepare calendars + $(SEARCH) @hugo --printI18nWarnings server --disableFastRender clean: diff --git a/netlify.toml b/netlify.toml index d07cba46..4fc74cc6 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,7 +1,6 @@ [build.environment] PYTHON_VERSION = "3.13" HUGO_VERSION = "0.141.0" - NODE_VERSION = "20" DART_SASS_VERSION = "1.83.4" DART_SASS_URL = "https://github.com/sass/dart-sass/releases/download/" @@ -14,18 +13,10 @@ tar -xf ${DART_SASS_TARBALL} && \ rm ${DART_SASS_TARBALL} && \ export PATH=/opt/build/repo/dart-sass:$PATH && \ - if ! command -v make &> /dev/null; then apt-get update && apt-get install -y make; fi && \ - npx --yes pagefind --site public && \ make html \ """ [[plugins]] package = "netlify-plugin-checklinks" - [plugins.inputs] - skipPatterns = [ - '*bot*', - 'https://fonts.gstatic.com', - 'https://fonts.googleapis.com', - 'https://cdn.jsdelivr.net' - ] + skipPatterns = ['*bot*', 'https://fonts.gstatic.com', 'https://fonts.googleapis.com', 'https://cdn.jsdelivr.net'] From 70e28fdc6b7f240bac8bdfa2bd9109a32ca15ace Mon Sep 17 00:00:00 2001 From: Basha MEGA Date: Sun, 9 Mar 2025 10:11:11 +0000 Subject: [PATCH 11/18] chore: environment fixes --- netlify.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netlify.toml b/netlify.toml index 4fc74cc6..864dd3e0 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,7 +1,7 @@ [build.environment] PYTHON_VERSION = "3.13" - HUGO_VERSION = "0.141.0" - DART_SASS_VERSION = "1.83.4" + HUGO_VERSION = "0.142.0" + NODE_VERSION = "20" DART_SASS_URL = "https://github.com/sass/dart-sass/releases/download/" [build] From 6c60d7f80579b4031a2bbfd859995f198da2852c Mon Sep 17 00:00:00 2001 From: Basha MEGA Date: Sun, 9 Mar 2025 10:16:14 +0000 Subject: [PATCH 12/18] chore: bump sass version --- netlify.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/netlify.toml b/netlify.toml index 864dd3e0..20ebfb8d 100644 --- a/netlify.toml +++ b/netlify.toml @@ -2,6 +2,7 @@ PYTHON_VERSION = "3.13" HUGO_VERSION = "0.142.0" NODE_VERSION = "20" + DART_SASS_VERSION = "1.79.4" DART_SASS_URL = "https://github.com/sass/dart-sass/releases/download/" [build] From 58727d14166bcd57e956c837e9171e2039ee5e3d Mon Sep 17 00:00:00 2001 From: Basha MEGA Date: Sun, 9 Mar 2025 10:30:03 +0000 Subject: [PATCH 13/18] chore:fix theme dir --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 153eaf7e..d544c9db 100644 --- a/Makefile +++ b/Makefile @@ -55,14 +55,17 @@ content/specs/core-projects/core-projects.json: content/specs/core-projects/[^_] @python tools/md-header-to-json.py $? > $@ html: prepare calendars core-project-json ## build the website in ./public + hugo --themesDir="./themes"; $(SEARCH) @hugo serve: prepare calendars core-project-json ## serve the website + hugo --themesDir="./themes"; $(SEARCH) @hugo --printI18nWarnings server serve-dev: prepare calendars + hugo --themesDir="../"; $(SEARCH) @hugo --printI18nWarnings server --disableFastRender From 8895aab8efefe9e6f0c0b0d7e08fed047a6cccfd Mon Sep 17 00:00:00 2001 From: Adam Basha <110662505+Bashamega@users.noreply.github.com> Date: Tue, 11 Mar 2025 06:22:11 +0200 Subject: [PATCH 14/18] Delete assets/js/search.js --- assets/js/search.js | 123 -------------------------------------------- 1 file changed, 123 deletions(-) delete mode 100644 assets/js/search.js diff --git a/assets/js/search.js b/assets/js/search.js deleted file mode 100644 index b0d11f5a..00000000 --- a/assets/js/search.js +++ /dev/null @@ -1,123 +0,0 @@ -// This file is attributed to the Scientific Python Developers -// Source: https://github.com/scientific-python/scientific-python-hugo-theme/pull/615/files - -// BSD 3-Clause License - -// Copyright (c) 2021--2023, Scientific Python Developers -// All rights reserved. - -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: - -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. - -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. - -// 3. Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. - -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -// ---- - -// Adapted from the Hugo Fresh theme, which has the following license: - -// MIT License - -// Copyright (c) 2019 Stefan M. - -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -"use strict"; - -window.addEventListener("DOMContentLoaded", () => { - let searchDialog = document.querySelector(".search-dialog"); - let searchButton = document.getElementById("search-button"); - - // Do nothing here if search is not enabled. - if (!searchDialog || !searchButton) return; - - const isMac = /(Mac|iPhone|iPod|iPad)/i.test(navigator.userAgent); - searchButton.title = `Search (${isMac ? "⌘" : "Ctrl"} + K)`; - - new PagefindUI({ - element: ".search-dialog", - autofocus: true, - resetStyles: false, - showSubResults: true, - }); - - let showSearch = () => searchDialog.showModal(); - let hideSearch = () => searchDialog.close(); - - let toggleSearch = () => { - if (!searchDialog.open) { - showSearch(); - } else { - hideSearch(); - } - }; - - let isClickOutside = (elem, clickEvt) => { - const elemDims = elem.getBoundingClientRect(); - return ( - clickEvt.clientX < elemDims.left || - clickEvt.clientX > elemDims.right || - clickEvt.clientY < elemDims.top || - clickEvt.clientY > elemDims.bottom - ); - }; - - // Close the search dialog if user clicks outside of it when it is open. - // This feels like functionality that should really be natively supported - // by the dialog element already. - // https://blog.webdevsimplified.com/2023-04/html-dialog/ - searchDialog.addEventListener("click", (evt) => { - if (searchDialog.open && isClickOutside(searchDialog, evt)) { - hideSearch(); - } - }); - - window.addEventListener("keydown", (evt) => { - if ( - ((isMac && evt.metaKey) || (!isMac && evt.ctrlKey)) && - evt.key === "k" - ) { - evt.preventDefault(); // prevents default browser behaviour - toggleSearch(); - } - }); - - document - .querySelector(".search-button") - .addEventListener("click", showSearch); -}); From d134217399fc2acec240b7f2d9e8824936b5742f Mon Sep 17 00:00:00 2001 From: Adam Basha <110662505+Bashamega@users.noreply.github.com> Date: Tue, 11 Mar 2025 06:22:28 +0200 Subject: [PATCH 15/18] Delete assets/css/search.css --- assets/css/search.css | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 assets/css/search.css diff --git a/assets/css/search.css b/assets/css/search.css deleted file mode 100644 index 9e66566b..00000000 --- a/assets/css/search.css +++ /dev/null @@ -1,26 +0,0 @@ -.search-button { - border-radius: 20px; - padding: 8px; - margin-right: 15px; - cursor: pointer; -} -.search-dialog { - padding: 15px; - width: 80%; - border-radius: 1rem; -} -.search-dialog::backdrop { - background-color: rgb(0, 0, 0, 0.5); - backdrop-filter: blur(3px); -} -.search-dialog input { - padding: 10px 15px; - color: #333; -} -.pagefind-ui button { - border: none; -} -/* unset a pagefind color setting to make results more legible in dark mode */ -.pagefind-ui__result-title > .pagefind-ui__result-link { - color: unset !important; -} From fdd633465cc65253683b6a8d339557e068299b5b Mon Sep 17 00:00:00 2001 From: Adam Basha <110662505+Bashamega@users.noreply.github.com> Date: Tue, 11 Mar 2025 06:24:43 +0200 Subject: [PATCH 16/18] Undo netlify changes --- netlify.toml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/netlify.toml b/netlify.toml index 20ebfb8d..4fc74cc6 100644 --- a/netlify.toml +++ b/netlify.toml @@ -1,8 +1,7 @@ [build.environment] PYTHON_VERSION = "3.13" - HUGO_VERSION = "0.142.0" - NODE_VERSION = "20" - DART_SASS_VERSION = "1.79.4" + HUGO_VERSION = "0.141.0" + DART_SASS_VERSION = "1.83.4" DART_SASS_URL = "https://github.com/sass/dart-sass/releases/download/" [build] From 29236e29f6df1e230c9bd48ba088b775ae5f375b Mon Sep 17 00:00:00 2001 From: Basha MEGA Date: Wed, 12 Mar 2025 05:02:07 +0000 Subject: [PATCH 17/18] chore: modify the makefile --- Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index d544c9db..82764927 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ .DEFAULT_GOAL := help SHELL:=/bin/bash + # Add help text after each target name starting with '\#\#' help: ## show this help @echo -e "Help for this makefile\n" @@ -12,6 +13,7 @@ prepare: git submodule update --init ((python -c 'import yaml2ics' && pre-commit) > /dev/null 2>&1) || pip install -q -r requirements.txt test -f .git/hooks/pre-commit || pre-commit install + hugo; $(SEARCH) CALENDAR_DIR = content/calendars @@ -56,17 +58,14 @@ content/specs/core-projects/core-projects.json: content/specs/core-projects/[^_] html: prepare calendars core-project-json ## build the website in ./public hugo --themesDir="./themes"; - $(SEARCH) @hugo serve: prepare calendars core-project-json ## serve the website hugo --themesDir="./themes"; - $(SEARCH) @hugo --printI18nWarnings server serve-dev: prepare calendars hugo --themesDir="../"; - $(SEARCH) @hugo --printI18nWarnings server --disableFastRender clean: From c010a9687abd2abfc6b3358deb6b4c7a1f614223 Mon Sep 17 00:00:00 2001 From: Basha MEGA Date: Wed, 12 Mar 2025 05:04:19 +0000 Subject: [PATCH 18/18] chore: remove the hugo theme dir --- Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Makefile b/Makefile index 82764927..ee170b6b 100644 --- a/Makefile +++ b/Makefile @@ -57,15 +57,12 @@ content/specs/core-projects/core-projects.json: content/specs/core-projects/[^_] @python tools/md-header-to-json.py $? > $@ html: prepare calendars core-project-json ## build the website in ./public - hugo --themesDir="./themes"; @hugo serve: prepare calendars core-project-json ## serve the website - hugo --themesDir="./themes"; @hugo --printI18nWarnings server serve-dev: prepare calendars - hugo --themesDir="../"; @hugo --printI18nWarnings server --disableFastRender clean: