Skip to content

Commit

Permalink
Merge pull request #45 from fusionbox/manifest-storage
Browse files Browse the repository at this point in the history
Added OptimizedManifestStaticFilesStorage
  • Loading branch information
etianen committed Feb 26, 2015
2 parents 3d174aa + 05f319b commit 05f6c4f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
13 changes: 10 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ Installation
``pip install django-require``.
2. Add ``'require'`` to your ``INSTALLED_APPS`` setting.
3. Set your ``STATICFILES_STORAGE`` setting to
``'require.storage.OptimizedStaticFilesStorage'`` or
``'require.storage.OptimizedCachedStaticFilesStorage'``.
``'require.storage.OptimizedStaticFilesStorage'``,
``'require.storage.OptimizedCachedStaticFilesStorage'`` or
``'require.storage.OptimizedManifestStaticFilesStorage'``.

Available settings
------------------
Expand Down Expand Up @@ -159,14 +160,20 @@ The r.js optimizer is run automatically whenever you call the
``collectstatic`` management command. The optimizer is run as a
post-processing step on your static files.

django-require provides two storage classes that are ready to use with
django-require provides three storage classes that are ready to use with
the r.js optimizer:

- ``require.storage.OptimizedStaticFilesStorage`` - A filesystem-based
storage that runs the r.js optimizer.
- ``require.storage.OptimizedCachedStaticFilesStorage`` - As above, but
fingerprints all files with an MD5 hash of their contents for HTTP
cache-busting.
- ``require.storage.OptimizedManifestStaticFilesStorage`` - As above, but
fingerprints all files with an MD5 hash of their contents for HTTP
cache-busting and stores the fingerprints in a JSON file on disk instead
of using a cache. Please note that the
``OptimizedManifestStaticFilesStorage`` is only available in Django 1.7 and
above.

Creating your own optimizing storage classes
--------------------------------------------
Expand Down
10 changes: 10 additions & 0 deletions require/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,13 @@ class OptimizedStaticFilesStorage(OptimizedFilesMixin, StaticFilesStorage):
class OptimizedCachedStaticFilesStorage(OptimizedFilesMixin, CachedStaticFilesStorage):

pass


try:
from django.contrib.staticfiles.storage import ManifestStaticFilesStorage
except ImportError: # Django < 1.7
pass
else:
class OptimizedManifestStaticFilesStorage(OptimizedFilesMixin, ManifestStaticFilesStorage):

pass

0 comments on commit 05f6c4f

Please sign in to comment.