Skip to content

Commit ec7d409

Browse files
committed
Add djhtml to pre-commit hooks and apply fixes
1 parent 5a25bf4 commit ec7d409

File tree

5 files changed

+145
-139
lines changed

5 files changed

+145
-139
lines changed

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,9 @@ repos:
5656
hooks:
5757
- id: prettier
5858
exclude_types: [html, css, javascript, json, scss]
59+
60+
- repo: https://github.com/rtts/djhtml
61+
rev: "3.0.7"
62+
hooks:
63+
- id: djhtml
64+
files: .*/templates/.*\.html$

trac-env/templates/custom_ticket.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ <h2>Please read this first:</h2>
1616
Don't use the ticket system for
1717
<a href="https://docs.djangoproject.com/en/dev/faq/help/">help with
1818
support questions</a>. <a href="https://docs.djangoproject.com/en/dev/faq/">
19-
check the FAQ</a> for common issues.
19+
check the FAQ</a> for common issues.
2020
</li>
2121
<li>
2222
Use <a href="https://www.transifex.com/projects/p/django/">Transifex</a> for

trac-env/templates/django_theme.html

Lines changed: 110 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,142 @@
11
<!DOCTYPE html>
22
<html lang="${trac_lang}"> {# jinjacheck: "attribute lang" OK #}
33

4-
# macro navigation(category)
5-
<div id="${category}" class="nav">
6-
# if chrome.nav[category]:
7-
<ul>{%
8-
for item in chrome.nav[category]
9-
%}<li ${{'class': {
10-
'first': loop.first, 'last': loop.last, 'active': item.active
11-
}}|htmlattr}>${item.label}</li>{%
12-
endfor
4+
# macro navigation(category)
5+
<div id="${category}" class="nav">
6+
# if chrome.nav[category]:
7+
<ul>{%
8+
for item in chrome.nav[category]
9+
%}<li ${{'class': {
10+
'first': loop.first, 'last': loop.last, 'active': item.active
11+
}}|htmlattr}>${item.label}</li>{%
12+
endfor
1313
%}</ul>
14-
# endif
15-
</div>
16-
# endmacro
17-
18-
# macro main()
19-
<div role="main">
20-
<div id="metanav" class="nav">
21-
<ul>
22-
# if req.is_authenticated:
14+
# endif
15+
</div>
16+
# endmacro
17+
18+
# macro main()
19+
<div role="main">
20+
<div id="metanav" class="nav">
21+
<ul>
22+
# if req.is_authenticated:
2323
<li>Logged in as ${req.authname}</li>
2424
<li>
2525
<form action="/github/logout" method="post" id="logout" class="trac-logout">
2626
<button type="submit">Logout</button>
2727
<input type="hidden" name="__FORM_TOKEN" value="${req.form_token}">
2828
</form>
2929
</li>
30-
# else
30+
# else
3131
<li><a href="/login?referer=${req.path_info|urlencode()}">Login</a></li>
32-
# endif
33-
<li><a href="${req.href.prefs()}">Preferences</a></li>
34-
</ul>
35-
</div>
36-
${navigation('mainnav')}
37-
<div id="main" ${{'class': {
38-
'uisymbols': req.session.get('ui.use_symbols'),
39-
'uinohelp': req.session.get('ui.hide_help'),
40-
}}|htmlattr}>
41-
42-
# if req.authname != 'anonymous' and not req.session.email:
43-
<div class="system-message" id="warning">
44-
Add an email address on the <a href="${req.href.prefs()}">Preferences</a>
45-
page to receive updates on tickets you own, have created, or been CCed on.
32+
# endif
33+
<li><a href="${req.href.prefs()}">Preferences</a></li>
34+
</ul>
4635
</div>
47-
# endif
36+
${navigation('mainnav')}
37+
<div id="main" ${{'class': {
38+
'uisymbols': req.session.get('ui.use_symbols'),
39+
'uinohelp': req.session.get('ui.hide_help'),
40+
}}|htmlattr}>
41+
42+
# if req.authname != 'anonymous' and not req.session.email:
43+
<div class="system-message" id="warning">
44+
Add an email address on the <a href="${req.href.prefs()}">Preferences</a>
45+
page to receive updates on tickets you own, have created, or been CCed on.
46+
</div>
47+
# endif
4848

49-
# if resourcepath_template:
50-
# include resourcepath_template ignore missing
51-
# endif
49+
# if resourcepath_template:
50+
# include resourcepath_template ignore missing
51+
# endif
5252

53-
# if chrome.ctxtnav:
54-
<div id="ctxtnav" class="nav">
55-
<h2>${_("Context Navigation")}</h2>
56-
<ul>
57-
# for elm in chrome.ctxtnav:
58-
<li ${{'class': {'first': loop.first, 'last': loop.last}}|htmlattr}>${
59-
elm}</li>
60-
# endfor
61-
</ul>
62-
<hr />
63-
</div>
64-
# endif
53+
# if chrome.ctxtnav:
54+
<div id="ctxtnav" class="nav">
55+
<h2>${_("Context Navigation")}</h2>
56+
<ul>
57+
# for elm in chrome.ctxtnav:
58+
<li ${{'class': {'first': loop.first, 'last': loop.last}}|htmlattr}>${
59+
elm}</li>
60+
# endfor
61+
</ul>
62+
<hr />
63+
</div>
64+
# endif
6565

66-
${jmacros.warnings(chrome.warnings)}
66+
${jmacros.warnings(chrome.warnings)}
6767

68-
${jmacros.notices(chrome.notices)}
68+
${jmacros.notices(chrome.notices)}
6969

70-
# block content
71-
# endblock content
70+
# block content
71+
# endblock content
72+
</div>
73+
<a href="#top" class="backtotop"><i class="icon icon-chevron-up"></i> Back to Top</a>
7274
</div>
73-
<a href="#top" class="backtotop"><i class="icon icon-chevron-up"></i> Back to Top</a>
74-
</div>
75-
# endmacro
75+
# endmacro
7676

77-
<head>
78-
# block head
79-
# endblock head
80-
</head>
77+
<head>
78+
# block head
79+
# endblock head
80+
</head>
8181

8282
{# we don't use the modernizer js lib anymore, but the css still uses some classes from it #}
83-
<body class="mdzr-boxshadow mdzr-svg">
84-
# block body
83+
<body class="mdzr-boxshadow mdzr-svg">
84+
# block body
8585

86-
# include 'site_header.html' ignore missing
86+
# include 'site_header.html' ignore missing
8787

88-
<div id="banner">
89-
<div class="copy-banner">
90-
<div class="container">
91-
<h1>Issues</h1>
88+
<div id="banner">
89+
<div class="copy-banner">
90+
<div class="container">
91+
<h1>Issues</h1>
92+
</div>
9293
</div>
93-
</div>
9494

95-
# if req.path_info == '/':
96-
<div class="container sidebar-right">
97-
${main()}
98-
<div role="complementary">
99-
<form action="/search/" id="sidebar_search" class="search form-input" role="search">
100-
<label class="visuallyhidden" for="q">Search:</label>
101-
<input id="id_sidebar_search_q" name="q" placeholder="Search Trac" type="search" />
102-
103-
<button type="submit">
104-
<i class="icon icon-search"></i>
105-
<span class="visuallyhidden">Search</span>
106-
</button>
107-
</form>
108-
<h3>Useful links</h3>
109-
<dl>
110-
<dt><a href="https://docs.djangoproject.com/en/dev/internals/contributing/">Contribution Guide</a></dt>
111-
<dd>You'd like to contribute to Django but don't know how? This document will explain our process and how to get involved.</dd>
112-
113-
<dt><a href="/query?status=!closed&amp;easy=1">"Easy Pickings"</a></dt>
114-
<dd>First time contributor and you're looking for something manageable? The "easy pickings" list is a good start.</dd>
115-
116-
<dt><a href="https://docs.djangoproject.com/en/dev/internals/security/">Security Policy</a></dt>
117-
<dd>You found a security issue in Django? You'd like to know more about our security policy? It's all in there.</dd>
118-
119-
<dt><a href="https://github.com/django/django">GitHub</a></dt>
120-
<dd>Want to peek under the hood and see Django's source code, file or help review a pull request? It's all on GitHub.</dd>
121-
122-
<dt><a href="https://dashboard.djangoproject.com/">Django Dashboard</a></dt>
123-
<dd>Confused about Trac's filtering system? This dashboard shows easy-to-read metrics and has links to pre-set filters to get you started.</dd>
124-
125-
<dt><a href="irc://irc.freenode.net/django-dev">#django-dev IRC channel</a></dt>
126-
<dd>Questions about a ticket? Stuck on how to write a unit test for your pull request? Come chat with us!</dd>
127-
</dl>
95+
# if req.path_info == '/':
96+
<div class="container sidebar-right">
97+
${main()}
98+
<div role="complementary">
99+
<form action="/search/" id="sidebar_search" class="search form-input" role="search">
100+
<label class="visuallyhidden" for="q">Search:</label>
101+
<input id="id_sidebar_search_q" name="q" placeholder="Search Trac" type="search" />
102+
103+
<button type="submit">
104+
<i class="icon icon-search"></i>
105+
<span class="visuallyhidden">Search</span>
106+
</button>
107+
</form>
108+
<h3>Useful links</h3>
109+
<dl>
110+
<dt><a href="https://docs.djangoproject.com/en/dev/internals/contributing/">Contribution Guide</a></dt>
111+
<dd>You'd like to contribute to Django but don't know how? This document will explain our process and how to get involved.</dd>
112+
113+
<dt><a href="/query?status=!closed&amp;easy=1">"Easy Pickings"</a></dt>
114+
<dd>First time contributor and you're looking for something manageable? The "easy pickings" list is a good start.</dd>
115+
116+
<dt><a href="https://docs.djangoproject.com/en/dev/internals/security/">Security Policy</a></dt>
117+
<dd>You found a security issue in Django? You'd like to know more about our security policy? It's all in there.</dd>
118+
119+
<dt><a href="https://github.com/django/django">GitHub</a></dt>
120+
<dd>Want to peek under the hood and see Django's source code, file or help review a pull request? It's all on GitHub.</dd>
121+
122+
<dt><a href="https://dashboard.djangoproject.com/">Django Dashboard</a></dt>
123+
<dd>Confused about Trac's filtering system? This dashboard shows easy-to-read metrics and has links to pre-set filters to get you started.</dd>
124+
125+
<dt><a href="irc://irc.freenode.net/django-dev">#django-dev IRC channel</a></dt>
126+
<dd>Questions about a ticket? Stuck on how to write a unit test for your pull request? Come chat with us!</dd>
127+
</dl>
128+
</div>
128129
</div>
129130
</div>
130-
</div>
131-
# else
132-
<div class="container full-width">
133-
${main()}
134-
</div>
135-
# endif
131+
# else
132+
<div class="container full-width">
133+
${main()}
134+
</div>
135+
# endif
136136

137-
# include 'site_footer.html' ignore missing
137+
# include 'site_footer.html' ignore missing
138138

139-
# endblock body
140-
</body>
139+
# endblock body
140+
</body>
141141

142142
</html>

trac-env/templates/plainlogin.html

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
# extends 'layout.html'
22

33
# block title
4-
Login ${ super() }
4+
Login ${ super() }
55
# endblock title
66

77
# block content
88
# if 'reserved' in req.args
9-
<div class="system-message">
10-
Sorry, but the username <strong>${req.args.reserved}</strong> is reserved on this website.
11-
Please log in with a different account.
12-
</div>
9+
<div class="system-message">
10+
Sorry, but the username <strong>${req.args.reserved}</strong> is reserved on this website.
11+
Please log in with a different account.
12+
</div>
1313
# endif
1414
<h1>Choose how you want to log in</h1>
1515

1616
<section class="login-github">
1717
<h2>Log in with your GitHub account</h2>
1818
<a href="/github/login">Log in with GitHub</a>
19-
<section>
19+
<section>
2020

21-
<section class="login-djangoproject">
22-
<h2>Log in with your DjangoProject account</h2>
23-
<form action="" method="post" class="plainlogin">
24-
${form.as_p()}
25-
<p>
26-
<button type="submit">Log in with DjangoProject</button>
27-
<input type="hidden" name="__FORM_TOKEN" value="${req.form_token}">{# Trac's CSRF protection #}
28-
<input type="hidden" name="referer" value="${referer|default('/')}">
29-
</p>
30-
</form>
31-
</section>
21+
<section class="login-djangoproject">
22+
<h2>Log in with your DjangoProject account</h2>
23+
<form action="" method="post" class="plainlogin">
24+
${form.as_p()}
25+
<p>
26+
<button type="submit">Log in with DjangoProject</button>
27+
<input type="hidden" name="__FORM_TOKEN" value="${req.form_token}">{# Trac's CSRF protection #}
28+
<input type="hidden" name="referer" value="${referer|default('/')}">
29+
</p>
30+
</form>
31+
</section>
3232

33-
<section class="login-managing">
34-
<h2>Account management</h2>
35-
<nav>
36-
<ul>
37-
<li><a href="https://www.djangoproject.com/accounts/register/">Create a new DjangoProject account</a></li>
38-
<li><a href="https://www.djangoproject.com/accounts/password_reset/">Reset your password</a></li>
39-
</ul>
40-
</nav>
41-
</section>
42-
# endblock content
33+
<section class="login-managing">
34+
<h2>Account management</h2>
35+
<nav>
36+
<ul>
37+
<li><a href="https://www.djangoproject.com/accounts/register/">Create a new DjangoProject account</a></li>
38+
<li><a href="https://www.djangoproject.com/accounts/password_reset/">Reset your password</a></li>
39+
</ul>
40+
</nav>
41+
</section>
42+
# endblock content

trac-env/templates/site_head.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
});
1313
</script>
1414
# if req.path_info.startswith('/ticket/'):
15-
<script type="text/javascript" src="${href.chrome('site/tickethacks.js')}"></script>
15+
<script type="text/javascript" src="${href.chrome('site/tickethacks.js')}"></script>
1616
# endif

0 commit comments

Comments
 (0)