diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2024-05-15 12:25:52 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarIT.de> | 2024-05-15 12:50:35 +0200 |
commit | 949a73103fb8af519544409aa7c0af8c6b72358e (patch) | |
tree | 84290918a623921dadf101d9d6e8f7d60a9af1d6 | |
parent | cc8b537e3446444cba4196b73bc49a7ef4a6def3 (diff) | |
download | searxng-949a73103fb8af519544409aa7c0af8c6b72358e.tar.gz searxng-949a73103fb8af519544409aa7c0af8c6b72358e.zip |
[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 <markus.heiser@darmarit.de>
-rw-r--r-- | searx/engines/hex.py | 25 |
1 files changed, 24 insertions, 1 deletions
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", |