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