From ca94fab29f0042b7ce7eb8cd0028abda8325bc15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksa=20Siri=C5=A1ki?= <31509435+aleksasiriski@users.noreply.github.com> Date: Sat, 16 Nov 2024 17:01:15 +0100 Subject: [PATCH 1/4] feat: remove categories from config and instead pass them as base64 encoded json param --- .../components/results/general/main.svelte | 2 +- .../components/results/general/single.svelte | 2 +- src/lib/components/results/images/main.svelte | 4 +- .../components/results/images/preview.svelte | 4 +- .../components/results/images/single.svelte | 4 +- .../results/infiniteloading/main.svelte | 21 ++- src/lib/components/searchbox/main.svelte | 10 +- src/lib/functions/api/additionalresults.js | 44 ++++- src/lib/functions/api/createurl.js | 2 +- src/lib/functions/api/fetchapi.js | 36 ++-- src/lib/functions/api/fetchapiversion.js | 2 +- src/lib/functions/api/proxyimage.js | 4 +- src/lib/functions/categories/images.js | 47 ++++++ src/lib/functions/categories/science.js | 36 ++++ src/lib/functions/categories/suggestions.js | 47 ++++++ src/lib/functions/categories/thorough.js | 159 ++++++++++++++++++ src/lib/functions/categories/web.js | 159 ++++++++++++++++++ src/lib/types/search/assert.js | 11 ++ src/lib/types/search/category.js | 82 +++++---- src/lib/types/search/categoryenum.js | 40 +++++ src/lib/types/search/response.js | 16 +- src/lib/types/search/result.js | 37 +++- src/lib/types/search/suggestion.js | 15 -- src/routes/opensearch.xml/+server.js | 2 +- src/routes/search/+page.js | 20 ++- src/routes/search/+page.svelte | 8 +- 26 files changed, 695 insertions(+), 119 deletions(-) create mode 100644 src/lib/functions/categories/images.js create mode 100644 src/lib/functions/categories/science.js create mode 100644 src/lib/functions/categories/suggestions.js create mode 100644 src/lib/functions/categories/thorough.js create mode 100644 src/lib/functions/categories/web.js create mode 100644 src/lib/types/search/assert.js create mode 100644 src/lib/types/search/categoryenum.js delete mode 100644 src/lib/types/search/suggestion.js diff --git a/src/lib/components/results/general/main.svelte b/src/lib/components/results/general/main.svelte index 879c3488..81f1dbe1 100644 --- a/src/lib/components/results/general/main.svelte +++ b/src/lib/components/results/general/main.svelte @@ -9,7 +9,7 @@ * @property {string} query * @property {string} category * @property {number} currentPage - * @property {ResultType[]} results + * @property {WebResultType[]} results */ /** @type {Props} */ diff --git a/src/lib/components/results/general/single.svelte b/src/lib/components/results/general/single.svelte index 56e8dfd7..b627cd33 100644 --- a/src/lib/components/results/general/single.svelte +++ b/src/lib/components/results/general/single.svelte @@ -4,7 +4,7 @@ /** * @typedef {object} Props - * @property {ResultType} result + * @property {WebResultType} result */ /** @type {Props} */ diff --git a/src/lib/components/results/images/main.svelte b/src/lib/components/results/images/main.svelte index 737bdb5a..a8a0fc93 100644 --- a/src/lib/components/results/images/main.svelte +++ b/src/lib/components/results/images/main.svelte @@ -10,8 +10,8 @@ * @property {string} query * @property {string} category * @property {number} currentPage - * @property {ResultType[]} results - * @property {ResultType | undefined} imagePreview + * @property {ImagesResultType[]} results + * @property {ImagesResultType | undefined} imagePreview */ /** @type {Props} */ diff --git a/src/lib/components/results/images/preview.svelte b/src/lib/components/results/images/preview.svelte index 9b18029f..b85354e4 100644 --- a/src/lib/components/results/images/preview.svelte +++ b/src/lib/components/results/images/preview.svelte @@ -3,8 +3,8 @@ /** * @typedef {object} Props - * @property {ResultType} result - * @property {ResultType | undefined} imagePreview + * @property {ImagesResultType} result + * @property {ImagesResultType | undefined} imagePreview */ /** @type {Props} */ diff --git a/src/lib/components/results/images/single.svelte b/src/lib/components/results/images/single.svelte index 733d5b3d..a38c4d1a 100644 --- a/src/lib/components/results/images/single.svelte +++ b/src/lib/components/results/images/single.svelte @@ -3,8 +3,8 @@ /** * @typedef {object} Props - * @property {ResultType} result - * @property {ResultType | undefined} imagePreview + * @property {ImagesResultType} result + * @property {ImagesResultType | undefined} imagePreview */ /** @type {Props} */ diff --git a/src/lib/components/results/infiniteloading/main.svelte b/src/lib/components/results/infiniteloading/main.svelte index dd0c39a5..0ab25d77 100644 --- a/src/lib/components/results/infiniteloading/main.svelte +++ b/src/lib/components/results/infiniteloading/main.svelte @@ -1,14 +1,18 @@ diff --git a/src/lib/components/searchbox/main.svelte b/src/lib/components/searchbox/main.svelte index 6cf1b1e9..a43d04d2 100644 --- a/src/lib/components/searchbox/main.svelte +++ b/src/lib/components/searchbox/main.svelte @@ -1,7 +1,7 @@