1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-19 19:00:10 +01:00

Merge pull request #2327 from renyhp/master

Add preference for displaying advanced settings
This commit is contained in:
Alexandre Flament 2020-11-26 17:37:43 +01:00 committed by GitHub
commit 6ada5bac60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 4 deletions

View File

@ -395,6 +395,17 @@ class Preferences:
settings['ui'].get('theme_args', {}).get('oscar_style', 'logicodev'),
is_locked('oscar-style'),
choices=['', 'logicodev', 'logicodev-dark', 'pointhi']),
'advanced_search': MapSetting(
settings['ui'].get('advanced_search', False),
is_locked('advanced_search'),
map={
'0': False,
'1': True,
'False': False,
'True': True,
'on': True,
}
),
}
self.engines = EnginesSetting('engines', choices=engines)

View File

@ -140,6 +140,15 @@
{{ preferences_item_footer(info, label, rtl) }}
{% endif %}
{% set label = _('Show advanced settings') %}
{% set info = _('Show advanced settings panel in the home page by default') %}
{{ preferences_item_header(info, label, rtl, 'advanced_search') }}
<select class="form-control {{ custom_select_class(rtl) }}" name="advanced_search" id="advanced_search">
<option value="1" {% if preferences.get_value('advanced_search')%}selected="selected"{% endif %}>{{ _('On') }}</option>
<option value="0" {% if not preferences.get_value('advanced_search')%}selected="selected"{% endif %}>{{ _('Off')}}</option>
</select>
{{ preferences_item_footer(info, label, rtl) }}
{% if 'doi_resolver' not in locked_preferences %}
{% set label = _('Open Access DOI resolver') %}
{% set info = _('Redirect to open-access versions of publications when available (plugin required)') %}

View File

@ -544,6 +544,9 @@ def index_error(output_format, error_message):
def index():
"""Render index page."""
# UI
advanced_search = request.preferences.get_value('advanced_search')
# redirect to search if there's a query in the request
if request.form.get('q'):
query = ('?' + request.query_string.decode()) if request.query_string else ''
@ -552,6 +555,7 @@ def index():
return render(
'index.html',
selected_categories=get_selected_categories(request.preferences, request.form),
advanced_search=advanced_search,
)
@ -572,6 +576,7 @@ def search():
if output_format == 'html':
return render(
'index.html',
advanced_search=request.preferences.get_value('advanced_search'),
selected_categories=get_selected_categories(request.preferences, request.form),
)
else:
@ -605,9 +610,6 @@ def search():
if result_container.redirect_url:
return redirect(result_container.redirect_url)
# UI
advanced_search = request.form.get('advanced_search', None)
# Server-Timing header
request.timings = result_container.get_timings()
@ -716,7 +718,6 @@ def search():
pageno=search_query.pageno,
time_range=search_query.time_range,
number_of_results=format_decimal(number_of_results),
advanced_search=advanced_search,
suggestions=suggestion_urls,
answers=result_container.answers,
corrections=correction_urls,