From 80fb77476fad4b229418c530f3ffda67f357a15a Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Sat, 6 Nov 2021 12:26:48 +0100 Subject: [PATCH] [mod] new preference: query_in_title * disable by default * settings.yml: ui.query_in_title * in /preferences: privacy tab when enabled, the result page's title contains the user query. previously: * oscar theme: the query was always included * simple theme: the query was included with the GET method --- searx/preferences.py | 11 +++++++++++ searx/settings.yml | 4 ++++ searx/settings_defaults.py | 1 + searx/templates/oscar/preferences.html | 11 +++++++++++ searx/templates/oscar/results.html | 2 +- searx/templates/simple/preferences.html | 12 ++++++++++++ searx/templates/simple/results.html | 2 +- searx/webapp.py | 1 + 8 files changed, 42 insertions(+), 2 deletions(-) diff --git a/searx/preferences.py b/searx/preferences.py index 5ff89c969..8cfa5404b 100644 --- a/searx/preferences.py +++ b/searx/preferences.py @@ -405,6 +405,17 @@ class Preferences: 'on': True, } ), + 'query_in_title': MapSetting( + settings['ui']['query_in_title'], + is_locked('query_in_title'), + map={ + '': settings['ui']['query_in_title'], + '0': False, + '1': True, + 'True': True, + 'False': False + } + ), } self.engines = EnginesSetting('engines', choices=engines) diff --git a/searx/settings.yml b/searx/settings.yml index f53e3257b..89bf4ff4c 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -66,6 +66,9 @@ ui: static_path: "" # Custom templates path - leave it blank if you didn't change templates_path: "" + # query_in_title: When true, the result page's titles contains the query + # it decreases the privacy, since the browser can records the page titles. + query_in_title: false # ui theme default_theme: oscar # Default interface locale - leave blank to detect from browser information or @@ -91,6 +94,7 @@ ui: # - language # - autocomplete # - method +# - query_in_title # searx supports result proxification using an external service: # https://github.com/asciimoo/morty uncomment below section if you have running diff --git a/searx/settings_defaults.py b/searx/settings_defaults.py index 1a755fb8b..79f72c52b 100644 --- a/searx/settings_defaults.py +++ b/searx/settings_defaults.py @@ -186,6 +186,7 @@ SCHEMA = { }, 'results_on_new_tab': SettingsValue(bool, False), 'advanced_search': SettingsValue(bool, False), + 'query_in_title': SettingsValue(bool, False), 'categories_order': SettingsValue(list, CATEGORY_ORDER), }, 'preferences': { diff --git a/searx/templates/oscar/preferences.html b/searx/templates/oscar/preferences.html index 944a390ef..a54ca25d9 100644 --- a/searx/templates/oscar/preferences.html +++ b/searx/templates/oscar/preferences.html @@ -280,6 +280,17 @@ {{ preferences_item_footer(image_proxy_info, image_proxy_label, rtl) }} {% endif %} + {% if 'query_in_title' not in locked_preferences %} + {% set query_in_title_label = _('Query in the page\'s title') %} + {% set query_in_title_info = _('When enabled, the result page\'s title contains your query. Your browser can record this title') %} + {{ preferences_item_header(query_in_title_info, query_in_title_label, rtl, 'query_in_title') }} + + {{ preferences_item_footer(query_in_title_info, query_in_title_label, rtl) }} + {% endif %} + {{ plugin_of_category('privacy' )}} diff --git a/searx/templates/oscar/results.html b/searx/templates/oscar/results.html index b5bedcd44..ce99fe0ac 100644 --- a/searx/templates/oscar/results.html +++ b/searx/templates/oscar/results.html @@ -16,7 +16,7 @@ {%- endmacro %} {%- macro search_url() %}{{ url_for('search', _external=True) }}?q={{ q|urlencode }}{% if selected_categories %}&categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}{% if pageno > 1 %}&pageno={{ pageno }}{% endif %}{% if time_range %}&time_range={{ time_range }}{% endif %}{% if current_language != 'all' %}&language={{ current_language }}{% endif %}{% endmacro -%} -{% block title %}{{ q|e }} - {% endblock %} +{% block title %}{% if query_in_title %}{{- q|e -}} - {% endif %}{% endblock %} {% block meta %}{{" "}}{% endblock %} {% block content %} {% include 'oscar/search.html' %} diff --git a/searx/templates/simple/preferences.html b/searx/templates/simple/preferences.html index 90d01d2b6..995170754 100644 --- a/searx/templates/simple/preferences.html +++ b/searx/templates/simple/preferences.html @@ -237,6 +237,18 @@
{{ _('Proxying image results through SearXNG') }}
{% endif %} + {% if 'query_in_title' not in locked_preferences %} +
+ {{ _('Query in the page\'s title') }} +

+ +

+
{{ _('When enabled, the result page\'s title contains your query. Your browser can record this title.') }}
+
+ {% endif %} {{ plugin_preferences('privacy') }} {{ tab_footer() }} diff --git a/searx/templates/simple/results.html b/searx/templates/simple/results.html index 59874dab3..05cbc45d7 100644 --- a/searx/templates/simple/results.html +++ b/searx/templates/simple/results.html @@ -7,7 +7,7 @@ {% endfor %} {% endfor %} {%- endmacro %} -{% block title %}{% if method == 'GET' %}{{- q|e -}} -{% endif %}{% endblock %} +{% block title %}{% if query_in_title %}{{- q|e -}} - {% endif %}{% endblock %} {% block meta %}{% endblock %} {% block content %} diff --git a/searx/webapp.py b/searx/webapp.py index 98480e4b6..ff4bf694c 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -425,6 +425,7 @@ def render(template_name, override_theme=None, **kwargs): kwargs['autocomplete'] = request.preferences.get_value('autocomplete') kwargs['results_on_new_tab'] = request.preferences.get_value('results_on_new_tab') kwargs['advanced_search'] = request.preferences.get_value('advanced_search') + kwargs['query_in_title'] = request.preferences.get_value('query_in_title') kwargs['safesearch'] = str(request.preferences.get_value('safesearch')) kwargs['theme'] = get_current_theme_name(override=override_theme) kwargs['all_categories'] = _get_ordered_categories()