Skip to content

Commit be7fc31

Browse files
committed
Move template to a separate file
1 parent a2b2b63 commit be7fc31

File tree

2 files changed

+54
-58
lines changed

2 files changed

+54
-58
lines changed

generate.py

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -61,66 +61,10 @@
6161
)
6262
print(completion_progress[-1])
6363

64-
template = Template(
65-
"""
66-
<html lang="en">
67-
<head>
68-
<title>Python Docs Translation Dashboard</title>
69-
<link rel="stylesheet" href="style.css">
70-
</head>
71-
<body>
72-
<h1>Python Docs Translation Dashboard</h1>
73-
<table>
74-
<thead>
75-
<tr>
76-
<th>language</th>
77-
<th>build</th>
78-
<th><a href="https://plausible.io/data-policy#how-we-count-unique-users-without-cookies">visitors<a/></th>
79-
<th>translators</th>
80-
<th>completion</th>
81-
</tr>
82-
</thead>
83-
<tbody>
84-
{% for language, repo, completion, translators, visitors, build, in_switcher in completion_progress | sort(attribute='2,3') | reverse %}
85-
<tr>
86-
{% if repo %}
87-
<td data-label="language">
88-
<a href="https://github.com/{{ repo }}" target="_blank">
89-
{{ language }}
90-
</a>
91-
</td>
92-
{% else %}
93-
<td data-label="language">{{ language }}</td>
94-
{% endif %}
95-
<td data-label="build">
96-
{% if build %}
97-
<a href="https://docs.python.org/{{ language }}/" target="_blank">✓{% if in_switcher %} in switcher{% endif %}</a>
98-
{% else %}
99-
100-
{% endif %}
101-
</td>
102-
<td data-label="visitors">
103-
<a href="https://plausible.io/docs.python.org?filters=((contains,page,(/{{ language }}/)))" target="_blank">
104-
{{ '{:,}'.format(visitors) }}
105-
</a>
106-
</td>
107-
<td data-label="translators">{{ '{:,}'.format(translators) }}</td>
108-
<td data-label="completion">
109-
<div class="progress-bar" style="width: {{ completion | round(2) }}%;">{{ completion | round(2) }}%</div>
110-
</td>
111-
</tr>
112-
{% endfor %}
113-
</tbody>
114-
</table>
115-
<p>Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.</p>
116-
</body>
117-
</html>
118-
"""
119-
)
64+
template = Template(Path('template.html').read_text())
12065

12166
output = template.render(
12267
completion_progress=completion_progress, generation_time=generation_time
12368
)
12469

125-
with open('index.html', 'w') as file:
126-
file.write(output)
70+
Path('index.html').write_text(output)

template.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<html lang="en">
2+
<head>
3+
<title>Python Docs Translation Dashboard</title>
4+
<link rel="stylesheet" href="style.css">
5+
</head>
6+
<body>
7+
<h1>Python Docs Translation Dashboard</h1>
8+
<table>
9+
<thead>
10+
<tr>
11+
<th>language</th>
12+
<th>build</th>
13+
<th><a href="https://plausible.io/data-policy#how-we-count-unique-users-without-cookies">visitors</a></th>
14+
<th>translators</th>
15+
<th>completion</th>
16+
</tr>
17+
</thead>
18+
<tbody>
19+
{% for language, repo, completion, translators, visitors, build, in_switcher in completion_progress | sort(attribute='2,3') | reverse %}
20+
<tr>
21+
{% if repo %}
22+
<td data-label="language">
23+
<a href="https://github.com/{{ repo }}" target="_blank">
24+
{{ language }}
25+
</a>
26+
</td>
27+
{% else %}
28+
<td data-label="language">{{ language }}</td>
29+
{% endif %}
30+
<td data-label="build">
31+
{% if build %}
32+
<a href="https://docs.python.org/{{ language }}/" target="_blank">✓{% if in_switcher %} in switcher{% endif %}</a>
33+
{% else %}
34+
35+
{% endif %}
36+
</td>
37+
<td data-label="visitors">
38+
<a href="https://plausible.io/docs.python.org?filters=((contains,page,(/{{ language }}/)))" target="_blank">
39+
{{ '{:,}'.format(visitors) }}
40+
</a>
41+
</td>
42+
<td data-label="translators">{{ translators }}</td>
43+
<td data-label="completion">
44+
<div class="progress-bar" style="width: {{ completion | round(2) }}%;">{{ completion | round(2) }}%</div>
45+
</td>
46+
</tr>
47+
{% endfor %}
48+
</tbody>
49+
</table>
50+
<p>Last updated at {{ generation_time.strftime('%A, %d %B %Y, %X %Z') }}.</p>
51+
</body>
52+
</html>

0 commit comments

Comments
 (0)