Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ef97906
init
StanFromIreland Jul 25, 2025
efd3269
Round 2
StanFromIreland Jul 25, 2025
5bf5310
Remove testing stuff
StanFromIreland Jul 25, 2025
aa30c9f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 25, 2025
eaf4773
Clean up
StanFromIreland Jul 25, 2025
14040d8
!fixup Cleanup
StanFromIreland Jul 25, 2025
d6640d5
refactoring
StanFromIreland Jul 25, 2025
f260ff5
Little fixes
StanFromIreland Jul 25, 2025
28b557a
Fix on mobile
StanFromIreland Jul 25, 2025
f4489ed
Fixes
StanFromIreland Jul 25, 2025
12a9457
Fix metadata generation and add progress bar
StanFromIreland Jul 26, 2025
1616734
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 26, 2025
737b24d
Improve language details page
StanFromIreland Jul 26, 2025
3cd64c9
Fix json gen and minor improvements
StanFromIreland Jul 26, 2025
924fcce
Grammar
StanFromIreland Jul 26, 2025
daa0233
Decrease radius by one pixel
StanFromIreland Jul 26, 2025
116f634
Concede
StanFromIreland Jul 28, 2025
d8a16cc
Add shadow
StanFromIreland Jul 29, 2025
08ff437
Fix card link
StanFromIreland Jul 29, 2025
da07650
(Hopefully final) Review
StanFromIreland Jul 30, 2025
a3f8f17
Some changes
StanFromIreland Aug 5, 2025
c311d93
Strip everything
StanFromIreland Aug 5, 2025
133668a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 5, 2025
994c330
Fixup
StanFromIreland Aug 5, 2025
d44ef5e
HTML structure
AA-Turner Aug 6, 2025
65370ec
Update templates/index.html.jinja
AA-Turner Aug 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
- run: sudo apt-get install -y gettext
- run: pip install -r requirements.txt
- run: uv run generate.py # generates index.html and index.json
- run: mkdir -p build && cp index.* style.css build
- name: Deploy 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/github-pages-deploy-action@v4
Expand Down Expand Up @@ -55,8 +54,8 @@ jobs:
if: github.event_name == 'pull_request'
run: |
curl -Lo index.html-public https://github.com/python-docs-translations/dashboard/raw/refs/heads/gh-pages/index.html
diff --color=always -u index.html-public index.html || :
cat index.html
diff --color=always -u index.html-public build/index.html || :
cat build/index.html
- run: uv run generate_metadata.py # generates metadata.html
- run: cp metadata.html warnings* build
- name: Deploy metadata view 🚀
Expand Down
34 changes: 27 additions & 7 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pathlib import Path

from git import Repo
from jinja2 import Template
from jinja2 import Environment, FileSystemLoader
from urllib3 import PoolManager

import build_status
Expand Down Expand Up @@ -93,16 +93,36 @@ class LanguageProjectData:
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
logging.info(f'starting at {generation_time}')
template = Template(Path('template.html.jinja').read_text())
Path('build').mkdir(parents=True, exist_ok=True)

output = template.render(
completion_progress=(completion_progress := list(get_completion_progress())),
completion_progress = list(get_completion_progress())
counts = get_counts(Path('clones', 'cpython', 'Doc', 'build', 'gettext'))

env = Environment(loader=FileSystemLoader('templates'))
index = env.get_template('index.html.jinja').render(
completion_progress=completion_progress,
generation_time=generation_time,
duration=(datetime.now(timezone.utc) - generation_time).seconds,
counts=counts,
)

chart = env.get_template('chart.html.jinja').render(
completion_progress=completion_progress,
generation_time=generation_time,
duration=(datetime.now(timezone.utc) - generation_time).seconds,
counts=get_counts(Path('clones', 'cpython', 'Doc', 'build', 'gettext')),
counts=counts,
)

Path('index.html').write_text(output)
Path('index.json').write_text(
lang_template = env.get_template('language.html.jinja')
for project in completion_progress:
code = project.language.code
html = lang_template.render(project=project)
Path(f'build/{code}.html').write_text(html)

Path('build/style.css').write_bytes(Path('src/style.css').read_bytes())
Path('build/logo.png').write_bytes(Path('src/logo.png').read_bytes())
Path('build/index.html').write_text(index)
Path('build/chart.html').write_text(chart)
Path('build/index.json').write_text(
json.dumps(completion_progress, indent=2, default=asdict)
)
12 changes: 6 additions & 6 deletions generate_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import dacite
from git import Repo
from jinja2 import Template
from jinja2 import Environment, FileSystemLoader
from urllib3 import request

import build_warnings
Expand Down Expand Up @@ -55,20 +55,20 @@ def get_language_repo_and_completion(
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
logging.info(f'starting at {generation_time}')
template = Template(Path('metadata.html.jinja').read_text())
if (index_path := Path('index.json')).exists():
index_json = loads(Path('index.json').read_text())
env = Environment(loader=FileSystemLoader('templates'))
if (index_path := Path('build/index.json')).exists():
index_json = loads(Path('build/index.json').read_text())
else:
index_json = request('GET', argv[1]).json()

completion_progress = [
dacite.from_dict(LanguageProjectData, project) for project in index_json
]

output = template.render(
output = env.get_template('metadata.html.jinja').render(
metadata=zip(completion_progress, get_projects_metadata(completion_progress)),
generation_time=generation_time,
duration=(datetime.now(timezone.utc) - generation_time).seconds,
)

Path('metadata.html').write_text(output)
Path('build/metadata.html').write_text(output)
Binary file added src/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 82 additions & 2 deletions style.css → src/style.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,86 @@
/* GLOBAL STYLES
-------------------------------------------------- */
/* Padding below the footer and lighter body text */

body {
font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif;
padding-top: 4.5rem;
padding-left: 1rem;
padding-right: 1rem;
padding-bottom: 3rem;
color: #5a5a5a;
background-color: rgb(245, 245, 245);
overflow-x: hidden; /* Risky, this need testing but I find scroll bar annoying */
}

a {
color: #0d0d0d;
}

a:hover {
color: #1595fe;
}

/* NAVAR
* ----------------------------------------*/

.navbar {
background-color: rgb(245, 245, 245);
border-bottom: 0.25px solid #999;
}

.navbar li {
transition: 0.3s background-color;
text-align: center;
background-color: transparent;
padding: 0rem 1rem;
text-decoration: none;
border-radius: 0.3rem;
}

.navbar li:hover {
background-color: #d0cccd;
}

.navbar li .nav-link {
color: #0d0d0d;
}

/* Cards and card columns
----------------------------- */

.row > [class^="col-"] {
display: flex;
}

.card {
flex: 1;
}

.card:hover {
background: linear-gradient(90deg, #cc9add 8.06%, #ebad98 106.93%);
text-decoration: none;
transform: scale(1.05);
transition: all 0.3s ease-in-out;
}

.card:hover .card-title,
.card:hover .card-subtitle,
.card:hover .card-text {
color: white;
}

.card:hover .card-link {
color: rgb(231, 231, 231);
}

@media (min-width: 768px) {
.card {
flex-basis: calc(33.33% - 30px);
}
}

/* -------------------------- OLD STUFF ------------------------------------ */

table {
border-collapse: collapse;
}
Expand All @@ -11,7 +91,7 @@ th, td {
white-space: nowrap;
}
th {
background-color: #f4f4f4;
background-color: #d6d6d6;
}
hr {
color: #f4f4f4;
Expand Down
73 changes: 73 additions & 0 deletions templates/base.html.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">

<title>Python Docs Translation Dashboard</title>

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.2.0/css/bootstrap.min.css" rel="stylesheet">
<link href="style.css" rel="stylesheet">
</head>

<body>
<header>
<nav class="navbar navbar-expand-md fixed-top">

<div class="navbar-brand">
<a href="./" style="all: unset; cursor: pointer;">
<img src="logo.png" style="height: 2rem;" alt="">
<span style="font-size: 1.25rem; font-weight: bold;">Translation Dashboard</span>
</a>
</div>

<div class="navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>

<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="chart.html">Chart</a>
</li>
<li class="nav-item">
<a class="nav-link" href="metadata.html">Metadata</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://devguide.python.org/documentation/translations/translating/">Devguide ❯ Translating</a>
</li>
</ul>
</div>
</nav>
</header>

<main role="main">
{% block main %}
{% endblock %}
</main>

</body>

<script>
function padnavbar() {
const navbar = document.querySelector('.navbar.fixed-top');
if (navbar) {
document.body.style.paddingTop = (navbar.offsetHeight + 10) + 'px';
}
}
window.addEventListener('load', padnavbar);
window.addEventListener('resize', padnavbar);
</script>

<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>

</html>
34 changes: 5 additions & 29 deletions template.html.jinja → templates/chart.html.jinja
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
<html lang="en">
<head>
<title>Python Docs Translation Dashboard</title>
<link rel="stylesheet" href="style.css">
<meta charset="UTF-8">
<meta name="description" content="Python Docs Translation Dashboard">
<base target="_blank">
</head>
<body>
<h1>Python Docs Translation Dashboard</h1>
<nav class="switchpages">
main | <a href="metadata.html" target="_self">meta</a>
</nav>
{% extends "base.html.jinja" %}

{% block main %}
<table>
<thead>
<tr>
<th>language</th>
<th>switcher</th>
<th>translators</th>
<th>completion*</th>
</tr>
</thead>
Expand All @@ -30,18 +18,6 @@ main | <a href="metadata.html" target="_self">meta</a>
{{ project.language.name }} ({{ project.language.code }})
{% endif %}
</td>
<td data-label="build">
{% if project.in_switcher %}
<a href="https://docs.python.org/{{ project.language.code }}/">✓</a>
{% elif project.built %}
<a href="https://docs.python.org/{{ project.language.code }}/">✗</a>
{% endif %}
</td>
<td data-label="translators">
{% if project.translators.link %}<a href="{{ project.translators.link }}">{% endif %}
{{ project.translators.number }}
{% if project.translators.link %}</a>{% endif %}
</td>
<td data-label="completion">
<div class="progress-bar"
style="width: {{ project.completion }}%;{% if project.change %}background: linear-gradient(to left, #94cf96 {{ project.change * 100 / project.completion }}%, #4caf50 {{ project.change * 100 / project.completion }}%);{% else %}background-color: #4caf50;{% endif %}"
Expand All @@ -66,7 +42,7 @@ For more information about translations, see the <a href="https://devguide.pytho
<p>You can download the data on this page in <a href="https://github.com/python-docs-translations/dashboard/blob/gh-pages/index.json">JSON format</a>.</p>
<p>You can also find the scripts used to generate these pages <a href="https://github.com/python-docs-translations/dashboard">here</a>.</p>
<p>Last updated at {{ generation_time.strftime('%A, %-d %B %Y, %-H:%M:%S %Z') }} (in {{ duration // 60 }}:{{ "{:02}".format(duration % 60) }} minutes).</p>
</body>

<script>
function updateProgressBarVisibility() {
document.querySelectorAll('.progress-bar').forEach(progressBar => {
Expand All @@ -85,4 +61,4 @@ For more information about translations, see the <a href="https://devguide.pytho

window.addEventListener('resize', updateProgressBarVisibility);
</script>
</html>
{% endblock %}
19 changes: 19 additions & 0 deletions templates/index.html.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends "base.html.jinja" %}

{% block main %}
<div>
<div class="row">
{% for project in completion_progress | sort(attribute='completion,translators.number') | reverse %}
<div class="col-12 col-sm-6 col-md-4 d-flex">
<a href="{{ project.language.code }}.html" class="card mb-3 w-100">
<div class="card-body">
<h5 class="card-title">{{ project.language.name }} ({{ project.language.code }})</h5>
<h6 class="card-subtitle mb-2 text-muted">Completion: {{ '{:.2f}%'.format(project.completion) }}</h6>
<h6 class="card-subtitle mb-2 text-muted">Translators: {{ project.translators.number }}</h6>
</div>
</a>
</div>
{% endfor %}
</div>
</div>
{% endblock %}
9 changes: 9 additions & 0 deletions templates/language.html.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends "base.html.jinja" %}

{% block main %}
{% if project.built %}
<h1><a href="https://docs.python.org/{{ project.language.code }}/3">{{ project.language.name }}</a></h1>
{% else %}
<h1>{{ project.language.name }}</h1>
{% endif %}
{% endblock %}
18 changes: 4 additions & 14 deletions metadata.html.jinja → templates/metadata.html.jinja
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
<html lang="en">
<head>
<title>Python Docs Translation Dashboard</title>
<link rel="stylesheet" href="style.css">
<meta charset="UTF-8">
<base target="_blank">
</head>
<body>
<h1>Python Docs Translation Dashboard</h1>
<nav class="switchpages">
<a href="index.html" target="_self">main</a> | meta
</nav>
{% extends "base.html.jinja" %}

{% block main %}
<table>
<thead>
<tr>
Expand Down Expand Up @@ -38,5 +29,4 @@
</table>
<p>* number of Sphinx build process warnings</p>
<p>Last updated at {{ generation_time.strftime('%A, %-d %B %Y, %-H:%M:%S %Z') }} (in {{ duration // 60 }}:{{ "{:02}".format(duration % 60) }} minutes).</p>
</body>
</html>
{% endblock %}
Loading