SearXNG is a free internet metasearch engine which aggregates results from various search services and databases. Users are neither tracked nor profiled.
Python bingbravedegoogleduckduckgogooglemetasearchprivacypythonqwantsearchsearch-enginesearxsearxngstartpageyahoo
[feat] search: add url formatting preference
Bnyroa7537a69357f
diff --git a/docs/admin/settings/settings_ui.rst b/docs/admin/settings/settings_ui.rstindex 86cd9d5bf..75f617683 100644--- a/docs/admin/settings/settings_ui.rst+++ b/docs/admin/settings/settings_ui.rst@@ -21,6 +21,7 @@simple_style: autosearch_on_category_select: truehotkeys: default+ url_formatting: pretty.. _static_use_hash:@@ -68,3 +69,6 @@``hotkeys``:Hotkeys to use in the search interface: ``default``, ``vim`` (Vim-like).++``url_formatting``:+ Formatting type to use for result URLs: ``pretty``, ``full`` or ``host``.diff --git a/searx/preferences.py b/searx/preferences.pyindex c1abd290e..209cf06f1 100644--- a/searx/preferences.py+++ b/searx/preferences.py@@ -472,6 +472,10 @@ class Preferences:settings['ui']['hotkeys'],choices=['default', 'vim']),+ 'url_formatting': EnumStringSetting(+ settings['ui']['url_formatting'],+ choices=['pretty', 'full', 'host']+ ),# fmt: on}diff --git a/searx/settings.yml b/searx/settings.ymlindex 77a4f625c..4fad73b40 100644--- a/searx/settings.yml+++ b/searx/settings.yml@@ -145,6 +145,8 @@ ui:search_on_category_select: true# Hotkeys: default or vimhotkeys: default+ # URL formatting: pretty, full or host+ url_formatting: pretty# Lock arbitrary settings on the preferences page. To find the ID of the user# setting you want to lock, check the ID of the form on the page "preferences".diff --git a/searx/settings_defaults.py b/searx/settings_defaults.pyindex 891cc1df3..b70aaf941 100644--- a/searx/settings_defaults.py+++ b/searx/settings_defaults.py@@ -205,6 +205,7 @@ SCHEMA = {'cache_url': SettingsValue(str, 'https://web.archive.org/web/'),'search_on_category_select': SettingsValue(bool, True),'hotkeys': SettingsValue(('default', 'vim'), 'default'),+ 'url_formatting': SettingsValue(('pretty', 'full', 'host'), 'pretty'),},'preferences': {'lock': SettingsValue(list, []),diff --git a/searx/static/themes/simple/src/less/style.less b/searx/static/themes/simple/src/less/style.lessindex 6f8549f70..74629f47d 100644--- a/searx/static/themes/simple/src/less/style.less+++ b/searx/static/themes/simple/src/less/style.less@@ -254,6 +254,10 @@ article[data-vim-selected].category-social {white-space: nowrap;flex-shrink: 1;padding-bottom: 1px;++ .url_i1 {+ unicode-bidi: plaintext;+ }}.url_o1::after {diff --git a/searx/templates/simple/preferences.html b/searx/templates/simple/preferences.htmlindex bc96e1198..665f2e638 100644--- a/searx/templates/simple/preferences.html+++ b/searx/templates/simple/preferences.html@@ -204,6 +204,7 @@{%- include 'simple/preferences/search_on_category_select.html' -%}{%- endif -%}{%- include 'simple/preferences/hotkeys.html' -%}+ {%- include 'simple/preferences/urlformatting.html' -%}{{- plugin_preferences('ui') -}}{{- tab_footer() -}}diff --git a/searx/templates/simple/preferences/urlformatting.html b/searx/templates/simple/preferences/urlformatting.htmlnew file mode 100644index 000000000..ba11bdb63--- /dev/null+++ b/searx/templates/simple/preferences/urlformatting.html@@ -0,0 +1,25 @@+<fieldset>{{- '' -}}+ <legend id="pref_url_formatting">{{- _('URL formatting') -}}</legend>{{- '' -}}+ <div class="value">{{- '' -}}+ <select name="url_formatting" aria-labelledby="pref_url_formatting">{{- '' -}}+ <option value="pretty"+ {%- if preferences.get_value('url_formatting') == 'pretty' %} selected="selected"+ {%- endif -%}>+ {{- _('Pretty') -}}+ </option>{{- '' -}}+ <option value="full"+ {%- if preferences.get_value('url_formatting') == 'full' %} selected="selected"+ {%- endif -%}>+ {{- _('Full') -}}+ </option>{{- '' -}}+ <option value="host"+ {%- if preferences.get_value('url_formatting') == 'host' %} selected="selected"+ {%- endif -%}>+ {{- _('Host') -}}+ </option>{{- '' -}}+ </select>{{- '' -}}+ </div>{{- '' -}}+ <div class="description">+ {{- _('Change result URL formatting') -}}+ </div>{{- '' -}}+</fieldset>{{- '' -}}diff --git a/searx/webapp.py b/searx/webapp.pyindex f7e7e1d5c..bbc71fdd6 100755--- a/searx/webapp.py+++ b/searx/webapp.py@@ -340,6 +340,14 @@ def get_enabled_categories(category_names: Iterable[str]):def get_pretty_url(parsed_url: urllib.parse.ParseResult):+ url_formatting_pref = request.preferences.get_value('url_formatting')++ if url_formatting_pref == 'full':+ return [parsed_url.geturl()]++ if url_formatting_pref == 'host':+ return [parsed_url.netloc]+path = parsed_url.pathpath = path[:-1] if len(path) > 0 and path[-1] == '/' else pathpath = unquote(path.replace("/", " › "))@@ -356,6 +364,7 @@ def get_client_settings():'translations': get_translations(),'search_on_category_select': req_pref.get_value('search_on_category_select'),'hotkeys': req_pref.get_value('hotkeys'),+ 'url_formatting': req_pref.get_value('url_formatting'),'theme_static_path': custom_url_for('static', filename='themes/simple'),}@@ -385,6 +394,7 @@ def render(template_name: str, **kwargs):kwargs['infinite_scroll'] = request.preferences.get_value('infinite_scroll')kwargs['search_on_category_select'] = request.preferences.get_value('search_on_category_select')kwargs['hotkeys'] = request.preferences.get_value('hotkeys')+ kwargs['url_formatting'] = request.preferences.get_value('url_formatting')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')