preferences.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. {%- from 'simple/icons.html' import icon_small, icon_big -%}
  2. {%- extends "simple/page_with_header.html" -%}
  3. {%- macro tabs_open() -%}
  4. <div class="tabs" role="tablist">
  5. {%- endmacro -%}
  6. {%- macro tab_header(name, id, label, checked) -%}
  7. <input type="radio" name="{{ name }}" id="tab-{{ id }}" {% if checked is sameas true %}checked="checked"{% endif %}>
  8. <label id="tab-label-{{ id }}" for="tab-{{ id }}" role="tab" aria-controls="tab-content-{{ id }}">{{ label }}</label>
  9. <section id="tab-content-{{ id }}" role="tabpanel" aria-hidden="false">
  10. {%- endmacro -%}
  11. {%- macro tab_footer() -%}
  12. </section>
  13. {%- endmacro -%}
  14. {%- macro tabs_close() -%}
  15. </div>
  16. {%- endmacro -%}
  17. {%- macro checkbox(name, checked, disabled) -%}
  18. {%- if checked == '?' -%}
  19. {{- icon_small('alert') -}}
  20. {%- else -%}
  21. <input type="checkbox" {%- if name %} name="{{ name }}" {%- endif %} value="None" {%- if checked %} checked {%- endif -%}{%- if disabled %} disabled {%- endif -%}>
  22. {%- endif -%}
  23. {%- endmacro -%}
  24. {%- macro checkbox_onoff_reversed(name, checked, labelledby) -%}
  25. <input type="checkbox" {{- ' ' -}}
  26. name="{{ name }}" {{- ' ' -}}
  27. id="{{ name }}" {{- ' ' -}}
  28. {%- if labelledby -%} aria-labelledby="{{ labelledby }}"{{- ' ' -}}{%- endif -%}
  29. class="checkbox-onoff reversed-checkbox"{{- ' ' -}}
  30. {%- if checked -%} checked{%- endif -%}>
  31. {%- endmacro -%}
  32. {%- macro plugin_preferences(section) -%}
  33. {%- for plugin in plugins_storage -%}
  34. {%- if plugin.preference_section == section -%}
  35. <fieldset>{{- '' -}}
  36. <legend>{{ _(plugin.name) }}</legend>{{- '' -}}
  37. <div class="value">
  38. {{- checkbox_onoff_reversed('plugin_' + plugin.id, plugin.id not in allowed_plugins, 'plugin_labelledby' + plugin.id) -}}
  39. </div>{{- '' -}}
  40. <div class="description" id="{{ 'plugin_labelledby' + plugin.id }}">
  41. {{- _(plugin.description) -}}
  42. </div>{{- '' -}}
  43. </fieldset>
  44. {%- endif -%}
  45. {%- endfor -%}
  46. {%- endmacro -%}
  47. {%- macro engine_about(search_engine) -%}
  48. {%- if search_engine.about is defined -%}
  49. {%- set about = search_engine.about -%}
  50. <div class="engine-tooltip" role="tooltip">{{- '' -}}
  51. <p class="engine-description"></p>{{- '' -}}
  52. <p><a href="{{about.website}}" rel="noreferrer">{{about.website}}</a></p>{{- '' -}}
  53. {%- if about.wikidata_id -%}
  54. <p><a href="https://www.wikidata.org/wiki/{{about.wikidata_id}}" rel="noreferrer">wikidata.org/wiki/{{about.wikidata_id}}</a></p>
  55. {%- endif -%}
  56. {%- if search_engine.enable_http -%}
  57. <p>{{- icon_big('exclamation-sign', 'No HTTPS') -}}{{- _('No HTTPS')-}}</p>
  58. {% endif -%}
  59. {%- if reliabilities.get(search_engine.name, {}).errors or reliabilities.get(search_engine.name, {}).checker -%}
  60. <a href="{{ url_for('stats', engine=search_engine.name|e) }}" {{- ' ' -}}
  61. title="{{ _('View error logs and submit a bug report') }}">
  62. {{- _('View error logs and submit a bug report') -}}
  63. </a>
  64. {%- endif -%}
  65. <p>{{- '' -}}
  66. <span class="right">{{ _("!bang for this engine") }}</span>{{- '' -}}
  67. {%- for bang in [search_engine.name] + [search_engine.shortcut] -%}
  68. <span class="bang"> {{ '!' + bang.replace(' ', '_') }}</span>
  69. {%- endfor -%}
  70. </p>{{- '' -}}
  71. <p>{{- '' -}}
  72. <span class="right">{{ _("!bang for its categories") }}</span>
  73. {%- for bang in search_engine.categories -%}
  74. <span class="bang">{{ '!' + bang.replace(' ', '_') }}</span>
  75. {%- endfor -%}
  76. </p>{{- '' -}}
  77. </div>
  78. {%- endif -%}
  79. {%- endmacro -%}
  80. {%- macro engine_time(engine_name) -%}
  81. <td class="{{ label }}">{{- '' -}}
  82. {%- if stats[engine_name].time != None -%}
  83. <span class="stacked-bar-chart-value">{{- stats[engine_name].time -}}</span>{{- '' -}}
  84. <span class="stacked-bar-chart" aria-hidden="true">
  85. {%- if max_rate95 is not none and max_rate95 > 0 -%}
  86. <div class="stacked-bar-chart-median bar{{ (100 * (stats[engine_name].time / max_rate95))|round }}"></div>{{- '' -}}
  87. <div class="stacked-bar-chart-rate80 bar{{ (100 * ((stats[engine_name].rate80 - stats[engine_name].time) / max_rate95))|round }}"></div>{{- '' -}}
  88. <div class="stacked-bar-chart-rate95 bar{{ (100 * ((stats[engine_name].rate95 - stats[engine_name].rate80) / max_rate95))|round }}"></div>{{- '' -}}
  89. <span class="stacked-bar-chart-rate100"></span>
  90. {%- endif -%}
  91. </span>{{- '' -}}
  92. <div class="engine-tooltip text-left" role="tooltip" id="{{engine_name}}_graph">{{- '' -}}
  93. <p>{{ _('Median') }}: {{ stats[engine_name].time }}</p>{{- '' -}}
  94. <p>{{ _('P80') }}: {{ stats[engine_name].rate80 }}</p>{{- '' -}}
  95. <p>{{ _('P95') }}: {{ stats[engine_name].rate95 }}</p>{{- '' -}}
  96. </div>
  97. {%- endif -%}
  98. </td>
  99. {%- endmacro -%}
  100. {%- macro engine_reliability(engine_name) -%}
  101. {%- set r = reliabilities.get(engine_name, {}).get('reliability', None) -%}
  102. {%- set checker_result = reliabilities.get(engine_name, {}).get('checker', []) -%}
  103. {%- set errors = reliabilities.get(engine_name, {}).get('errors', []) -%}
  104. {%- if r != None -%}
  105. {%- if r <= 50 -%}
  106. {% set label = 'danger' -%}
  107. {%- elif r < 80 -%}
  108. {%- set label = 'warning' -%}
  109. {%- elif r < 90 %}
  110. {%- set label = '' -%}
  111. {%- else -%}
  112. {%- set label = 'success' -%}
  113. {%- endif -%}
  114. {% else %}
  115. {%- set r = '' -%}
  116. {%- endif -%}
  117. {%- if checker_result or errors -%}
  118. <td class="{{ label }} column-reliability">{{- '' -}}
  119. <a href="{{ url_for('stats', engine=engine_name|e) }}">{{- '' -}}
  120. <span>
  121. {{- icon_big('alert', 'The engine is not reliabled') }} {{ r -}}
  122. </span>{{- '' -}}
  123. </a>{{- '' -}}
  124. <div class="engine-tooltip" role="tooltip" id="{{engine_name}}_reliability">
  125. {%- if checker_result -%}
  126. <p>{{ _("Failed checker test(s): ") }} {{ ', '.join(checker_result) }}</p>
  127. {%- endif -%}
  128. {%- if errors -%}<p>{{ _('Errors:') }}</p>{%- endif -%}
  129. {%- for error in errors -%}
  130. <p>{{ error }}</p>{{- '' -}}
  131. {%- endfor -%}
  132. </div>{{- '' -}}
  133. </td>
  134. {%- else -%}
  135. <td class="{{ label }}">{% if r %}<span>{{ r }}</span>
  136. {%- endif -%}
  137. </td>
  138. {%- endif -%}
  139. {%- endmacro -%}
  140. {%- block head -%}{%- endblock -%}
  141. {%- block linkto_preferences -%}{%- endblock -%}
  142. {%- block content -%}
  143. <h1>{{ _('Preferences') }}</h1>
  144. <form id="search_form" method="post" action="{{ url_for('preferences') }}" autocomplete="off">
  145. {{- tabs_open() -}}
  146. {# tab: general #}
  147. {{- tab_header('maintab', 'general', _('General'), True) -}}
  148. {%- if 'categories' not in locked_preferences -%}
  149. <fieldset>
  150. <legend>{{- _('Default categories') -}}</legend>
  151. {% set display_tooltip = false %}
  152. {% include 'simple/categories.html' %}
  153. </fieldset>
  154. {%- endif -%}
  155. {%- if 'language' not in locked_preferences -%}
  156. {%- include 'simple/preferences/language.html' -%}
  157. {% endif %}
  158. {%- if 'autocomplete' not in locked_preferences -%}
  159. {%- include 'simple/preferences/autocomplete.html' -%}
  160. {%- endif -%}
  161. {%- if 'favicon' not in locked_preferences -%}
  162. {%- include 'simple/preferences/favicon.html' -%}
  163. {%- endif -%}
  164. {% if 'safesearch' not in locked_preferences %}
  165. {%- include 'simple/preferences/safesearch.html' -%}
  166. {%- endif -%}
  167. {%- include 'simple/preferences/tokens.html' -%}
  168. {{- plugin_preferences('general') -}}
  169. {%- if 'doi_resolver' not in locked_preferences %}
  170. {%- include 'simple/preferences/doi_resolver.html' -%}
  171. {%- endif -%}
  172. {{- tab_footer() -}}
  173. {# tab: ui #}
  174. {{- tab_header('maintab', 'ui', _('User interface')) -}}
  175. {%- if 'locale' not in locked_preferences -%}
  176. {%- include 'simple/preferences/ui_locale.html' -%}
  177. {%- endif -%}
  178. {%- if 'theme' not in locked_preferences -%}
  179. {%- include 'simple/preferences/theme.html' -%}
  180. {%- endif -%}
  181. {%- if 'results_on_new_tab' not in locked_preferences -%}
  182. {%- include 'simple/preferences/results_on_new_tab.html' -%}
  183. {%- endif -%}
  184. {%- if 'infinite_scroll' not in locked_preferences -%}
  185. {%- include 'simple/preferences/infinite_scroll.html' -%}
  186. {%- endif -%}
  187. {%- if 'search_on_category_select' not in locked_preferences -%}
  188. {%- include 'simple/preferences/search_on_category_select.html' -%}
  189. {%- endif -%}
  190. {%- include 'simple/preferences/hotkeys.html' -%}
  191. {%- include 'simple/preferences/urlformatting.html' -%}
  192. {{- plugin_preferences('ui') -}}
  193. {{- tab_footer() -}}
  194. {# tab: privacy #}
  195. {{- tab_header('maintab', 'privacy', _('Privacy')) -}}
  196. {%- if 'method' not in locked_preferences -%}
  197. {%- include 'simple/preferences/method.html' -%}
  198. {%- endif -%}
  199. {%- if 'image_proxy' not in locked_preferences -%}
  200. {%- include 'simple/preferences/image_proxy.html' -%}
  201. {%- endif -%}
  202. {%- if 'query_in_title' not in locked_preferences -%}
  203. {%- include 'simple/preferences/query_in_title.html' -%}
  204. {%- endif -%}
  205. {{- plugin_preferences('privacy') -}}
  206. {{- tab_footer() -}}
  207. {# tab: enignes #}
  208. {{- tab_header('maintab', 'engines', _('Engines')) -}}
  209. <p>
  210. {{- _('Currently used search engines') -}}
  211. </p>
  212. {{- tabs_open() -}}
  213. {%- include 'simple/preferences/engines.html' -%}
  214. {{- tabs_close() -}}
  215. {{- tab_footer() -}}
  216. {# tab: query #}
  217. {{- tab_header('maintab', 'query', _('Special Queries')) -}}
  218. {%- if answer_storage -%}
  219. {%- include 'simple/preferences/answerers.html' -%}
  220. {%- endif -%}
  221. {{- tab_footer() -}}
  222. {# tab: cookies #}
  223. {{- tab_header('maintab', 'cookies', _('Cookies')) -}}
  224. {%- include 'simple/preferences/cookies.html' -%}
  225. {{- tab_footer() -}}
  226. {{- tabs_close() -}}
  227. {# footer with save & reset buttons #}
  228. {%- include 'simple/preferences/footer.html' -%}
  229. </form>{{- '' -}}
  230. {%- endblock -%}