mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-09 19:56:48 +00:00
A theme change compiled Bootswatch with libsass (34 MB, upstream deprecated) into two tracked files, which updates, rollbacks and new Docker containers then reset. The 27 themes now ship as static/css/themes/<theme>.min.css, built by "manage.py build_themes"; the Settings page only saves the theme name and every page links that file (zephyr when no settings are in context, as on the 500 page). libsass moves to dev/requirements.txt; a test checks that each shipped file is its theme compiled from dev/scss. The "Theme SASS Path" setting is removed, and the theme default "flaty", a typo that never applied, becomes zephyr, the theme those installs showed. The update and rollback steps restore an older version's rewritten theme files only where they are modified.
27 lines
888 B
Python
27 lines
888 B
Python
from pathlib import Path
|
|
|
|
import sass
|
|
from django.conf import settings
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from appsettings.views import THEMES_DIR
|
|
|
|
SCSS = Path(settings.BASE_DIR, "dev", "scss")
|
|
|
|
|
|
def compile_theme(theme):
|
|
return sass.compile(
|
|
string=f"@import '{SCSS}/wvc-themes/{theme}/variables';\n"
|
|
f"@import '{SCSS}/bootstrap-overrides.scss';\n"
|
|
f"@import '{SCSS}/wvc-themes/{theme}/bootswatch';",
|
|
output_style="compressed",
|
|
)
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = "Compile the themes in dev/scss/wvc-themes into static/css/themes (needs libsass, dev/requirements.txt)."
|
|
|
|
def handle(self, *args, **options):
|
|
THEMES_DIR.mkdir(exist_ok=True)
|
|
for theme in sorted(p.name for p in (SCSS / "wvc-themes").iterdir() if p.is_dir()):
|
|
(THEMES_DIR / f"{theme}.min.css").write_text(compile_theme(theme))
|