Bug 1258700 - Update to WhiteNoise 3.0

There are some backwards incompatible changes:
http://whitenoise.evans.io/en/latest/changelog.html
https://github.com/evansd/whitenoise/compare/v2.0.6...v3.0

Specifically:
* The CLI compression utility must now be called via
`python -m whitenoise.compress` rather than `python -m whitenoise.gzip`.
* The `whitenoise.django.GzipManifestStaticFilesStorage` storage backend
has moved to `whitenoise.storage.CompressedManifestStaticFilesStorage`.
* The internal `add_files()` method has been split into two and the part
which we need to subclass is now named `update_files_dictionary()`. See:
07f9c0bece
This commit is contained in:
Ed Morley 2016-03-22 14:14:38 +00:00
Родитель 566c0318ad
Коммит 5b48f4b49b
5 изменённых файлов: 6 добавлений и 6 удалений

Просмотреть файл

@ -12,7 +12,7 @@ echo $SOURCE_VERSION > dist/revision.txt
# WhiteNoise can then serve in preference to the originals. This is required
# since WhiteNoise's Django storage backend only gzips assets handled by
# collectstatic, and so does not affect files in the `dist/` directory.
python -m whitenoise.gzip dist
python -m whitenoise.compress dist
# The post_compile script is run in a sub-shell, so we need to source the
# buildpack's utils script again, so we can use set-env/set-default-env:

Просмотреть файл

@ -69,7 +69,7 @@ def update(ctx):
# WhiteNoise can then serve in preference to the originals. This is required
# since WhiteNoise's Django storage backend only gzips assets handled by
# collectstatic, and so does not affect files in the `dist/` directory.
ctx.local("python2.7 -m whitenoise.gzip dist")
ctx.local("python2.7 -m whitenoise.compress dist")
# Collect the static files (eg for the Persona or Django admin UI)
run_local_with_env(ctx, "python2.7 manage.py collectstatic --noinput")
# Update the database schema, if necessary.

Просмотреть файл

@ -4,7 +4,7 @@ gunicorn==19.4.5 --hash=sha256:c57f1b005a4b90933303c8deed9bedeb509331aa6a0a99002
wsgi-sslify==1.0.1 --hash=sha256:cde368fda0fb9958dd58bc2cb955d0bf3df1b79c132d97cee90be5fda34a5089
whitenoise==2.0.6 --hash=sha256:826ffe5d608c9dc8daebef1b0b43d01f7958f17c2fce36e75c80e26160172c4f
whitenoise==3.0 --hash=sha256:2537cf2b0c12e1c8beaa23605076344a89d08b686592abffddb6ba13b284a8c6
Django==1.8.10 --hash=sha256:471b41cb53d675138475b488c429424ed143e57ad755a2c8ab1206ac30490284

Просмотреть файл

@ -48,7 +48,7 @@ PERFHERDER_ALERTS_MAX_AGE = timedelta(weeks=2)
# Create hashed+gzipped versions of assets during collectstatic,
# which will then be served by WhiteNoise with a suitable max-age.
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
TEMPLATE_LOADERS = [
"django.template.loaders.filesystem.Loader",

Просмотреть файл

@ -9,8 +9,8 @@ class CustomWhiteNoise(DjangoWhiteNoise):
IMMUTABLE_FILE_RE = re.compile(r'\.min-[a-f0-9]{32}\.(js|css)$')
INDEX_NAME = 'index.html'
def add_files(self, *args, **kwargs):
super(CustomWhiteNoise, self).add_files(*args, **kwargs)
def update_files_dictionary(self, *args):
super(CustomWhiteNoise, self).update_files_dictionary(*args)
index_page_suffix = "/" + self.INDEX_NAME
index_name_length = len(self.INDEX_NAME)
index_files = {}