diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2021-05-16 13:16:44 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2021-05-17 17:41:22 +0200 |
commit | cdfb4b7ff9829cb9048b573f7f1775dc8029f75a (patch) | |
tree | 62b056ab6e7e934de9629f4d04d41ffc79c93c7b /searx/templates | |
parent | 965817f2942c31eddba44ace307b6c872479b922 (diff) | |
download | searxng-cdfb4b7ff9829cb9048b573f7f1775dc8029f75a.tar.gz searxng-cdfb4b7ff9829cb9048b573f7f1775dc8029f75a.zip |
[fix] make /stats more CSP compliant - bar graph
Replace bar graph's *styles* (see below) by CSP compliant implementation in
``searx/static/themes/__common__/less/stats.less`` ::
./simple/stats.html:49: <span style="width: calc(max(2px, 100%*{{ (engine_stat.result_count / engine_stats.max_result_count )|round(3) }}))" class="stacked-bar-chart-serie1"></span>{{- "" -}}
./simple/stats.html:57: <span style="width: calc(max(2px, 100%*{{ (engine_stat.http / engine_stats.max_time )|round(3) }}))" class="stacked-bar-chart-serie1"></span>{{- "" -}}
./simple/stats.html:58: <span style="width: calc(100%*{{ engine_stat.processing / engine_stats.max_time |round(3) }})" class="stacked-bar-chart-serie2"></span>{{- "" -}}
./oscar/stats.html:50: <span style="width: calc(max(2px, 100%*{{ (engine_stat.result_count / engine_stats.max_result_count )|round(3) }}))" class="stacked-bar-chart-serie1"></span>{{- "" -}}
./oscar/stats.html:58: <span style="width: calc(max(2px, 100%*{{ (engine_stat.http / engine_stats.max_time )|round(3) }}))" class="stacked-bar-chart-serie1"></span>{{- "" -}}
./oscar/stats.html:59: <span style="width: calc(100%*{{ engine_stat.processing / engine_stats.max_time |round(3) }})" class="stacked-bar-chart-serie2"></span>{{- "" -}}
Reported-by: https://github.com/searxng/searxng/issues/57
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/templates')
-rw-r--r-- | searx/templates/oscar/stats.html | 18 | ||||
-rw-r--r-- | searx/templates/simple/stats.html | 20 |
2 files changed, 20 insertions, 18 deletions
diff --git a/searx/templates/oscar/stats.html b/searx/templates/oscar/stats.html index 49c776ea8..8b57e39b6 100644 --- a/searx/templates/oscar/stats.html +++ b/searx/templates/oscar/stats.html @@ -45,19 +45,19 @@ </td> <td> {%- if engine_stat.result_count -%} - <span class="stacked-bar-chart-value">{{- engine_stat.result_count | int -}}</span>{{- "" -}} - <span class="stacked-bar-chart" aria-hidden="true">{{- "" -}} - <span style="width: calc(max(2px, 100%*{{ (engine_stat.result_count / engine_stats.max_result_count )|round(3) }}))" class="stacked-bar-chart-serie1"></span>{{- "" -}} - </span> + <div class="bar-chart-value">{{- engine_stat.result_count | int -}}</div>{{- "" -}} + <div class="bar-chart-graph" aria-hidden="true"> + <div class="bar-chart-bar bar{{ (100 * engine_stat.result_count / engine_stats.max_result_count)|round }}"></div>{{- "" -}} + </div> {%- endif -%} </td> <td> {%- if engine_stat.total -%} - <span class="stacked-bar-chart-value">{{- engine_stat.total | round(1) -}}</span>{{- "" -}} - <span class="stacked-bar-chart" aria-labelledby="{{engine_stat.name}}_time" aria-hidden="true">{{- "" -}} - <span style="width: calc(max(2px, 100%*{{ (engine_stat.http / engine_stats.max_time )|round(3) }}))" class="stacked-bar-chart-serie1"></span>{{- "" -}} - <span style="width: calc(100%*{{ engine_stat.processing / engine_stats.max_time |round(3) }})" class="stacked-bar-chart-serie2"></span>{{- "" -}} - </span>{{- "" -}} + <div class="bar-chart-value">{{- engine_stat.total | round(1) -}}</div>{{- "" -}} + <div class="bar-chart-graph" aria-labelledby="{{engine_stat.name}}_time" aria-hidden="true"> + <div class="bar-chart-serie1 bar{{ (100 * engine_stat.http / engine_stats.max_time)|round }}"></div>{{- "" -}} + <div class="bar-chart-serie2 bar{{ (100 * engine_stat.processing / engine_stats.max_time)|round }}"></div>{{- "" -}} + </div> <div class="engine-tooltip text-left" role="tooltip" id="{{engine_stat.name}}_time">{{- "" -}} <table class="table table-striped"> <tr> diff --git a/searx/templates/simple/stats.html b/searx/templates/simple/stats.html index 098a54065..c2396f0e5 100644 --- a/searx/templates/simple/stats.html +++ b/searx/templates/simple/stats.html @@ -44,19 +44,21 @@ </td> <td> {%- if engine_stat.result_count -%} - <span class="stacked-bar-chart-value">{{- engine_stat.result_count | int -}}</span>{{- "" -}} - <span class="stacked-bar-chart" aria-hidden="true">{{- "" -}} - <span style="width: calc(max(2px, 100%*{{ (engine_stat.result_count / engine_stats.max_result_count )|round(3) }}))" class="stacked-bar-chart-serie1"></span>{{- "" -}} - </span> + + <div class="bar-chart-value">{{- engine_stat.result_count | int -}}</div>{{- "" -}} + <div class="bar-chart-graph" aria-hidden="true"> + <div class="bar-chart-bar bar{{ (100 * engine_stat.result_count / engine_stats.max_result_count)|round }}"></div>{{- "" -}} + </div> {%- endif -%} </td> <td> {%- if engine_stat.total -%} - <span class="stacked-bar-chart-value">{{- engine_stat.total | round(1) -}}</span>{{- "" -}} - <span class="stacked-bar-chart" aria-labelledby="{{engine_stat.name}}_time" aria-hidden="true">{{- "" -}} - <span style="width: calc(max(2px, 100%*{{ (engine_stat.http / engine_stats.max_time )|round(3) }}))" class="stacked-bar-chart-serie1"></span>{{- "" -}} - <span style="width: calc(100%*{{ engine_stat.processing / engine_stats.max_time |round(3) }})" class="stacked-bar-chart-serie2"></span>{{- "" -}} - </span>{{- "" -}} + + <div class="bar-chart-value">{{- engine_stat.total | round(1) -}}</div>{{- "" -}} + <div class="bar-chart-graph" aria-labelledby="{{engine_stat.name}}_time" aria-hidden="true"> + <div class="bar-chart-serie1 bar{{ (100 * engine_stat.http / engine_stats.max_time)|round }}"></div>{{- "" -}} + <div class="bar-chart-serie2 bar{{ (100 * engine_stat.processing / engine_stats.max_time)|round }}"></div>{{- "" -}} + </div> <div class="engine-tooltip" role="tooltip" id="{{engine_stat.name}}_time">{{- "" -}} <table> <tr> |