preferences.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. {% from 'simple/macros.html' import icon, tabs_open, tabs_close, tab_header, tab_footer, checkbox_onoff, checkbox %}
  2. {% extends "simple/base.html" %}
  3. {%- macro plugin_preferences(section) -%}
  4. {%- for plugin in plugins -%}
  5. {%- if plugin.preference_section == section -%}
  6. <fieldset>{{- '' -}}
  7. <legend>{{ _(plugin.name) }}</legend>{{- '' -}}
  8. <div class="value">
  9. {{- checkbox_onoff('plugin_' + plugin.id, plugin.id not in allowed_plugins) -}}
  10. </div>{{- '' -}}
  11. <div class="description">
  12. {{- _(plugin.description) -}}
  13. </div>{{- '' -}}
  14. </fieldset>
  15. {%- endif -%}
  16. {%- endfor -%}
  17. {%- endmacro -%}
  18. {% macro engine_about(search_engine) -%}
  19. {% if search_engine.about is defined %}
  20. {% set about = search_engine.about %}
  21. <div class="engine-tooltip" role="tooltip">{{- "" -}}
  22. <p><a href="{{about.website}}" rel="noreferrer">{{about.website}}</a></p>
  23. {%- 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 -%}
  24. {%- if search_engine.enable_http %}<p>{{ icon('exclamation-sign', 'No HTTPS') }}{{ _('No HTTPS')}}</p>{% endif -%}
  25. {%- if reliabilities.get(search_engine.name, {}).errors or reliabilities.get(search_engine.name, {}).checker -%}
  26. <a href="{{ url_for('stats', engine=search_engine.name|e) }}" title="{{ _('View error logs and submit a bug report') }}">
  27. {{ _('View error logs and submit a bug report') }}
  28. </a>
  29. {%- endif -%}
  30. </div>
  31. {%- endif -%}
  32. {%- endmacro %}
  33. {%- macro engine_time(engine_name) -%}
  34. <td class="{{ label }}" style="padding: 2px; width: 13rem;">{{- "" -}}
  35. {%- if stats[engine_name].time != None -%}
  36. <span class="stacked-bar-chart-value">{{- stats[engine_name].time -}}</span>{{- "" -}}
  37. <span class="stacked-bar-chart" aria-labelledby="{{engine_name}}_chart" aria-hidden="true">
  38. {%- if max_rate95 is not none and max_rate95 > 0 -%}
  39. <span style="width: calc(max(2px, 100%*{{ (stats[engine_name].time / max_rate95)|round(3) }}))" class="stacked-bar-chart-median"></span>{{- "" -}}
  40. <span style="width: calc(100%*{{ ((stats[engine_name].rate80 - stats[engine_name].time) / max_rate95)|round(3) }})" class="stacked-bar-chart-rate80"></span>{{- "" -}}
  41. <span style="width: calc(100%*{{ ((stats[engine_name].rate95 - stats[engine_name].rate80) / max_rate95)|round(3) }})" class="stacked-bar-chart-rate95"></span>{{- "" -}}
  42. <span class="stacked-bar-chart-rate100"></span>
  43. {%- endif -%}
  44. </span>{{- "" -}}
  45. <div class="engine-tooltip text-left" role="tooltip" id="{{engine_name}}_graph">{{- "" -}}
  46. <p>{{ _('Median') }}: {{ stats[engine_name].time }}</p>{{- "" -}}
  47. <p>{{ _('P80') }}: {{ stats[engine_name].rate80 }}</p>{{- "" -}}
  48. <p>{{ _('P95') }}: {{ stats[engine_name].rate95 }}</p>{{- "" -}}
  49. </div>
  50. {%- endif -%}
  51. </td>
  52. {%- endmacro -%}
  53. {%- macro engine_reliability(engine_name) -%}
  54. {% set r = reliabilities.get(engine_name, {}).get('reliablity', None) %}
  55. {% set checker_result = reliabilities.get(engine_name, {}).get('checker', []) %}
  56. {% set errors = reliabilities.get(engine_name, {}).get('errors', []) %}
  57. {% if r != None %}
  58. {% if r <= 50 %}{% set label = 'danger' %}
  59. {% elif r < 80 %}{% set label = 'warning' %}
  60. {% elif r < 90 %}{% set label = '' %}
  61. {% else %}{% set label = 'success' %}
  62. {% endif %}
  63. {% else %}
  64. {% set r = '' %}
  65. {% endif %}
  66. {% if checker_result or errors %}
  67. <td class="{{ label }}">{{- "" -}}
  68. <a href="{{ url_for('stats', engine=engine_name|e) }}">{{- "" -}}
  69. <span aria-labelledby="{{engine_name}}_reliability">
  70. {{ icon('warning', 'The engine is not reliabled') }} {{ r -}}
  71. </span>{{- "" -}}
  72. </a>{{- "" -}}
  73. <div class="engine-tooltip" style="right: 12rem;" role="tooltip" id="{{engine_name}}_reliability">
  74. {%- if checker_result -%}
  75. <p>{{ _("Failed checker test(s): ") }} {{ ', '.join(checker_result) }}</p>
  76. {%- endif -%}
  77. {%- if errors %}<p>{{ _('Errors:') }}</p>{% endif -%}
  78. {%- for error in errors -%}
  79. <p>{{ error }} </p>{{- "" -}}
  80. {%- endfor -%}
  81. </div>{{- "" -}}
  82. </td>
  83. {%- else -%}
  84. <td class="{{ label }}"><span>{{ r }}</span></td>
  85. {%- endif -%}
  86. {%- endmacro -%}
  87. {% block head %} {% endblock %}
  88. {% block content %}
  89. <a href="{{ url_for('index') }}"><h1><span>searx</span></h1></a>
  90. <h2>{{ _('Preferences') }}</h2>
  91. <form id="search_form" method="post" action="{{ url_for('preferences') }}">
  92. {{ tabs_open() }}
  93. {{ tab_header('maintab', 'general', _('General')) }}
  94. {% if 'categories' not in locked_preferences %}
  95. <fieldset>
  96. <legend>{{ _('Default categories') }}</legend>
  97. {% set display_tooltip = false %}
  98. {% include 'simple/categories.html' %}
  99. </fieldset>
  100. {% endif %}
  101. {% if 'language' not in locked_preferences %}
  102. <fieldset>
  103. <legend>{{ _('Search language') }}</legend>
  104. <p class="value">{{- '' -}}
  105. <select name='language'>{{- '' -}}
  106. <option value="all" {% if current_language == 'all' %}selected="selected"{% endif %}>{{ _('Default language') }}</option>
  107. {%- for lang_id,lang_name,country_name,english_name in language_codes | sort(attribute=1) -%}
  108. <option value="{{ lang_id }}" {% if lang_id == current_language %}selected="selected"{% endif %}>{{ lang_name }} {% if country_name %}({{ country_name }}) {% endif %}- {{ lang_id }}</option>
  109. {%- endfor -%}
  110. </select>{{- '' -}}
  111. </p>
  112. <div class="description">{{ _('What language do you prefer for search?') }}</div>
  113. </fieldset>
  114. {% endif %}
  115. {% if 'autocomplete' not in locked_preferences %}
  116. <fieldset>
  117. <legend>{{ _('Autocomplete') }}</legend>
  118. <p class="value">
  119. <select name="autocomplete">
  120. <option value=""> - </option>
  121. {%- for backend in autocomplete_backends -%}
  122. <option value="{{ backend }}" {% if backend == autocomplete %}selected="selected"{% endif %}>{{ backend }}</option>
  123. {%- endfor -%}
  124. </select>
  125. </p>
  126. <div class="description">{{ _('Find stuff as you type') }}</div>
  127. </fieldset>
  128. {% endif %}
  129. {% if 'safesearch' not in locked_preferences %}
  130. <fieldset>
  131. <legend>{{ _('SafeSearch') }}</legend>
  132. <p class="value">
  133. <select name='safesearch'>
  134. <option value="2" {% if safesearch == '2' %}selected="selected"{% endif %}>{{ _('Strict') }}</option>
  135. <option value="1" {% if safesearch == '1' %}selected="selected"{% endif %}>{{ _('Moderate') }}</option>
  136. <option value="0" {% if safesearch == '0' %}selected="selected"{% endif %}>{{ _('None') }}</option>
  137. </select>
  138. </p>
  139. <p class="description">{{ _('Filter content') }}</p>
  140. </fieldset>
  141. {% endif %}
  142. {{ plugin_preferences('general') }}
  143. {% if 'doi_resolver' not in locked_preferences %}
  144. <fieldset>
  145. <legend>{{ _('Open Access DOI resolver') }}</legend>
  146. <p class="value">
  147. <select id='doi_resolver' name='doi_resolver'>
  148. {%- for doi_resolver_name,doi_resolver_url in doi_resolvers.items() -%}
  149. <option value="{{ doi_resolver_name }}" {% if doi_resolver_url == current_doi_resolver %}selected="selected"{% endif %}>
  150. {{- doi_resolver_name }} - {{ doi_resolver_url -}}
  151. </option>
  152. {%- endfor -%}
  153. </select>
  154. </p>
  155. <div class="description"><!-- {{ _('Redirect to open-access versions of publications when available (plugin required)') }} --></div>
  156. </fieldset>
  157. {% endif %}
  158. {{ tab_footer() }}
  159. {{ tab_header('maintab', 'engines', _('Engines')) }}
  160. <p>{{ _('Currently used search engines') }}</p>
  161. {{ tabs_open() }}
  162. {% for categ in all_categories %}
  163. {{ tab_header('enginetab', 'category' + categ, _(categ)) }}
  164. <div class="scrollx">
  165. <table class="striped">
  166. <tr>
  167. <th class="engine_checkbox">{{ _("Allow") }}</th>
  168. <th class="name">{{ _("Engine name") }}</th>
  169. <th class="shortcut">{{ _("Shortcut") }}</th>
  170. <th>{{ _("Supports selected language") }}</th>
  171. <th>{{ _("SafeSearch") }}</th>
  172. <th>{{ _("Time range") }}</th>
  173. <th>{{ _("Response time") }}</th>
  174. <th>{{ _("Max time") }}</th>
  175. <th>{{ _("Reliablity") }}</th>
  176. </tr>
  177. {% for search_engine in engines_by_category[categ] %}
  178. {% if not search_engine.private %}
  179. {% set engine_id = 'engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_') %}
  180. <tr>
  181. <td class="engine_checkbox">{{ checkbox_onoff(engine_id, (search_engine.name, categ) in disabled_engines) }}</td>
  182. <th class="name">{% if search_engine.enable_http %}{{ icon('warning', 'No HTTPS') }}{% endif %} {{ search_engine.name }} {{ engine_about(search_engine) }}</th>
  183. <td class="shortcut">{{ shortcuts[search_engine.name] }}</td>
  184. <td>{{ checkbox(engine_id + '_supported_languages', supports[search_engine.name]['supports_selected_language'], true, true) }}</td>
  185. <td>{{ checkbox(engine_id + '_safesearch', supports[search_engine.name]['safesearch'], true, true) }}</td>
  186. <td>{{ checkbox(engine_id + '_time_range_support', supports[search_engine.name]['time_range_support'], true, true) }}</td>
  187. {{ engine_time(search_engine.name) }}
  188. <td class="{{ 'danger' if stats[search_engine.name]['warn_timeout'] else '' }}">{{ search_engine.timeout }}</td>
  189. {{ engine_reliability(search_engine.name) }}
  190. </tr>
  191. {% endif %}
  192. {% endfor %}
  193. </table>
  194. </div>
  195. {{ tab_footer() }}
  196. {% endfor %}
  197. {{ tabs_close() }}
  198. {{ tab_footer() }}
  199. {{ tab_header('maintab', 'ui', _('User interface')) }}
  200. {% if 'locale' not in locked_preferences %}
  201. <fieldset>
  202. <legend>{{ _('Interface language') }}</legend>
  203. <p class="value">
  204. <select name='locale'>
  205. {% for locale_id,locale_name in locales.items() | sort %}
  206. <option value="{{ locale_id }}" {% if locale_id == current_locale %}selected="selected"{% endif %}>{{ locale_name }}</option>
  207. {% endfor %}
  208. </select>
  209. </p>
  210. <div class="description">{{ _('Change the language of the layout') }}</div>
  211. </fieldset>
  212. {% endif %}
  213. {% if 'theme' not in locked_preferences %}
  214. <fieldset>
  215. <legend>{{ _('Themes') }}</legend>
  216. <p class="value">
  217. <select name="theme">
  218. {%- for name in themes -%}
  219. <option value="{{ name }}" {% if name == theme %}selected="selected"{% endif %}>{{ name }}</option>
  220. {%- endfor -%}
  221. </select>
  222. </p>
  223. <div class="description">{{ _('Change searx layout') }}</div>
  224. </fieldset>
  225. {% endif %}
  226. {% if 'results_on_new_tab' not in locked_preferences %}
  227. <fieldset>
  228. <legend>{{ _('Results on new tabs') }}</legend>
  229. <p class="value">
  230. <select name='results_on_new_tab'>
  231. <option value="1" {% if results_on_new_tab %}selected="selected"{% endif %}>{{ _('On') }}</option>
  232. <option value="0" {% if not results_on_new_tab %}selected="selected"{% endif %}>{{ _('Off')}}</option>
  233. </select>
  234. </p>
  235. <div class="description">{{_('Open result links on new browser tabs') }}</div>
  236. </fieldset>
  237. {% endif %}
  238. {{ plugin_preferences('ui') }}
  239. {{ tab_footer() }}
  240. {{ tab_header('maintab', 'cookies', _('Cookies')) }}
  241. <p class="text-muted" style="margin:20px 0;">
  242. {{ _('This is the list of cookies and their values searx is storing on your computer.') }}<br />
  243. {{ _('With that list, you can assess searx transparency.') }}<br />
  244. </p>
  245. {% if cookies %}
  246. <table class="cookies">
  247. <tr>
  248. <th>{{ _('Cookie name') }}</th>
  249. <th>{{ _('Value') }}</th>
  250. </tr>
  251. {% for cookie in cookies %}
  252. <tr>
  253. <td>{{ cookie }}</td>
  254. <td>{{ cookies[cookie] }}</td>
  255. </tr>
  256. {% endfor %}
  257. </table>
  258. {% else %}
  259. {% include 'oscar/messages/no_cookies.html' %}
  260. {% endif %}
  261. <h4>{{ _('Search URL of the currently saved preferences') }} :</h4>
  262. <div class="selectable_url">
  263. <pre>{{ url_for('index', _external=True) }}?preferences={{ preferences_url_params|e }}{% raw %}&amp;q=%s{% endraw %}</pre>
  264. </div>
  265. <p class="small_font">{{ _('Note: specifying custom settings in the search URL can reduce privacy by leaking data to the clicked result sites.') }}</p>
  266. {{ tab_footer() }}
  267. {{ tab_header('maintab', 'privacy', _('Privacy')) }}
  268. {% if 'method' not in locked_preferences %}
  269. <fieldset>
  270. <legend>{{ _('Method') }}</legend>
  271. <p class="value">
  272. <select name='method'>
  273. <option value="POST" {% if method == 'POST' %}selected="selected"{% endif %}>POST</option>
  274. <option value="GET" {% if method == 'GET' %}selected="selected"{% endif %}>GET</option>
  275. </select>
  276. </p>
  277. <div class="description">{{ _('Search language') }}</div>
  278. </fieldset>
  279. {% endif %}
  280. {% if 'image_proxy' not in locked_preferences %}
  281. <fieldset>
  282. <legend>{{ _('Image proxy') }}</legend>
  283. <p class="value">
  284. <select name='image_proxy'>
  285. <option value="1" {% if image_proxy %}selected="selected"{% endif %}>{{ _('Enabled') }}</option>
  286. <option value="" {% if not image_proxy %}selected="selected"{% endif %}>{{ _('Disabled') }}</option>
  287. </select>
  288. </p>
  289. <div class="description">{{ _('Proxying image results through searx') }}</div>
  290. </fieldset>
  291. {% endif %}
  292. {{ plugin_preferences('privacy') }}
  293. {{ tab_footer() }}
  294. {{ tabs_close() }}
  295. <p class="small_font">{{ _('These settings are stored in your cookies, this allows us not to store this data about you.') }}
  296. <br />
  297. {{ _("These cookies serve your sole convenience, we don't use these cookies to track you.") }}
  298. </p>
  299. <input type="submit" value="{{ _('save') }}" />
  300. <div class="{% if rtl %}left{% else %}right{% endif %} preferences_back"><a href="{{ url_for('clear_cookies') }}">{{ _('Reset defaults') }}</a></div>
  301. <div class="{% if rtl %}left{% else %}right{% endif %} preferences_back"><a href="{{ url_for('index') }}">{{ _('back') }}</a></div>
  302. </form>
  303. {% endblock %}