forked from Ponysearch/Ponysearch
[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>
This commit is contained in:
parent
cc8b537e34
commit
949a73103f
1 changed files with 24 additions and 1 deletions
|
@ -22,6 +22,29 @@ categories = ["it", "packages"]
|
||||||
paging = True
|
paging = True
|
||||||
search_url = "https://hex.pm/api/packages/"
|
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):
|
def request(query: str, params):
|
||||||
args = urlencode({"page": params["pageno"], "search": query})
|
args = urlencode({"page": params["pageno"], "search": query})
|
||||||
|
@ -35,7 +58,7 @@ def response(resp):
|
||||||
meta = package["meta"]
|
meta = package["meta"]
|
||||||
published_date = package.get("updated_at")
|
published_date = package.get("updated_at")
|
||||||
published_date = parser.parse(published_date)
|
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(
|
results.append(
|
||||||
{
|
{
|
||||||
"template": "packages.html",
|
"template": "packages.html",
|
||||||
|
|
Loading…
Reference in a new issue