preferences.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. {% from 'simple/macros.html' import tabs_open, tabs_close, tab_header, tab_footer, checkbox_onoff, checkbox %}
  2. {% from 'simple/icons.html' import icon_big %}
  3. {% extends "simple/page_with_header.html" %}
  4. {%- macro plugin_preferences(section) -%}
  5. {%- for plugin in plugins -%}
  6. {%- if plugin.preference_section == section -%}
  7. <fieldset>{{- '' -}}
  8. <legend>{{ _(plugin.name) }}</legend>{{- '' -}}
  9. <div class="value">
  10. {{- checkbox_onoff('plugin_' + plugin.id, plugin.id not in allowed_plugins) -}}
  11. </div>{{- '' -}}
  12. <div class="description">
  13. {{- _(plugin.description) -}}
  14. </div>{{- '' -}}
  15. </fieldset>
  16. {%- endif -%}
  17. {%- endfor -%}
  18. {%- endmacro -%}
  19. {% macro engine_about(search_engine) -%}
  20. {% if search_engine.about is defined %}
  21. {% set about = search_engine.about %}
  22. <div class="engine-tooltip" role="tooltip">{{- "" -}}
  23. <p class="engine-description"></p>
  24. <p><a href="{{about.website}}" rel="noreferrer">{{about.website}}</a></p>
  25. {%- 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 -%}
  26. {%- if search_engine.enable_http %}<p>{{ icon_big('exclamation-sign', 'No HTTPS') }}{{ _('No HTTPS')}}</p>{% endif -%}
  27. {%- if reliabilities.get(search_engine.name, {}).errors or reliabilities.get(search_engine.name, {}).checker -%}
  28. <a href="{{ url_for('stats', engine=search_engine.name|e) }}" title="{{ _('View error logs and submit a bug report') }}">
  29. {{ _('View error logs and submit a bug report') }}
  30. </a>
  31. {%- endif -%}
  32. </div>
  33. {%- endif -%}
  34. {%- endmacro %}
  35. {%- macro engine_time(engine_name) -%}
  36. <td class="{{ label }}">{{- "" -}}
  37. {%- if stats[engine_name].time != None -%}
  38. <span class="stacked-bar-chart-value">{{- stats[engine_name].time -}}</span>{{- "" -}}
  39. <span class="stacked-bar-chart" aria-labelledby="{{engine_name}}_chart" aria-hidden="true">
  40. {%- if max_rate95 is not none and max_rate95 > 0 -%}
  41. <div class="stacked-bar-chart-median bar{{ (100 * (stats[engine_name].time / max_rate95))|round }}"></div>{{- "" -}}
  42. <div class="stacked-bar-chart-rate80 bar{{ (100 * ((stats[engine_name].rate80 - stats[engine_name].time) / max_rate95))|round }}"></div>{{- "" -}}
  43. <div class="stacked-bar-chart-rate95 bar{{ (100 * ((stats[engine_name].rate95 - stats[engine_name].rate80) / max_rate95))|round }}"></div>{{- "" -}}
  44. <span class="stacked-bar-chart-rate100"></span>
  45. {%- endif -%}
  46. </span>{{- "" -}}
  47. <div class="engine-tooltip text-left" role="tooltip" id="{{engine_name}}_graph">{{- "" -}}
  48. <p>{{ _('Median') }}: {{ stats[engine_name].time }}</p>{{- "" -}}
  49. <p>{{ _('P80') }}: {{ stats[engine_name].rate80 }}</p>{{- "" -}}
  50. <p>{{ _('P95') }}: {{ stats[engine_name].rate95 }}</p>{{- "" -}}
  51. </div>
  52. {%- endif -%}
  53. </td>
  54. {%- endmacro -%}
  55. {%- macro engine_reliability(engine_name) -%}
  56. {% set r = reliabilities.get(engine_name, {}).get('reliablity', None) %}
  57. {% set checker_result = reliabilities.get(engine_name, {}).get('checker', []) %}
  58. {% set errors = reliabilities.get(engine_name, {}).get('errors', []) %}
  59. {% if r != None %}
  60. {% if r <= 50 %}{% set label = 'danger' %}
  61. {% elif r < 80 %}{% set label = 'warning' %}
  62. {% elif r < 90 %}{% set label = '' %}
  63. {% else %}{% set label = 'success' %}
  64. {% endif %}
  65. {% else %}
  66. {% set r = '' %}
  67. {% endif %}
  68. {% if checker_result or errors %}
  69. <td class="{{ label }} column-reliability">{{- "" -}}
  70. <a href="{{ url_for('stats', engine=engine_name|e) }}">{{- "" -}}
  71. <span aria-labelledby="{{engine_name}}_reliability">
  72. {{ icon_big('warning', 'The engine is not reliabled') }} {{ r -}}
  73. </span>{{- "" -}}
  74. </a>{{- "" -}}
  75. <div class="engine-tooltip" role="tooltip" id="{{engine_name}}_reliability">
  76. {%- if checker_result -%}
  77. <p>{{ _("Failed checker test(s): ") }} {{ ', '.join(checker_result) }}</p>
  78. {%- endif -%}
  79. {%- if errors %}<p>{{ _('Errors:') }}</p>{% endif -%}
  80. {%- for error in errors -%}
  81. <p>{{ error }} </p>{{- "" -}}
  82. {%- endfor -%}
  83. </div>{{- "" -}}
  84. </td>
  85. {%- else -%}
  86. <td class="{{ label }}"><span>{{ r }}</span></td>
  87. {%- endif -%}
  88. {%- endmacro -%}
  89. {% block head %} {% endblock %}
  90. {% block content %}
  91. <h1>{{ _('Preferences') }}</h1>
  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. <fieldset>
  160. <legend>{{ _('Engine tokens') }}</legend>
  161. <p class="value">
  162. <input name="tokens" type="text" autocomplete="off" spellcheck="false" autocorrect="off" value='{{ preferences.tokens.get_value() }}'/>
  163. </p>
  164. <p class="description">{{ _('Access tokens for private engines') }}</p>
  165. </fieldset>
  166. {{ tab_footer() }}
  167. {{ tab_header('maintab', 'ui', _('User interface')) }}
  168. {% if 'locale' not in locked_preferences %}
  169. <fieldset>
  170. <legend>{{ _('Interface language') }}</legend>
  171. <p class="value">
  172. <select name='locale'>
  173. {% for locale_id,locale_name in locales.items() | sort %}
  174. <option value="{{ locale_id }}" {% if locale_id == current_locale %}selected="selected"{% endif %}>{{ locale_name }}</option>
  175. {% endfor %}
  176. </select>
  177. </p>
  178. <div class="description">{{ _('Change the language of the layout') }}</div>
  179. </fieldset>
  180. {% endif %}
  181. {% if 'theme' not in locked_preferences %}
  182. <fieldset>
  183. <legend>{{ _('Theme') }}</legend>
  184. <p class="value">
  185. <select name="theme">
  186. {%- for name in themes -%}
  187. <option value="{{ name }}" {% if name == theme %}selected="selected"{% endif %}>{{ name }}</option>
  188. {%- endfor -%}
  189. </select>
  190. </p>
  191. <div class="description">{{ _('Change SearXNG layout') }}</div>
  192. </fieldset>
  193. <fieldset>
  194. <legend>{{ _('Theme style') }}</legend>
  195. <p class="value">
  196. <select name="simple_style">
  197. {%- for name in ['auto', 'light', 'dark'] -%}
  198. <option value="{{ name }}" {% if name == preferences.get_value('simple_style') %}selected="selected"{% endif %}>{{ _(name) }}</option>
  199. {%- endfor -%}
  200. </select>
  201. </p>
  202. <div class="description">{{ _('Choose auto to follow your browser settings') }}</div>
  203. </fieldset>
  204. {% endif %}
  205. {% if 'results_on_new_tab' not in locked_preferences %}
  206. <fieldset>
  207. <legend>{{ _('Results on new tabs') }}</legend>
  208. <p class="value">
  209. <select name='results_on_new_tab'>
  210. <option value="1" {% if results_on_new_tab %}selected="selected"{% endif %}>{{ _('On') }}</option>
  211. <option value="0" {% if not results_on_new_tab %}selected="selected"{% endif %}>{{ _('Off')}}</option>
  212. </select>
  213. </p>
  214. <div class="description">{{_('Open result links on new browser tabs') }}</div>
  215. </fieldset>
  216. {% endif %}
  217. {{ plugin_preferences('ui') }}
  218. {{ tab_footer() }}
  219. {{ tab_header('maintab', 'privacy', _('Privacy')) }}
  220. {% if 'method' not in locked_preferences %}
  221. <fieldset>
  222. <legend>{{ _('HTTP Method') }}</legend>
  223. <p class="value">
  224. <select name='method'>
  225. <option value="POST" {% if method == 'POST' %}selected="selected"{% endif %}>POST</option>
  226. <option value="GET" {% if method == 'GET' %}selected="selected"{% endif %}>GET</option>
  227. </select>
  228. </p>
  229. <div class="description">{{ _('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>') }}</div>
  230. </fieldset>
  231. {% endif %}
  232. {% if 'image_proxy' not in locked_preferences %}
  233. <fieldset>
  234. <legend>{{ _('Image proxy') }}</legend>
  235. <p class="value">
  236. <select name='image_proxy'>
  237. <option value="1" {% if image_proxy %}selected="selected"{% endif %}>{{ _('Enabled') }}</option>
  238. <option value="" {% if not image_proxy %}selected="selected"{% endif %}>{{ _('Disabled') }}</option>
  239. </select>
  240. </p>
  241. <div class="description">{{ _('Proxying image results through SearXNG') }}</div>
  242. </fieldset>
  243. {% endif %}
  244. {% if 'query_in_title' not in locked_preferences %}
  245. <fieldset>
  246. <legend>{{ _("Query in the page's title") }}</legend>
  247. <p class="value">
  248. <select name='query_in_title'>
  249. <option value="1" {% if query_in_title %}selected="selected"{% endif %}>{{ _('Enabled') }}</option>
  250. <option value="" {% if not query_in_title %}selected="selected"{% endif %}>{{ _('Disabled') }}</option>
  251. </select>
  252. </p>
  253. <div class="description">{{ _("When enabled, the result page's title contains your query. Your browser can record this title") }}</div>
  254. </fieldset>
  255. {% endif %}
  256. {{ plugin_preferences('privacy') }}
  257. {{ tab_footer() }}
  258. {{ tab_header('maintab', 'engines', _('Engines')) }}
  259. <p>{{ _('Currently used search engines') }}</p>
  260. {{ tabs_open() }}
  261. {% for categ in categories_as_tabs + [OTHER_CATEGORY] %}
  262. {{ tab_header('enginetab', 'category' + categ, _(categ)) }}
  263. {% if categ == OTHER_CATEGORY %}
  264. <p>{{_('This tab does not show up for search results, but you can search the engines listed here via bangs.')}}</p>
  265. {% endif %}
  266. <div class="scrollx">
  267. <table class="striped">
  268. <tr>
  269. <th class="engine_checkbox">{{ _("Allow") }}</th>
  270. <th class="name">{{ _("Engine name") }}</th>
  271. <th class="shortcut">{{ _("Shortcut") }}</th>
  272. <th>{{ _("Supports selected language") }}</th>
  273. <th>{{ _("SafeSearch") }}</th>
  274. <th>{{ _("Time range") }}</th>
  275. <th>{{ _("Response time") }}</th>
  276. <th>{{ _("Max time") }}</th>
  277. <th>{{ _("Reliability") }}</th>
  278. </tr>
  279. {% for group, engines in engines_by_category[categ] | group_engines_in_tab %}
  280. {% if loop.length > 1 %}
  281. <tr><th colspan="9" class="engine-group">{{_(group)}}</th></tr>
  282. {% endif %}
  283. {% for search_engine in engines %}
  284. {% if not search_engine.private %}
  285. {% set engine_id = 'engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_') %}
  286. <tr>
  287. <td class="engine_checkbox">{{ checkbox_onoff(engine_id, (search_engine.name, categ) in disabled_engines) }}</td>
  288. <th class="name" data-engine-name="{{ search_engine.name }}">{% if search_engine.enable_http %}{{ icon_big('warning', 'No HTTPS') }}{% endif %}
  289. {{ search_engine.name }}
  290. {%- if search_engine.about and search_engine.about.language %}
  291. ({{search_engine.about.language | upper}})
  292. {%- endif %}
  293. {{ engine_about(search_engine) }}
  294. </th>
  295. <td class="shortcut">{{ shortcuts[search_engine.name] }}</td>
  296. <td>{{ checkbox(engine_id + '_supported_languages', supports[search_engine.name]['supports_selected_language'], true, true) }}</td>
  297. <td>{{ checkbox(engine_id + '_safesearch', supports[search_engine.name]['safesearch'], true, true) }}</td>
  298. <td>{{ checkbox(engine_id + '_time_range_support', supports[search_engine.name]['time_range_support'], true, true) }}</td>
  299. {{ engine_time(search_engine.name) }}
  300. <td class="{{ 'danger' if stats[search_engine.name]['warn_timeout'] else '' }}">{{ search_engine.timeout }}</td>
  301. {{ engine_reliability(search_engine.name) }}
  302. </tr>
  303. {% endif %}
  304. {% endfor %}
  305. {% endfor %}
  306. </table>
  307. </div>
  308. {{ tab_footer() }}
  309. {% endfor %}
  310. {{ tabs_close() }}
  311. {{ tab_footer() }}
  312. {{ tab_header('maintab', 'query', _('Special Queries')) }}
  313. {% if answerers %}
  314. <div class="scrollx">
  315. <table class="striped">
  316. <tr>
  317. <th>{{ _('Allow') }}</th>
  318. <th>{{ _('Keywords') }}</th>
  319. <th>{{ _('Name') }}</th>
  320. <th>{{ _('Description') }}</th>
  321. <th>{{ _('Examples') }}</th>
  322. </tr>
  323. <td></td>
  324. <th scope="colgroup" colspan="4">{{ _("This is the list of SearXNG's instant answering modules.") }}</th>
  325. {% for answerer in answerers %}
  326. <tr>
  327. <td></td>
  328. <td>{{ answerer.keywords|join(', ') }}</td>
  329. <td>{{ answerer.info.name }}</td>
  330. <td>{{ answerer.info.description }}</td>
  331. <td>{{ answerer.info.examples|join(', ') }}</td>
  332. </tr>
  333. {% endfor %}
  334. <td></td>
  335. <th scope="colgroup" colspan="4">{{ _('This is the list of plugins.') }}</th>
  336. {%- for plugin in plugins -%}
  337. {%- if plugin.preference_section == 'query' -%}
  338. <tr>
  339. <td>{{- checkbox_onoff('plugin_' + plugin.id, plugin.id not in allowed_plugins) -}}</td>
  340. <td>{{ plugin.query_keywords|join(', ') }}</td>
  341. <td>{{ _(plugin.name) }}</td>
  342. <td>{{ _(plugin.description) }}</td>
  343. <td>{{ plugin.query_examples }}</td>
  344. </tr>
  345. {%- endif -%}
  346. {%- endfor -%}
  347. </table>
  348. </div>
  349. {% endif %}
  350. {{ tab_footer() }}
  351. {{ tab_header('maintab', 'cookies', _('Cookies')) }}
  352. <p class="text-muted">
  353. {{ _('This is the list of cookies and their values SearXNG is storing on your computer.') }}<br />
  354. {{ _('With that list, you can assess SearXNG transparency.') }}<br />
  355. </p>
  356. {% if cookies %}
  357. <table class="cookies">
  358. <tr>
  359. <th>{{ _('Cookie name') }}</th>
  360. <th>{{ _('Value') }}</th>
  361. </tr>
  362. {% for cookie in cookies %}
  363. <tr>
  364. <td>{{ cookie }}</td>
  365. <td>{{ cookies[cookie] }}</td>
  366. </tr>
  367. {% endfor %}
  368. </table>
  369. {% else %}
  370. {% include 'oscar/messages/no_cookies.html' %}
  371. {% endif %}
  372. <h4>{{ _('Search URL of the currently saved preferences') }} :</h4>
  373. <div class="selectable_url">
  374. <pre>{{ url_for('index', _external=True) }}?preferences={{ preferences_url_params|e }}{% raw %}&amp;q=%s{% endraw %}</pre>
  375. </div>
  376. <p class="small_font">{{ _('Note: specifying custom settings in the search URL can reduce privacy by leaking data to the clicked result sites.') }}</p>
  377. {{ tab_footer() }}
  378. {{ tabs_close() }}
  379. <p class="small_font">{{ _('These settings are stored in your cookies, this allows us not to store this data about you.') }}
  380. <br />
  381. {{ _("These cookies serve your sole convenience, we don't use these cookies to track you.") }}
  382. </p>
  383. <input type="submit" value="{{ _('Save') }}" />
  384. <div class="{% if rtl %}left{% else %}right{% endif %} preferences_back"><a href="{{ url_for('clear_cookies') }}">{{ _('Reset defaults') }}</a></div>
  385. <div class="{% if rtl %}left{% else %}right{% endif %} preferences_back"><a href="{{ url_for('index') }}">{{ _('Back') }}</a></div>
  386. </form>
  387. {% endblock %}