Skip to content

Commit 9c3f370

Browse files
committed
Add djlint for automatic template formatting + fixing
In response to jupyterhub#3178 (comment), I realized we can automate all this now.
1 parent 93aa4fb commit 9c3f370

File tree

7 files changed

+157
-148
lines changed

7 files changed

+157
-148
lines changed

.pre-commit-config.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ repos:
7171
images/minesweeper/requirements.txt|
7272
images/federation-redirect/requirements.txt
7373
74+
# Autoformat jinja2 templates
75+
- repo: https://github.com/Riverside-Healthcare/djLint
76+
rev: v1.36.4
77+
hooks:
78+
- id: djlint-reformat-jinja
79+
- id: djlint-jinja
80+
7481
# Lint: Python code
7582
- repo: https://github.com/PyCQA/flake8
7683
rev: "7.1.1"

docs/source/_templates/navigation.html

+9-7
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
be overridden so this custom theme handles title and
55
toctree for sidebar
66
#}
7-
<h3>{{ _('Table of Contents') }}</h3>
7+
<h3>{{ _("Table of Contents") }}</h3>
88
{{ toctree(includehidden=theme_sidebar_includehidden, collapse=theme_sidebar_collapse) }}
99
{% if theme_extra_nav_links %}
10-
<hr />
11-
<ul>
12-
{% for text, uri in theme_extra_nav_links.items() %}
13-
<li class="toctree-l1"><a href="{{ uri }}">{{ text }}</a></li>
14-
{% endfor %}
15-
</ul>
10+
<hr />
11+
<ul>
12+
{% for text, uri in theme_extra_nav_links.items() %}
13+
<li class="toctree-l1">
14+
<a href="{{ uri }}">{{ text }}</a>
15+
</li>
16+
{% endfor %}
17+
</ul>
1618
{% endif %}

docs/source/_templates/relations.html

+18-11
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,22 @@
33
alabaster theme does not provide previous/next page by default
44
#}
55
<div class="relations">
6-
<h3>Navigation</h3>
7-
<ul>
8-
<li><a href="{{ pathto(master_doc) }}">Documentation Home</a><ul>
9-
{%- if prev %}
10-
<li><a href="{{ prev.link|e }}" title="Previous">Previous topic</a></li>
11-
{%- endif %}
12-
{%- if next %}
13-
<li><a href="{{ next.link|e }}" title="Next">Next topic</a></li>
14-
{%- endif %}
15-
</ul>
16-
</ul>
6+
<h3>Navigation</h3>
7+
<ul>
8+
<li>
9+
<a href="{{ pathto(master_doc) }}">Documentation Home</a>
10+
<ul>
11+
{%- if prev %}
12+
<li>
13+
<a href="{{ prev.link|e }}" title="Previous">Previous topic</a>
14+
</li>
15+
{%- endif %}
16+
{%- if next %}
17+
<li>
18+
<a href="{{ next.link|e }}" title="Next">Next topic</a>
19+
</li>
20+
{%- endif %}
21+
</ul>
22+
</li>
23+
</ul>
1724
</div>

images/analytics-publisher/index.html

+53-56
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,54 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html lang="en">
3-
4-
<head>
5-
<meta charset="utf-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7-
8-
<link rel="stylesheet" href="static/bootstrap-4.1.3.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO">
9-
<style>
10-
</style>
11-
<title>MyBinder.org Events Archive</title>
12-
</head>
13-
14-
<body>
15-
<div class='container' id='main-container'>
16-
<div class='jumbotron'>
17-
<h1 class='display-3'>MyBinder.org Events Archive</h1>
18-
<p class='lead'>
19-
Daily archive of analytics events emitted by MyBinder.org.
20-
<a href="https://mybinder-sre.readthedocs.io/en/latest/analytics/events-archive.html">Documentation</a>
21-
</p>
22-
<p>
23-
<a href='index.jsonl'>Machine readable index</a> also available.
24-
Ask questions about this dataset or show off cool stuff built with it at the
25-
the <a href="https://discourse.jupyter.org/">Jupyter Discourse Forum</a>.
26-
</p>
27-
<p class='font-weight-light'>
28-
Released under the <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0 license</a>.
29-
</p>
30-
</div>
31-
<table class='table'>
32-
<thead>
33-
<th>Date</th>
34-
<th>Filename</th>
35-
<th>Number of Events</th>
36-
</thead>
37-
{% for archive in archives %}
38-
<tr>
39-
<td>{{ archive.date }}</td>
40-
<td><a href="{{ archive.name }}">{{ archive.name }}</a></td>
41-
<td>{{ archive.count }}</td>
42-
</tr>
43-
{% endfor %}
44-
</table>
45-
46-
<br />
47-
<div id='footer' class='border-top row'>
48-
<div class='col-sm font-weight-light text-right pb-2 pt-2'>
49-
Generated by love with
50-
<a href='https://github.com/jupyterhub/mybinder.org-deploy/tree/HEAD/images/analytics-publisher'>
51-
these scripts
52-
</a> at {{ generated_time }}
53-
</p>
54-
</div>
55-
</body>
56-
57-
</html>
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport"
6+
content="width=device-width, initial-scale=1, shrink-to-fit=no">
7+
<link rel="stylesheet"
8+
href="static/bootstrap-4.1.3.min.css"
9+
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO">
10+
<style></style>
11+
<title>MyBinder.org Events Archive</title>
12+
</head>
13+
<body>
14+
<div class='container' id='main-container'>
15+
<div class='jumbotron'>
16+
<h1 class='display-3'>MyBinder.org Events Archive</h1>
17+
<p class='lead'>
18+
Daily archive of analytics events emitted by MyBinder.org.
19+
<a href="https://mybinder-sre.readthedocs.io/en/latest/analytics/events-archive.html">Documentation</a>
20+
</p>
21+
<p>
22+
<a href='index.jsonl'>Machine readable index</a> also available.
23+
Ask questions about this dataset or show off cool stuff built with it at the
24+
the <a href="https://discourse.jupyter.org/">Jupyter Discourse Forum</a>.
25+
</p>
26+
<p class='font-weight-light'>
27+
Released under the <a href="https://creativecommons.org/publicdomain/zero/1.0/">CC0 license</a>.
28+
</p>
29+
</div>
30+
<table class='table'>
31+
<thead>
32+
<th>Date</th>
33+
<th>Filename</th>
34+
<th>Number of Events</th>
35+
</thead>
36+
{% for archive in archives %}
37+
<tr>
38+
<td>{{ archive.date }}</td>
39+
<td>
40+
<a href="{{ archive.name }}">{{ archive.name }}</a>
41+
</td>
42+
<td>{{ archive.count }}</td>
43+
</tr>
44+
{% endfor %}
45+
</table>
46+
<br />
47+
<div id='footer' class='border-top row'>
48+
<div class='col-sm font-weight-light text-right pb-2 pt-2'>
49+
Generated by love with
50+
<a href='https://github.com/jupyterhub/mybinder.org-deploy/tree/HEAD/images/analytics-publisher'>these scripts</a> at {{ generated_time }}
51+
</p>
52+
</div>
53+
</body>
54+
</html>
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
11
{% extends "templates/login.html" %}
2-
32
{% block header_buttons %}
4-
{% block login_widget %}
5-
{% endblock %}
6-
<span class="flex-spacer"></span>
7-
{{super()}}
3+
{% block login_widget %}
4+
{% endblock login_widget %}
5+
<span class="flex-spacer"></span>
6+
{{ super() }}
87
{% endblock header_buttons %}
9-
108
{% block site %}
11-
<div id="ipython-main-app" class="container">
12-
<h1>Binder inaccessible</h1>
13-
<h2>
14-
You can get a new Binder for this repo by clicking <a href="{{binder_url}}">here</a>.
15-
</h2>
16-
<p>
17-
The shareable URL for this repo is: <tt>{{binder_url}}</tt>
18-
</p>
19-
20-
<h4>Is this a Binder that you created?</h4>
21-
<p>
22-
If so, your authentication cookie for this Binder has been deleted or expired.
23-
You can launch a new Binder for this repo by clicking <a href="{{binder_url}}">here</a>.
24-
</p>
25-
26-
<h4>Did someone give you this Binder link?</h4>
27-
<p>
28-
If so, the link is outdated or incorrect.
29-
Recheck the link for typos or ask the person who gave you the link for an updated link.
30-
A shareable Binder link should look like <tt>{{binder_url}}</tt>.
31-
</div>
9+
<div id="ipython-main-app" class="container">
10+
<h1>Binder inaccessible</h1>
11+
<h2>
12+
You can get a new Binder for this repo by clicking <a href="{{ binder_url }}">here</a>.
13+
</h2>
14+
<p>
15+
The shareable URL for this repo is: <tt>{{ binder_url }}</tt>
16+
</p>
17+
<h4>Is this a Binder that you created?</h4>
18+
<p>
19+
If so, your authentication cookie for this Binder has been deleted or expired.
20+
You can launch a new Binder for this repo by clicking <a href="{{ binder_url }}">here</a>.
21+
</p>
22+
<h4>Did someone give you this Binder link?</h4>
23+
<p>
24+
If so, the link is outdated or incorrect.
25+
Recheck the link for typos or ask the person who gave you the link for an updated link.
26+
A shareable Binder link should look like <tt>{{ binder_url }}</tt>.
27+
</p>
28+
</div>
3229
{% endblock site %}
+36-34
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
11
{% extends "templates/page.html" %}
2-
32
{% block header_buttons %}
4-
5-
{% block login_widget %}
6-
{% endblock %}
7-
8-
{% if jitsi_url %}
9-
<span>
10-
<a id="visit-repo-link" href="{{ jitsi_url }}" class="btn btn-default btn-sm navbar-btn" target="_blank"
11-
style="margin-right: 2px; margin-left: 4px;">Join this repo's Video Chat</a>
12-
</span>
13-
{% endif %}
14-
15-
{% if ref_url %}
16-
<span>
17-
<a id="visit-repo-link" href="{{ ref_url }}" class="btn btn-default btn-sm navbar-btn" target="_blank"
18-
style="margin-right: 2px; margin-left: 4px;">Visit repo</a>
19-
</span>
20-
{% endif %}
21-
22-
{% if persistent_binder_url %}
23-
<span>
24-
<button id="copy-binder-link" title="Copy binder link to clipboard" class="btn btn-default btn-sm navbar-btn"
25-
style="margin-right: 0; margin-left: 2px;"
26-
data-url="{{ persistent_binder_url }}" onclick="copy_link_into_clipboard(this);">
27-
Copy Binder link
28-
</button>
29-
</span>
30-
{% endif %}
31-
3+
{% block login_widget %}{% endblock %}
4+
{% if jitsi_url %}
5+
<span>
6+
<a id="visit-repo-link"
7+
href="{{ jitsi_url }}"
8+
class="btn btn-default btn-sm navbar-btn"
9+
target="_blank"
10+
style="margin-right: 2px;
11+
margin-left: 4px">Join this repo's Video Chat</a>
12+
</span>
13+
{% endif %}
14+
{% if ref_url %}
15+
<span>
16+
<a id="visit-repo-link"
17+
href="{{ ref_url }}"
18+
class="btn btn-default btn-sm navbar-btn"
19+
target="_blank"
20+
style="margin-right: 2px;
21+
margin-left: 4px">Visit repo</a>
22+
</span>
23+
{% endif %}
24+
{% if persistent_binder_url %}
25+
<span>
26+
<button id="copy-binder-link"
27+
title="Copy binder link to clipboard"
28+
class="btn btn-default btn-sm navbar-btn"
29+
style="margin-right: 0;
30+
margin-left: 2px"
31+
data-url="{{ persistent_binder_url }}"
32+
onclick="copy_link_into_clipboard(this);">Copy Binder link</button>
33+
</span>
34+
{% endif %}
3235
{% endblock header_buttons %}
33-
3436
{% block script %}
35-
{% if persistent_binder_url %}
36-
<script type='text/javascript'>
37+
{% if persistent_binder_url %}
38+
<script type='text/javascript'>
3739
function copy_link_into_clipboard(b) {
3840
var $temp = $("<input>");
3941
$(b).parent().append($temp);
4042
$temp.val($(b).data('url')).select();
4143
document.execCommand("copy");
4244
$temp.remove();
4345
}
44-
</script>
45-
{% endif %}
46+
</script>
47+
{% endif %}
4648
{% endblock %}
+10-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
{% extends "templates/tree.html" %}
2-
32
{% block headercontainer %}
4-
<span class="flex-spacer"></span>
5-
{% endblock %}
6-
3+
<span class="flex-spacer"></span>
4+
{% endblock headercontainer %}
75
{% block header_buttons %}
8-
{{super()}}
9-
{% if shutdown_button %}
10-
<span id="shutdown_widget">
11-
<button id="shutdown" class="btn btn-sm navbar-btn"
12-
title="{% trans %}Stop the Jupyter server{% endtrans %}">
13-
{% trans %}Quit{% endtrans %}
14-
</button>
15-
</span>
16-
{% endif %}
6+
{{ super() }}
7+
{% if shutdown_button %}
8+
<span id="shutdown_widget">
9+
<button id="shutdown"
10+
class="btn btn-sm navbar-btn"
11+
title="{% trans %}Stop the Jupyter server{% endtrans %}">{% trans %}Quit{% endtrans %}</button>
12+
</span>
13+
{% endif %}
1714
{% endblock header_buttons %}

0 commit comments

Comments
 (0)