Skip to content

Commit 0e70c5d

Browse files
committed
Merge branch 'master' into pipeline-next
Conflicts: pipeline/conf/settings.py
2 parents 277d1fe + 02c03f3 commit 0e70c5d

File tree

6 files changed

+100
-38
lines changed

6 files changed

+100
-38
lines changed

docs/compressors.rst

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,48 @@ Compressors
55
===========
66

77

8-
YUI compressor
8+
Yuglify compressor
9+
==================
10+
11+
The Yuglify compressor uses `yuglify <http://github.com/yui/yuglify>`_
12+
for compressing javascript and stylesheets.
13+
14+
To use it for your stylesheets add this to your ``PIPELINE_CSS_COMPRESSOR`` ::
15+
16+
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'
17+
18+
To use it for your javascripts add this to your ``PIPELINE_JS_COMPRESSOR`` ::
19+
20+
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'
21+
22+
23+
``PIPELINE_YUGLIFY_BINARY``
24+
---------------------------
25+
26+
Command line to execute for the Yuglify program.
27+
You will most likely change this to the location of yuglify on your system.
28+
29+
Defaults to ``'/usr/bin/env yuglify'``.
30+
31+
``PIPELINE_YUGLIFY_CSS_ARGUMENTS``
32+
----------------------------------
33+
34+
Additional arguments to use when compressing CSS.
35+
36+
Defaults to ``''``.
37+
38+
``PIPELINE_YUGLIFY_JS_ARGUMENTS``
39+
---------------------------------
40+
41+
Additional arguments to use when compressing JavaScript.
42+
43+
Defaults to ``''``.
44+
45+
46+
YUI Compressor compressor
947
=========================
1048

11-
The YUI compressor uses `yuglify <http://github.com/yui/yuglify>`_
49+
The YUI compressor uses `yui-compressor <http://developer.yahoo.com/yui/compressor/>`_
1250
for compressing javascript and stylesheets.
1351

1452
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`` ::
2664
Command line to execute for the YUI program.
2765
You will most likely change this to the location of yui-compressor on your system.
2866

29-
Defaults to ``'/usr/bin/env yuglify'``.
67+
Defaults to ``'/usr/bin/env yuicompressor'``.
68+
69+
.. warning::
70+
Don't point to ``yuicompressor.jar`` directly, we expect to find a executable script.
71+
3072

3173
``PIPELINE_YUI_CSS_ARGUMENTS``
3274
------------------------------

docs/configuration.rst

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Configuration and list of available settings for Pipeline
1111
Specifying files
1212
================
1313

14-
You specify groups of files to be compressed in your settings. You can use glob
14+
You specify groups of files to be compressed in your settings. You can use glob
1515
syntax to select multiples files.
1616

1717
The basic syntax for specifying CSS/JavaScript groups files is ::
@@ -49,46 +49,46 @@ Group options
4949
....................
5050

5151
**Required**
52-
52+
5353
Is a tuple with the source files to be compressed.
5454
The files are concatenated in the order specified in the tuple.
55-
55+
5656

5757
``output_filename``
5858
...................
59-
59+
6060
**Required**
61-
61+
6262
Is the filename of the (to be) compressed file.
6363

6464
``variant``
6565
...........
6666

6767
**Optional**
68-
68+
6969
Is the variant you want to apply to your CSS. This allow you to embed images
7070
and fonts in CSS with data-URI.
7171
Allowed values are : ``None`` and ``datauri``.
72-
72+
7373
Defaults to ``None``.
7474

7575
``template_name``
7676
.................
7777

7878
**Optional**
79-
79+
8080
Name of the template used to render ``<script>`` for js package or ``<link>`` for css package.
81-
81+
8282
Defaults to ``None``.
8383

8484
``extra_context``
8585
.................
8686

8787
**Optional**
88-
88+
8989
Is a dictionary of values to add to the template context,
9090
when generating the HTML for the HTML-tags with the templatetags.
91-
91+
9292
For CSS, if you do not specify ``extra_context``/``media``, the default media in
9393
the ``<link>`` output will be ``media="all"``.
9494

@@ -119,21 +119,21 @@ Other settings
119119
Compressor class to be applied to CSS files.
120120

121121
If empty or ``None``, CSS files won't be compressed.
122-
123-
Defaults to ``'pipeline.compressors.yui.YUICompressor'``.
122+
123+
Defaults to ``'pipeline.compressors.yuglify.YuglifyCompressor'``.
124124

125125
``PIPELINE_JS_COMPRESSOR``
126126
...........................
127127

128128
Compressor class to be applied to JavaScript files.
129129

130130
If empty or ``None``, JavaScript files won't be compressed.
131-
132-
Defaults to ``'pipeline.compressors.yui.YUICompressor'``
131+
132+
Defaults to ``'pipeline.compressors.yuglify.YuglifyCompressor'``
133133

134134
.. note::
135135

136-
Please note that in order to use YUI Compressor, you need to install YUI Compressor (see :doc:`installation` for more details).
136+
Please note that in order to use Yuglify compressor, you need to install Yuglify (see :doc:`installation` for more details).
137137

138138
``PIPELINE_TEMPLATE_NAMESPACE``
139139
...............................
@@ -159,15 +159,15 @@ Other settings
159159
Pipeline doesn't bundle a javascript template library, but the default
160160
setting is to use the
161161
`underscore <http://documentcloud.github.com/underscore/>`_ template function.
162-
162+
163163
Defaults to ``"_.template"``
164164

165165

166166
Embedding fonts and images
167167
==========================
168168

169-
You can embed fonts and images directly in your compiled css, using Data-URI in
170-
modern browsers.
169+
You can embed fonts and images directly in your compiled css, using Data-URI in
170+
modern browsers.
171171

172172
To do so, setup variant group options to the method you wish to use : ::
173173

@@ -198,14 +198,14 @@ You can override these rules using the following settings:
198198

199199
Setting that controls the maximum image size (in bytes) to embed in CSS using Data-URIs.
200200
Internet Explorer 8 has issues with assets under 32 kilobytes.
201-
201+
202202
Defaults to ``32700``
203-
203+
204204
``PIPELINE_EMBED_PATH``
205205
.......................
206206

207207
Setting the directory that an asset needs to be in so that it is embedded
208-
208+
209209
Defaults to ``r'[/]?embed/'``
210210

211211

docs/installation.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ Installation
55
============
66

77
1. Either check out Pipeline from GitHub_ or to pull a release off PyPI_ ::
8-
8+
99
pip install django-pipeline
10-
10+
1111

1212
2. Add 'pipeline' to your ``INSTALLED_APPS`` ::
1313

@@ -21,16 +21,16 @@ Installation
2121

2222

2323
.. note::
24-
You need to use ``Django>=1.4`` or ``django-staticfiles>=1.2.1`` to be able to use this version of pipeline.
24+
You need to use ``Django>=1.4`` or ``django-staticfiles>=1.2.1`` to be able to use this version of pipeline.
2525

2626
.. _GitHub: http://github.com/cyberdelia/django-pipeline
2727
.. _PyPI: http://pypi.python.org/pypi/django-pipeline
2828

2929
Recommendations
3030
===============
3131

32-
Pipeline's default CSS and JS compressor is the YUI compressor, which uses yuglify.
33-
yuglify wraps UglifyJS and cssmin, applying the default YUI configurations to them.
32+
Pipeline's default CSS and JS compressor is Yuglify.
33+
Yuglify wraps UglifyJS and cssmin, applying the default YUI configurations to them.
3434
It can be downloaded from: https://github.com/yui/yuglify/.
3535

3636
If you do not install yuglify, make sure to disable the compressor in your settings.

pipeline/compressors/yuglify.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from __future__ import unicode_literals
2+
3+
from pipeline.conf import settings
4+
from pipeline.compressors import SubProcessCompressor
5+
6+
7+
class YuglifyCompressor(SubProcessCompressor):
8+
def compress_common(self, content, compress_type, arguments):
9+
command = '%s --type=%s %s' % (settings.PIPELINE_YUGLIFY_BINARY, compress_type, arguments)
10+
return self.execute_command(command, content)
11+
12+
def compress_js(self, js):
13+
return self.compress_common(js, 'js', settings.PIPELINE_YUGLIFY_JS_ARGUMENTS)
14+
15+
def compress_css(self, css):
16+
return self.compress_common(css, 'css', settings.PIPELINE_YUGLIFY_CSS_ARGUMENTS)

pipeline/conf/settings.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
'pipeline.storage.PipelineFinderStorage')
1111

1212
PIPELINE_CSS_COMPRESSOR = getattr(settings, 'PIPELINE_CSS_COMPRESSOR',
13-
'pipeline.compressors.yui.YUICompressor')
13+
'pipeline.compressors.yuglify.YuglifyCompressor')
1414
PIPELINE_JS_COMPRESSOR = getattr(settings, 'PIPELINE_JS_COMPRESSOR',
15-
'pipeline.compressors.yui.YUICompressor')
15+
'pipeline.compressors.yuglify.YuglifyCompressor')
1616
PIPELINE_COMPILERS = getattr(settings, 'PIPELINE_COMPILERS', [])
1717

1818
PIPELINE_CSS = getattr(settings, 'PIPELINE_CSS', {})
@@ -27,9 +27,13 @@
2727
PIPELINE_CSSTIDY_BINARY = getattr(settings, 'PIPELINE_CSSTIDY_BINARY', '/usr/bin/env csstidy')
2828
PIPELINE_CSSTIDY_ARGUMENTS = getattr(settings, 'PIPELINE_CSSTIDY_ARGUMENTS', '--template=highest')
2929

30-
PIPELINE_YUI_BINARY = getattr(settings, 'PIPELINE_YUI_BINARY', '/usr/bin/env yuglify')
31-
PIPELINE_YUI_CSS_ARGUMENTS = getattr(settings, 'PIPELINE_YUI_CSS_ARGUMENTS', '--terminal')
32-
PIPELINE_YUI_JS_ARGUMENTS = getattr(settings, 'PIPELINE_YUI_JS_ARGUMENTS', '--terminal')
30+
PIPELINE_YUGLIFY_BINARY = getattr(settings, 'PIPELINE_YUI_BINARY', '/usr/bin/env yuglify')
31+
PIPELINE_YUGLIFY_CSS_ARGUMENTS = getattr(settings, 'PIPELINE_YUI_CSS_ARGUMENTS', '--terminal')
32+
PIPELINE_YUGLIFY_JS_ARGUMENTS = getattr(settings, 'PIPELINE_YUI_JS_ARGUMENTS', '--terminal')
33+
34+
PIPELINE_YUI_BINARY = getattr(settings, 'PIPELINE_YUI_BINARY', '/usr/bin/env yuicompressor')
35+
PIPELINE_YUI_CSS_ARGUMENTS = getattr(settings, 'PIPELINE_YUI_CSS_ARGUMENTS', '')
36+
PIPELINE_YUI_JS_ARGUMENTS = getattr(settings, 'PIPELINE_YUI_JS_ARGUMENTS', '')
3337

3438
PIPELINE_CLOSURE_BINARY = getattr(settings, 'PIPELINE_CLOSURE_BINARY', '/usr/bin/env closure')
3539
PIPELINE_CLOSURE_ARGUMENTS = getattr(settings, 'PIPELINE_CLOSURE_ARGUMENTS', '')

tests/tests/test_compressor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from django.test import TestCase
1212

1313
from pipeline.compressors import Compressor, TEMPLATE_FUNC
14-
from pipeline.compressors.yui import YUICompressor
14+
from pipeline.compressors.yuglify import YuglifyCompressor
1515

1616
from tests.utils import _
1717

@@ -22,10 +22,10 @@ def setUp(self):
2222
self.compressor = Compressor()
2323

2424
def test_js_compressor_class(self):
25-
self.assertEquals(self.compressor.js_compressor, YUICompressor)
25+
self.assertEquals(self.compressor.js_compressor, YuglifyCompressor)
2626

2727
def test_css_compressor_class(self):
28-
self.assertEquals(self.compressor.css_compressor, YUICompressor)
28+
self.assertEquals(self.compressor.css_compressor, YuglifyCompressor)
2929

3030
def test_concatenate_and_rewrite(self):
3131
css = self.compressor.concatenate_and_rewrite([

0 commit comments

Comments
 (0)