From cf878441b91903f58cb43dc7577ece30a6fa913a Mon Sep 17 00:00:00 2001 From: Jannis Portmann Date: Sun, 9 Jul 2023 11:03:52 +0200 Subject: [PATCH 1/4] Package command as external app --- entrypoint.sh | 2 +- .../management/commands/getlocales.py | 52 ------------------- pflaenzli/pflaenzli_django/settings.py | 1 + requirements.txt | 1 + 4 files changed, 3 insertions(+), 53 deletions(-) delete mode 100644 pflaenzli/pflaenzli/management/commands/getlocales.py diff --git a/entrypoint.sh b/entrypoint.sh index dcff8f3..82e50ab 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,6 +1,6 @@ #!/bin/bash python manage.py migrate -python manage.py getlocales +python manage.py loco python manage.py makemessages -l en -l de python manage.py compilemessages -f python manage.py getplzindex diff --git a/pflaenzli/pflaenzli/management/commands/getlocales.py b/pflaenzli/pflaenzli/management/commands/getlocales.py deleted file mode 100644 index 5c0fc93..0000000 --- a/pflaenzli/pflaenzli/management/commands/getlocales.py +++ /dev/null @@ -1,52 +0,0 @@ -import os -import requests - -from django.core.management.base import BaseCommand -from django.utils.translation import trans_real -from django.apps import apps -from pflaenzli_django.settings import LOCO_API_KEY - -API_URL = ' https://localise.biz/api/export/locale' - - -class Command(BaseCommand): - help = 'Fetch translations from Loco (Localise.biz) and write them to message files' - - def handle(self, *args, **options): - errors = 0 - - if LOCO_API_KEY is None or LOCO_API_KEY == '': - self.stdout.write(self.style.ERROR('An API key is required')) - return - - app_config = apps.get_app_config('pflaenzli') - app_path = app_config.path - - for locale in trans_real.get_languages(): - url = f'{API_URL}/{locale}.po' - self.stdout.write(f'Getting translations for locale {self.style.SUCCESS(locale)}') - response = requests.get(url, auth=(LOCO_API_KEY, '')) - - if response.status_code == 200: - destination = f'{app_path}/locale/{locale}/LC_MESSAGES/django.po' - self.stdout.write(f'Saving to {destination}') - - os.makedirs(os.path.dirname(destination), exist_ok=True) - - with open(destination, 'wb') as f: - f.write(response.content) - - self.stdout.write(self.style.SUCCESS( - f'Locale {locale} successfully saved to {destination}\n')) - - else: - self.stdout.write(self.style.ERROR( - f'There was an error processing the request to {url}: {response.status_code}\n')) - errors += 1 - - if errors == len(trans_real.get_languages()): - self.stdout.write(self.style.ERROR('No locales could be downloaded.')) - elif errors > 1: - self.stdout.write(self.style.WARNING('There were errors getting some locales.')) - else: - self.stdout.write(self.style.SUCCESS('All translations fetched and written to message files.')) diff --git a/pflaenzli/pflaenzli_django/settings.py b/pflaenzli/pflaenzli_django/settings.py index 012c67c..f79baac 100644 --- a/pflaenzli/pflaenzli_django/settings.py +++ b/pflaenzli/pflaenzli_django/settings.py @@ -50,6 +50,7 @@ INSTALLED_APPS = [ "crispy_bootstrap5", "friendly_captcha", "django.contrib.sitemaps", + "djangoloco", ] MIDDLEWARE = [ diff --git a/requirements.txt b/requirements.txt index b8f6919..09a8ac7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ crispy-bootstrap5==0.7 Django==4.1.7 +djangoloco==1.0 django-bootstrap5==22.2 django-crispy-forms==2.0 django-jquery==3.1.0 -- 2.43.0 From 79f071f290952fd20750cbfe334775e5d3054f47 Mon Sep 17 00:00:00 2001 From: Jannis Portmann Date: Sun, 9 Jul 2023 14:59:41 +0200 Subject: [PATCH 2/4] Add custom fonts --- pflaenzli/pflaenzli/static/base.css | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pflaenzli/pflaenzli/static/base.css b/pflaenzli/pflaenzli/static/base.css index ca3d96e..28ccc90 100644 --- a/pflaenzli/pflaenzli/static/base.css +++ b/pflaenzli/pflaenzli/static/base.css @@ -1,3 +1,5 @@ +@import url('https://fonts.googleapis.com/css2?family=Aleo:wght@400;700&family=Lato:ital,wght@0,400;0,700;1,400;1,700&display=swap'); + :root { /* Primary */ --pfl-color: #4c6e4dff; @@ -20,6 +22,10 @@ --bs-heading-color: #000; --pfl-logo: url('/static/light.png'); --pfl-home-background: url('/static/home/home-light.webp'); + + --bs-body-font-family: 'Lato', sans-serif; + --pfl-heading-font-family: 'Aleo', serif; + } :root[data-bs-theme='dark'] { @@ -86,10 +92,19 @@ a { text-decoration: none; } +.btn, +.badge { + font-family: 'Lato', sans-serif; +} + .nav-tabs .nav-link { color: var(--pfl-primary-text) } +.navbar-brand { + font-family: var(--pfl-heading-font-family); +} + .pfl-logo { height: 2rem; width: 2rem; @@ -159,4 +174,13 @@ a { --bs-btn-hover-bg: var(--bg-pfl-orange); --bs-btn-hover-border-color: var(--bg-pfl-orange); --bs-btn-active-bg: var(--pfl-orange); +} + +h1, +h2, +h3, +h4, +h5 { + font-family: var(--pfl-heading-font-family); + font-weight: 500; } \ No newline at end of file -- 2.43.0 From c91b1ce8032083685b86b23a50e8b29d1edf5db7 Mon Sep 17 00:00:00 2001 From: Jannis Portmann Date: Sun, 9 Jul 2023 18:14:01 +0200 Subject: [PATCH 3/4] Update django --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 09a8ac7..4381b3a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ crispy-bootstrap5==0.7 -Django==4.1.7 +Django==4.1.10 djangoloco==1.0 django-bootstrap5==22.2 django-crispy-forms==2.0 -- 2.43.0 From 1feb34c50169fe0f0063b3ebabb7b3e26479297f Mon Sep 17 00:00:00 2001 From: Jannis Portmann Date: Sun, 9 Jul 2023 18:48:47 +0200 Subject: [PATCH 4/4] Fix button active state --- pflaenzli/pflaenzli/static/base.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pflaenzli/pflaenzli/static/base.css b/pflaenzli/pflaenzli/static/base.css index 28ccc90..0a3ecad 100644 --- a/pflaenzli/pflaenzli/static/base.css +++ b/pflaenzli/pflaenzli/static/base.css @@ -59,6 +59,7 @@ --bs-btn-hover-border-color: var(--bg-pfl-color); --bs-btn-focus-shadow-rgb: 49, 132, 253; --bs-btn-active-bg: var(--pfl-color); + --bs-btn-active-color: var(--bs-body-bg); --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); } @@ -67,6 +68,9 @@ --bs-btn-hover-bg: var(--bg-pfl-brown); --bs-btn-color: var(--bs-heading-color); --bs-btn-hover-color: var(--bs-heading-color); + --bs-btn-active-bg: var(--bg-pfl-brown); + --bs-btn-active-color: var(--bs-heading-color); + --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); } .bg-pfl { -- 2.43.0