Skip to content

Commit 45135be

Browse files
Yoann MOROCUTTIYoann MOROCUTTI
authored andcommitted
feat: Remove unused HTML style element to avoid CSP errors. Symfony classes have been used instead to format toolbar and profiler panel
[csp]
1 parent 836c76c commit 45135be

File tree

4 files changed

+60
-145
lines changed

4 files changed

+60
-145
lines changed

Resources/public/simple-http-bundle.css

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ button[data-simple-http-replay] img.rotating {
238238
background: none;
239239
}
240240

241-
242241
.simple-http-badge {
243242
display: inline-block;
244243
background: #CCC;
@@ -248,10 +247,23 @@ button[data-simple-http-replay] img.rotating {
248247
color: white;
249248
}
250249

251-
252-
253250
.http-call__title__method,
254251
.http-call__path {
255252
font-weight: bold;
256253
color: #222;
254+
}
255+
256+
.http-call__title__method {
257+
display: inline-block;
258+
vertical-align: top;
259+
}
260+
261+
.http-call__path {
262+
text-overflow: ellipsis;
263+
width: 85%;
264+
white-space: nowrap;
265+
display: inline-block;
266+
overflow-x: hidden;
267+
text-decoration: none;
268+
border-bottom: 0;
257269
}

Resources/views/Collector/partials/call.html.twig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<div id="call-{{ index }}" class="http-call http-call--{{ call.request.method | lower }} {{ call.request.schemeAndHttpHost | simple_http_md5 }}">
33

44
<h3 class="http-call__title">
5-
{#<span style="float: right"><a href="#" class="replay" data-request="{{ call.request|json_encode }}" data-index="{{ index }}">Replay</a></span>#}
65
<span class="http-call__title__method">{{ call.request.method }}</span>
76
<span title="{{ call.request.requestUri }}" class="http-call__path">{{ call.request.requestUri }}</span><br/>
87
<span class="http-call__title__webhost">{{ call.request.schemeAndHttpHost }}</span>

Resources/views/Collector/partials/summary.html.twig

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44

55
<table>
66
<tbody>
7-
<tr>
8-
<td>
9-
{% if sfDebugLink %}
10-
<a style="float: right;display: inline-block;" href="{{ sfDebugLink }}" target="_blank">
11-
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAgElEQVQYV5XQMQpCQQxF0fNX4G60stFGdyBYuSE3InwQBG20URDclPKKkSAfxXST3FxepvO9nm3c/QDHOGAU8IxZWXhggkB7bHAMGP0clwI3aN36DawRAvVY4VYzxljBHba444pp4CFjve8t+Rtc4vTxVYtc22LFmEeaQ5XlSLwAJVAaAqoDe/cAAAAASUVORK5CYII=" />
12-
Symfony External debug link
13-
</a>
14-
{% endif %}
15-
{% if debugLink %}
16-
<a style="float: right;display: inline-block;margin-left: 1em;" href="{{ debugLink }}" target="_blank">
17-
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAgElEQVQYV5XQMQpCQQxF0fNX4G60stFGdyBYuSE3InwQBG20URDclPKKkSAfxXST3FxepvO9nm3c/QDHOGAU8IxZWXhggkB7bHAMGP0clwI3aN36DawRAvVY4VYzxljBHba444pp4CFjve8t+Rtc4vTxVYtc22LFmEeaQ5XlSLwAJVAaAqoDe/cAAAAASUVORK5CYII=" />
18-
External debug link
19-
</a>
20-
{% endif %}
7+
<tr>
8+
<td>
9+
{% if sfDebugLink %}
10+
<a style="float: right;display: inline-block;" href="{{ sfDebugLink }}" target="_blank">
11+
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAgElEQVQYV5XQMQpCQQxF0fNX4G60stFGdyBYuSE3InwQBG20URDclPKKkSAfxXST3FxepvO9nm3c/QDHOGAU8IxZWXhggkB7bHAMGP0clwI3aN36DawRAvVY4VYzxljBHba444pp4CFjve8t+Rtc4vTxVYtc22LFmEeaQ5XlSLwAJVAaAqoDe/cAAAAASUVORK5CYII=" />
12+
Symfony External debug link
13+
</a>
14+
{% endif %}
15+
{% if debugLink %}
16+
<a style="float: right;display: inline-block;margin-left: 1em;" href="{{ debugLink }}" target="_blank">
17+
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAgElEQVQYV5XQMQpCQQxF0fNX4G60stFGdyBYuSE3InwQBG20URDclPKKkSAfxXST3FxepvO9nm3c/QDHOGAU8IxZWXhggkB7bHAMGP0clwI3aN36DawRAvVY4VYzxljBHba444pp4CFjve8t+Rtc4vTxVYtc22LFmEeaQ5XlSLwAJVAaAqoDe/cAAAAASUVORK5CYII=" />
18+
External debug link
19+
</a>
20+
{% endif %}
2121

22-
Duration total {{ time.total|simple_http_format_ms }},
23-
24-
wait {{ time.connection|simple_http_format_ms }} ({{ connection_percent|number_format(0) }}%),
25-
process {{ (time.total - time.connection)|simple_http_format_ms }} ({{ process_percent|number_format(0) }}%)
26-
</td>
27-
</tr>
22+
Duration total {{ '%0.2f'|format(time.total * 1000) ~ 'ms' }},
23+
24+
wait {{ '%0.2f'|format(time.connection * 1000) ~ 'ms' }} ({{ connection_percent|number_format(0) }}%),
25+
process {{ '%0.2f'|format((time.total - time.connection) * 1000) ~ 'ms' }} ({{ process_percent|number_format(0) }}%)
26+
</td>
27+
</tr>
2828
</tbody>
2929
</table>
Lines changed: 25 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,22 @@
11
{% extends '@WebProfiler/Profiler/layout.html.twig' %}
22

3-
{% macro css_custom_status_styles() %}
4-
5-
<style>
6-
.simplehttpprofiler-status-count .sf-toolbar-value {
7-
border-radius: 1px;
8-
padding: 0 5px;
9-
display: inline-block;
10-
line-height: 22px;
11-
}
12-
13-
#menu-profiler .selected .simplehttpprofiler-status-count .sf-toolbar-value.sf-toolbar-status-red,
14-
.sf-toolbar-block:hover .simplehttpprofiler-status-count .sf-toolbar-value.sf-toolbar-status-red {
15-
background: rgb(176, 65, 62);
16-
}
17-
}
18-
19-
.simplehttpprofiler-status-count .sf-toolbar-value.sf-toolbar-status-red {
20-
background: rgb(125, 46, 44);
21-
}
22-
23-
#menu-profiler .selected .simplehttpprofiler-status-count .sf-toolbar-value.sf-toolbar-status-yellow,
24-
.sf-toolbar-block:hover .simplehttpprofiler-status-count .sf-toolbar-value.sf-toolbar-status-yellow {
25-
background: rgb(164, 105, 23);
26-
}
27-
28-
.simplehttpprofiler-status-count .sf-toolbar-value.sf-toolbar-status-yellow {
29-
background: rgb(125, 80, 18);
30-
}
31-
32-
#menu-profiler .selected .simplehttpprofiler-status-count .sf-toolbar-value.sf-toolbar-status-green,
33-
.sf-toolbar-block:hover .simplehttpprofiler-status-count .sf-toolbar-value.sf-toolbar-status-green {
34-
background: rgb(80, 127, 91);
35-
}
36-
37-
.simplehttpprofiler-status-count .sf-toolbar-value.sf-toolbar-status-green {
38-
background: rgb(58, 86, 65);
39-
}
40-
41-
</style>
42-
{% endmacro %}
43-
44-
45-
463
{% block toolbar %}
47-
48-
{% set icon %}
49-
50-
{% import _self as customMacro %}
51-
{{ customMacro.css_custom_status_styles() }}
52-
53-
<span class="icon"><img alt="" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgZGF0YS1uYW1lPSJMYXllciAxIiBpZD0iTGF5ZXJfMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxkZWZzPjxzdHlsZT4uY2xzLTF7ZmlsbDojQUFBO308L3N0eWxlPjwvZGVmcz48dGl0bGUvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTQsMTZhNyw3LDAsMCwxLDctN2g4LjM2bC0xLjUyLjM5LTEuMjYsMS4yNmEyLDIsMCwxLDAsMi44MywyLjgzbDUtNWEyLDIsMCwwLDAsMC0yLjgzbC01LTVhMiwyLDAsMCwwLTIuODMsMi44M2wxLjE3LDEuMTdMMTkuMyw1SDExQTExLDExLDAsMCwwLDIuNzgsMjMuMzFhMiwyLDAsMCwwLDMtMi42NkE3LDcsMCwwLDEsNCwxNloiLz48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik0yOS4xOCw4LjY0YTIsMiwwLDAsMC0zLDIuNjhBNyw3LDAsMCwxLDIxLDIzSDEzbDEuMjQtLjQyLDEuMTYtMS4xNmEyLDIsMCwwLDAtMi44My0yLjgzbC01LDVhMiwyLDAsMCwwLDAsMi44M2w1LDVhMiwyLDAsMCwwLDIuODMtMi44M2wtMS4yMi0xLjIyTDEzLDI3aDhBMTEsMTEsMCwwLDAsMjkuMTgsOC42NFoiLz48L3N2Zz4=" /></span>
54-
55-
<span class="simplehttpprofiler-status-count">
56-
{% if collector.hasServerErrors %}
57-
<span class="sf-toolbar-value sf-toolbar-status-red">{{ collector.serverErrorsCount }}</span>
58-
{% endif %}
59-
{% if collector.hasClientErrors %}
60-
<span class="sf-toolbar-value sf-toolbar-status-yellow">{{ collector.clientErrorsCount }}</span>
61-
{% endif %}
62-
{% if collector.countSuccessfullRequest %}
63-
<span class="sf-toolbar-value sf-toolbar-status-green">{{ collector.countSuccessfullRequest }}</span>
64-
{% endif %}
65-
</span>
66-
67-
<span class="sf-toolbar-value">{{ collector.totalTime|simple_http_format_ms }}</span>
68-
69-
70-
{% endset %}
4+
{% set icon %}
5+
<svg width="24" height="24" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" fill="#AAAAAA">
6+
<path d="M4,16a7,7,0,0,1,7-7h8.36l-1.52.39-1.26,1.26a2,2,0,1,0,2.83,2.83l5-5a2,2,0,0,0,0-2.83l-5-5a2,2,0,0,0-2.83,2.83l1.17,1.17L19.3,5H11A11,11,0,0,0,2.78,23.31a2,2,0,0,0,3-2.66A7,7,0,0,1,4,16Z"/>
7+
<path d="M29.18,8.64a2,2,0,0,0-3,2.68A7,7,0,0,1,21,23H13l1.24-.42,1.16-1.16a2,2,0,0,0-2.83-2.83l-5,5a2,2,0,0,0,0,2.83l5,5a2,2,0,0,0,2.83-2.83l-1.22-1.22L13,27h8A11,11,0,0,0,29.18,8.64Z"/>
8+
</svg>
9+
10+
<span class="sf-toolbar-value">{{ collector.countRequests }}</span>
11+
<span class="sf-toolbar-info-piece-additional-detail">
12+
<span class="sf-toolbar-label">in</span>
13+
<span class="sf-toolbar-value">{{ '%0.2f'|format(collector.totalTime) }}</span>
14+
<span class="sf-toolbar-label">s</span>
15+
</span>
16+
{% endset %}
7117

7218
{% set text %}
73-
7419
{% for index, call in collector.calls %}
75-
7620
<div class="sf-toolbar-info-piece">
7721
<span style="display: table-cell">
7822
{% if call.response %}
@@ -84,18 +28,18 @@
8428

8529
<a style="display: table-cell"
8630
href="{{ path('_profiler', { 'token': token, 'panel': 'simplehttpprofiler' }) }}#request{{ index }}">
87-
<span>{{ call.request.method }} {{ call.request.requestUri }}</span>
31+
<span>{{ call.request.method }} {{ call.request.requestUri }}</span>
8832
</a>
8933

9034

9135
</div>
9236

9337
<div class="sf-toolbar-info-piece">
94-
<b style="font-weight: normal">{{ call.time.total|simple_http_format_ms }}</b>
38+
<b style="font-weight: normal">{{ '%0.2f'|format(call.time.total * 1000) ~ 'ms' }}</b>
9539
<b>
9640
{{ call.request.schemeAndHttpHost }}
9741
{% if call.debugLink %}
98-
-
42+
-
9943
<a style="text-transform: uppercase;
10044
font-variant: small-caps;
10145
display: inline-block;
@@ -150,66 +94,30 @@
15094
{% endblock %}
15195

15296
{% block menu %}
153-
<span class="label">
154-
<span class="icon"><img alt="" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgZGF0YS1uYW1lPSJMYXllciAxIiBpZD0iTGF5ZXJfMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxkZWZzPjxzdHlsZT4uY2xzLTF7ZmlsbDojQUFBO308L3N0eWxlPjwvZGVmcz48dGl0bGUvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTQsMTZhNyw3LDAsMCwxLDctN2g4LjM2bC0xLjUyLjM5LTEuMjYsMS4yNmEyLDIsMCwxLDAsMi44MywyLjgzbDUtNWEyLDIsMCwwLDAsMC0yLjgzbC01LTVhMiwyLDAsMCwwLTIuODMsMi44M2wxLjE3LDEuMTdMMTkuMyw1SDExQTExLDExLDAsMCwwLDIuNzgsMjMuMzFhMiwyLDAsMCwwLDMtMi42NkE3LDcsMCwwLDEsNCwxNloiLz48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik0yOS4xOCw4LjY0YTIsMiwwLDAsMC0zLDIuNjhBNyw3LDAsMCwxLDIxLDIzSDEzbDEuMjQtLjQyLDEuMTYtMS4xNmEyLDIsMCwwLDAtMi44My0yLjgzbC01LDVhMiwyLDAsMCwwLDAsMi44M2w1LDVhMiwyLDAsMCwwLDIuODMtMi44M2wtMS4yMi0xLjIyTDEzLDI3aDhBMTEsMTEsMCwwLDAsMjkuMTgsOC42NFoiLz48L3N2Zz4=" /></span>
97+
<span class="label {% if collector.hasServerErrors %}label-status-error{% elseif collector.hasClientErrors %}label-status-warning{% endif %}">
98+
<span class="icon">
99+
<svg width="24" height="24" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" fill="#AAAAAA">
100+
<path d="M4,16a7,7,0,0,1,7-7h8.36l-1.52.39-1.26,1.26a2,2,0,1,0,2.83,2.83l5-5a2,2,0,0,0,0-2.83l-5-5a2,2,0,0,0-2.83,2.83l1.17,1.17L19.3,5H11A11,11,0,0,0,2.78,23.31a2,2,0,0,0,3-2.66A7,7,0,0,1,4,16Z"/>
101+
<path d="M29.18,8.64a2,2,0,0,0-3,2.68A7,7,0,0,1,21,23H13l1.24-.42,1.16-1.16a2,2,0,0,0-2.83-2.83l-5,5a2,2,0,0,0,0,2.83l5,5a2,2,0,0,0,2.83-2.83l-1.22-1.22L13,27h8A11,11,0,0,0,29.18,8.64Z"/>
102+
</svg>
103+
</span>
155104

156105
<strong>HTTP</strong>
157106

158-
{% import _self as customMacro %}
159-
{{ customMacro.css_custom_status_styles() }}
160-
161-
<span class="count simplehttpprofiler-status-count" style="background: transparent">
162-
{% if collector.hasServerErrors %}
163-
<b class="sf-toolbar-value sf-toolbar-status-red">{{ collector.serverErrorsCount }}</b>
164-
{% endif %}
165-
{% if collector.hasClientErrors %}
166-
<b class="sf-toolbar-value sf-toolbar-status-yellow">{{ collector.clientErrorsCount }}</b>
167-
{% endif %}
168-
{% if collector.countSuccessfullRequest %}
169-
<b class="sf-toolbar-value sf-toolbar-status-green">{{ collector.countSuccessfullRequest }}</b>
170-
{% endif %}
171-
172-
<span>{{ collector.totalTime|simple_http_format_ms }}</span>
107+
<span class="count">
108+
{{ collector.countRequests }} - {{ '%0.2f'|format(collector.totalTime * 1000) ~ 'ms' }}
173109
</span>
174-
175110
</span>
176111
{% endblock %}
177112

178113
{% block head %}
179-
180114
{{ parent() }}
181115

182-
183116
<link rel="stylesheet" href="{{ asset('bundles/simplehttp/libs/highlightjs/highlightjs-8.5.css') }}" />
184117
<link rel="stylesheet" href="{{ asset('bundles/simplehttp/simple-http-bundle.css') }}" />
185-
186-
187118
{% endblock %}
188119

189-
190-
191-
192120
{% block panel %}
193-
194-
195-
<style>
196-
.http-call__title__method {
197-
display: inline-block;
198-
vertical-align: top;
199-
}
200-
201-
.http-call__path {
202-
text-overflow: ellipsis;
203-
width: 85%;
204-
white-space: nowrap;
205-
display: inline-block;
206-
overflow-x: hidden;
207-
text-decoration: none;
208-
border-bottom: 0;
209-
}
210-
</style>
211-
212-
213121
<table>
214122
<tr>
215123
<th width="120">
@@ -225,16 +133,12 @@
225133
</tr>
226134
</table>
227135

228-
229136
{% for index, call in collector.calls %}
230137
<a name="request{{ index }}"></a>
231138
{% include '@SimpleHttp/Collector/partials/call.html.twig' with { 'call': call } %}
232139
{% endfor %}
233140

234-
235141
<script type="text/javascript" src="{{ asset('bundles/simplehttp/libs/jquery/jquery-1.12.1.js') }}"></script>
236142
<script type="text/javascript" src="{{ asset('bundles/simplehttp/libs/highlightjs/highlightjs-8.5.js') }}"></script>
237143
<script type="text/javascript" src="{{ asset('bundles/simplehttp/simple-http-bundle.js') }}"></script>
238-
239-
240144
{% endblock %}

0 commit comments

Comments
 (0)