mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
[feat] engine: add selfh.st/icons for logos of common self-hosted programs
This commit is contained in:
parent
6dab7fe78b
commit
303f9c9b27
2 changed files with 60 additions and 0 deletions
54
searx/engines/selfhst.py
Normal file
54
searx/engines/selfhst.py
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
"""selfh.st/icons - A collection of logos for self-hosted dashboards and
|
||||||
|
documentation"""
|
||||||
|
|
||||||
|
from dateutil import parser
|
||||||
|
|
||||||
|
about = {
|
||||||
|
'website': 'https://selfh.st/icons/',
|
||||||
|
'official_api_documentation': 'https://selfh.st/icons-about/',
|
||||||
|
"use_official_api": True,
|
||||||
|
"require_api_key": False,
|
||||||
|
"results": 'JSON',
|
||||||
|
}
|
||||||
|
categories = ['images']
|
||||||
|
|
||||||
|
|
||||||
|
icons_list_url = 'https://cdn.selfh.st/directory/icons.json'
|
||||||
|
icons_cdn_base_url = 'https://cdn.jsdelivr.net'
|
||||||
|
|
||||||
|
|
||||||
|
def request(query, params):
|
||||||
|
params['url'] = icons_list_url
|
||||||
|
params['query'] = query
|
||||||
|
return params
|
||||||
|
|
||||||
|
|
||||||
|
def response(resp):
|
||||||
|
results = []
|
||||||
|
|
||||||
|
query_parts = resp.search_params['query'].lower().split(' ')
|
||||||
|
for item in resp.json():
|
||||||
|
keyword = item['Reference'].lower()
|
||||||
|
if not any(query_part in keyword for query_part in query_parts):
|
||||||
|
continue
|
||||||
|
|
||||||
|
img_format = None
|
||||||
|
for format_name in ('SVG', 'PNG', 'WebP'):
|
||||||
|
if item[format_name] == 'Yes':
|
||||||
|
img_format = format_name.lower()
|
||||||
|
break
|
||||||
|
|
||||||
|
img_src = f'{icons_cdn_base_url}/gh/selfhst/icons/{img_format}/{item["Reference"]}.{img_format}'
|
||||||
|
result = {
|
||||||
|
'template': 'images.html',
|
||||||
|
'url': img_src,
|
||||||
|
'title': item['Name'],
|
||||||
|
'content': '',
|
||||||
|
'img_src': img_src,
|
||||||
|
'img_format': img_format,
|
||||||
|
'publishedDate': parser.parse(item['CreatedAt']),
|
||||||
|
}
|
||||||
|
results.append(result)
|
||||||
|
|
||||||
|
return results
|
|
@ -1658,6 +1658,12 @@ engines:
|
||||||
about:
|
about:
|
||||||
website: https://searchmysite.net
|
website: https://searchmysite.net
|
||||||
|
|
||||||
|
- name: selfhst icons
|
||||||
|
engine: selfhst
|
||||||
|
shortcut: si
|
||||||
|
inactive: true
|
||||||
|
disabled: true
|
||||||
|
|
||||||
- name: sepiasearch
|
- name: sepiasearch
|
||||||
engine: sepiasearch
|
engine: sepiasearch
|
||||||
shortcut: sep
|
shortcut: sep
|
||||||
|
|
Loading…
Add table
Reference in a new issue