From 90f87b4c001fd959eaa55c1607bcb349d49ecd3d Mon Sep 17 00:00:00 2001 From: kvan7 Date: Thu, 2 Nov 2023 15:39:57 +0000 Subject: [PATCH] update initial prefs --- UPDATE.md | 2 +- searx/engines/devdocs.py | 96 ++++++++++++++++++++++++++++++++++++++++ searx/settings.yml | 7 +-- 3 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 searx/engines/devdocs.py diff --git a/UPDATE.md b/UPDATE.md index ca9489cb6..aac03c33a 100644 --- a/UPDATE.md +++ b/UPDATE.md @@ -4,6 +4,6 @@ Updating steps, follow exactly. 1. Commit and push changes to github 2. login to server, (gar use `server` alias) -3. run the command `cd /usr/local/searxng/searxng-src && git pull` +3. run the command `cd /usr/local/searxng/searxng-src && sudo git pull` 4. run the command `sudo -H ./utils/searxng.sh instance update` 5. confirm update diff --git a/searx/engines/devdocs.py b/searx/engines/devdocs.py new file mode 100644 index 000000000..d391a72d6 --- /dev/null +++ b/searx/engines/devdocs.py @@ -0,0 +1,96 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# lint: pylint +"""Within this module we implement a devdocs. Do not look to +close to the implementation, its just a simple example which queries `The Art +Institute of Chicago `_ + +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 = { + "website": 'https://devdocs.io', + # "wikidata_id": 'Q239303', + "official_api_documentation": 'https://devdocs.io/help', + "use_official_api": True, + "require_api_key": False, + "results": 'JSON', +} + + +# if there is a need for globals, use a leading underline +_my_online_engine = None + + +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 `__ + + """ + # 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 `__ + + """ + 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 diff --git a/searx/settings.yml b/searx/settings.yml index e10401a78..429fe0e0a 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -295,6 +295,7 @@ categories_as_tabs: science: files: social media: + # devdocs: engines: - name: 9gag @@ -1493,7 +1494,7 @@ engines: engine: startpage shortcut: sp timeout: 6.0 - disabled: true + disabled: false additional_tests: rosebud: *test_rosebud @@ -1599,7 +1600,7 @@ engines: - name: yahoo engine: yahoo shortcut: yh - disabled: true + disabled: false - name: yahoo news engine: yahoo_news @@ -1633,7 +1634,7 @@ engines: content_query: Snippet categories: [general, web] shortcut: wib - disabled: true + disabled: false about: website: https://wiby.me/