diff --git a/src/pretix/base/templates/empty.html b/src/pretix/base/templates/empty.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/pretix/helpers/template_loaders.py b/src/pretix/helpers/template_loaders.py new file mode 100644 index 0000000000..419bd22639 --- /dev/null +++ b/src/pretix/helpers/template_loaders.py @@ -0,0 +1,36 @@ +# +# This file is part of pretix (Community Edition). +# +# Copyright (C) 2014-2020 Raphael Michel and contributors +# Copyright (C) 2020-2021 rami.io GmbH and contributors +# +# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General +# Public License as published by the Free Software Foundation in version 3 of the License. +# +# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are +# applicable granting you additional permissions and placing additional restrictions on your usage of this software. +# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive +# this file, see . +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more +# details. +# +# You should have received a copy of the GNU Affero General Public License along with this program. If not, see +# . +# +from django.template.loaders.app_directories import Loader +from django.template.utils import get_app_template_dirs + + +class AppLoader(Loader): + + def get_dirs(self): + ds = get_app_template_dirs('templates') + ignore_patterns = { + # Ignore templates of plugins we don't actually use as they cause trouble during + # static file compression + '/django_filters/', + '/django_otp/', + } + return [d for d in ds if not any(p in str(d) for p in ignore_patterns)] diff --git a/src/pretix/presale/style.py b/src/pretix/presale/style.py index b74d8f235a..eee9591c23 100644 --- a/src/pretix/presale/style.py +++ b/src/pretix/presale/style.py @@ -26,7 +26,7 @@ from urllib.parse import urljoin, urlsplit import django_libsass import sass -from compressor.filters.cssmin import CSSCompressorFilter +from compressor.filters.cssmin import CSSMinFilter from django.conf import settings from django.core.cache import cache from django.core.files.base import ContentFile, File @@ -115,7 +115,7 @@ def compile_scss(object, file="main.scss", fonts=True): include_paths=[sassdir], output_style='nested', custom_functions=cf ) - cssf = CSSCompressorFilter(css) + cssf = CSSMinFilter(css) css = cssf.output() cache.set('sass_compile_{}_{}'.format(cp, srcchecksum), css, 600) diff --git a/src/pretix/settings.py b/src/pretix/settings.py index 18f2b998f0..2521770627 100644 --- a/src/pretix/settings.py +++ b/src/pretix/settings.py @@ -593,7 +593,7 @@ CSRF_FAILURE_VIEW = 'pretix.base.views.errors.csrf_failure' template_loaders = ( 'django.template.loaders.filesystem.Loader', - 'django.template.loaders.app_directories.Loader', + 'pretix.helpers.template_loaders.AppLoader', ) if not DEBUG: template_loaders = ( @@ -648,6 +648,10 @@ COMPRESS_PRECOMPILERS = ( ('text/vue', 'pretix.helpers.compressor.VueCompiler'), ) +COMPRESS_OFFLINE_CONTEXT = { + 'basetpl': 'empty.html', +} + COMPRESS_ENABLED = COMPRESS_OFFLINE = not debug_fallback COMPRESS_FILTERS = { @@ -655,7 +659,10 @@ COMPRESS_FILTERS = { # CssAbsoluteFilter is incredibly slow, especially when dealing with our _flags.scss # However, we don't need it if we consequently use the static() function in Sass # 'compressor.filters.css_default.CssAbsoluteFilter', - 'compressor.filters.cssmin.CSSCompressorFilter', + 'compressor.filters.cssmin.rCSSMinFilter', + ), + 'js': ( + 'compressor.filters.jsmin.JSMinFilter', ) } diff --git a/src/setup.py b/src/setup.py index c0ead90ebb..9547b747a3 100644 --- a/src/setup.py +++ b/src/setup.py @@ -165,13 +165,12 @@ setup( 'celery==4.4.*', 'chardet==4.0.*', 'cryptography>=3.4.2', - 'csscompressor', 'css-inline==0.7.*', 'defusedcsv>=1.1.0', 'dj-static', 'Django==3.2.*', 'django-bootstrap3==15.0.*', - 'django-compressor==2.4.*', + 'django-compressor==3.1.*', 'django-countries==7.2.*', 'django-filter==21.1', 'django-formset-js-improved==0.5.0.2',