summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2023-09-16 17:14:18 +0200
committerMarkus Heiser <markus.heiser@darmarIT.de>2023-09-19 08:06:06 +0200
commit317db5b04f6de919e996df943f7f0a845b8238a9 (patch)
tree913bf68346fbd18b5cd0363658c259dbac4a1b4f
parent09935e289730027f6d7e1476916381bd6a98349c (diff)
downloadsearxng-317db5b04f6de919e996df943f7f0a845b8238a9.tar.gz
searxng-317db5b04f6de919e996df943f7f0a845b8238a9.zip
[mod] preferences: implement drop-down menu for hotkeys (default, vim)
Replace the on/off checkbox of the vim-hotkeys in the preferences by a drop-down menu. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
-rw-r--r--searx/plugins/vim_hotkeys.py10
-rw-r--r--searx/preferences.py4
-rw-r--r--searx/settings.yml1
-rw-r--r--searx/templates/simple/preferences.html1
-rw-r--r--searx/templates/simple/preferences/hotkeys.html23
-rwxr-xr-xsearx/webapp.py3
6 files changed, 30 insertions, 12 deletions
diff --git a/searx/plugins/vim_hotkeys.py b/searx/plugins/vim_hotkeys.py
deleted file mode 100644
index 3eeaf8c00..000000000
--- a/searx/plugins/vim_hotkeys.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from flask_babel import gettext
-
-name = gettext('Vim-like hotkeys')
-description = gettext(
- 'Navigate search results with Vim-like hotkeys '
- '(JavaScript required). '
- 'Press "h" key on main or result page to get help.'
-)
-default_on = False
-preference_section = 'ui'
diff --git a/searx/preferences.py b/searx/preferences.py
index 20d3eb2cb..c65a9b9d0 100644
--- a/searx/preferences.py
+++ b/searx/preferences.py
@@ -465,6 +465,10 @@ class Preferences:
settings['ui']['search_on_category_select'],
locked=is_locked('search_on_category_select')
),
+ 'hotkeys': EnumStringSetting(
+ 'default',
+ choices=['default', 'vim']
+ ),
# fmt: on
}
diff --git a/searx/settings.yml b/searx/settings.yml
index 1d0ad1ab1..3990ebaf3 100644
--- a/searx/settings.yml
+++ b/searx/settings.yml
@@ -215,7 +215,6 @@ outgoing:
# # these plugins are disabled if nothing is configured ..
# - 'Hostname replace' # see hostname_replace configuration below
# - 'Open Access DOI rewrite'
-# - 'Vim-like hotkeys'
# - 'Tor check plugin'
# # Read the docs before activate: auto-detection of the language could be
# # detrimental to users expectations / users can activate the plugin in the
diff --git a/searx/templates/simple/preferences.html b/searx/templates/simple/preferences.html
index 3d62682bb..9dab84fd1 100644
--- a/searx/templates/simple/preferences.html
+++ b/searx/templates/simple/preferences.html
@@ -200,6 +200,7 @@
{%- if 'search_on_category_select' not in locked_preferences -%}
{%- include 'simple/preferences/search_on_category_select.html' -%}
{%- endif -%}
+ {%- include 'simple/preferences/hotkeys.html' -%}
{{- plugin_preferences('ui') -}}
{{- tab_footer() -}}
diff --git a/searx/templates/simple/preferences/hotkeys.html b/searx/templates/simple/preferences/hotkeys.html
new file mode 100644
index 000000000..c13d0c8d2
--- /dev/null
+++ b/searx/templates/simple/preferences/hotkeys.html
@@ -0,0 +1,23 @@
+<fieldset>{{- '' -}}
+ <legend id="pref_hotkeys">{{- _('Hotkeys') -}}</legend>{{- '' -}}
+ <div class="value">{{- '' -}}
+ <select name="hotkeys" aria-labelledby="pref_hotkeys">{{- '' -}}
+ <option value="default"
+ {%- if hotkeys == 'default' %} selected="selected"
+ {%- endif -%}>
+ SearXNG{{- '' -}}
+ </option>{{- '' -}}
+ <option value="vim"
+ {%- if hotkeys == 'vim' %} selected="selected"
+ {%- endif -%}>
+ {{- _('Vim-like') -}}
+ </option>{{- '' -}}
+ </select>{{- '' -}}
+ </div>{{- '' -}}
+ <div class="description">
+ {{- _(
+ 'Navigate search results with hotkeys (JavaScript required). '
+ 'Press "h" key on main or result page to get help.'
+ ) -}}
+ </div>{{- '' -}}
+</fieldset>{{- '' -}}
diff --git a/searx/webapp.py b/searx/webapp.py
index 719ff92a1..fe6dd6b74 100755
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -362,7 +362,7 @@ def get_client_settings():
'infinite_scroll': req_pref.get_value('infinite_scroll'),
'translations': get_translations(),
'search_on_category_select': req_pref.get_value('searx.plugins.search_on_category_select'),
- 'hotkeys': req_pref.plugins.choices['searx.plugins.vim_hotkeys'],
+ 'hotkeys': req_pref.get_value('hotkeys'),
'theme_static_path': custom_url_for('static', filename='themes/simple'),
}
@@ -390,6 +390,7 @@ def render(template_name: str, **kwargs):
kwargs['autocomplete'] = request.preferences.get_value('autocomplete')
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['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')