Commit 2c68d7be by Timothée Peignier

change cssmin compressor

parent 5ca05981
...@@ -158,18 +158,29 @@ To us it for your stylesheets add this to your ``PIPELINE_CSS_COMPRESSOR`` :: ...@@ -158,18 +158,29 @@ To us it for your stylesheets add this to your ``PIPELINE_CSS_COMPRESSOR`` ::
Default to ``'--template=highest'`` Default to ``'--template=highest'``
cssmin compressor CSSMin compressor
================= =================
The cssmin compressor uses the `cssmin <http://pypi.python.org/pypi/cssmin/>`_ The cssmin compressor uses the `cssmin <https://github.com/jbleuzen/node-cssmin>`_
Python library to compress stylesheets. To use it, specify this command to compress stylesheets. To use it, add this to your ``PIPELINE_CSS_COMPRESSOR`` ::
``PIPELINE_CSS_COMPRESSOR`` ::
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.cssmin.CssminCompressor' PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.cssmin.CSSMinCompressor'
Install the cssmin library with your favorite Python package manager. E.g. :: ``PIPELINE_CSSMIN_BINARY``
---------------------------
Command line to execute for cssmin program.
You will most likely change this to the location of cssmin on your system.
Defaults to ``'/usr/bin/env cssmin'``
``PIPELINE_CSSMIN_ARGUMENTS``
------------------------------
Additional arguments to use when cssmin is called.
Default to ``''``
pip install cssmin
Write your own compressor class Write your own compressor class
=============================== ===============================
......
from __future__ import absolute_import from pipeline.conf import settings
from pipeline.compressors import SubProcessCompressor
from pipeline.compressors import CompressorBase
class CSSMinCompressor(SubProcessCompressor):
class CssminCompressor(CompressorBase):
"""
CSS compressor based on the Python library cssmin
(http://pypi.python.org/pypi/cssmin/).
"""
def compress_css(self, css): def compress_css(self, css):
from cssmin import cssmin command = "%s %s" % (settings.PIPELINE_CSSMIN_BINARY, settings.PIPELINE_CSSMIN_ARGUMENTS)
return cssmin(css) return self.execute_command(command, css)
...@@ -37,6 +37,9 @@ PIPELINE_CLOSURE_ARGUMENTS = getattr(settings, 'PIPELINE_CLOSURE_ARGUMENTS', '') ...@@ -37,6 +37,9 @@ PIPELINE_CLOSURE_ARGUMENTS = getattr(settings, 'PIPELINE_CLOSURE_ARGUMENTS', '')
PIPELINE_UGLIFYJS_BINARY = getattr(settings, 'PIPELINE_UGLIFYJS_BINARY', '/usr/bin/env uglifyjs') PIPELINE_UGLIFYJS_BINARY = getattr(settings, 'PIPELINE_UGLIFYJS_BINARY', '/usr/bin/env uglifyjs')
PIPELINE_UGLIFYJS_ARGUMENTS = getattr(settings, 'PIPELINE_UGLIFYJS_ARGUMENTS', '') PIPELINE_UGLIFYJS_ARGUMENTS = getattr(settings, 'PIPELINE_UGLIFYJS_ARGUMENTS', '')
PIPELINE_CSSMIN_BINARY = getattr(settings, 'PIPELINE_CSSMIN_BINARY', '/usr/bin/env cssmin')
PIPELINE_CSSMIN_ARGUMENTS = getattr(settings, 'PIPELINE_CSSMIN_ARGUMENTS', '')
PIPELINE_COFFEE_SCRIPT_BINARY = getattr(settings, 'PIPELINE_COFFEE_SCRIPT_BINARY', '/usr/bin/env coffee') PIPELINE_COFFEE_SCRIPT_BINARY = getattr(settings, 'PIPELINE_COFFEE_SCRIPT_BINARY', '/usr/bin/env coffee')
PIPELINE_COFFEE_SCRIPT_ARGUMENTS = getattr(settings, 'PIPELINE_COFFEE_SCRIPT_ARGUMENTS', '') PIPELINE_COFFEE_SCRIPT_ARGUMENTS = getattr(settings, 'PIPELINE_COFFEE_SCRIPT_ARGUMENTS', '')
......
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