Commit bf5ecf27 by Timothée Peignier

one compressor ought to be enough for anybody, but I might be wrong

parent 5ed85860
......@@ -17,17 +17,13 @@ YUI Compressor compressor
The YUI compressor use `yui-compressor <http://developer.yahoo.com/yui/compressor/>`_
for compressing javascript and stylesheets.
To us it for your stylesheets add this to your ``PIPELINE_CSS_COMPRESSORS`` ::
To use it for your stylesheets add this to your ``PIPELINE_CSS_COMPRESSOR`` ::
PIPELINE_CSS_COMPRESSORS = (
'pipeline.compressors.yui.YUICompressor',
)
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yui.YUICompressor'
To use it for your javascripts add this to your ``PIPELINE_JS_COMPRESSORS`` ::
To use it for your javascripts add this to your ``PIPELINE_JS_COMPRESSOR`` ::
PIPELINE_JS_COMPRESSORS = (
'pipeline.compressors.yui.YUICompressor',
)
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.yui.YUICompressor'
``PIPELINE_YUI_BINARY``
......@@ -59,9 +55,9 @@ Closure Compiler compressor
The Closure compressor use `Google Closure Compiler <http://code.google.com/closure/compiler/>`_
to compress javascripts.
To use it add this to your ``PIPELINE_JS_COMPRESSORS`` ::
To use it add this to your ``PIPELINE_JS_COMPRESSOR`` ::
PIPELINE_JS_COMPRESSORS = (
PIPELINE_JS_COMPRESSOR = (
'pipeline.compressors.closure.ClosureCompressor',
)
......@@ -88,11 +84,9 @@ UglifyJS compressor
The UglifyJS compressor use `UglifyJS <https://github.com/mishoo/UglifyJS/>`_ to
compress javascripts.
To use it add this to your ``PIPELINE_JS_COMPRESSORS`` ::
To use it add this to your ``PIPELINE_JS_COMPRESSOR`` ::
PIPELINE_JS_COMPRESSORS = (
'pipeline.compressors.uglifyjs.UglifyJSCompressor',
)
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.uglifyjs.UglifyJSCompressor'
``PIPELINE_UGLIFYJS_BINARY``
......@@ -117,11 +111,9 @@ JSMin compressor
The jsmin compressor use Douglas Crockford jsmin tool to
compress javascripts.
To use it add this to your ``PIPELINE_JS_COMPRESSORS`` ::
To use it add this to your ``PIPELINE_JS_COMPRESSOR`` ::
PIPELINE_JS_COMPRESSORS = (
'pipeline.compressors.jsmin.JSMinCompressor',
)
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.jsmin.JSMinCompressor'
CSSTidy compressor
==================
......@@ -129,11 +121,9 @@ CSSTidy compressor
The CSStidy compressor use `CSStidy <http://csstidy.sourceforge.net/>`_ to compress
stylesheets.
To us it for your stylesheets add this to your ``PIPELINE_CSS_COMPRESSORS`` ::
To us it for your stylesheets add this to your ``PIPELINE_CSS_COMPRESSOR`` ::
PIPELINE_CSS_COMPRESSORS = (
'pipeline.compressors.csstidy.CSSTidyCompressor',
)
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.csstidy.CSSTidyCompressor'
``PIPELINE_CSSTIDY_BINARY``
---------------------------
......@@ -160,8 +150,8 @@ of compressors.
All you need to do is to create a class that inherits from ``pipeline.compressors.CompressorBase``
and implements ``compress_css`` and/or a ``compress_js`` when needed.
Finally, specify it in the tuple of compressors ``PIPELINE_CSS_COMPRESSORS`` or
``PIPELINE_JS_COMPRESSORS`` (see :doc:`configuration` for more information) in the settings.
Finally, specify it in the tuple of compressors ``PIPELINE_CSS_COMPRESSOR`` or
``PIPELINE_JS_COMPRESSOR`` (see :doc:`configuration` for more information) in the settings.
Example
-------
......
......@@ -161,22 +161,19 @@ Other settings
This will output a file like ``/media/c/screen.r1213947531.css``,
which will be re-generated and updated when you change your source files.
``PIPELINE_CSS_COMPRESSORS``
``PIPELINE_CSS_COMPRESSOR``
............................
A tuple of compressors to be applied to CSS files.
Compressor class to be applied to CSS files.
Defaults to ``('pipeline.compressors.yui.YUICompressor',)``.
Defaults to ``'pipeline.compressors.yui.YUICompressor'``.
``PIPELINE_JS_COMPRESSORS``
``PIPELINE_JS_COMPRESSOR``
...........................
A tuple of compressors to be applied to JavaScript files.
Compressor class to be applied to JavaScript files.
Defaults to ``('pipeline.compressors.yui.YUICompressor',)``
Also ``PIPELINE_*_COMPRESSORS`` can be set to an empty tuple or ``None`` to not use any compressor.
The files will however still be concatenated to one file.
Defaults to ``'pipeline.compressors.yui.YUICompressor'``
.. note::
......
......@@ -35,28 +35,26 @@ class Compressor(object):
def __init__(self, verbose=False):
self.verbose = verbose
def js_compressors(self):
return [to_class(compressor) for compressor in settings.PIPELINE_JS_COMPRESSORS]
js_compressors = property(js_compressors)
def js_compressor(self):
return to_class(settings.PIPELINE_JS_COMPRESSOR)
js_compressor = property(js_compressor)
def css_compressors(self):
return [to_class(compressor) for compressor in settings.PIPELINE_CSS_COMPRESSORS]
css_compressors = property(css_compressors)
def css_compressor(self):
return to_class(settings.PIPELINE_CSS_COMPRESSOR)
css_compressor = property(css_compressor)
def compress_js(self, paths, templates=None):
"""Concatenate and compress JS files"""
js = self.concatenate(paths)
if templates:
js = js + self.compile_templates(templates)
for compressor in self.js_compressors:
js = getattr(compressor(verbose=self.verbose), 'compress_js')(js)
js = getattr(self.js_compressor(verbose=self.verbose), 'compress_js')(js)
return js
def compress_css(self, paths, variant=None):
"""Concatenate and compress CSS files"""
css = self.concatenate_and_rewrite(paths, variant)
for compressor in self.css_compressors:
css = getattr(compressor(verbose=self.verbose), 'compress_css')(css)
css = getattr(self.css_compressor(verbose=self.verbose), 'compress_css')(css)
if not variant:
return css
elif variant == "datauri":
......
......@@ -18,12 +18,12 @@ PIPELINE_VERSIONING = getattr(settings, 'PIPELINE_VERSIONING', 'pipeline.version
PIPELINE_STORAGE = getattr(settings, 'PIPELINE_STORAGE',
'pipeline.storage.CompressStorage')
PIPELINE_CSS_COMPRESSORS = getattr(settings, 'PIPELINE_CSS_COMPRESSORS', [
PIPELINE_CSS_COMPRESSOR = getattr(settings, 'PIPELINE_CSS_COMPRESSOR',
'pipeline.compressors.yui.YUICompressor'
])
PIPELINE_JS_COMPRESSORS = getattr(settings, 'PIPELINE_JS_COMPRESSORS', [
)
PIPELINE_JS_COMPRESSOR = getattr(settings, 'PIPELINE_JS_COMPRESSOR',
'pipeline.compressors.yui.YUICompressor'
])
)
PIPELINE_COMPILERS = getattr(settings, 'PIPELINE_COMPILERS', [])
PIPELINE_CSS = getattr(settings, 'PIPELINE_CSS', {})
......@@ -55,11 +55,5 @@ PIPELINE_SASS_ARGUMENTS = getattr(settings, 'PIPELINE_SASS_ARGUMENTS', '')
PIPELINE_LESS_BINARY = getattr(settings, 'PIPELINE_LESS_BINARY', '/usr/local/bin/lessc')
PIPELINE_LESS_ARGUMENTS = getattr(settings, 'PIPELINE_LESS_ARGUMENTS', '')
if PIPELINE_CSS_COMPRESSORS is None:
PIPELINE_CSS_COMPRESSORS = []
if PIPELINE_JS_COMPRESSORS is None:
PIPELINE_JS_COMPRESSORS = []
if PIPELINE_COMPILERS is None:
PIPELINE_COMPILERS = []
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