From 0a6c488417f83fc2fbfcdb8d80b5978a14c561c4 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 16 May 2021 14:18:42 +0200 Subject: [PATCH] [fix] make /stats more CSP compliant - simple theme Replace simple theme's *styles* (see below) by CSP compliant implementation in ``searx/static/themes/simple/less/stats.less`` :: ./simple/stats.html:26: ./simple/stats.html:28: ./simple/stats.html:29: ./simple/stats.html:32: ./simple/stats.html:37: ./simple/stats.html:106:
{{ th_sort('name', _("Engine name")) }}{{ th_sort('score', _('Scores')) }}{{ th_sort('reliability', _('Reliability')) }} ./simple/stats.html:90: {{ engine_reliabilities.get(engine_stat.name, {}).get('reliablity') }}
./simple/stats.html:107: ./simple/stats.html:110: ./simple/stats.html:112: ./simple/stats.html:114: ./simple/stats.html:119: {{ param }} ./simple/stats.html:136: Reported-by: https://github.com/searxng/searxng/issues/57 Signed-off-by: Markus Heiser --- .../static/themes/__common__/less/stats.less | 47 +++++++++++++++++++ searx/templates/simple/stats.html | 36 +++++++------- 2 files changed, 65 insertions(+), 18 deletions(-) diff --git a/searx/static/themes/__common__/less/stats.less b/searx/static/themes/__common__/less/stats.less index 6c2117b39..2204fb02b 100644 --- a/searx/static/themes/__common__/less/stats.less +++ b/searx/static/themes/__common__/less/stats.less @@ -1,3 +1,50 @@ +#main_stats { + + table { + margin: 0 auto 0 0; + } + + table .engine-name { + width: 20rem; + } + + table .engine-scores { + width: 7rem; + } + + table .result-count { + } + + table .response-time { + } + + table .engine-reliability { + text-align: right; + } + + table.engine-error { + max-width: 1280px; + margin: 1rem; + border: 1px solid gray; + } + + table.engine-error th.engine-error-type, + table.engine-error td.engine-error-type, + failed-test { + width: 10rem; + } + + table.engine-error span.log_parameters + { + border-right: 1px solid gray; + padding: 0 1rem 0 0; + margin: 0 0 0 0.5rem; + } +} + +@media screen and (max-width: 75em) { +} + .bar-chart-value { width: 3em; } diff --git a/searx/templates/simple/stats.html b/searx/templates/simple/stats.html index c2396f0e5..968208381 100644 --- a/searx/templates/simple/stats.html +++ b/searx/templates/simple/stats.html @@ -23,18 +23,18 @@ {% if not engine_stats.get('time') %} {{ _('There is currently no data available. ') }} {% else %} -
{{ _('Exception') }}{{ error.exception_classname }}{{ _('Message') }}{{ error.log_message }}{{ _('Percentage') }}{{ error.percentage }}{{ _('Failed test') }}
+
- - - - - + + + + + {% for engine_stat in engine_stats.get('time', []) %} - - + - - - + {% endfor %}
{{ th_sort('name', _("Engine name")) }}{{ th_sort('score', _('Scores')) }}{{ th_sort('result_count', _('Result count')) }}{{ th_sort('time', _('Response time')) }}{{ th_sort('reliability', _('Reliability')) }}{{ th_sort('name', _("Engine name")) }}{{ th_sort('score', _('Scores')) }}{{ th_sort('result_count', _('Result count')) }}{{ th_sort('time', _('Response time')) }}{{ th_sort('reliability', _('Reliability')) }}
{{ engine_stat.name }} + {{ engine_stat.name }} {% if engine_stat.score %} {{ engine_stat.score|round(1) }} {% endif %} + {%- if engine_stat.result_count -%}
{{- engine_stat.result_count | int -}}
{{- "" -}} @@ -51,7 +51,7 @@ {%- endif -%}
+ {%- if engine_stat.total -%}
{{- engine_stat.total | round(1) -}}
{{- "" -}} @@ -89,7 +89,7 @@ {%- endif -%}
{{ engine_reliabilities.get(engine_stat.name, {}).get('reliablity') }} {{ engine_reliabilities.get(engine_stat.name, {}).get('reliablity') }}
@@ -105,20 +105,20 @@ {% set ns.first = false %}

{% if secondary %}{{ _('Warnings') }}{% else %}{{ _('Errors and exceptions') }}{% endif %}

{% endif %} - - +
+ {%- if error.exception_classname -%} - + {%- elif error.log_message -%} - + {%- endif -%} - + {% if error.log_parameters and error.log_parameters != (None, None, None) %}{{- '' -}} @@ -135,7 +135,7 @@

{{ _('Checker') }}

{{ _('Exception') }}{{ error.exception_classname }}{{ _('Exception') }}{{ error.exception_classname }}{{ _('Message') }}{{ error.log_message }}{{ _('Message') }}{{ error.log_message }}{{ _('Percentage') }}{{ error.percentage }}{{ _('Percentage') }}{{ error.percentage }}
{{ _('Parameter') }} {%- for param in error.log_parameters -%} - {{ param }} + {{ param }} {%- endfor -%}
- + {% for test_name, results in engine_reliabilities[selected_engine_name].checker.items() %}
{{ _('Failed test') }}{{ _('Failed test') }} {{ _('Comment(s)') }}