Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-pipeline
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-pipeline
Commits
0e70c5da
Commit
0e70c5da
authored
Dec 22, 2012
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into pipeline-next
Conflicts: pipeline/conf/settings.py
parents
277d1fe0
02c03f37
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
100 additions
and
38 deletions
+100
-38
docs/compressors.rst
+45
-3
docs/configuration.rst
+22
-22
docs/installation.rst
+5
-5
pipeline/compressors/yuglify.py
+16
-0
pipeline/conf/settings.py
+9
-5
tests/tests/test_compressor.py
+3
-3
No files found.
docs/compressors.rst
View file @
0e70c5da
...
@@ -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 `yu
glify <http://github.com/yui/yuglify
>`_
The YUI compressor uses `yu
i-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``
------------------------------
------------------------------
...
...
docs/configuration.rst
View file @
0e70c5da
...
@@ -11,7 +11,7 @@ Configuration and list of available settings for Pipeline
...
@@ -11,7 +11,7 @@ Configuration and list of available settings for Pipeline
Specifying files
Specifying files
================
================
You specify groups of files to be compressed in your settings. You can use glob
You specify groups of files to be compressed in your settings. You can use glob
syntax to select multiples files.
syntax to select multiples files.
The basic syntax for specifying CSS/JavaScript groups files is ::
The basic syntax for specifying CSS/JavaScript groups files is ::
...
@@ -49,46 +49,46 @@ Group options
...
@@ -49,46 +49,46 @@ Group options
....................
....................
**Required**
**Required**
Is a tuple with the source files to be compressed.
Is a tuple with the source files to be compressed.
The files are concatenated in the order specified in the tuple.
The files are concatenated in the order specified in the tuple.
``output_filename``
``output_filename``
...................
...................
**Required**
**Required**
Is the filename of the (to be) compressed file.
Is the filename of the (to be) compressed file.
``variant``
``variant``
...........
...........
**Optional**
**Optional**
Is the variant you want to apply to your CSS. This allow you to embed images
Is the variant you want to apply to your CSS. This allow you to embed images
and fonts in CSS with data-URI.
and fonts in CSS with data-URI.
Allowed values are : ``None`` and ``datauri``.
Allowed values are : ``None`` and ``datauri``.
Defaults to ``None``.
Defaults to ``None``.
``template_name``
``template_name``
.................
.................
**Optional**
**Optional**
Name of the template used to render ``<script>`` for js package or ``<link>`` for css package.
Name of the template used to render ``<script>`` for js package or ``<link>`` for css package.
Defaults to ``None``.
Defaults to ``None``.
``extra_context``
``extra_context``
.................
.................
**Optional**
**Optional**
Is a dictionary of values to add to the template context,
Is a dictionary of values to add to the template context,
when generating the HTML for the HTML-tags with the templatetags.
when generating the HTML for the HTML-tags with the templatetags.
For CSS, if you do not specify ``extra_context``/``media``, the default media in
For CSS, if you do not specify ``extra_context``/``media``, the default media in
the ``<link>`` output will be ``media="all"``.
the ``<link>`` output will be ``media="all"``.
...
@@ -119,8 +119,8 @@ Other settings
...
@@ -119,8 +119,8 @@ Other settings
Compressor class to be applied to CSS files.
Compressor class to be applied to CSS files.
If empty or ``None``, CSS files won't be compressed.
If empty or ``None``, CSS files won't be compressed.
Defaults to ``'pipeline.compressors.yu
i.YUI
Compressor'``.
Defaults to ``'pipeline.compressors.yu
glify.Yuglify
Compressor'``.
``PIPELINE_JS_COMPRESSOR``
``PIPELINE_JS_COMPRESSOR``
...........................
...........................
...
@@ -128,12 +128,12 @@ Other settings
...
@@ -128,12 +128,12 @@ Other settings
Compressor class to be applied to JavaScript files.
Compressor class to be applied to JavaScript files.
If empty or ``None``, JavaScript files won't be compressed.
If empty or ``None``, JavaScript files won't be compressed.
Defaults to ``'pipeline.compressors.yu
i.YUI
Compressor'``
Defaults to ``'pipeline.compressors.yu
glify.Yuglify
Compressor'``
.. note::
.. note::
Please note that in order to use Y
UI Compressor, you need to install YUI Compressor
(see :doc:`installation` for more details).
Please note that in order to use Y
uglify compressor, you need to install Yuglify
(see :doc:`installation` for more details).
``PIPELINE_TEMPLATE_NAMESPACE``
``PIPELINE_TEMPLATE_NAMESPACE``
...............................
...............................
...
@@ -159,15 +159,15 @@ Other settings
...
@@ -159,15 +159,15 @@ Other settings
Pipeline doesn't bundle a javascript template library, but the default
Pipeline doesn't bundle a javascript template library, but the default
setting is to use the
setting is to use the
`underscore <http://documentcloud.github.com/underscore/>`_ template function.
`underscore <http://documentcloud.github.com/underscore/>`_ template function.
Defaults to ``"_.template"``
Defaults to ``"_.template"``
Embedding fonts and images
Embedding fonts and images
==========================
==========================
You can embed fonts and images directly in your compiled css, using Data-URI in
You can embed fonts and images directly in your compiled css, using Data-URI in
modern browsers.
modern browsers.
To do so, setup variant group options to the method you wish to use : ::
To do so, setup variant group options to the method you wish to use : ::
...
@@ -198,14 +198,14 @@ You can override these rules using the following settings:
...
@@ -198,14 +198,14 @@ You can override these rules using the following settings:
Setting that controls the maximum image size (in bytes) to embed in CSS using Data-URIs.
Setting that controls the maximum image size (in bytes) to embed in CSS using Data-URIs.
Internet Explorer 8 has issues with assets under 32 kilobytes.
Internet Explorer 8 has issues with assets under 32 kilobytes.
Defaults to ``32700``
Defaults to ``32700``
``PIPELINE_EMBED_PATH``
``PIPELINE_EMBED_PATH``
.......................
.......................
Setting the directory that an asset needs to be in so that it is embedded
Setting the directory that an asset needs to be in so that it is embedded
Defaults to ``r'[/]?embed/'``
Defaults to ``r'[/]?embed/'``
...
...
docs/installation.rst
View file @
0e70c5da
...
@@ -5,9 +5,9 @@ Installation
...
@@ -5,9 +5,9 @@ Installation
============
============
1. Either check out Pipeline from GitHub_ or to pull a release off PyPI_ ::
1. Either check out Pipeline from GitHub_ or to pull a release off PyPI_ ::
pip install django-pipeline
pip install django-pipeline
2. Add 'pipeline' to your ``INSTALLED_APPS`` ::
2. Add 'pipeline' to your ``INSTALLED_APPS`` ::
...
@@ -21,7 +21,7 @@ Installation
...
@@ -21,7 +21,7 @@ Installation
.. note::
.. note::
You need to use ``Django>=1.4`` or ``django-staticfiles>=1.2.1`` to be able to use this version of pipeline.
You need to use ``Django>=1.4`` or ``django-staticfiles>=1.2.1`` to be able to use this version of pipeline.
.. _GitHub: http://github.com/cyberdelia/django-pipeline
.. _GitHub: http://github.com/cyberdelia/django-pipeline
.. _PyPI: http://pypi.python.org/pypi/django-pipeline
.. _PyPI: http://pypi.python.org/pypi/django-pipeline
...
@@ -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 y
uglify.
Pipeline's default CSS and JS compressor is
Y
uglify.
y
uglify wraps UglifyJS and cssmin, applying the default YUI configurations to them.
Y
uglify 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.
...
...
pipeline/compressors/yuglify.py
0 → 100644
View file @
0e70c5da
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
)
pipeline/conf/settings.py
View file @
0e70c5da
...
@@ -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.yu
i.YUI
Compressor'
)
'pipeline.compressors.yu
glify.Yuglify
Compressor'
)
PIPELINE_JS_COMPRESSOR
=
getattr
(
settings
,
'PIPELINE_JS_COMPRESSOR'
,
PIPELINE_JS_COMPRESSOR
=
getattr
(
settings
,
'PIPELINE_JS_COMPRESSOR'
,
'pipeline.compressors.yu
i.YUI
Compressor'
)
'pipeline.compressors.yu
glify.Yuglify
Compressor'
)
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'
,
''
)
...
...
tests/tests/test_compressor.py
View file @
0e70c5da
...
@@ -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.yu
i
import
YUI
Compressor
from
pipeline.compressors.yu
glify
import
Yuglify
Compressor
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
,
Y
UI
Compressor
)
self
.
assertEquals
(
self
.
compressor
.
js_compressor
,
Y
uglify
Compressor
)
def
test_css_compressor_class
(
self
):
def
test_css_compressor_class
(
self
):
self
.
assertEquals
(
self
.
compressor
.
css_compressor
,
Y
UI
Compressor
)
self
.
assertEquals
(
self
.
compressor
.
css_compressor
,
Y
uglify
Compressor
)
def
test_concatenate_and_rewrite
(
self
):
def
test_concatenate_and_rewrite
(
self
):
css
=
self
.
compressor
.
concatenate_and_rewrite
([
css
=
self
.
compressor
.
concatenate_and_rewrite
([
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment