From 362cc13aeb5c647387e8ed77cbd4919f86fd0833 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 9 Oct 2025 22:03:32 +0200 Subject: [PATCH] [feat] preferences hash: show applied settings in pref page when searching with 'search url of the currently saved preferences' Previously, when using a search url copied from the cookies tab, clicking at the settings icon at the top right would show the browser preferences and not the preferences that were set and used with the search url. Please see https://github.com/searxng/searxng/issues/5227 for more information. To test: - change some preferences - copy the preferences search url in the settings' cookies tab - reset the preferences or clear cookies - paste the copied search url into the search bar to search for something - press the settings icon - you can now see/preview the actual settings that were used for the search - by pressing 'save', you can keep these preferences closes #5227 --- client/simple/src/less/toolkit.less | 9 +++++++++ searx/templates/simple/base.html | 6 +++++- searx/templates/simple/preferences.html | 10 ++++++++++ searx/webapp.py | 7 +++++-- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/client/simple/src/less/toolkit.less b/client/simple/src/less/toolkit.less index 223ab9571..364eb73c5 100644 --- a/client/simple/src/less/toolkit.less +++ b/client/simple/src/less/toolkit.less @@ -193,6 +193,15 @@ div.selectable_url { border-color: var(--color-warning); } +.dialog-warning-block { + .dialog(); + + display: block; + color: var(--color-warning); + background: var(--color-warning-background); + border-color: var(--color-warning); +} + .dialog-modal { .dialog(); diff --git a/searx/templates/simple/base.html b/searx/templates/simple/base.html index 3ddc62ace..c8e75b713 100644 --- a/searx/templates/simple/base.html +++ b/searx/templates/simple/base.html @@ -51,7 +51,11 @@ {%- endif -%} {%- endblock -%} {%- block linkto_preferences -%} - {{ icon_big('settings') }}{{ _('Preferences') }} + {%- if request.args.get('preferences') -%} + {{ icon_big('settings') }}{{ _('Preferences') }} + {%- else -%} + {{ icon_big('settings') }}{{ _('Preferences') }} + {%- endif -%} {%- endblock -%} {% block header %} diff --git a/searx/templates/simple/preferences.html b/searx/templates/simple/preferences.html index e86e926cc..87bd99c45 100644 --- a/searx/templates/simple/preferences.html +++ b/searx/templates/simple/preferences.html @@ -155,6 +155,16 @@

{{ _('Preferences') }}

+ {%- if request.args.get('preferences_preview_only') == 'true' -%} +
+

{{ _("This is a preview of the settings used by the 'Search URL' you used to get here.") }}

+ +
+ {%- endif -%} +
{{- tabs_open() -}} diff --git a/searx/webapp.py b/searx/webapp.py index 4be087a09..218959a9c 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -861,8 +861,11 @@ def preferences(): # save preferences using the link the /preferences?preferences=... if sxng_request.args.get('preferences') or sxng_request.form.get('preferences'): - resp = make_response(redirect(url_for('index', _external=True))) - return sxng_request.preferences.save(resp) + # if preferences_preview_only is 'true', the prefs from the 'preferences' query are + # shown in the settings page, but they're not applied unless the user presses 'save' + if sxng_request.args.get('preferences_preview_only') != 'true': + resp = make_response(redirect(url_for('index', _external=True))) + return sxng_request.preferences.save(resp) # save preferences if sxng_request.method == 'POST':