Commit 7dc5c7b8 by Timothée Peignier

make it pass a real world tests

parent fa19a325
......@@ -3,6 +3,8 @@ from django.conf import settings
PIPELINE = getattr(settings, 'PIPELINE', not settings.DEBUG)
PIPELINE_ROOT = getattr(settings, 'PIPELINE_ROOT', settings.STATIC_ROOT)
PIPELINE_URL = getattr(settings, 'PIPELINE_URL', settings.STATIC_URL)
PIPELINE_STORAGE = getattr(settings, 'PIPELINE_STORAGE',
'pipeline.storage.PipelineFinderStorage')
......
try:
from staticfiles import finders
from staticfiles.storage import CachedStaticFilesStorage, StaticFilesStorage
except ImportError:
from django.contrib.staticfiles import finders
from django.contrib.staticfiles.storage import CachedStaticFilesStorage, StaticFilesStorage
from django.core.files.storage import get_storage_class
......@@ -18,25 +20,50 @@ class PipelineStorage(StaticFilesStorage):
packager = Packager()
for package_name in packager.packages['css']:
package = packager.package_for('css', package_name)
for path in package['paths']:
if path in paths:
paths.remove(path)
output_file = packager.pack_stylesheets(package)
paths.append(output_file)
for package_name in packager.packages['js']:
package = packager.package_for('js', package_name)
for path in package['paths']:
if path in paths:
paths.remove(path)
output_file = packager.pack_javascripts(package)
paths.append(output_file)
return super(PipelineStorage, self).post_process(paths, dry_run, **options)
super_class = super(PipelineStorage, self)
if hasattr(super_class, 'post_process'):
return super_class.post_process(paths, dry_run, **options)
return paths
class PipelineCachedStorage(PipelineStorage, CachedStaticFilesStorage):
pass
class BaseFinderStorage(PipelineStorage):
finders = None
def __init__(self, finders=None, *args, **kwargs):
if finders is not None:
self.finders = finders
if self.finders is None:
raise ImproperlyConfigured("The storage %r doesn't have a finders class assigned." % self.__class__)
super(BaseFinderStorage, self).__init__(*args, **kwargs)
def path(self, name):
path = self.finders.find(name)
if not path:
path = super(BaseFinderStorage, self).path(name)
return path
def exists(self, name):
exists = self.finders.find(name) != None
if not exists:
exists = super(BaseFinderStorage, self).exists(name)
return exists
class PipelineFinderStorage(BaseFinderStorage):
finders = finders
class DefaultStorage(LazyObject):
def _setup(self):
self._wrapped = get_storage_class(settings.PIPELINE_STORAGE)()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment