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
bf5ecf27
Commit
bf5ecf27
authored
Jun 03, 2011
by
Timothée Peignier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one compressor ought to be enough for anybody, but I might be wrong
parent
5ed85860
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
53 deletions
+32
-53
docs/compressors.rst
+14
-24
docs/configuration.rst
+6
-9
pipeline/compressors/__init__.py
+8
-10
pipeline/conf/settings.py
+4
-10
No files found.
docs/compressors.rst
View file @
bf5ecf27
...
...
@@ -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 us
e 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_COMPRESSOR
S
`` ::
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_COMPRESSOR
S
`` ::
To use it add this to your ``PIPELINE_JS_COMPRESSOR`` ::
PIPELINE_JS_COMPRESSOR
S
= (
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_COMPRESSOR
S
`` ::
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_COMPRESSOR
S
`` ::
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_COMPRESSOR
S
`` ::
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_COMPRESSOR
S
`` or
``PIPELINE_JS_COMPRESSOR
S
`` (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
-------
...
...
docs/configuration.rst
View file @
bf5ecf27
...
...
@@ -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_COMPRESSOR
S
``
``PIPELINE_CSS_COMPRESSOR``
............................
A tuple of compressor
s to be applied to CSS files.
Compressor clas
s to be applied to CSS files.
Defaults to ``
('pipeline.compressors.yui.YUICompressor',)
``.
Defaults to ``
'pipeline.compressors.yui.YUICompressor'
``.
``PIPELINE_JS_COMPRESSOR
S
``
``PIPELINE_JS_COMPRESSOR``
...........................
A tuple of compressor
s to be applied to JavaScript files.
Compressor clas
s 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::
...
...
pipeline/compressors/__init__.py
View file @
bf5ecf27
...
...
@@ -35,28 +35,26 @@ class Compressor(object):
def
__init__
(
self
,
verbose
=
False
):
self
.
verbose
=
verbose
def
js_compressor
s
(
self
):
return
[
to_class
(
compressor
)
for
compressor
in
settings
.
PIPELINE_JS_COMPRESSORS
]
js_compressor
s
=
property
(
js_compressors
)
def
js_compressor
(
self
):
return
to_class
(
settings
.
PIPELINE_JS_COMPRESSOR
)
js_compressor
=
property
(
js_compressor
)
def
css_compressor
s
(
self
):
return
[
to_class
(
compressor
)
for
compressor
in
settings
.
PIPELINE_CSS_COMPRESSORS
]
css_compressor
s
=
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"
:
...
...
pipeline/conf/settings.py
View file @
bf5ecf27
...
...
@@ -18,12 +18,12 @@ PIPELINE_VERSIONING = getattr(settings, 'PIPELINE_VERSIONING', 'pipeline.version
PIPELINE_STORAGE
=
getattr
(
settings
,
'PIPELINE_STORAGE'
,
'pipeline.storage.CompressStorage'
)
PIPELINE_CSS_COMPRESSOR
S
=
getattr
(
settings
,
'PIPELINE_CSS_COMPRESSORS'
,
[
PIPELINE_CSS_COMPRESSOR
=
getattr
(
settings
,
'PIPELINE_CSS_COMPRESSOR'
,
'pipeline.compressors.yui.YUICompressor'
]
)
PIPELINE_JS_COMPRESSOR
S
=
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
=
[]
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