[mod] engine hex: add sort_criteria & page_size to configuration

This commit is contained in:
Daniel Kukula 2024-05-16 20:44:34 +01:00 committed by Markus Heiser
parent 75e4b65127
commit 87165ac532
2 changed files with 7 additions and 1 deletions

View File

@ -21,6 +21,9 @@ categories = ["it", "packages"]
# engine dependent config # engine dependent config
paging = True paging = True
search_url = "https://hex.pm/api/packages/" search_url = "https://hex.pm/api/packages/"
# Valid values: name inserted_at updated_at total_downloads recent_downloads
sort_criteria = "recent_downloads"
page_size = 10
linked_terms = { linked_terms = {
# lower-case : replacement # lower-case : replacement
@ -47,7 +50,7 @@ linked_terms = {
def request(query: str, params): def request(query: str, params):
args = urlencode({"page": params["pageno"], "search": query}) args = urlencode({"page": params["pageno"], "per_page": page_size, "sort": sort_criteria, "search": query})
params["url"] = f"{search_url}?{args}" params["url"] = f"{search_url}?{args}"
return params return params

View File

@ -923,6 +923,9 @@ engines:
engine: hex engine: hex
shortcut: hex shortcut: hex
disabled: true disabled: true
# Valid values: name inserted_at updated_at total_downloads recent_downloads
sort_criteria: "recent_downloads"
page_size: 10
- name: crates.io - name: crates.io
engine: crates engine: crates