searxng/searx/templates/oscar/preferences.html
2021-04-21 18:49:13 +02:00

440 lines
27 KiB
HTML

{% from 'oscar/macros.html' import preferences_item_header, preferences_item_header_rtl, preferences_item_footer, preferences_item_footer_rtl, checkbox_toggle, support_toggle, custom_select_class %}
{% extends "oscar/base.html" %}
{%- macro engine_about(search_engine, id) -%}
{% if search_engine.about is defined or stats[search_engine.name]['result_count'] > 0 %}
{% set about = search_engine.about %}
<div class="engine-tooltip" role="tooltip" id="{{ id }}">{{- "" -}}
{% if search_engine.about is defined %}
<h5><a href="{{about.website}}" rel="noreferrer">{{about.website}}</a></h5>
{%- if about.wikidata_id -%}<p><a href="https://www.wikidata.org/wiki/{{about.wikidata_id}}" rel="noreferrer">wikidata.org/wiki/{{about.wikidata_id}}</a></p>{%- endif -%}
{% endif %}
{%- if search_engine.enable_http %}<p>{{ icon('exclamation-sign', 'No HTTPS') }}{{ _('No HTTPS')}}</p>{% endif -%}
{%- if stats[search_engine.name]['result_count'] -%}
<p>{{ _('Number of results') }}: {{ stats[search_engine.name]['result_count'] }} ( {{ _('Avg.') }} )</p>{{- "" -}}
{%- endif -%}
</div>
{%- endif -%}
{%- endmacro %}
{%- macro engine_time(engine_name, css_align_class) -%}
<td class="{{ label }}" style="padding: 2px">{{- "" -}}
{%- if stats[engine_name].time != None -%}
<span class="stacked-bar-chart-value">{{- stats[engine_name].time -}}</span>{{- "" -}}
<span class="stacked-bar-chart" aria-labelledby="{{engine_name}}_chart" aria-hidden="true">{{- "" -}}
<span style="width: calc(max(2px, 100%*{{ (stats[engine_name].time / max_rate95)|round(3) }}))" class="stacked-bar-chart-median"></span>{{- "" -}}
<span style="width: calc(100%*{{ ((stats[engine_name].rate80 - stats[engine_name].time) / max_rate95)|round(3) }})" class="stacked-bar-chart-rate80"></span>{{- "" -}}
<span style="width: calc(100%*{{ ((stats[engine_name].rate95 - stats[engine_name].rate80) / max_rate95)|round(3) }})" class="stacked-bar-chart-rate95"></span>{{- "" -}}
<span class="stacked-bar-chart-rate100"></span>{{- "" -}}
</span>{{- "" -}}
<div class="engine-tooltip text-left" role="tooltip" id="{{engine_name}}_graph">{{- "" -}}
<p>{{ _('Median') }}: {{ stats[engine_name].time }}</p>{{- "" -}}
<p>{{ _('P80') }}: {{ stats[engine_name].rate80 }}</p>{{- "" -}}
<p>{{ _('P95') }}: {{ stats[engine_name].rate95 }}</p>{{- "" -}}
</div>
{%- endif -%}
</td>
{%- endmacro -%}
{%- macro engine_reliability(engine_name, css_align_class) -%}
{% set r = reliabilities.get(engine_name, {}).get('reliablity', None) %}
{% set checker_result = reliabilities.get(engine_name, {}).get('checker', []) %}
{% set errors = reliabilities.get(engine_name, {}).get('errors', []) %}
{% if r != None %}
{% if r <= 50 %}{% set label = 'danger' %}
{% elif r < 80 %}{% set label = 'warning' %}
{% elif r < 90 %}{% set label = 'default' %}
{% else %}{% set label = 'success' %}
{% endif %}
{% else %}
{% set r = '' %}
{% endif %}
{% if checker_result or errors %}
<td class="{{ css_align_class }} {{ label }}">{{- "" -}}
<span aria-labelledby="{{engine_name}}_reliablity">
{%- if reliabilities[engine_name].checker %}{{ icon('exclamation-sign', 'The checker fails on the some tests') }}{% endif %} {{ r -}}
</span>{{- "" -}}
<div class="engine-tooltip text-left" role="tooltip" id="{{engine_name}}_reliablity">
{%- if checker_result -%}
<p>{{ _("Failed checker test(s): ") }} {{ ', '.join(checker_result) }}</p>
{%- endif -%}
{%- for error in errors -%}
<p>{{ error }} </p>{{- "" -}}
{%- endfor -%}
</div>{{- "" -}}
</td>
{%- else -%}
<td class="{{ css_align_class }} {{ label }}"><span>{{ r }}</span></td>
{%- endif -%}
{%- endmacro -%}
{%- block title %}{{ _('preferences') }} - {% endblock -%}
{% block content %}
<div>
<h1>{{ _('Preferences') }}</h1>
<form method="post" action="{{ url_for('preferences') }}" id="search_form">
<!-- Nav tabs -->
<ul class="nav nav-tabs nav-justified hide_if_nojs" role="tablist">
<li class="active"><a href="#tab_general" role="tab" data-toggle="tab">{{ _('General') }}</a></li>
<li><a href="#tab_engine" role="tab" data-toggle="tab">{{ _('Engines') }}</a></li>
<li><a href="#tab_plugins" role="tab" data-toggle="tab">{{ _('Plugins') }}</a></li>
{% if answerers %}<li><a href="#tab_answerers" role="tab" data-toggle="tab">{{ _('Answerers') }}</a></li>{% endif %}
<li><a href="#tab_cookies" role="tab" data-toggle="tab">{{ _('Cookies') }}</a></li>
</ul>
<!-- Tab panes -->
<noscript>
<h3>{{ _('General') }}</h3>
</noscript>
<div class="tab-content">
<div class="tab-pane active" id="tab_general">
<fieldset>
<div class="container-fluid">
{% if 'categories' not in locked_preferences %}
<div class="row form-group">
{% if rtl %}
<div class="col-sm-11 col-md-10">
{% include 'oscar/categories.html' %}
</div>
<label class="col-sm-3 col-md-2" for="categories">{{ _('Default categories') }}</label>
{% else %}
<label class="col-sm-3 col-md-2" for="categories">{{ _('Default categories') }}</label>
<div class="col-sm-11 col-md-10 search-categories">
{% include 'oscar/categories.html' %}
</div>
{% endif %}
</div>
{% endif %}
{% if 'language' not in locked_preferences %}
{% set language_label = _('Search language') %}
{% set language_info = _('What language do you prefer for search?') %}
{{ preferences_item_header(language_info, language_label, rtl, 'language') }}
{% include 'oscar/languages.html' %}
{{ preferences_item_footer(language_info, language_label, rtl) }}
{% endif %}
{% if 'locale' not in locked_preferences %}
{% set locale_label = _('Interface language') %}
{% set locale_info = _('Change the language of the layout') %}
{{ preferences_item_header(locale_info, locale_label, rtl, 'locale') }}
<select class="form-control {{ custom_select_class(rtl)}}" name="locale" id="locale">
{% for locale_id,locale_name in locales.items() | sort %}
<option value="{{ locale_id }}" {% if locale_id == current_locale %}selected="selected"{% endif %}>{{ locale_name }}</option>
{% endfor %}
</select>
{{ preferences_item_footer(locale_info, locale_label, rtl) }}
{% endif %}
{% if 'autocomplete' not in locked_preferences %}
{% set autocomplete_label = _('Autocomplete') %}
{% set autocomplete_info = _('Find stuff as you type') %}
{{ preferences_item_header(autocomplete_info, autocomplete_label, rtl, 'autocomplete') }}
<select class="form-control {{ custom_select_class(rtl) }}" name="autocomplete" id="autocomplete">
<option value=""> - </option>
{% for backend in autocomplete_backends %}
<option value="{{ backend }}" {% if backend == autocomplete %}selected="selected"{% endif %}>{{ backend }}</option>
{% endfor %}
</select>
{{ preferences_item_footer(autocomplete_info, autocomplete_label, rtl) }}
{% endif %}
{% if 'image_proxy' not in locked_preferences %}
{% set image_proxy_label = _('Image proxy') %}
{% set image_proxy_info = _('Proxying image results through searx') %}
{{ preferences_item_header(image_proxy_info, image_proxy_label, rtl, 'image_proxy') }}
<select class="form-control {{ custom_select_class(rtl) }}" name="image_proxy" id="image_proxy">
<option value="1" {% if image_proxy %}selected="selected"{% endif %}>{{ _('Enabled') }}</option>
<option value="" {% if not image_proxy %}selected="selected"{% endif %}>{{ _('Disabled')}}</option>
</select>
{{ preferences_item_footer(image_proxy_info, image_proxy_label, rtl) }}
{% endif %}
{% if 'method' not in locked_preferences %}
{% set method_label = _('Method') %}
{% set method_info = _('Change how forms are submited, <a href="http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods" rel="external">learn more about request methods</a>') %}
{{ preferences_item_header(method_info, method_label, rtl, 'method') }}
<select class="form-control {{ custom_select_class(rtl) }}" name="method" id="method">
<option value="POST" {% if method == 'POST' %}selected="selected"{% endif %}>POST</option>
<option value="GET" {% if method == 'GET' %}selected="selected"{% endif %}>GET</option>
</select>
{{ preferences_item_footer(method_info, method_label, rtl) }}
{% endif %}
{% if 'safesearch' not in locked_preferences %}
{% set safesearch_label = _('SafeSearch') %}
{% set safesearch_info = _('Filter content') %}
{{ preferences_item_header(safesearch_info, safesearch_label, rtl, 'safesearch') }}
<select class="form-control {{ custom_select_class(rtl) }}" name="safesearch" id="safesearch">
<option value="2" {% if safesearch == '2' %}selected="selected"{% endif %}>{{ _('Strict') }}</option>
<option value="1" {% if safesearch == '1' %}selected="selected"{% endif %}>{{ _('Moderate') }}</option>
<option value="0" {% if safesearch == '0' %}selected="selected"{% endif %}>{{ _('None') }}</option>
</select>
{{ preferences_item_footer(safesearch_info, safesearch_label, rtl) }}
{% endif %}
{% if 'theme' not in locked_preferences %}
{% set theme_label = _('Themes') %}
{% set theme_info = _('Change searx layout') %}
{{ preferences_item_header(theme_info, theme_label, rtl, 'theme') }}
<select class="form-control {{ custom_select_class(rtl) }}" name="theme" id="theme">
{% for name in themes %}
<option value="{{ name }}" {% if name == theme %}selected="selected"{% endif %}>{{ name }}</option>
{% endfor %}
</select>
{{ preferences_item_footer(theme_info, theme_label, rtl) }}
{% endif %}
{% if 'oscar-style' not in locked_preferences %}
{{ preferences_item_header(_('Choose style for this theme'), _('Style'), rtl, 'oscar_style') }}
<select class="form-control {{ custom_select_class(rtl) }}" name="oscar-style" id="oscar_style">
<option value="logicodev" >Logicodev</option>
<option value="pointhi" {% if preferences.get_value('oscar-style') == 'pointhi' %}selected="selected"{% endif %}>Pointhi</option>
<option value="logicodev-dark" {% if preferences.get_value('oscar-style') == 'logicodev-dark' %}selected="selected"{% endif %}>Logicodev dark</option>
</select>
{{ preferences_item_footer(_('Choose style for this theme'), _('Style'), rtl) }}
{% endif %}
{% if 'results_on_new_tab' not in locked_preferences %}
{% set label = _('Results on new tabs') %}
{% set info = _('Open result links on new browser tabs') %}
{{ preferences_item_header(info, label, rtl, 'results_on_new_tab') }}
<select class="form-control {{ custom_select_class(rtl) }}" name="results_on_new_tab" id="results_on_new_tab">
<option value="1" {% if results_on_new_tab %}selected="selected"{% endif %}>{{ _('On') }}</option>
<option value="0" {% if not results_on_new_tab %}selected="selected"{% endif %}>{{ _('Off')}}</option>
</select>
{{ 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)') %}
{{ preferences_item_header(info, label, rtl, 'doi_resolver') }}
<select class="form-control {{ custom_select_class(rtl) }}" name="doi_resolver" id="doi_resolver">
{% for doi_resolver_name,doi_resolver_url in doi_resolvers.items() %}
<option value="{{ doi_resolver_name }}" {% if doi_resolver_url == current_doi_resolver %}selected="selected"{% endif %}>
{{ doi_resolver_name }} - {{ doi_resolver_url }}
</option>
{% endfor %}
</select>
{{ preferences_item_footer(info, label, rtl) }}
{% endif %}
{% set label = _('Engine tokens') %}
{% set info = _('Access tokens for private engines') %}
{{ preferences_item_header(info, label, rtl, 'tokens') }}
<input class="form-control" id="tokens" name="tokens" value='{{ preferences.tokens.get_value() }}'/>
{{ preferences_item_footer(info, label, rtl) }}
</div>
</fieldset>
</div>
<div class="tab-pane active_if_nojs" id="tab_engine">
<!-- Nav tabs -->
<ul class="nav nav-tabs nav-justified hide_if_nojs" role="tablist">
{% for categ in all_categories %}
<li{% if loop.first %} class="active"{% endif %}><a href="#tab_engine_{{ categ|replace(' ', '_') }}" role="tab" data-toggle="tab">{{ _(categ) }}</a></li>
{% endfor %}
</ul>
<noscript>
<h3>{{ _('Engines') }}</h3>
</noscript>
<!-- Tab panes -->
<div class="tab-content">
<div class="hide_if_nojs">
<p class="text-{% if rtl %}left{% else %}right{% endif %}">
<button type="button" class="btn btn-default btn-success" id="allow-all-engines">{{ _("Allow all") }}</button>
<button type="button" class="btn btn-default btn-danger" id="disable-all-engines">{{ _("Disable all") }}</button>
</p>
</div>
{% for categ in all_categories %}
<noscript><label>{{ _(categ) }}</label>
</noscript>
<div class="tab-pane{% if loop.first %} active{% endif %} active_if_nojs" id="tab_engine_{{ categ|replace(' ', '_') }}">
<div class="container-fluid">
<fieldset>
<div class="table-responsive">
<table class="table table-hover table-condensed table-striped">
<tr>
{% if not rtl %}
<th scope="col">{{ _("Allow") }}</th>
<th scope="col">{{ _("Engine name") }}</th>
<th scope="col">{{ _("Shortcut") }}</th>
<th scope="col" style="width: 10rem">{{ _("Selected language") }}</th>
<th scope="col" style="width: 10rem">{{ _("SafeSearch") }}</th>
<th scope="col" style="width: 10rem">{{ _("Time range") }}</th>
<th scope="col">{{ _("Response time") }}</th>
<th scope="col" class="text-right" style="width: 7rem">{{ _("Max time") }}</th>
<th scope="col" class="text-right" style="width: 7rem">{{ _("Reliablity") }}</th>
{% else %}
<th scope="col">{{ _("Reliablity") }}</th>
<th scope="col">{{ _("Max time") }}</th>
<th scope="col" class="text-right">{{ _("Response time") }}</th>
<th scope="col" class="text-right">{{ _("Time range") }}</th>
<th scope="col" class="text-right">{{ _("SafeSearch") }}</th>
<th scope="col" class="text-right">{{ _("Selected language") }}</th>
<th scope="col" class="text-right">{{ _("Shortcut") }}</th>
<th scope="col" class="text-right">{{ _("Engine name") }}</th>
<th scope="col" class="text-right">{{ _("Allow") }}</th>
{% endif %}
</tr>
{% for search_engine in engines_by_category[categ] %}
{% if not search_engine.private %}
<tr>
{% if not rtl %}
<td class="onoff-checkbox">
{{- checkbox_toggle('engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_'), (search_engine.name, categ) in disabled_engines) -}}
</td>
<th scope="row"><span aria-labelledby="{{ 'tooltip_' + categ + '_' + search_engine.name }}">
{%- if search_engine.enable_http %}{{ icon('exclamation-sign', 'No HTTPS') }}{% endif -%}
{{- search_engine.name -}}</span>
{{- engine_about(search_engine, 'tooltip_' + categ + '_' + search_engine.name) -}}
</th>
<td class="name">{{ shortcuts[search_engine.name] }}</td>
<td>{{ support_toggle(supports[search_engine.name]['supports_selected_language']) }}</td>
<td>{{ support_toggle(supports[search_engine.name]['safesearch']) }}</td>
<td>{{ support_toggle(supports[search_engine.name]['time_range_support']) }}</td>
{{ engine_time(search_engine.name, 'text-right') }}
<td class="text-right {{ 'danger' if stats[search_engine.name]['warn_timeout'] else '' }}">{% if stats[search_engine.name]['warn_timeout'] %}{{ icon('exclamation-sign') }} {% endif %}{{ search_engine.timeout }}</td>
{{ engine_reliability(search_engine.name, 'text-right ') }}
{% else %}
{{ engine_reliability(search_engine.name, 'text-left') }}
<td class="text-left {{ 'danger' if stats[search_engine.name]['warn_timeout'] else '' }}">{{ search_engine.timeout }}{% if stats[search_engine.name]['warn_time'] %} {{ icon('exclamation-sign')}}{% endif %}</td>
{{ engine_time(search_engine.name, 'text-left') }}
<td>{{ support_toggle(supports[search_engine.name]['time_range_support']) }}</td>
<td>{{ support_toggle(supports[search_engine.name]['safesearch']) }}</td>
<td>{{ support_toggle(supports[search_engine.name]['supports_selected_language']) }}</td>
<td>{{ shortcuts[search_engine.name] }}</td>
<th scope="row"><span>{% if search_engine.enable_http %}{{ icon('exclamation-sign', 'No HTTPS') }}{% endif %}{{ search_engine.name }}</span>{{ engine_about(search_engine) }}</th>
<td class="onoff-checkbox">
{{ checkbox_toggle('engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_'), (search_engine.name, categ) in disabled_engines) }}
</td>
{% endif %}
</tr>
{% endif %}
{% endfor %}
</table>
</div>
</fieldset>
</div>
</div>
{% endfor %}
</div>
</div>
<div class="tab-pane active_if_nojs" id="tab_plugins">
<noscript>
<h3>{{ _('Plugins') }}</h3>
</noscript>
<fieldset>
<div class="container-fluid">
{% for plugin in plugins %}
{% if plugin.preference_section != 'onions' %}
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{{ _(plugin.name) }}</h3>
</div>
<div class="panel-body">
<div class="col-xs-6 col-sm-4 col-md-6"><label for="{{'plugin_' + plugin.id}}">{{ _(plugin.description) }}</label></div>
<div class="col-xs-6 col-sm-4 col-md-6">
<div class="onoff-checkbox">
{{ checkbox_toggle('plugin_' + plugin.id, plugin.id not in allowed_plugins) }}
</div>
</div>
</div>
</div>
{% endif %}
{% endfor %}
</div>
</fieldset>
</div>
{% if answerers %}
<div class="tab-pane active_if_nojs" id="tab_answerers">
<noscript>
<h3>{{ _('Answerers') }}</h3>
</noscript>
<p class="text-muted">
{{ _('This is the list of searx\'s instant answering modules.') }}
</p>
<table class="table table-striped">
<tr>
<th{% if rtl %} class="text-right"{% endif %}>{{ _('Name') }}</th>
<th{% if rtl %} class="text-right"{% endif %}>{{ _('Keywords') }}</th>
<th{% if rtl %} class="text-right"{% endif %}>{{ _('Description') }}</th>
<th{% if rtl %} class="text-right"{% endif %}>{{ _('Examples') }}</th>
</tr>
{% for answerer in answerers %}
<tr>
<td>{{ answerer.info.name }}</td>
<td>{{ answerer.keywords|join(', ') }}</td>
<td>{{ answerer.info.description }}</td>
<td>{{ answerer.info.examples|join(', ') }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
<div class="tab-pane active_if_nojs" id="tab_cookies">
<noscript>
<h3>{{ _('Cookies') }}</h3>
</noscript>
<p class="text-muted">
{{ _('This is the list of cookies and their values searx is storing on your computer.') }}<br />
{{ _('With that list, you can assess searx transparency.') }}<br />
</p>
{% if cookies %}
<table class="table table-striped">
<tr>
<th class="text-muted{% if rtl %} text-right{% endif %}">{{ _('Cookie name') }}</th>
<th class="text-muted{% if rtl %} text-right{% endif %}">{{ _('Value') }}</th>
</tr>
{% for cookie in cookies %}
<tr>
<td class="text-muted">{{ cookie }}</td>
<td class="text-muted">{{ cookies[cookie] }}</td>
</tr>
{% endfor %}
</table>
{% else %}
{% include 'oscar/messages/no_cookies.html' %}
{% endif %}
</div>
</div>
<p class="text-muted">
{{ _('These settings are stored in your cookies, this allows us not to store this data about you.') }}
{{ _("These cookies serve your sole convenience, we don't use these cookies to track you.") }}
</p>
<p>
{{ _('Search URL of the currently saved preferences') }}
<small class="text-muted">({{ _('Note: specifying custom settings in the search URL can reduce privacy by leaking data to the clicked result sites.') }})</small>:
</p>
<div class="tab-pane">
<input readonly="" class="form-control select-all-on-click cursor-text" type="url" value="{{ url_for('index', _external=True) }}?preferences={{ preferences_url_params|e }}{% raw %}&amp;q=%s{% endraw %}">
<input type="submit" class="btn btn-primary" value="{{ _('save') }}" />
<a href="{{ url_for('index') }}"><div class="btn btn-default">{{ _('back') }}</div></a>
<a href="{{ url_for('clear_cookies') }}"><div class="btn btn-default">{{ _('Reset defaults') }}</div></a>
</div>
</form>
</div>
{% endblock %}