preferences.html 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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-labelledby="tab-label-{{ id }}" 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('warning') -}}
  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) -%}
  25. <input type="checkbox" {{- ' ' -}}
  26. name="{{ name }}" {{- ' ' -}}
  27. id="{{ name }}" {{- ' ' -}}
  28. aria-labelledby="pref_{{ name }}"{{- ' ' -}}
  29. class="checkbox-onoff reversed-checkbox"{{- ' ' -}}
  30. {%- if checked -%} checked{%- endif -%}/>
  31. {%- endmacro -%}
  32. {%- macro plugin_preferences(section) -%}
  33. {%- for plugin in plugins -%}
  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) -}}
  39. </div>{{- '' -}}
  40. <div class="description">
  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-labelledby="{{engine_name}}_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 aria-labelledby="{{engine_name}}_reliability">
  121. {{- icon_big('warning', '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_header('maintab', 'general', _('General'), True) -}}
  147. {%- if 'categories' not in locked_preferences -%}
  148. <fieldset>
  149. <legend>{{- _('Default categories') -}}</legend>
  150. {% set display_tooltip = false %}
  151. {% include 'simple/categories.html' %}
  152. </fieldset>
  153. {%- endif -%}
  154. {%- if 'language' not in locked_preferences -%}
  155. {%- include 'simple/preferences/language.html' -%}
  156. {% endif %}
  157. {%- if 'autocomplete' not in locked_preferences -%}
  158. {%- include 'simple/preferences/autocomplete.html' -%}
  159. {%- endif -%}
  160. {% if 'safesearch' not in locked_preferences %}
  161. {%- include 'simple/preferences/safesearch.html' -%}
  162. {%- endif -%}
  163. {{- plugin_preferences('general') -}}
  164. {%- if 'doi_resolver' not in locked_preferences %}
  165. {%- include 'simple/preferences/doi_resolver.html' -%}
  166. {%- endif -%}
  167. {%- include 'simple/preferences/tokens.html' -%}
  168. {{- tab_footer() -}}
  169. {{- tab_header('maintab', 'ui', _('User interface')) -}}
  170. {%- if 'locale' not in locked_preferences -%}
  171. {%- include 'simple/preferences/ui_locale.html' -%}
  172. {%- endif -%}
  173. {%- if 'theme' not in locked_preferences -%}
  174. {%- include 'simple/preferences/theme.html' -%}
  175. {%- endif -%}
  176. {%- if 'results_on_new_tab' not in locked_preferences -%}
  177. {%- include 'simple/preferences/results_on_new_tab.html' -%}
  178. {%- endif -%}
  179. {%- if 'infinite_scroll' not in locked_preferences -%}
  180. {%- include 'simple/preferences/infinite_scroll.html' -%}
  181. {%- endif -%}
  182. {{- plugin_preferences('ui') -}}
  183. {{- tab_footer() -}}
  184. {{- tab_header('maintab', 'privacy', _('Privacy')) -}}
  185. {%- if 'method' not in locked_preferences -%}
  186. {%- include 'simple/preferences/method.html' -%}
  187. {%- endif -%}
  188. {%- if 'image_proxy' not in locked_preferences -%}
  189. {%- include 'simple/preferences/image_proxy.html' -%}
  190. {%- endif -%}
  191. {%- if 'query_in_title' not in locked_preferences -%}
  192. {%- include 'simple/preferences/query_in_title.html' -%}
  193. {%- endif -%}
  194. {{- plugin_preferences('privacy') -}}
  195. {{- tab_footer() -}}
  196. {{- tab_header('maintab', 'engines', _('Engines')) -}}
  197. <p>
  198. {{- _('Currently used search engines') -}}
  199. </p>
  200. {{- tabs_open() -}}
  201. {%- include 'simple/preferences/engines.html' -%}
  202. {{- tabs_close() -}}
  203. {{- tab_footer() -}}
  204. {{- tab_header('maintab', 'query', _('Special Queries')) -}}
  205. {%- if answerers -%}
  206. {%- include 'simple/preferences/answerers.html' -%}
  207. {%- endif -%}
  208. {{- tab_footer() -}}
  209. {{- tab_header('maintab', 'cookies', _('Cookies')) -}}
  210. {%- include 'simple/preferences/cookies.html' -%}
  211. {{- tab_footer() -}}
  212. {{- tabs_close() -}}
  213. {%- include 'simple/preferences/footer.html' -%}
  214. </form>{{- '' -}}
  215. {%- endblock -%}