From 1174fde1f349b300ee008b6d77b366aadbaa9758 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Wed, 3 Dec 2025 09:57:42 +0100 Subject: [PATCH] [feat] engines: add lucide icons (#5503) --- searx/engines/lucide.py | 69 +++++++++++++++++++++++++++++++++++++++++ searx/settings.yml | 5 +++ 2 files changed, 74 insertions(+) create mode 100644 searx/engines/lucide.py diff --git a/searx/engines/lucide.py b/searx/engines/lucide.py new file mode 100644 index 000000000..ad62f3038 --- /dev/null +++ b/searx/engines/lucide.py @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +"""Browse one of the largest collections of copyleft icons +that can be used for own projects (e.g. apps, websites). + +.. _Website: https://lucide.dev + +""" + +import typing as t + +from searx.result_types import EngineResults + +if t.TYPE_CHECKING: + from extended_types import SXNG_Response + from search.processors.online import OnlineParams + + +about = { + "website": "https://lucide.dev/", + "wikidata_id": None, + "official_api_documentation": None, + "use_official_api": True, + "results": "JSON", +} + +cdn_base_url = "https://cdn.jsdelivr.net/npm/lucide-static" +categories = ["images", "icons"] + + +def request(query: str, params: "OnlineParams"): + params["url"] = f"{cdn_base_url}/tags.json" + params['query'] = query + return params + + +def response(resp: "SXNG_Response") -> EngineResults: + res = EngineResults() + query_parts = resp.search_params["query"].lower().split(" ") + + def is_result_match(result: tuple[str, list[str]]) -> bool: + icon_name, tags = result + + for part in query_parts: + if part in icon_name: + return True + + for tag in tags: + if part in tag: + return True + + return False + + filtered_results = filter(is_result_match, resp.json().items()) + for icon_name, tags in filtered_results: + img_src = f"{cdn_base_url}/icons/{icon_name}.svg" + res.add( + res.types.LegacyResult( + { + "template": "images.html", + "url": img_src, + "title": icon_name, + "content": ", ".join(tags), + "img_src": img_src, + "img_format": "SVG", + } + ) + ) + + return res diff --git a/searx/settings.yml b/searx/settings.yml index 6f6833f5d..be0d8259b 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -1293,6 +1293,11 @@ engines: require_api_key: false results: HTML + - name: lucide + engine: lucide + shortcut: luc + timeout: 3.0 + - name: marginalia engine: marginalia shortcut: mar