From ee381b546c5e7e6634d897ec664e449bb70b84e9 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sun, 21 Mar 2021 15:30:16 +0100 Subject: [PATCH] Switch from django compressor to whitenoise --- articles/compressor.py | 37 ----- articles/templates/articles/base.html | 30 ++-- .../articles/snippets/analytics.html | 18 ++- blog/settings.py | 31 +--- docker/nginx-dev.conf | 5 - docker/nginx.conf | 5 - docker/run.sh | 1 - poetry.lock | 134 +++++++----------- pyproject.toml | 4 +- 9 files changed, 83 insertions(+), 182 deletions(-) delete mode 100644 articles/compressor.py diff --git a/articles/compressor.py b/articles/compressor.py deleted file mode 100644 index ed3a014..0000000 --- a/articles/compressor.py +++ /dev/null @@ -1,37 +0,0 @@ -import itertools - -from django.conf import settings - - -class DummyArticleWithCode: - has_code = True - - -class DummyArticleNoCode: - has_code = False - - -class DummyNonAuthenticatedUser: - is_authenticated = False - - -class DummyAuthenticatedUser: - is_authenticated = True - - -def offline_context(): - article_possibilities = [None, DummyArticleWithCode(), DummyArticleNoCode()] - user_possibilities = [DummyAuthenticatedUser(), DummyNonAuthenticatedUser()] - goatcounter_possibilities = [None, settings.GOATCOUNTER_DOMAIN] - all_possibilities = [ - article_possibilities, - user_possibilities, - goatcounter_possibilities, - ] - for _tuple in itertools.product(*all_possibilities): - yield { - "STATIC_URL": settings.STATIC_URL, - "article": _tuple[0], - "user": _tuple[1], - "goatcounter_domain": _tuple[2], - } diff --git a/articles/templates/articles/base.html b/articles/templates/articles/base.html index 849d2f3..e5f43dd 100644 --- a/articles/templates/articles/base.html +++ b/articles/templates/articles/base.html @@ -1,4 +1,4 @@ -{% load static compress %} +{% load static %} {% spaceless %} @@ -14,17 +14,15 @@ {% include "articles/snippets/analytics_head.html" %} {% include "articles/snippets/page_metadata.html" %} - {% compress css inline %} - - - - {% if article and article.has_code %} - - {% endif %} - {% if user.is_authenticated %} - - {% endif %} - {% endcompress %} + + + + {% if article and article.has_code %} + + {% endif %} + {% if user.is_authenticated %} + + {% endif %} {% block append_css %} {% endblock %} @@ -61,11 +59,9 @@ {% include "articles/snippets/analytics.html" %} -{% compress js inline %} - {% if user.is_authenticated %} - - {% endif %} -{% endcompress %} +{% if user.is_authenticated %} + +{% endif %} diff --git a/articles/templates/articles/snippets/analytics.html b/articles/templates/articles/snippets/analytics.html index 387b1ff..54e90ff 100644 --- a/articles/templates/articles/snippets/analytics.html +++ b/articles/templates/articles/snippets/analytics.html @@ -1,15 +1,13 @@ -{% load static compress %} +{% load static %} {% if not user.is_authenticated and goatcounter_domain is not None %} - {% compress js inline %} - - - {% endcompress %} + +