Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mod] new preference: query_in_title #485

Merged
merged 1 commit into from Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions searx/preferences.py
Expand Up @@ -405,6 +405,17 @@ def __init__(self, themes, categories, engines, plugins):
'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)
Expand Down
4 changes: 4 additions & 0 deletions searx/settings.yml
Expand Up @@ -66,6 +66,9 @@ ui:
static_path: ""
# Custom templates path - leave it blank if you didn't change
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
default_theme: oscar
# Default interface locale - leave blank to detect from browser information or
Expand All @@ -91,6 +94,7 @@ ui:
# - language
# - autocomplete
# - method
# - query_in_title

# searx supports result proxification using an external service:
# https://github.com/asciimoo/morty uncomment below section if you have running
Expand Down
1 change: 1 addition & 0 deletions searx/settings_defaults.py
Expand Up @@ -186,6 +186,7 @@ def apply_schema(settings, schema, path_list):
},
'results_on_new_tab': SettingsValue(bool, False),
'advanced_search': SettingsValue(bool, False),
'query_in_title': SettingsValue(bool, False),
'categories_order': SettingsValue(list, CATEGORY_ORDER),
},
'preferences': {
Expand Down
11 changes: 11 additions & 0 deletions searx/templates/oscar/preferences.html
Expand Up @@ -280,6 +280,17 @@ <h3>{{ _('Privacy') }}</h3>
{{ preferences_item_footer(image_proxy_info, image_proxy_label, rtl) }}
{% 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') %}
return42 marked this conversation as resolved.
Show resolved Hide resolved
{{ 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' )}}
</div>
</fieldset>
Expand Down
2 changes: 1 addition & 1 deletion searx/templates/oscar/results.html
Expand Up @@ -16,7 +16,7 @@
{%- 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 content %}
{% include 'oscar/search.html' %}
Expand Down
12 changes: 12 additions & 0 deletions searx/templates/simple/preferences.html
Expand Up @@ -237,6 +237,18 @@ <h2>{{ _('Preferences') }}</h2>
<div class="description">{{ _('Proxying image results through SearXNG') }}</div>
</fieldset>
{% 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>
return42 marked this conversation as resolved.
Show resolved Hide resolved
</fieldset>
{% endif %}
{{ plugin_preferences('privacy') }}
{{ tab_footer() }}

Expand Down
2 changes: 1 addition & 1 deletion searx/templates/simple/results.html
Expand Up @@ -7,7 +7,7 @@
{% endfor %}
{% endfor %}
{%- 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 content %}
<nav id="linkto_preferences"><a href="{{ url_for('preferences') }}">{{ icon('navicon-round') }}</a></nav>
Expand Down
1 change: 1 addition & 0 deletions searx/webapp.py
Expand Up @@ -425,6 +425,7 @@ def render(template_name, override_theme=None, **kwargs):
kwargs['autocomplete'] = request.preferences.get_value('autocomplete')
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')
kwargs['safesearch'] = str(request.preferences.get_value('safesearch'))
kwargs['theme'] = get_current_theme_name(override=override_theme)
kwargs['all_categories'] = _get_ordered_categories()
Expand Down