diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index f0bf3e5a3..5eda43558 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -21,6 +21,7 @@ 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: uv run generate_related_projects.py # generates related.html - name: Deploy 🚀 if: github.event_name != 'pull_request' uses: JamesIves/github-pages-deploy-action@v4 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cdf264e4a..e6bd22ccc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,5 +46,11 @@ repos: - id: deptry args: ["--per-rule-ignores", "DEP002=python-docs-theme", "--package-module-name-map", "gitpython=git,sphinx-lint=sphinxlint"] + - repo: https://github.com/oxipng/oxipng # PNG optimizer + rev: v9.1.5 + hooks: + - id: oxipng + args: [ --strip=safe, --alpha ] + ci: autoupdate_schedule: quarterly diff --git a/generate.py b/generate.py index 2a8292b56..c2014d49c 100644 --- a/generate.py +++ b/generate.py @@ -7,6 +7,7 @@ from dataclasses import dataclass, asdict from datetime import datetime, timezone from pathlib import Path +from shutil import copyfile from git import Repo from jinja2 import Environment, FileSystemLoader @@ -104,9 +105,8 @@ class LanguageProjectData: generation_time=generation_time, duration=(datetime.now(timezone.utc) - generation_time).seconds, ) - - Path('build/style.css').write_bytes(Path('src/style.css').read_bytes()) - Path('build/logo.png').write_bytes(Path('src/logo.png').read_bytes()) + copyfile('src/style.css', 'build/style.css') + copyfile('src/logo.png', 'build/logo.png') Path('build/index.html').write_text(index) Path('build/index.json').write_text( diff --git a/generate_related_projects.py b/generate_related_projects.py new file mode 100644 index 000000000..74b2b2d80 --- /dev/null +++ b/generate_related_projects.py @@ -0,0 +1,21 @@ +import tomllib +from pathlib import Path +from shutil import copyfile, copytree + +from jinja2 import Environment, FileSystemLoader + + +if __name__ == '__main__': + Path('build').mkdir(parents=True, exist_ok=True) + + with open('related_projects.toml', 'rb') as f: + data = tomllib.load(f) + projects = data['projects'] + + env = Environment(loader=FileSystemLoader('templates')) + related = env.get_template('related.html.jinja').render(projects=projects) + + Path('build/related.html').write_text(related) + copyfile('src/style.css', 'build/style.css') + copyfile('src/logo.png', 'build/logo.png') + copytree('src/images', 'build/images', dirs_exist_ok=True) diff --git a/related_projects.toml b/related_projects.toml new file mode 100644 index 000000000..dcb50abf4 --- /dev/null +++ b/related_projects.toml @@ -0,0 +1,35 @@ +[[projects]] +name = "packaging.python.org" +description = "Python Packaging User Guide translation" +logo = "images/pypa_logo.png" +url = "https://hosted.weblate.org/projects/pypa/packaging-python-org/#information" + +[[projects]] +name = "PyPI (Warehouse)" +description = "Python Package Index translation" +logo = "images/pypi_logo.svg" +url = "https://hosted.weblate.org/projects/pypa/warehouse/#information" + +[[projects]] +name = "Scientific Python" +description = "Scientific Python ecosystem translations" +logo = "images/scientific-python_logo.svg" +url = "https://scientific-python-translations.github.io/status/" + +[[projects]] +name = "micro:bit" +description = "micro:bit translation programme" +logo = "images/microbit_logo.svg" +url = "https://microbit.org/translate/" + +[[projects]] +name = "Django" +description = "Localizing Django" +logo = "images/django_logo.svg" +url = "https://docs.djangoproject.com/en/dev/internals/contributing/localizing/" + +[[projects]] +name = "Sphinx" +description = "Sphinx documentation generator translation" +logo = "images/sphinx_logo.png" +url = "https://www.sphinx-doc.org/en/master/usage/advanced/intl.html#contributing-to-sphinx-reference-translation" diff --git a/src/images/django_logo.svg b/src/images/django_logo.svg new file mode 100644 index 000000000..5aec8805e --- /dev/null +++ b/src/images/django_logo.svg @@ -0,0 +1,38 @@ + + + + +]> + diff --git a/src/images/microbit_logo.svg b/src/images/microbit_logo.svg new file mode 100644 index 000000000..349080bc0 --- /dev/null +++ b/src/images/microbit_logo.svg @@ -0,0 +1,15 @@ + diff --git a/src/images/pypa_logo.png b/src/images/pypa_logo.png new file mode 100644 index 000000000..79331c100 Binary files /dev/null and b/src/images/pypa_logo.png differ diff --git a/src/images/pypi_logo.svg b/src/images/pypi_logo.svg new file mode 100644 index 000000000..ffdf09b5c --- /dev/null +++ b/src/images/pypi_logo.svg @@ -0,0 +1 @@ + diff --git a/src/images/scientific-python_logo.svg b/src/images/scientific-python_logo.svg new file mode 100644 index 000000000..aed685014 --- /dev/null +++ b/src/images/scientific-python_logo.svg @@ -0,0 +1,132 @@ + + diff --git a/src/images/sphinx_logo.png b/src/images/sphinx_logo.png new file mode 100644 index 000000000..3a2d94a6d Binary files /dev/null and b/src/images/sphinx_logo.png differ diff --git a/src/logo.png b/src/logo.png index cc4111478..6d1150eab 100644 Binary files a/src/logo.png and b/src/logo.png differ diff --git a/src/style.css b/src/style.css index f374c6dff..f862bceff 100644 --- a/src/style.css +++ b/src/style.css @@ -40,6 +40,9 @@ body { .navbar-brand a { text-decoration: none; outline-offset: 8px; + font-size: 1.25rem; + font-weight: 700; + color: #4a4a4a; } .nav-link svg { @@ -160,3 +163,35 @@ td[data-label="warnings"], td[data-label="lint"] { text-align: left; } } + +/* -------------------------- Related Projects ------------------------------- */ + +.related-card { + display: flex; + flex-direction: column; +} + +.related-card .card-body { + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; +} + +.related-logo { + width: 85px; + height: 85px; + object-fit: contain; +} + +.btn-translate { + background-color: #1595fe; + border-color: #1595fe; + padding: 0.5rem 2rem; + font-weight: 500; +} + +.btn-translate:hover { + background-color: #0d7ad4; + border-color: #0d7ad4; +} diff --git a/templates/base.html.jinja b/templates/base.html.jinja index 7f271c110..028dd36ca 100644 --- a/templates/base.html.jinja +++ b/templates/base.html.jinja @@ -19,7 +19,7 @@
@@ -49,6 +49,14 @@ Translating +