Commit 0e70c5da by Timothée Peignier

Merge branch 'master' into pipeline-next

Conflicts:
	pipeline/conf/settings.py
parents 277d1fe0 02c03f37
...@@ -5,10 +5,48 @@ Compressors ...@@ -5,10 +5,48 @@ Compressors
=========== ===========
YUI compressor Yuglify compressor
==================
The Yuglify compressor uses `yuglify <http://github.com/yui/yuglify>`_
for compressing javascript and stylesheets.
To use it for your stylesheets add this to your ``PIPELINE_CSS_COMPRESSOR`` ::
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'
To use it for your javascripts add this to your ``PIPELINE_JS_COMPRESSOR`` ::
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'
``PIPELINE_YUGLIFY_BINARY``
---------------------------
Command line to execute for the Yuglify program.
You will most likely change this to the location of yuglify on your system.
Defaults to ``'/usr/bin/env yuglify'``.
``PIPELINE_YUGLIFY_CSS_ARGUMENTS``
----------------------------------
Additional arguments to use when compressing CSS.
Defaults to ``''``.
``PIPELINE_YUGLIFY_JS_ARGUMENTS``
---------------------------------
Additional arguments to use when compressing JavaScript.
Defaults to ``''``.
YUI Compressor compressor
========================= =========================
The YUI compressor uses `yuglify <http://github.com/yui/yuglify>`_ The YUI compressor uses `yui-compressor <http://developer.yahoo.com/yui/compressor/>`_
for compressing javascript and stylesheets. for compressing javascript and stylesheets.
To use it for your stylesheets add this to your ``PIPELINE_CSS_COMPRESSOR`` :: To use it for your stylesheets add this to your ``PIPELINE_CSS_COMPRESSOR`` ::
...@@ -26,7 +64,11 @@ To use it for your javascripts add this to your ``PIPELINE_JS_COMPRESSOR`` :: ...@@ -26,7 +64,11 @@ To use it for your javascripts add this to your ``PIPELINE_JS_COMPRESSOR`` ::
Command line to execute for the YUI program. Command line to execute for the YUI program.
You will most likely change this to the location of yui-compressor on your system. You will most likely change this to the location of yui-compressor on your system.
Defaults to ``'/usr/bin/env yuglify'``. Defaults to ``'/usr/bin/env yuicompressor'``.
.. warning::
Don't point to ``yuicompressor.jar`` directly, we expect to find a executable script.
``PIPELINE_YUI_CSS_ARGUMENTS`` ``PIPELINE_YUI_CSS_ARGUMENTS``
------------------------------ ------------------------------
......
...@@ -120,7 +120,7 @@ Other settings ...@@ -120,7 +120,7 @@ Other settings
If empty or ``None``, CSS files won't be compressed. If empty or ``None``, CSS files won't be compressed.
Defaults to ``'pipeline.compressors.yui.YUICompressor'``. Defaults to ``'pipeline.compressors.yuglify.YuglifyCompressor'``.
``PIPELINE_JS_COMPRESSOR`` ``PIPELINE_JS_COMPRESSOR``
........................... ...........................
...@@ -129,11 +129,11 @@ Other settings ...@@ -129,11 +129,11 @@ Other settings
If empty or ``None``, JavaScript files won't be compressed. If empty or ``None``, JavaScript files won't be compressed.
Defaults to ``'pipeline.compressors.yui.YUICompressor'`` Defaults to ``'pipeline.compressors.yuglify.YuglifyCompressor'``
.. note:: .. note::
Please note that in order to use YUI Compressor, you need to install YUI Compressor (see :doc:`installation` for more details). Please note that in order to use Yuglify compressor, you need to install Yuglify (see :doc:`installation` for more details).
``PIPELINE_TEMPLATE_NAMESPACE`` ``PIPELINE_TEMPLATE_NAMESPACE``
............................... ...............................
......
...@@ -29,8 +29,8 @@ Installation ...@@ -29,8 +29,8 @@ Installation
Recommendations Recommendations
=============== ===============
Pipeline's default CSS and JS compressor is the YUI compressor, which uses yuglify. Pipeline's default CSS and JS compressor is Yuglify.
yuglify wraps UglifyJS and cssmin, applying the default YUI configurations to them. Yuglify wraps UglifyJS and cssmin, applying the default YUI configurations to them.
It can be downloaded from: https://github.com/yui/yuglify/. It can be downloaded from: https://github.com/yui/yuglify/.
If you do not install yuglify, make sure to disable the compressor in your settings. If you do not install yuglify, make sure to disable the compressor in your settings.
......
from __future__ import unicode_literals
from pipeline.conf import settings
from pipeline.compressors import SubProcessCompressor
class YuglifyCompressor(SubProcessCompressor):
def compress_common(self, content, compress_type, arguments):
command = '%s --type=%s %s' % (settings.PIPELINE_YUGLIFY_BINARY, compress_type, arguments)
return self.execute_command(command, content)
def compress_js(self, js):
return self.compress_common(js, 'js', settings.PIPELINE_YUGLIFY_JS_ARGUMENTS)
def compress_css(self, css):
return self.compress_common(css, 'css', settings.PIPELINE_YUGLIFY_CSS_ARGUMENTS)
...@@ -10,9 +10,9 @@ PIPELINE_STORAGE = getattr(settings, 'PIPELINE_STORAGE', ...@@ -10,9 +10,9 @@ PIPELINE_STORAGE = getattr(settings, 'PIPELINE_STORAGE',
'pipeline.storage.PipelineFinderStorage') 'pipeline.storage.PipelineFinderStorage')
PIPELINE_CSS_COMPRESSOR = getattr(settings, 'PIPELINE_CSS_COMPRESSOR', PIPELINE_CSS_COMPRESSOR = getattr(settings, 'PIPELINE_CSS_COMPRESSOR',
'pipeline.compressors.yui.YUICompressor') 'pipeline.compressors.yuglify.YuglifyCompressor')
PIPELINE_JS_COMPRESSOR = getattr(settings, 'PIPELINE_JS_COMPRESSOR', PIPELINE_JS_COMPRESSOR = getattr(settings, 'PIPELINE_JS_COMPRESSOR',
'pipeline.compressors.yui.YUICompressor') 'pipeline.compressors.yuglify.YuglifyCompressor')
PIPELINE_COMPILERS = getattr(settings, 'PIPELINE_COMPILERS', []) PIPELINE_COMPILERS = getattr(settings, 'PIPELINE_COMPILERS', [])
PIPELINE_CSS = getattr(settings, 'PIPELINE_CSS', {}) PIPELINE_CSS = getattr(settings, 'PIPELINE_CSS', {})
...@@ -27,9 +27,13 @@ PIPELINE_DISABLE_WRAPPER = getattr(settings, 'PIPELINE_DISABLE_WRAPPER', False) ...@@ -27,9 +27,13 @@ PIPELINE_DISABLE_WRAPPER = getattr(settings, 'PIPELINE_DISABLE_WRAPPER', False)
PIPELINE_CSSTIDY_BINARY = getattr(settings, 'PIPELINE_CSSTIDY_BINARY', '/usr/bin/env csstidy') PIPELINE_CSSTIDY_BINARY = getattr(settings, 'PIPELINE_CSSTIDY_BINARY', '/usr/bin/env csstidy')
PIPELINE_CSSTIDY_ARGUMENTS = getattr(settings, 'PIPELINE_CSSTIDY_ARGUMENTS', '--template=highest') PIPELINE_CSSTIDY_ARGUMENTS = getattr(settings, 'PIPELINE_CSSTIDY_ARGUMENTS', '--template=highest')
PIPELINE_YUI_BINARY = getattr(settings, 'PIPELINE_YUI_BINARY', '/usr/bin/env yuglify') PIPELINE_YUGLIFY_BINARY = getattr(settings, 'PIPELINE_YUI_BINARY', '/usr/bin/env yuglify')
PIPELINE_YUI_CSS_ARGUMENTS = getattr(settings, 'PIPELINE_YUI_CSS_ARGUMENTS', '--terminal') PIPELINE_YUGLIFY_CSS_ARGUMENTS = getattr(settings, 'PIPELINE_YUI_CSS_ARGUMENTS', '--terminal')
PIPELINE_YUI_JS_ARGUMENTS = getattr(settings, 'PIPELINE_YUI_JS_ARGUMENTS', '--terminal') PIPELINE_YUGLIFY_JS_ARGUMENTS = getattr(settings, 'PIPELINE_YUI_JS_ARGUMENTS', '--terminal')
PIPELINE_YUI_BINARY = getattr(settings, 'PIPELINE_YUI_BINARY', '/usr/bin/env yuicompressor')
PIPELINE_YUI_CSS_ARGUMENTS = getattr(settings, 'PIPELINE_YUI_CSS_ARGUMENTS', '')
PIPELINE_YUI_JS_ARGUMENTS = getattr(settings, 'PIPELINE_YUI_JS_ARGUMENTS', '')
PIPELINE_CLOSURE_BINARY = getattr(settings, 'PIPELINE_CLOSURE_BINARY', '/usr/bin/env closure') PIPELINE_CLOSURE_BINARY = getattr(settings, 'PIPELINE_CLOSURE_BINARY', '/usr/bin/env closure')
PIPELINE_CLOSURE_ARGUMENTS = getattr(settings, 'PIPELINE_CLOSURE_ARGUMENTS', '') PIPELINE_CLOSURE_ARGUMENTS = getattr(settings, 'PIPELINE_CLOSURE_ARGUMENTS', '')
......
...@@ -11,7 +11,7 @@ except ImportError: ...@@ -11,7 +11,7 @@ except ImportError:
from django.test import TestCase from django.test import TestCase
from pipeline.compressors import Compressor, TEMPLATE_FUNC from pipeline.compressors import Compressor, TEMPLATE_FUNC
from pipeline.compressors.yui import YUICompressor from pipeline.compressors.yuglify import YuglifyCompressor
from tests.utils import _ from tests.utils import _
...@@ -22,10 +22,10 @@ class CompressorTest(TestCase): ...@@ -22,10 +22,10 @@ class CompressorTest(TestCase):
self.compressor = Compressor() self.compressor = Compressor()
def test_js_compressor_class(self): def test_js_compressor_class(self):
self.assertEquals(self.compressor.js_compressor, YUICompressor) self.assertEquals(self.compressor.js_compressor, YuglifyCompressor)
def test_css_compressor_class(self): def test_css_compressor_class(self):
self.assertEquals(self.compressor.css_compressor, YUICompressor) self.assertEquals(self.compressor.css_compressor, YuglifyCompressor)
def test_concatenate_and_rewrite(self): def test_concatenate_and_rewrite(self):
css = self.compressor.concatenate_and_rewrite([ css = self.compressor.concatenate_and_rewrite([
......
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