mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
stuffs
This commit is contained in:
parent
651ae09303
commit
0392224e19
4 changed files with 19 additions and 87 deletions
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
|
@ -12,6 +12,10 @@
|
||||||
"editor.tabSize": 2,
|
"editor.tabSize": 2,
|
||||||
"editor.insertSpaces": true
|
"editor.insertSpaces": true
|
||||||
},
|
},
|
||||||
|
"[python]"{
|
||||||
|
"editor.tabSize": 4,
|
||||||
|
"editor.insertSpaces": true
|
||||||
|
},
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"kvan"
|
"kvan"
|
||||||
]
|
]
|
||||||
|
|
|
@ -17,3 +17,4 @@ markdown-it-py==3.0.0
|
||||||
typing_extensions==4.8.0
|
typing_extensions==4.8.0
|
||||||
fasttext-predict==0.9.2.1
|
fasttext-predict==0.9.2.1
|
||||||
pytomlpp==1.0.13
|
pytomlpp==1.0.13
|
||||||
|
requests-html==0.10.0
|
||||||
|
|
|
@ -1,96 +1,22 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
# lint: pylint
|
"""
|
||||||
"""Within this module we implement a devdocs. Do not look to
|
Dummy Offline
|
||||||
close to the implementation, its just a simple example which queries `The Art
|
|
||||||
Institute of Chicago <https://www.artic.edu>`_
|
|
||||||
|
|
||||||
To get in use of this *demo* engine add the following entry to your engines
|
|
||||||
list in ``settings.yml``:
|
|
||||||
|
|
||||||
.. code:: yaml
|
|
||||||
|
|
||||||
- name: DevDocs
|
|
||||||
engine: devdocs
|
|
||||||
shortcut: dev
|
|
||||||
disabled: false
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from json import loads
|
|
||||||
from urllib.parse import urlencode
|
|
||||||
|
|
||||||
engine_type = 'online'
|
|
||||||
send_accept_language_header = True
|
|
||||||
categories = ['general']
|
|
||||||
disabled = True
|
|
||||||
timeout = 2.0
|
|
||||||
categories = ['images']
|
|
||||||
paging = True
|
|
||||||
page_size = 20
|
|
||||||
|
|
||||||
search_api = 'https://devdocs.io/#q='
|
|
||||||
image_api = ''
|
|
||||||
|
|
||||||
|
# about
|
||||||
about = {
|
about = {
|
||||||
"website": 'https://devdocs.io',
|
"wikidata_id": None,
|
||||||
# "wikidata_id": 'Q239303',
|
"official_api_documentation": None,
|
||||||
"official_api_documentation": 'https://devdocs.io/help',
|
"use_official_api": False,
|
||||||
"use_official_api": True,
|
|
||||||
"require_api_key": False,
|
"require_api_key": False,
|
||||||
"results": 'JSON',
|
"results": 'HTML',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# if there is a need for globals, use a leading underline
|
def search(query, request_params):
|
||||||
_my_online_engine = None
|
return [
|
||||||
|
{
|
||||||
|
'result': 'this is what you get',
|
||||||
def init(engine_settings):
|
}
|
||||||
"""Initialization of the (online) engine. If no initialization is needed, drop
|
]
|
||||||
this init function.
|
|
||||||
|
|
||||||
"""
|
|
||||||
global _my_online_engine # pylint: disable=global-statement
|
|
||||||
_my_online_engine = engine_settings.get('name')
|
|
||||||
|
|
||||||
|
|
||||||
def request(query, params):
|
|
||||||
"""Build up the ``params`` for the online request. In this example we build a
|
|
||||||
URL to fetch images from `devdocs.io <https://devdocs.io>`__
|
|
||||||
|
|
||||||
"""
|
|
||||||
# args = urlencode(
|
|
||||||
# {
|
|
||||||
# 'q': query,
|
|
||||||
# }
|
|
||||||
# )
|
|
||||||
params['url'] = search_api + query
|
|
||||||
return params
|
|
||||||
|
|
||||||
|
|
||||||
def response(resp):
|
|
||||||
"""Parse out the result items from the response. In this we parse the
|
|
||||||
response from `devdocs.io <https://devdocs.io>`__
|
|
||||||
|
|
||||||
"""
|
|
||||||
results = []
|
|
||||||
json_data = loads(resp.text)
|
|
||||||
|
|
||||||
for result in json_data['data']:
|
|
||||||
|
|
||||||
if not result['image_id']:
|
|
||||||
continue
|
|
||||||
|
|
||||||
results.append(
|
|
||||||
{
|
|
||||||
'url': 'https://artic.edu/artworks/%(id)s' % result,
|
|
||||||
'title': result['title'] + " (%(date_display)s) // %(artist_display)s" % result,
|
|
||||||
'content': result['medium_display'],
|
|
||||||
'author': ', '.join(result['artist_titles']),
|
|
||||||
'img_src': image_api + '/%(image_id)s/full/843,/0/default.jpg' % result,
|
|
||||||
'img_format': result['dimensions'],
|
|
||||||
'template': 'images.html',
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
return results
|
|
||||||
|
|
|
@ -1064,6 +1064,7 @@ engines:
|
||||||
- name: metacpan
|
- name: metacpan
|
||||||
engine: metacpan
|
engine: metacpan
|
||||||
shortcut: cpan
|
shortcut: cpan
|
||||||
|
categories: [it, code, packages]
|
||||||
disabled: true
|
disabled: true
|
||||||
number_of_results: 20
|
number_of_results: 20
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue