From 76c964378756b2661fab3be685fc61377343c9ed Mon Sep 17 00:00:00 2001 From: Marn Vermuldir Date: Thu, 20 Jun 2024 18:47:22 -0500 Subject: [PATCH] Added Bootswatch Slate theme v5.3.3 --- README.md | 19 ++++++++ eunicore/theme/__init__.py | 0 eunicore/theme/slate/__init__.py | 0 eunicore/theme/slate/apps.py | 9 ++++ eunicore/theme/slate/auth_hooks.py | 43 +++++++++++++++++++ .../eunicore/theme/slate/css/tweaks.css | 4 ++ 6 files changed, 75 insertions(+) create mode 100644 eunicore/theme/__init__.py create mode 100644 eunicore/theme/slate/__init__.py create mode 100644 eunicore/theme/slate/apps.py create mode 100644 eunicore/theme/slate/auth_hooks.py create mode 100644 eunicore/theme/slate/static/eunicore/theme/slate/css/tweaks.css diff --git a/README.md b/README.md index 7759dff..262ac07 100644 --- a/README.md +++ b/README.md @@ -152,3 +152,22 @@ template loader's dirs if it isn't already present. ### Templates The `eunicore/templates` directory can be used to override any template file used by the Alliance Auth application. + +### AA v4.x Theme + +Add `eunicore.theme.slate` to INSTALLED_APPS. + +Add the following to `local.py` as well if you only the Slate theme available. + +```python +# Sets default theme to Slate. +DEFAULT_THEME = "eunicore.theme.slate.auth_hooks.SlateThemeHook" + +# Legacy AAv3 user.profile.night_mode=1. This is the default set by the EUni Auth Backend. +DEFAULT_THEME_DARK = "eunicore.theme.slate.auth_hooks.SlateThemeHook" + +# Remove the default BS5 themes +INSTALLED_APPS.remove("allianceauth.theme.darkly") +INSTALLED_APPS.remove("allianceauth.theme.flatly") +INSTALLED_APPS.remove("allianceauth.theme.materia") +``` diff --git a/eunicore/theme/__init__.py b/eunicore/theme/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/eunicore/theme/slate/__init__.py b/eunicore/theme/slate/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/eunicore/theme/slate/apps.py b/eunicore/theme/slate/apps.py new file mode 100644 index 0000000..82dab7f --- /dev/null +++ b/eunicore/theme/slate/apps.py @@ -0,0 +1,9 @@ +# Django +from django.apps import AppConfig + + +class SlateThemeConfig(AppConfig): + name = "eunicore.theme.slate" + label = "slate" + version = "5.3.3" + verbose_name = f"Bootswatch Slate v{version}" diff --git a/eunicore/theme/slate/auth_hooks.py b/eunicore/theme/slate/auth_hooks.py new file mode 100644 index 0000000..c35f2c8 --- /dev/null +++ b/eunicore/theme/slate/auth_hooks.py @@ -0,0 +1,43 @@ +# Django +from django.templatetags.static import static + +# Alliance Auth +from allianceauth import hooks +from allianceauth.theme.hooks import ThemeHook + + +class SlateThemeHook(ThemeHook): + """ + Bootswatch Slate Theme + https://bootswatch.com/slate/ + """ + + def __init__(self): + ThemeHook.__init__( + self, + "Slate", + "Shades of gunmetal gray", + css=[ + { + "url": "https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.3.3/slate/bootstrap.min.css", + "integrity": "sha512-3EVe7TjxthzbTGfmRFr7zIvHjDWW7viFDgKOoTJ7S5IIrrKVN5rbPVjj0F7nT6rTyAkURnzwoujxlALvHoO9jw==", + }, + {"url": static("eunicore/theme/slate/css/tweaks.css")}, + ], + js=[ + { + "url": "https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.11.8/umd/popper.min.js", + "integrity": "sha512-TPh2Oxlg1zp+kz3nFA0C5vVC6leG/6mm1z9+mA81MI5eaUVqasPLO8Cuk4gMF4gUfP5etR73rgU/8PNMsSesoQ==", + }, + { + "url": "https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.3/js/bootstrap.min.js", + "integrity": "sha512-ykZ1QQr0Jy/4ZkvKuqWn4iF3lqPZyij9iRv6sGqLRdTPkY69YX6+7wvVGmsdBbiIfN/8OdsI7HABjvEok6ZopQ==", + }, + ], + header_padding="4.5em", + ) + + +@hooks.register("theme_hook") +def register_slate_hook(): + return SlateThemeHook() diff --git a/eunicore/theme/slate/static/eunicore/theme/slate/css/tweaks.css b/eunicore/theme/slate/static/eunicore/theme/slate/css/tweaks.css new file mode 100644 index 0000000..963d86f --- /dev/null +++ b/eunicore/theme/slate/static/eunicore/theme/slate/css/tweaks.css @@ -0,0 +1,4 @@ +/* Default body color doesn't contrast enough under .bg-success for the dashboard software version */ +#aa-dashboard-panel-software-version .bg-success { + --bs-body-color: #fff; +}