mirror of
https://github.com/searxng/searxng.git
synced 2026-05-22 10:54:30 +02:00
b9340f50c2
I've been profiling the `/preferences` endpoint using werkzeug's `ProfilerMiddleware` (i.e. just do `app.wsgi_app = ProfilerMiddleware(app.wsgi_app)`) and look at the outputs in the terminal when doing `make run`. It turns out that 95%+ of the time spent were inside babel's Locale parsing (> 700ms on my machine). That's because, when opening the settings, we loaded the full engine traits of each engine and checked if it matches the user-defined search language. As we have 250+ engines, and babel is very slow when parsing Locale's, this took a very long time. By removing this feature that shows whether the selected search language is supported by the engine, the load time went down from 800ms to 50ms on my machine (which is still very slow, but well, that's future work on optimizing).
98 lines
3.9 KiB
HTML
98 lines
3.9 KiB
HTML
{%- set ns = namespace(checked=true) -%}
|
|
{%- for categ in categories_as_tabs + [DEFAULT_CATEGORY] -%}
|
|
|
|
{{- tab_header('enginetab', 'category_' + categ, _(categ), ns.checked ) -}}
|
|
|
|
{%- set ns.checked = false -%}
|
|
{%- if categ == DEFAULT_CATEGORY -%}
|
|
<p>
|
|
{{- _('This tab does not exist in the user interface, but you can search with these engines via !bangs.') -}}
|
|
{{- ' ' -}}<a href="{{ url_for('info', pagename='search-syntax') }}">ⓘ</a>
|
|
</p>
|
|
{%- endif -%}
|
|
|
|
<div class="hide_if_nojs" id="toggle-all-engines-container">
|
|
<button type="button" class="button enable-all-engines">{{ _("Enable all") }}</button>
|
|
<button type="button" class="button disable-all-engines">{{ _("Disable all") }}</button>
|
|
</div>
|
|
|
|
<div class="scrollx">{{- '' -}}
|
|
<table class="striped table_engines">{{- '' -}}
|
|
|
|
<tr>{{- '' -}}
|
|
<th class="checkbox-col">{{- _("Allow") -}}</th>{{- '' -}}
|
|
<th class="name">{{- _("Engine name") -}}</th>{{- '' -}}
|
|
<th class="shortcut">{{ _("!bang") -}}</th>{{- '' -}}
|
|
<th>{{- _("SafeSearch") -}}</th>{{- '' -}}
|
|
<th>{{- _("Time range") -}}</th>{{- '' -}}
|
|
<th>{{- _("Weight") }}</th>
|
|
{%- if enable_metrics -%}
|
|
<th>{{- _("Response time") -}}</th>
|
|
{%- endif -%}
|
|
<th>{{- _("Max time") -}}</th>
|
|
{%- if enable_metrics -%}
|
|
<th>{{- _("Reliability") }}</th>
|
|
{%- endif -%}
|
|
</tr>{{- '' -}}
|
|
|
|
{%- for group, group_bang, engines in engines_by_category[categ] | group_engines_in_tab -%}
|
|
|
|
{%- if loop.length > 1 -%}
|
|
<tr class="pref-group" >{{- '' -}}
|
|
<th colspan="2">{{- _(group) -}}</th>{{- '' -}}
|
|
<th colspan="8">
|
|
{%- if group_bang -%}
|
|
<span class="bang">{{- group_bang -}}</span>
|
|
{%- endif -%}</th>{{- '' -}}
|
|
</tr>{{- '' -}}
|
|
{%- endif -%}
|
|
|
|
{%- for search_engine in engines -%}
|
|
{%- if not search_engine.private -%}
|
|
{%- set engine_id = 'engine_' + search_engine.name|replace(' ', '_') + '__' + categ|replace(' ', '_') -%}
|
|
<tr>{{- '' -}}
|
|
<td>
|
|
{{- checkbox_onoff_reversed(engine_id, (search_engine.name, categ) in disabled_engines) -}}
|
|
</td>{{- '' -}}
|
|
<th class="name" data-engine-name="{{ search_engine.name }}">
|
|
{%- if search_engine.enable_http -%}
|
|
{{- icon_big('alert', 'No HTTPS') -}}
|
|
{%- endif -%}
|
|
<label for="{{ engine_id }}">
|
|
{{- ' ' -}}{{- search_engine.name -}}
|
|
{%- if search_engine.about and search_engine.about.language -%}
|
|
{{- ' ' -}}({{search_engine.about.language | upper}})
|
|
{%- endif -%}
|
|
</label>
|
|
{{- engine_about(search_engine) -}}
|
|
</th>{{- '' -}}
|
|
<td class="shortcut">{{- '' -}}
|
|
<span class="bang">{{ '!' + shortcuts[search_engine.name] }}</span>{{- '' -}}
|
|
</td>{{- '' -}}
|
|
<td>
|
|
{{- checkbox(None, supports[search_engine.name]['safesearch'], true) -}}
|
|
</td>{{- '' -}}
|
|
<td>
|
|
{{- checkbox(None, supports[search_engine.name]['time_range_support'], true) -}}
|
|
</td>{{- '' -}}
|
|
<td>{{- search_engine.weight or '1.0' -}}</td>{{- '' -}}
|
|
{%- if enable_metrics -%}
|
|
{{- engine_time(search_engine.name) -}}
|
|
{%- endif -%}
|
|
<td class="{{ 'danger' if stats[search_engine.name]['warn_timeout'] else '' }}">
|
|
{{- search_engine.timeout -}}
|
|
</td>{{- '' -}}
|
|
{%- if enable_metrics -%}
|
|
{{- engine_reliability(search_engine.name) -}}
|
|
{%- endif -%}
|
|
</tr>
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
{%- endfor -%}
|
|
</table>{{- '' -}}
|
|
</div>
|
|
|
|
{{- tab_footer() -}}
|
|
|
|
{%- endfor -%}
|