diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index 18a45d851..42e1f08bc 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -71,6 +71,9 @@ def load_engine(engine_data): if not hasattr(engine, 'language_support'): engine.language_support = True + if not hasattr(engine, 'safesearch'): + engine.safesearch = False + if not hasattr(engine, 'timeout'): engine.timeout = settings['server']['request_timeout'] diff --git a/searx/templates/oscar/preferences.html b/searx/templates/oscar/preferences.html index 693167807..ee4e6ab57 100644 --- a/searx/templates/oscar/preferences.html +++ b/searx/templates/oscar/preferences.html @@ -134,21 +134,48 @@
+
+ + + {% if not rtl %} + + + + + + + {% else %} + + + + + + + {% endif %} + {% for search_engine in engines_by_category[categ] %} {% if not search_engine.private %} -
+
{% if not rtl %} -
{{ search_engine.name }} ({{ shortcuts[search_engine.name] }})
+ + + + + + + {% else %} + + + + + + {% endif %} -
- {{ checkbox_toggle('engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_'), (search_engine.name, categ) in blocked_engines) }} -
- {% if rtl %} -
{{ search_engine.name }} ({{ shortcuts[search_engine.name] }})‎
- {% endif %} - + {% endif %} {% endfor %} +
{{ _("Allow") }}{{ _("Engine name") }}{{ _("Shortcut") }}{{ _("SafeSearch") }}{{ _("Avg. time") }}{{ _("Max time") }}{{ _("Max time") }}{{ _("Avg. time") }}{{ _("SafeSearch") }}{{ _("Shortcut") }}{{ _("Engine name") }}{{ _("Allow") }}
{{ checkbox_toggle('engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_'), (search_engine.name, categ) in blocked_engines) }}{{ search_engine.name }}{{ shortcuts[search_engine.name] }}{{ 'N/A' if stats[search_engine.name].time==None else stats[search_engine.name].time }}{{ search_engine.timeout }}{{ search_engine.timeout }}{{ 'N/A' if stats[search_engine.name].time==None else stats[search_engine.name].time }}{{ shortcuts[search_engine.name] }}{{ search_engine.name }}{{ checkbox_toggle('engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_'), (search_engine.name, categ) in blocked_engines) }}
+
diff --git a/searx/webapp.py b/searx/webapp.py index 3ef5a72c8..8587d546a 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -623,6 +623,24 @@ def preferences(): resp.set_cookie('theme', theme, max_age=cookie_max_age) return resp + + # stats for preferences page + stats = {} + + for c in categories: + for e in categories[c]: + stats[e.name] = {'time': None, + 'warn_timeout': False, + 'warn_time': False} + if e.timeout > settings['server']['request_timeout']: + stats[e.name]['warn_timeout'] = True + + for engine_stat in get_engines_stats()[0][1]: + stats[engine_stat.get('name')]['time'] = round(engine_stat.get('avg'), 3) + if engine_stat.get('avg') > settings['server']['request_timeout']: + stats[engine_stat.get('name')]['warn_time'] = True + # end of stats + return render('preferences.html', locales=settings['locales'], current_locale=get_locale(), @@ -630,6 +648,7 @@ def preferences(): image_proxy=image_proxy, language_codes=language_codes, engines_by_category=categories, + stats=stats, blocked_engines=blocked_engines, autocomplete_backends=autocomplete_backends, shortcuts={y: x for x, y in engine_shortcuts.items()},