preferences.html 15 KB

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