Skip to content

Commit 763a008

Browse files
xitim-schilling
authored andcommitted
check for unsave inline script or styles in Makefile
1 parent 0b58338 commit 763a008

File tree

7 files changed

+19
-6
lines changed

7 files changed

+19
-6
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ style: package-lock.json
88
flake8
99
npx eslint --ignore-path .gitignore --fix .
1010
npx prettier --ignore-path .gitignore --write $(PRETTIER_TARGETS)
11+
! grep -r '\(style=\|onclick=\|<script>\|<style\)' debug_toolbar/templates/
1112

1213
style_check: package-lock.json
1314
isort -c .
1415
black --target-version=py36 --check .
1516
flake8
1617
npx eslint --ignore-path .gitignore .
1718
npx prettier --ignore-path .gitignore --check $(PRETTIER_TARGETS)
19+
! grep -r '\(style=\|onclick=\|<script>\|<style\)' debug_toolbar/templates/
1820

1921
example:
2022
python example/manage.py migrate --noinput

debug_toolbar/static/debug_toolbar/css/toolbar.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,9 @@
601601
#djDebug .djdt-width-60 {
602602
width: 60%;
603603
}
604+
#djDebug .djdt-max-height-100 {
605+
max-height: 100%;
606+
}
604607
#djDebug .djdt-highlighted {
605608
background-color: lightgrey;
606609
}

debug_toolbar/static/debug_toolbar/js/toolbar.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ const djdt = {
4444
inner.previousElementSibling.remove(); // Remove AJAX loader
4545
inner.innerHTML = data.content;
4646
$$.executeScripts(data.scripts);
47+
$$.applyStyle("padding-left");
48+
$$.applyStyle("background-color");
4749
});
4850
}
4951
}

debug_toolbar/static/debug_toolbar/js/utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ const $$ = {
3232
document.head.appendChild(el);
3333
});
3434
},
35+
applyStyle(name) {
36+
const selector = "#djDebug [data-" + name + "]";
37+
document.querySelectorAll(selector).forEach(function (element) {
38+
element.style[name] = element.getAttribute("data-" + name);
39+
});
40+
},
3541
};
3642

3743
function ajax(url, init) {

debug_toolbar/templates/debug_toolbar/panels/history.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{{ refresh_form }}
44
<button class="refreshHistory">Refresh</button>
55
</form>
6-
<table style="max-height:100%;">
6+
<table class="djdt-max-height-100">
77
<thead>
88
<tr>
99
<th>{% trans "Time" %}</th>

debug_toolbar/templates/debug_toolbar/panels/profiling.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
{% for call in func_list %}
1515
<tr class="{% for parent_id in call.parent_ids %} djToggleDetails_{{ parent_id }}{% endfor %}" id="profilingMain_{{ call.id }}">
1616
<td>
17-
<div style="padding-left:{{ call.indent }}px">
17+
<div data-padding-left="{{ call.indent }}px">
1818
{% if call.has_subfuncs %}
1919
<button type="button" class="djProfileToggleDetails djToggleSwitch" data-toggle-name="profilingMain" data-toggle-id="{{ call.id }}">-</button>
2020
{% else %}

debug_toolbar/templates/debug_toolbar/panels/sql.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<ul>
33
{% for alias, info in databases %}
44
<li>
5-
<strong><span class="djdt-color" style="background-color:rgb({{ info.rgb_color|join:', ' }})"></span> {{ alias }}</strong>
5+
<strong><span class="djdt-color" data-background-color="rgb({{ info.rgb_color|join:', ' }})"></span> {{ alias }}</strong>
66
{{ info.time_spent|floatformat:"2" }} ms ({% blocktrans count info.num_queries as num %}{{ num }} query{% plural %}{{ num }} queries{% endblocktrans %}
77
{% if info.similar_count %}
88
{% blocktrans with count=info.similar_count trimmed %}
@@ -40,21 +40,21 @@
4040
<tbody>
4141
{% for query in queries %}
4242
<tr class="{% if query.is_slow %} djDebugRowWarning{% endif %}" id="sqlMain_{{ forloop.counter }}">
43-
<td><span class="djdt-color" style="background-color:rgb({{ query.rgb_color|join:', '}})"></span></td>
43+
<td><span class="djdt-color" data-background-color="rgb({{ query.rgb_color|join:', '}})"></span></td>
4444
<td class="djdt-toggle">
4545
<button type="button" class="djToggleSwitch" data-toggle-name="sqlMain" data-toggle-id="{{ forloop.counter }}">+</button>
4646
</td>
4747
<td>
4848
<div class="djDebugSql">{{ query.sql|safe }}</div>
4949
{% if query.similar_count %}
5050
<strong>
51-
<span class="djdt-color" style="background-color:{{ query.similar_color }}"></span>
51+
<span class="djdt-color" data-background-color="{{ query.similar_color }}"></span>
5252
{% blocktrans with count=query.similar_count %}{{ count }} similar queries.{% endblocktrans %}
5353
</strong>
5454
{% endif %}
5555
{% if query.duplicate_count %}
5656
<strong>
57-
<span class="djdt-color" style="background-color:{{ query.duplicate_color }}"></span>
57+
<span class="djdt-color" data-background-color="{{ query.duplicate_color }}"></span>
5858
{% blocktrans with dupes=query.duplicate_count %}Duplicated {{ dupes }} times.{% endblocktrans %}
5959
</strong>
6060
{% endif %}

0 commit comments

Comments
 (0)