From 949a73103fb8af519544409aa7c0af8c6b72358e Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 15 May 2024 12:25:52 +0200 Subject: [PATCH] [mod] hex engine: normalize (some of) the linked terms The names of the links are rather tags than real names, and they sometimes vary greatly in their spelling: - GitHub: github, Github - Source code: Repository, SCM, Project Source Code - Documentation: docs, Documentation It was standardized to terms such as 'Source code' and 'Documentation', as translations already exist for these terms. Signed-off-by: Markus Heiser --- searx/engines/hex.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/searx/engines/hex.py b/searx/engines/hex.py index 28b536d97..2c1036f4d 100644 --- a/searx/engines/hex.py +++ b/searx/engines/hex.py @@ -22,6 +22,29 @@ categories = ["it", "packages"] paging = True search_url = "https://hex.pm/api/packages/" +linked_terms = { + # lower-case : replacement + "author": "Author", + "bitbucket": "Bitbucket", + "bug tracker": "Issue tracker", + "changelog": "Changelog", + "doc": "Documentation", + "docs": "Documentation", + "documentation": "Documentation", + "github repository": "GitHub", + "github": "GitHub", + "gitlab": "GitLab", + "issues": "Issue tracker", + "project source code": "Source code", + "repository": "Source code", + "scm": "Source code", + "sourcehut": "SourceHut", + "sources": "Source code", + "sponsor": "Sponsors", + "sponsors": "Sponsors", + "website": "Homepage", +} + def request(query: str, params): args = urlencode({"page": params["pageno"], "search": query}) @@ -35,7 +58,7 @@ def response(resp): meta = package["meta"] published_date = package.get("updated_at") published_date = parser.parse(published_date) - links = meta.get("links") + links = {linked_terms.get(k.lower(), k): v for k, v in meta.get("links").items()} results.append( { "template": "packages.html",