1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-23 04:27:46 +01:00

Merge pull request #485 from dalf/pref_query_in_title

[mod] new preference: query_in_title
This commit is contained in:
Alexandre Flament 2021-11-24 13:10:27 +01:00 committed by GitHub
commit 42c1a938f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 42 additions and 2 deletions

View File

@ -411,6 +411,17 @@ class Preferences:
'on': True, '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) self.engines = EnginesSetting('engines', choices=engines)

View File

@ -66,6 +66,9 @@ ui:
static_path: "" static_path: ""
# Custom templates path - leave it blank if you didn't change # Custom templates path - leave it blank if you didn't change
templates_path: "" 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 # ui theme
default_theme: oscar default_theme: oscar
# Default interface locale - leave blank to detect from browser information or # Default interface locale - leave blank to detect from browser information or
@ -93,6 +96,7 @@ ui:
# - language # - language
# - autocomplete # - autocomplete
# - method # - method
# - query_in_title
# searx supports result proxification using an external service: # searx supports result proxification using an external service:
# https://github.com/asciimoo/morty uncomment below section if you have running # https://github.com/asciimoo/morty uncomment below section if you have running

View File

@ -188,6 +188,7 @@ SCHEMA = {
}, },
'results_on_new_tab': SettingsValue(bool, False), 'results_on_new_tab': SettingsValue(bool, False),
'advanced_search': SettingsValue(bool, False), 'advanced_search': SettingsValue(bool, False),
'query_in_title': SettingsValue(bool, False),
'categories_order': SettingsValue(list, CATEGORY_ORDER), 'categories_order': SettingsValue(list, CATEGORY_ORDER),
}, },
'preferences': { 'preferences': {

View File

@ -280,6 +280,17 @@
{{ preferences_item_footer(image_proxy_info, image_proxy_label, rtl) }} {{ preferences_item_footer(image_proxy_info, image_proxy_label, rtl) }}
{% endif %} {% 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') }}
<select class="form-control {{ custom_select_class(rtl) }}" name="query_in_title" id="query_in_title">
<option value="1" {% if query_in_title %}selected="selected"{% endif %}>{{ _('Enabled') }}</option>
<option value="" {% if not query_in_title %}selected="selected"{% endif %}>{{ _('Disabled')}}</option>
</select>
{{ preferences_item_footer(query_in_title_info, query_in_title_label, rtl) }}
{% endif %}
{{ plugin_of_category('privacy' )}} {{ plugin_of_category('privacy' )}}
</div> </div>
</fieldset> </fieldset>

View File

@ -16,7 +16,7 @@
{%- endmacro %} {%- endmacro %}
{%- macro search_url() %}{{ url_for('search', _external=True) }}?q={{ q|urlencode }}{% if selected_categories %}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}{% if pageno > 1 %}&amp;pageno={{ pageno }}{% endif %}{% if time_range %}&amp;time_range={{ time_range }}{% endif %}{% if current_language != 'all' %}&amp;language={{ current_language }}{% endif %}{% endmacro -%} {%- macro search_url() %}{{ url_for('search', _external=True) }}?q={{ q|urlencode }}{% if selected_categories %}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}{% endif %}{% if pageno > 1 %}&amp;pageno={{ pageno }}{% endif %}{% if time_range %}&amp;time_range={{ time_range }}{% endif %}{% if current_language != 'all' %}&amp;language={{ current_language }}{% endif %}{% endmacro -%}
{% block title %}{{ q|e }} - {% endblock %} {% block title %}{% if query_in_title %}{{- q|e -}} - {% endif %}{% endblock %}
{% block meta %}{{" "}}<link rel="alternate" type="application/rss+xml" title="Searx search: {{ q|e }}" href="{{ search_url() }}&amp;format=rss">{% endblock %} {% block meta %}{{" "}}<link rel="alternate" type="application/rss+xml" title="Searx search: {{ q|e }}" href="{{ search_url() }}&amp;format=rss">{% endblock %}
{% block content %} {% block content %}
{% include 'oscar/search.html' %} {% include 'oscar/search.html' %}

View File

@ -256,6 +256,18 @@
<div class="description">{{ _('Proxying image results through SearXNG') }}</div> <div class="description">{{ _('Proxying image results through SearXNG') }}</div>
</fieldset> </fieldset>
{% endif %} {% endif %}
{% if 'query_in_title' not in locked_preferences %}
<fieldset>
<legend>{{ _('Query in the page\'s title') }}</legend>
<p class="value">
<select name='query_in_title'>
<option value="1" {% if query_in_title %}selected="selected"{% endif %}>{{ _('Enabled') }}</option>
<option value="" {% if not query_in_title %}selected="selected"{% endif %}>{{ _('Disabled') }}</option>
</select>
</p>
<div class="description">{{ _('When enabled, the result page\'s title contains your query. Your browser can record this title.') }}</div>
</fieldset>
{% endif %}
{{ plugin_preferences('privacy') }} {{ plugin_preferences('privacy') }}
{{ tab_footer() }} {{ tab_footer() }}

View File

@ -7,7 +7,7 @@
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{%- endmacro %} {%- endmacro %}
{% block title %}{% if method == 'GET' %}{{- q|e -}} -{% endif %}{% endblock %} {% block title %}{% if query_in_title %}{{- q|e -}} - {% endif %}{% endblock %}
{% block meta %}<link rel="alternate" type="application/rss+xml" title="Searx search: {{ q|e }}" href="{{ url_for('search', _external=True) }}?q={{ q|urlencode }}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}&amp;pageno={{ pageno }}&amp;time_range={{ time_range }}&amp;language={{ current_language }}&amp;safesearch={{ safesearch }}&amp;format=rss">{% endblock %} {% block meta %}<link rel="alternate" type="application/rss+xml" title="Searx search: {{ q|e }}" href="{{ url_for('search', _external=True) }}?q={{ q|urlencode }}&amp;categories={{ selected_categories|join(",") | replace(' ','+') }}&amp;pageno={{ pageno }}&amp;time_range={{ time_range }}&amp;language={{ current_language }}&amp;safesearch={{ safesearch }}&amp;format=rss">{% endblock %}
{% block content %} {% block content %}
<nav id="linkto_preferences"><a href="{{ url_for('preferences') }}">{{ icon_big('menu-outline') }}</a></nav> <nav id="linkto_preferences"><a href="{{ url_for('preferences') }}">{{ icon_big('menu-outline') }}</a></nav>

View File

@ -441,6 +441,7 @@ def render(template_name, override_theme=None, **kwargs):
kwargs['autocomplete'] = request.preferences.get_value('autocomplete') kwargs['autocomplete'] = request.preferences.get_value('autocomplete')
kwargs['results_on_new_tab'] = request.preferences.get_value('results_on_new_tab') kwargs['results_on_new_tab'] = request.preferences.get_value('results_on_new_tab')
kwargs['advanced_search'] = request.preferences.get_value('advanced_search') 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['safesearch'] = str(request.preferences.get_value('safesearch'))
kwargs['theme'] = get_current_theme_name(override=override_theme) kwargs['theme'] = get_current_theme_name(override=override_theme)
kwargs['all_categories'] = _get_ordered_categories() kwargs['all_categories'] = _get_ordered_categories()