diff options
| author | Alexandre Flament <alex@al-f.net> | 2021-09-25 11:29:25 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-25 11:29:25 +0200 |
| commit | b046322c7b9467a7de6e9e289e1c5b0c0baaf4a6 (patch) | |
| tree | 13174681c3d10bcc86faa417c9fb639e0a98692e /searx/webapp.py | |
| parent | 0c3314b33872d68d97d8aede8786a7f56f9831d8 (diff) | |
| parent | 39876d9f144700b223819a0f50101625a1b85e3c (diff) | |
Merge pull request #333 from dalf/enh-engine-descriptions
RFC: /preferences: display engine descriptions
Diffstat (limited to 'searx/webapp.py')
| -rwxr-xr-x | searx/webapp.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index cffde08a3..21b00188c 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -54,6 +54,7 @@ from searx import ( settings, searx_debug, ) +from searx.data import ENGINE_DESCRIPTIONS from searx.settings_defaults import OUTPUT_FORMATS from searx.settings_loader import get_default_settings_path from searx.exceptions import SearxParameterException @@ -393,7 +394,9 @@ def image_proxify(url): def get_translations(): return { # when there is autocompletion - 'no_item_found': gettext('No item found') + 'no_item_found': gettext('No item found'), + # /preferences: the source of the engine description (wikipedata, wikidata, website) + 'Source': gettext('Source'), } @@ -1140,6 +1143,23 @@ def image_proxy(): return '', 400 +@app.route('/engine_descriptions.json', methods=['GET']) +def engine_descriptions(): + locale = get_locale().split('_')[0] + result = ENGINE_DESCRIPTIONS['en'].copy() + if locale != 'en': + for engine, description in ENGINE_DESCRIPTIONS.get(locale, {}).items(): + result[engine] = description + for engine, description in result.items(): + if len(description) ==2 and description[1] == 'ref': + ref_engine, ref_lang = description[0].split(':') + description = ENGINE_DESCRIPTIONS[ref_lang][ref_engine] + if isinstance(description, str): + description = [ description, 'wikipedia' ] + result[engine] = description + return jsonify(result) + + @app.route('/stats', methods=['GET']) def stats(): """Render engine statistics page.""" |