diff --git a/.gitignore b/.gitignore
index 6946804..5d7c419 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,13 +1,10 @@
/.direnv
-/.hugo_build.lock
-
-/resources/_gen
-/public
-/result
-
-__pycache__
+/static/style.css
+/app/_static
db.sqlite3
vm.qcow2
+__pycache__
/.pre-commit-config.yaml
+result
diff --git a/app/e11sync/settings.py b/app/e11sync/settings.py
index 9a29f26..ea03db4 100644
--- a/app/e11sync/settings.py
+++ b/app/e11sync/settings.py
@@ -5,8 +5,7 @@ from os import environ
BASE_DIR = Path(__file__).resolve().parent.parent
_DEBUG = bool(environ.get('E11SYNC_DEBUG', False))
-_COMPRESS_OFFLINE = bool(environ.get('E11SYNC_COMPRESS_OFFLINE', False))
-_STATIC_ROOT = environ.get('E11SYNC_STATIC_ROOT', '/tmp/e11sync-static')
+_STATIC_ROOT = environ.get('E11SYNC_STATIC_ROOT', BASE_DIR / '_static')
_GEOIP_PATH = environ.get('GEOIP_PATH')
if db := environ.get('E11SYNC_DATABASE_PATH'):
_DATABASE_PATH = db
@@ -25,7 +24,6 @@ else:
if not environ.get("E11SYNC_DEBUG_PRINTED"):
print("DEBUG={}".format(_DEBUG))
print(secret_key_msg)
- print("COMPRESS_OFFLINE={}".format(_COMPRESS_OFFLINE))
print("STATIC_ROOT={}".format(_STATIC_ROOT))
print("GEOIP_PATH={}".format(_GEOIP_PATH))
print("DATABASE_PATH={}".format(_DATABASE_PATH))
@@ -45,7 +43,6 @@ INTERNAL_IPS = ["127.0.0.1"]
# Application definition
INSTALLED_APPS = (['debug_toolbar'] if DEBUG else []) + [
- 'compressor',
'e11sync.apps.E11SyncConfig',
'signup.apps.SignupConfig',
@@ -115,34 +112,16 @@ STATIC_URL = 'static/'
STATICFILES_FINDERS = [
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
- "compressor.finders.CompressorFinder",
]
-STATIC_ROOT = _STATIC_ROOT
-
-# At the time of testing:
-# main-full.css: 34K
-# main-mini.css: 49K
-# main-full.css.br: 5.0K
-# main-mini.css.br: 7.1K
-#
-# Minifying those files will necessitate sourcemaps, which
-# is not currently possible due to
-# https://github.com/django-compressor/django-compressor/issues/438
-# Since the savings with minification are not that huge, let's keep
-# it a bir larger, but much simpler.
-COMPRESS_ENABLED = True
-
-COMPRESS_OFFLINE = _COMPRESS_OFFLINE
-
-COMPRESS_FILTERS = {
- 'css': [],
- 'js': [],
+_storage = 'django.contrib.staticfiles.storage'
+STORAGES = {
+ "staticfiles": {
+ "BACKEND": _storage + ".ManifestStaticFilesStorage",
+ },
}
-COMPRESS_PRECOMPILERS = (
- ('text/x-scss', 'sass --no-source-map {infile} {outfile}'),
-)
+STATIC_ROOT = _STATIC_ROOT
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
diff --git a/app/e11sync/static/style.css b/app/e11sync/static/style.css
new file mode 120000
index 0000000..b296d1a
--- /dev/null
+++ b/app/e11sync/static/style.css
@@ -0,0 +1 @@
+../../../static/style.css
\ No newline at end of file
diff --git a/app/e11sync/templates/base.html b/app/e11sync/templates/base.html
index e19fb85..5199551 100644
--- a/app/e11sync/templates/base.html
+++ b/app/e11sync/templates/base.html
@@ -1,13 +1,11 @@
-{% load compress static %}
+{% load static %}
{% block "title" %}11sync.net{% endblock %}
- {% compress css %}
-
- {% endcompress %}
+
diff --git a/flake.nix b/flake.nix
index 4dbd794..a0b3fc1 100644
--- a/flake.nix
+++ b/flake.nix
@@ -98,7 +98,6 @@
(python3.withPackages
(ps: [
ps.django
- ps.django-compressor
ps.geoip2
ps.django-debug-toolbar
diff --git a/pkgs/e11sync-backend.nix b/pkgs/e11sync-backend.nix
index 4ba03a1..03ec0ed 100644
--- a/pkgs/e11sync-backend.nix
+++ b/pkgs/e11sync-backend.nix
@@ -17,7 +17,6 @@
python3.withPackages
(ps: [
ps.django
- ps.django-compressor
ps.geoip2
]);
in
@@ -51,13 +50,12 @@ in
--set E11SYNC_DATABASE_PATH "${databasePath}" \
''} \
--set E11SYNC_STATIC_ROOT "${e11sync-static.passthru.manifest}" \
- --set E11SYNC_COMPRESS_OFFLINE 1 \
--set E11SYNC_DEBUG "" \
--set GEOIP_PATH "${geoip-mmdb}" \
'';
passthru.tests.unit =
runCommand "e11sync-test" {
- src = ../app;
+ srcs = ../app;
buildInputs = [
pythonEnv
dart-sass
@@ -66,6 +64,7 @@ in
unpackPhase
patchShebangs --build app/manage.py
export GEOIP_PATH="${geoip-mmdb}"
+ export E11SYNC_STATIC_ROOT="${e11sync-static.passthru.manifest}"
app/manage.py test app
mkdir -p $out
'';
diff --git a/pkgs/e11sync-static.nix b/pkgs/e11sync-static.nix
index 2717dc6..de80b6f 100644
--- a/pkgs/e11sync-static.nix
+++ b/pkgs/e11sync-static.nix
@@ -9,33 +9,31 @@
}: let
self = stdenv.mkDerivation {
name = "e11sync-static";
- src = ../app;
+ srcs = [../app ../static];
+ sourceRoot = ".";
nativeBuildInputs = [
python3Packages.django
- python3Packages.django-compressor
dart-sass
findutils
];
- patchPhase = ''patchShebangs --build manage.py'';
+ patchPhase = ''patchShebangs --build app/manage.py'';
buildPhase = ''
- export E11SYNC_STATIC_ROOT=$PWD/static
export E11SYNC_DEBUG=
- export E11SYNC_COMPRESS_OFFLINE=1
- ./manage.py collectstatic
- ./manage.py compress
+ make -C static style.css
+ app/manage.py collectstatic
- find static/ \
+ find app/_static \
-name '*.css' -or \
-name '*.js' -or \
-name '*.svg' | \
tee >(xargs -n1 -P''$(nproc) ${zopfli}/bin/zopfli) | \
xargs -n1 -P''$(nproc) ${brotli}/bin/brotli
'';
- installPhase = ''mv static $out'';
+ installPhase = ''mv app/_static $out'';
passthru.manifest = runCommand "e11sync-static-manifest" {} ''
- mkdir -p $out/CACHE
- cp ${self}/CACHE/manifest.json $out/CACHE/
+ mkdir -p $out
+ cp ${self}/staticfiles.json $out/
'';
};
in
diff --git a/static/Makefile b/static/Makefile
new file mode 100644
index 0000000..3260b10
--- /dev/null
+++ b/static/Makefile
@@ -0,0 +1,2 @@
+style.css: style.scss grids-responsive.css pure.css
+ sass --no-source-map $< $@
diff --git a/app/e11sync/static/grids-responsive.css b/static/grids-responsive.css
similarity index 100%
rename from app/e11sync/static/grids-responsive.css
rename to static/grids-responsive.css
diff --git a/app/e11sync/static/pure.css b/static/pure.css
similarity index 100%
rename from app/e11sync/static/pure.css
rename to static/pure.css
diff --git a/app/e11sync/static/style.scss b/static/style.scss
similarity index 100%
rename from app/e11sync/static/style.scss
rename to static/style.scss