Commit 04f169cb by Timothée Peignier

forking django-compress into django-pipeline

parent 9d1394be
django-compress was originally created by Andreas Pelme <andreas@pelme.se> in
2008.
Pipeline is a fork of django-compress which was originally created by
Andreas Pelme <andreas@pelme.se> in 2008.
These people have provided bug fixes, new features, improved the documentation
or just made django-compress more awesome.
or just made Pipeline more awesome.
* Alexander Artemenko <svetlyak40wt>
* Andreas Cederström <andreas@klydd.se>
......@@ -21,6 +21,6 @@ or just made django-compress more awesome.
* Ara Anjargolian <ara818@gmail.com>
* Timothée Peignier <timothee.peignier@tryphon.org>
The Python-version of jsmin (http://www.crockford.com/javascript/jsmin.html)
is included in django-compress. It was translated from to Python by Baruch
The python version of jsmin (http://www.crockford.com/javascript/jsmin.html)
is included in Pipeline. It was translated from to Python by Baruch
Evan, from the original jsmin implementation by Douglas Crockford.
django-compress
---------------
Pipeline
--------
Copyright (c) 2008 Andreas Pelme <andreas@pelme.se>
Copyright (c) 2011 Timothée Peignier <timothee.peignier@tryphon.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
recursive-include compress/templates *.html
recursive-include pipeline/templates *.html
include docs/*
include AUTHORS
include LICENSE
django-compress
===============
Pipeline
========
django-compress is an asset packaging library for Django, providing both CSS and JavaScript concatenation and compression, built-in JavaScript template support, and optional data-URI image embedding.
Pipeline is an asset packaging library for Django, providing both CSS and JavaScript concatenation and compression, built-in JavaScript template support, and optional data-URI image embedding.
To install it :
pip install -e git://github.com/cyberdelia/django-compress.git#egg=compress
pip install -e git://github.com/cyberdelia/django-pipeline.git#egg=pipeline
For documentation, usage, and examples, see :
http://django-compress.readthedocs.org/
http://django-pipeline.readthedocs.org/
To suggest a feature or report a bug :
https://github.com/cyberdelia/django-compress/issues
https://github.com/cyberdelia/django-pipeline/issues
from django.conf import settings
COMPRESS_ROOT = getattr(settings, 'COMPRESS_ROOT', settings.MEDIA_ROOT)
COMPRESS_URL = getattr(settings, 'COMPRESS_URL', settings.MEDIA_URL)
COMPRESS = getattr(settings, 'COMPRESS', not settings.DEBUG)
COMPRESS_SOURCE = getattr(settings, 'COMPRESS_SOURCE', settings.STATIC_ROOT)
COMPRESS_ROOT = getattr(settings, 'COMPRESS_ROOT', settings.STATIC_ROOT)
COMPRESS_URL = getattr(settings, 'COMPRESS_URL', settings.STATIC_URL)
COMPRESS_AUTO = getattr(settings, 'COMPRESS_AUTO', True)
COMPRESS_VERSION = getattr(settings, 'COMPRESS_VERSION', False)
COMPRESS_VERSION_PLACEHOLDER = getattr(settings, 'COMPRESS_VERSION_PLACEHOLDER', '?')
COMPRESS_VERSION_DEFAULT = getattr(settings, 'COMPRESS_VERSION_DEFAULT', '0')
COMPRESS_VERSION_REMOVE_OLD = getattr(settings, 'COMPRESS_VERSION_REMOVE_OLD', True)
COMPRESS_VERSIONING = getattr(settings, 'COMPRESS_VERSIONING', 'compress.versioning.mtime.MTimeVersioning')
COMPRESS_STORAGE = getattr(settings, 'COMPRESS_STORAGE',
'compress.storage.CompressStorage')
COMPRESS_CSS_COMPRESSORS = getattr(settings, 'COMPRESS_CSS_COMPRESSORS', [
'compress.compressors.yui.YUICompressor'
])
COMPRESS_JS_COMPRESSORS = getattr(settings, 'COMPRESS_JS_COMPRESSORS', [
'compress.compressors.yui.YUICompressor'
])
COMPRESS_COMPILERS = getattr(settings, 'COMPRESS_COMPILERS', [])
COMPRESS_CSS = getattr(settings, 'COMPRESS_CSS', {})
COMPRESS_JS = getattr(settings, 'COMPRESS_JS', {})
COMPRESS_TEMPLATE_NAMESPACE = getattr(settings, 'COMPRESS_TEMPLATE_NAMESPACE', "window.JST")
COMPRESS_TEMPLATE_EXT = getattr(settings, 'COMPRESS_TEMPLATE_EXT', ".jst")
COMPRESS_TEMPLATE_FUNC = getattr(settings, 'COMPRESS_TEMPLATE_FUNC', "_.template")
COMPRESS_CSSTIDY_BINARY = '/usr/local/bin/csstidy'
COMPRESS_CSSTIDY_ARGUMENTS = '--template=highest'
COMPRESS_YUI_BINARY = getattr(settings, 'COMPRESS_YUI_BINARY', '/usr/local/bin/yuicompressor')
COMPRESS_YUI_CSS_ARGUMENTS = getattr(settings, 'COMPRESS_YUI_CSS_ARGUMENTS', '')
COMPRESS_YUI_JS_ARGUMENTS = getattr(settings, 'COMPRESS_YUI_JS_ARGUMENTS', '')
COMPRESS_CLOSURE_BINARY = getattr(settings, 'COMPRESS_CLOSURE_BINARY', '/usr/local/bin/closure')
COMPRESS_CLOSURE_ARGUMENTS = getattr(settings, 'COMPRESS_CLOSURE_ARGUMENTS', '')
COMPRESS_UGLIFYJS_BINARY = getattr(settings, 'COMPRESS_UGLIFYJS_BINARY', '/usr/local/bin/uglifyjs')
COMPRESS_UGLIFYJS_ARGUMENTS = getattr(settings, 'COMPRESS_UGLIFYJS_ARGUMENTS', '')
COMPRESS_COFFEE_SCRIPT_BINARY = getattr(settings, 'COMPRESS_COFFEE_SCRIPT_BINARY', '/usr/local/bin/coffee')
COMPRESS_COFFEE_SCRIPT_ARGUMENTS = getattr(settings, 'COMPRESS_COFFEE_SCRIPT_ARGUMENTS', '')
COMPRESS_SASS_BINARY = getattr(settings, 'COMPRESS_SASS_BINARY', '/usr/local/bin/sass')
COMPRESS_SASS_ARGUMENTS = getattr(settings, 'COMPRESS_SASS_ARGUMENTS', '')
COMPRESS_LESS_BINARY = getattr(settings, 'COMPRESS_LESS_BINARY', '/usr/local/bin/lessc')
COMPRESS_LESS_ARGUMENTS = getattr(settings, 'COMPRESS_LESS_ARGUMENTS', '')
if COMPRESS_CSS_COMPRESSORS is None:
COMPRESS_CSS_COMPRESSORS = []
if COMPRESS_JS_COMPRESSORS is None:
COMPRESS_JS_COMPRESSORS = []
if COMPRESS_COMPILERS is None:
COMPRESS_COMPILERS = []
......@@ -72,17 +72,17 @@ qthelp:
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/django-compress.qhcp"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/django-pipeline.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/django-compress.qhc"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/django-pipeline.qhc"
devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/django-compress"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/django-compress"
@echo "# mkdir -p $$HOME/.local/share/devhelp/django-pipeline"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/django-pipeline"
@echo "# devhelp"
epub:
......
......@@ -33,9 +33,9 @@ Therefore it is completely rewritten without any thoughts on backwards compatibi
This changeset also introduces a couple of other changes that could potentially break old code.
* The `bump_filename` option was removed from the group settings. There is no need specifying it for ALL groups, if you actually use it, you most likely want to use it on all your compressed files.
* The bump_filename options is replaced by the setting COMPRESS_VERSION, and is completely ignored.
* The bump_filename options is replaced by the setting PIPELINE_VERSION, and is completely ignored.
* The querystring is no longer used to determine a files version, since it was use
* If ``COMPRESS_VERSION`` is used, you specify the version part of the `output_filename` file with '?'. This placeholder can be changed with COMPRESS_VERSION_PLACEHOLDER.
* If ``PIPELINE_VERSION`` is used, you specify the version part of the `output_filename` file with '?'. This placeholder can be changed with PIPELINE_VERSION_PLACEHOLDER.
E.g.::
......@@ -44,13 +44,13 @@ E.g.::
'output_filename': 'c/screen.r?.css',
},
* ``COMPRESS_VERSION`` requires ``COMPRESS_AUTO`` to be enabled.
``COMPRESS_AUTO`` is enabled by default, but if you explicitly set it to ``False`` an ``ImproperlyConfiguredError`` exception will be thrown.
* ``PIPELINE_VERSION`` requires ``PIPELINE_AUTO`` to be enabled.
``PIPELINE_AUTO`` is enabled by default, but if you explicitly set it to ``False`` an ``ImproperlyConfiguredError`` exception will be thrown.
``COMPRESS_AUTO`` changes
``PIPELINE_AUTO`` changes
* The CSS/Javascript files are not checked during Django's initialization anymore.
It was not really useful and did not make sense.
The automatic part is now handled by the templatetags (i.e. what used to be ``COMPRESS_TEMPLATE_AUTO``).
* ``COMPRESS_AUTO`` is replaced by ``COMPRESS_AUTO_TEMPLATE``, and the old behavior
of ``COMPRESS_AUTO`` is removed. This might be really confusing, the :doc:`configuration` should make it clear.
\ No newline at end of file
The automatic part is now handled by the templatetags (i.e. what used to be ``PIPELINE_TEMPLATE_AUTO``).
* ``PIPELINE_AUTO`` is replaced by ``PIPELINE_AUTO_TEMPLATE``, and the old behavior
of ``PIPELINE_AUTO`` is removed. This might be really confusing, the :doc:`configuration` should make it clear.
\ No newline at end of file
......@@ -11,13 +11,13 @@ Coffee Script compiler
The Coffee Script compiler use `Coffee Script <http://jashkenas.github.com/coffee-script/>`_
to compile your javascripts.
To use it add this to your ``COMPRESS_COMPILERS`` ::
To use it add this to your ``PIPELINE_COMPILERS`` ::
COMPRESS_COMPILERS = (
'compress.compilers.coffee.CoffeeScriptCompiler',
PIPELINE_COMPILERS = (
'pipeline.compilers.coffee.CoffeeScriptCompiler',
)
``COMPRESS_COFFEE_SCRIPT_BINARY``
``PIPELINE_COFFEE_SCRIPT_BINARY``
---------------------------------
Command line to execute for coffee program.
......@@ -25,7 +25,7 @@ To use it add this to your ``COMPRESS_COMPILERS`` ::
Defaults to ``'/usr/local/bin/coffee'``.
``COMPRESS_COFFEE_SCRIPT_ARGUMENTS``
``PIPELINE_COFFEE_SCRIPT_ARGUMENTS``
------------------------------------
Additional arguments to use when coffee is called.
......@@ -38,13 +38,13 @@ LESS compiler
The LESS compiler use `LESS <http://lesscss.org/>`_
to compile your stylesheets.
To use it add this to your ``COMPRESS_COMPILERS`` ::
To use it add this to your ``PIPELINE_COMPILERS`` ::
COMPRESS_COMPILERS = (
'compress.compilers.less.LessCompiler',
PIPELINE_COMPILERS = (
'pipeline.compilers.less.LessCompiler',
)
``COMPRESS_LESS_BINARY``
``PIPELINE_LESS_BINARY``
------------------------
Command line to execute for lessc program.
......@@ -52,7 +52,7 @@ To use it add this to your ``COMPRESS_COMPILERS`` ::
Defaults to ``'/usr/local/bin/lessc'``.
``COMPRESS_LESS_ARGUMENTS``
``PIPELINE_LESS_ARGUMENTS``
---------------------------
Additional arguments to use when lessc is called.
......@@ -65,14 +65,14 @@ SASS compiler
The SASS compiler use `SASS <http://sass-lang.com/>`_
to compile your stylesheets.
To use it add this to your ``COMPRESS_COMPILERS`` ::
To use it add this to your ``PIPELINE_COMPILERS`` ::
COMPRESS_COMPILERS = (
'compress.compilers.sass.SASSCompiler',
PIPELINE_COMPILERS = (
'pipeline.compilers.sass.SASSCompiler',
)
``COMPRESS_SASS_BINARY``
``PIPELINE_SASS_BINARY``
------------------------
Command line to execute for sass program.
......@@ -80,7 +80,7 @@ To use it add this to your ``COMPRESS_COMPILERS`` ::
Defaults to ``'/usr/local/bin/sass'``.
``COMPRESS_SASS_ARGUMENTS``
``PIPELINE_SASS_ARGUMENTS``
---------------------------
Additional arguments to use when sass is called.
......@@ -94,17 +94,17 @@ Write your own compiler class
To write your own compiler class, for example want to implement other types
of compilers.
All you need to do is to create a class that inherits from ``compress.compilers.CompilerBase``
All you need to do is to create a class that inherits from ``pipeline.compilers.CompilerBase``
and implements ``match_file`` and ``compile_file`` when needed.
Finally, specify it in the tuple of compilers ``COMPRESS_COMPILERS`` in the settings.
Finally, specify it in the tuple of compilers ``PIPELINE_COMPILERS`` in the settings.
Example
-------
A custom compiler for a imaginary compiler called jam ::
from compress.compilers import CompilerBase
from pipeline.compilers import CompilerBase
class JamCompiler(CompilerBase):
output_extension = 'js'
......
......@@ -8,7 +8,7 @@ Template tags
=============
If you need to change the output of the HTML-tags generated from the templatetags,
this can be done by overriding the templates ``compress/css.html`` and ``compress/js.html``.
this can be done by overriding the templates ``pipeline/css.html`` and ``pipeline/js.html``.
YUI Compressor compressor
......@@ -17,20 +17,20 @@ 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 ``COMPRESS_CSS_COMPRESSORS`` ::
To us it for your stylesheets add this to your ``PIPELINE_CSS_COMPRESSORS`` ::
COMPRESS_CSS_COMPRESSORS = (
'compress.compressors.yui.YUICompressor',
PIPELINE_CSS_COMPRESSORS = (
'pipeline.compressors.yui.YUICompressor',
)
To use it for your javascripts add this to your ``COMPRESS_JS_COMPRESSORS`` ::
To use it for your javascripts add this to your ``PIPELINE_JS_COMPRESSORS`` ::
COMPRESS_JS_COMPRESSORS = (
'compress.compressors.yui.YUICompressor',
PIPELINE_JS_COMPRESSORS = (
'pipeline.compressors.yui.YUICompressor',
)
``COMPRESS_YUI_BINARY``
``PIPELINE_YUI_BINARY``
-----------------------
Command line to execute for the YUI program.
......@@ -38,14 +38,14 @@ To use it for your javascripts add this to your ``COMPRESS_JS_COMPRESSORS`` ::
Defaults to ``'/usr/local/bin/yuicompressor'``.
``COMPRESS_YUI_CSS_ARGUMENTS``
``PIPELINE_YUI_CSS_ARGUMENTS``
------------------------------
Additional arguments to use when compressing CSS.
Defaults to ``''``.
``COMPRESS_YUI_JS_ARGUMENTS``
``PIPELINE_YUI_JS_ARGUMENTS``
-----------------------------
Additional arguments to use when compressing JavaScript.
......@@ -59,14 +59,14 @@ 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 ``COMPRESS_JS_COMPRESSORS`` ::
To use it add this to your ``PIPELINE_JS_COMPRESSORS`` ::
COMPRESS_JS_COMPRESSORS = (
'compress.compressors.closure.ClosureCompressor',
PIPELINE_JS_COMPRESSORS = (
'pipeline.compressors.closure.ClosureCompressor',
)
``COMPRESS_CLOSURE_BINARY``
``PIPELINE_CLOSURE_BINARY``
---------------------------
Command line to execute for the Closure Compiler program.
......@@ -74,7 +74,7 @@ To use it add this to your ``COMPRESS_JS_COMPRESSORS`` ::
Default to ``'/usr/local/bin/closure'``
``COMPRESS_CLOSURE_ARGUMENTS``
``PIPELINE_CLOSURE_ARGUMENTS``
------------------------------
Additional arguments to use when closure is called.
......@@ -88,14 +88,14 @@ UglifyJS compressor
The UglifyJS compressor use `UglifyJS <https://github.com/mishoo/UglifyJS/>`_ to
compress javascripts.
To use it add this to your ``COMPRESS_JS_COMPRESSORS`` ::
To use it add this to your ``PIPELINE_JS_COMPRESSORS`` ::
COMPRESS_JS_COMPRESSORS = (
'compress.compressors.uglifyjs.UglifyJSCompressor',
PIPELINE_JS_COMPRESSORS = (
'pipeline.compressors.uglifyjs.UglifyJSCompressor',
)
``COMPRESS_UGLIFYJS_BINARY``
``PIPELINE_UGLIFYJS_BINARY``
----------------------------
Command line to execute for the Closure Compiler program.
......@@ -103,7 +103,7 @@ To use it add this to your ``COMPRESS_JS_COMPRESSORS`` ::
Defaults to ``'/usr/local/bin/uglifyjs'``.
``COMPRESS_UGLIFYJS_ARGUMENTS``
``PIPELINE_UGLIFYJS_ARGUMENTS``
-------------------------------
Additional arguments to use when uglifyjs is called.
......@@ -117,10 +117,10 @@ JSMin compressor
The jsmin compressor use Douglas Crockford jsmin tool to
compress javascripts.
To use it add this to your ``COMPRESS_JS_COMPRESSORS`` ::
To use it add this to your ``PIPELINE_JS_COMPRESSORS`` ::
COMPRESS_JS_COMPRESSORS = (
'compress.compressors.jsmin.JSMinCompressor',
PIPELINE_JS_COMPRESSORS = (
'pipeline.compressors.jsmin.JSMinCompressor',
)
CSSTidy compressor
......@@ -129,13 +129,13 @@ CSSTidy compressor
The CSStidy compressor use `CSStidy <http://csstidy.sourceforge.net/>`_ to compress
stylesheets.
To us it for your stylesheets add this to your ``COMPRESS_CSS_COMPRESSORS`` ::
To us it for your stylesheets add this to your ``PIPELINE_CSS_COMPRESSORS`` ::
COMPRESS_CSS_COMPRESSORS = (
'compress.compressors.csstidy.CSSTidyCompressor',
PIPELINE_CSS_COMPRESSORS = (
'pipeline.compressors.csstidy.CSSTidyCompressor',
)
``COMPRESS_CSSTIDY_BINARY``
``PIPELINE_CSSTIDY_BINARY``
---------------------------
Command line to execute for csstidy program.
......@@ -143,7 +143,7 @@ To us it for your stylesheets add this to your ``COMPRESS_CSS_COMPRESSORS`` ::
Defaults to ``'/usr/local/bin/csstidy'``
``COMPRESS_CSSTIDY_ARGUMENTS``
``PIPELINE_CSSTIDY_ARGUMENTS``
------------------------------
Additional arguments to use when csstidy is called.
......@@ -157,18 +157,18 @@ Write your own compressor class
To write your own compressor class, for example want to implement other types
of compressors.
All you need to do is to create a class that inherits from ``compress.compressors.CompressorBase``
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 ``COMPRESS_CSS_COMPRESSORS`` or
``COMPRESS_JS_COMPRESSORS`` (see :doc:`configuration` for more information) in the settings.
Finally, specify it in the tuple of compressors ``PIPELINE_CSS_COMPRESSORS`` or
``PIPELINE_JS_COMPRESSORS`` (see :doc:`configuration` for more information) in the settings.
Example
-------
A custom compressor for a imaginary compressor called jam ::
from compress.compressors import CompressorBase
from pipeline.compressors import CompressorBase
class JamCompressor(CompressorBase):
def compress_js(self, js):
......
# -*- coding: utf-8 -*-
#
# django-compress documentation build configuration file, created by
# Pipeline documentation build configuration file, created by
# sphinx-quickstart on Sat Apr 30 17:47:55 2011.
#
# This file is execfile()d with the current directory set to its containing dir.
......@@ -40,8 +40,8 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'django-compress'
copyright = u'2011, Andreas Pelme'
project = u'django-pipeline'
copyright = u'2011, Timothée Peignier'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
......@@ -164,7 +164,7 @@ html_static_path = ['_static']
#html_file_suffix = None
# Output file base name for HTML help builder.
htmlhelp_basename = 'django-compressdoc'
htmlhelp_basename = 'django-pipelinedoc'
# -- Options for LaTeX output --------------------------------------------------
......@@ -178,8 +178,8 @@ htmlhelp_basename = 'django-compressdoc'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'django-compress.tex', u'django-compress Documentation',
u'Andreas Pelme', 'manual'),
('index', 'django-pipeline.tex', u'Pipeline Documentation',
u'Timothée Peignier', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of
......@@ -211,6 +211,6 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'django-compress', u'django-compress Documentation',
[u'Andreas Pelme'], 1)
('index', 'django-pipeline', u'Pipeline Documentation',
[u'Timothée Peignier'], 1)
]
......@@ -5,7 +5,7 @@ Configuration
=============
Configuration and list of available settings for django-compress
Configuration and list of available settings for Pipeline
.. note::
......@@ -19,7 +19,7 @@ syntax to select multiples files.
The basic syntax for specifying CSS/JavaScript groups files is ::
COMPRESS_CSS = {
PIPELINE_CSS = {
'group_one': {
'source_filenames': (
'css/style.css',
......@@ -35,7 +35,7 @@ The basic syntax for specifying CSS/JavaScript groups files is ::
# other CSS groups goes here
}
COMPRESS_JS = {
PIPELINE_JS = {
'all': {
'source_filenames': (
'js/jquery-1.2.3.js',
......@@ -91,21 +91,21 @@ Group options
.. note::
Note that all filenames are specified relative to ``COMPRESS_ROOT``, and thus the source
files needs to be in your ``COMPRESS_ROOT``.
Note that all filenames are specified relative to ``PIPELINE_ROOT``, and thus the source
files needs to be in your ``PIPELINE_ROOT``.
Other settings
--------------
``COMPRESS``
``PIPELINE``
............
When ``COMPRESS`` is ``True``, CSS and JavaScripts will be concatenated and filtered.
When ``PIPELINE`` is ``True``, CSS and JavaScripts will be concatenated and filtered.
When ``False``, the source-files will be used instead.
Defaults to ``not DEBUG`` (compressed files will only be used when ``DEBUG`` is ``False``).
``COMPRESS_AUTO``
``PIPELINE_AUTO``
.................
Auto-generate CSS and JavaScript files whenever needed, when the template tags
......@@ -120,7 +120,7 @@ Other settings
Defaults to ``True``.
``COMPRESS_VERSION``
``PIPELINE_VERSION``
....................
Regulates whether or not to add a "version number" to the outputted files
......@@ -128,10 +128,10 @@ Other settings
For more information, see :doc:`farfutureexpires`.
When you specify ``COMPRESS_VERSION`` you will also need to add a placeholder
When you specify ``PIPELINE_VERSION`` you will also need to add a placeholder
(which by default is ``?``) for the version number in the ``output_filename`` setting.
``COMPRESS_VERSION_REMOVE_OLD``
``PIPELINE_VERSION_REMOVE_OLD``
...............................
When ``True``, old compressed files will be removed when new versions are generated.
......@@ -145,9 +145,9 @@ Other settings
Example::
COMPRESS = True
COMPRESS_VERSION = True
COMPRESS_CSS = {
PIPELINE = True
PIPELINE_VERSION = True
PIPELINE_CSS = {
'screen': {
'source_filenames': (
'css/screen/style.css', 'css/screen/paginator.css',
......@@ -161,28 +161,28 @@ 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.
``COMPRESS_CSS_COMPRESSORS``
``PIPELINE_CSS_COMPRESSORS``
............................
A tuple of compressors to be applied to CSS files.
Defaults to ``('compress.compressors.yui.YUICompressor',)``.
Defaults to ``('pipeline.compressors.yui.YUICompressor',)``.
``COMPRESS_JS_COMPRESSORS``
``PIPELINE_JS_COMPRESSORS``
...........................
A tuple of compressors to be applied to JavaScript files.
Defaults to ``('compress.compressors.yui.YUICompressor',)``
Defaults to ``('pipeline.compressors.yui.YUICompressor',)``
Also ``COMPRESS_*_COMPRESSORS`` can be set to an empty tuple or ``None`` to not use any compressor.
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.
.. note::
Please note that in order to use YUI Compressor, you need to install YUI Compressor (see :doc:`installation` for more details).
``COMPRESS_TEMPLATE_NAMESPACE``
``PIPELINE_TEMPLATE_NAMESPACE``
...............................
Object name where all of your compiled templates will be added, from within your browser.
......@@ -191,19 +191,19 @@ The files will however still be concatenated to one file.
Defaults to ``"window.JST"``
``COMPRESS_TEMPLATE_EXT``
``PIPELINE_TEMPLATE_EXT``
.........................
The extension for which django-compress will consider the file as a Javascript templates.
The extension for which Pipeline will consider the file as a Javascript templates.
To use a different extension, like ``.mustache``, set this settings to ``.mustache``.
Defaults to ``".jst"``
``COMPRESS_TEMPLATE_FUNC``
``PIPELINE_TEMPLATE_FUNC``
..........................
JavaScript function that compiles your JavaScript templates.
django-compress doesn't bundle a javascript template library, but the default
Pipeline doesn't bundle a javascript template library, but the default
settings is to use the
`underscore <http://documentcloud.github.com/underscore/>`_ template function.
......@@ -214,7 +214,7 @@ Rewriting CSS urls
==================
If source CSS contain a relative URL (i.e. relative to current file),
those URL will be converted to full relative path using ``COMPRESS_URL``.
those URL will be converted to full relative path using ``PIPELINE_URL``.
This conversion is performed before any compressors are applied ::
media/js/fancybox/
......@@ -237,17 +237,17 @@ In resulting CSS it will be rewritten to ::
background-image:url(/js/fancybox/fancybox-x.png);
background-image:url(/js/fancybox/fancybox-y.png);
(Assuming ``COMPRESS_URL`` is '' or '/', with non-empty ``COMPRESS_URL`` result will be another).
(Assuming ``PIPELINE_URL`` is '' or '/', with non-empty ``PIPELINE_URL`` result will be another).
External urls
=============
While django-compress does a great job of minimizing the amount of http requests
While Pipeline does a great job of minimizing the amount of http requests
on your site (hence increasing performance) there are sometimes cases when you
want to include external files as well. Let's take an example::
COMPRESS_JS = {
PIPELINE_JS = {
'jquery': {
'external_urls': (
'http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js',
......@@ -266,14 +266,14 @@ In template::
{% compressed_js 'jquery' %}
{% compressed_js 'all' %}
Output in when ``settings.COMPRESS = False``::
Output in when ``settings.PIPELINE = False``::
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.2/jquery-ui.min.js" charset="utf-8"></script>
<script type="text/javascript" src="/media/js/blog.js" charset="utf-8"></script>
<script type="text/javascript" src="/media/js/comments.js" charset="utf-8"></script>
Output in when ``settings.COMPRESS = True``::
Output in when ``settings.PIPELINE = True``::
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.2/jquery-ui.min.js" charset="utf-8"></script>
......
......@@ -4,7 +4,7 @@
Far future expires
==================
Details about the "Far future expires" technique, and how to implement it with help from django-compress
Details about the "Far future expires" technique, and how to implement it with help from Pipeline
General details and considerations about the "Far future expires" technique
===========================================================================
......@@ -30,10 +30,10 @@ This technique obviously has a drawback, when you want to change your files,
you need to change their names, since their URLs will be cached... that's right: forever!
The solution to that is pretty obvious too: change the URLs.
COMPRESS_VERSION
PIPELINE_VERSION
================
If you specify ``COMPRESS_VERSION`` in your configuration, you can add a placeholder
If you specify ``PIPELINE_VERSION`` in your configuration, you can add a placeholder
to the filenames to output the version number of the different files.
The filename itself will be changed when any of the source files are updated.
......
.. django-compress documentation master file, created by
sphinx-quickstart on Sat Apr 30 17:47:55 2011.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Introduction
============
django-compress is an asset packaging library for Django, providing
Pipeline is an asset packaging library for Django, providing
both CSS and JavaScript concatenation and compression, built-in JavaScript
template support, and optional data-URI image and font embedding.
You can report bugs and discuss features on the `issues page <https://github.com/cyberdelia/django-compress/issues>`_.
You can report bugs and discuss features on the `issues page <https://github.com/cyberdelia/django-pipeline/issues>`_.
Table Of Contents
=================
......
......@@ -4,26 +4,26 @@
Installation
============
1. Either check out django-compress 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-compress
pip install django-pipeline
2. Add 'compress' to your ``INSTALLED_APPS`` ::
INSTALLED_APPS = (
'compress',
'pipeline',
)
.. _GitHub: http://github.com/pelme/django-compress
.. _PyPI: http://pypi.python.org/
.. _GitHub: http://github.com/cyberdelia/django-pipeline
.. _PyPI: http://pypi.python.org/pypi/django-pipeline
Recommendations
===============
By default django-compress uses YUI Compressor to compress CSS and JS.
By default Pipeline uses YUI Compressor to compress CSS and JS.
YUI Compressor is an excellent stand-alone application for dealing with JS and CSS-files.
YUI Compressor can be downloaded from: http://developer.yahoo.com/yui/compressor/.
If you do not install YUI COMPRESSOR, make sure to disable the compressor in your settings.
If you do not install YUI Compressor, make sure to disable the compressor in your settings.
......@@ -95,9 +95,9 @@ if "%1" == "qthelp" (
echo.
echo.Build finished; now you can run "qcollectiongenerator" with the ^
.qhcp project file in %BUILDDIR%/qthelp, like this:
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\django-compress.qhcp
echo.^> qcollectiongenerator %BUILDDIR%\qthelp\django-pipeline.qhcp
echo.To view the help file:
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\django-compress.ghc
echo.^> assistant -collectionFile %BUILDDIR%\qthelp\django-pipeline.ghc
goto end
)
......
......@@ -4,12 +4,12 @@
Usage
=====
Describes how to use django-compress when it is installed and configured.
Describes how to use Pipeline when it is installed and configured.
Automated generation
====================
If ``COMPRESS`` and ``COMPRESS_AUTO`` is enabled (``True``), the source files
If ``PIPELINE`` and ``PIPELINE_AUTO`` is enabled (``True``), the source files
will be automatically updated, and re-generated if needed when invoked from the
templatetags.
The last modified time of the files will be compared, and if any of the
......@@ -32,7 +32,7 @@ To force all files to be re-generated, use the argument ``--force`` ::
Templatetags
============
django-compress includes two template tags: ``compressed_css`` and ``compressed_js``,
Pipeline includes two template tags: ``compressed_css`` and ``compressed_js``,
in a template library called ``compressed``.
They are used to output the ``<link>`` and ``<script>``-tags for the
......@@ -40,7 +40,7 @@ specified CSS/JavaScript-groups (as specified in the settings).
The first argument must be the name of the CSS/JavaScript group.
The templatetags will either output the source filenames or the compressed filenames,
depending on the ``COMPRESS`` setting, if you do not specify the ``COMPRESS`` setting,
depending on the ``PIPELINE`` setting, if you do not specify the ``PIPELINE`` setting,
the source files will be used in DEBUG-mode, and compressed files in non-DEBUG-mode.
Example
......@@ -58,12 +58,12 @@ with the name “scripts”, you would use the following code to output them all
Middleware
==========
To enable HTML compression add ``compress.middleware.MinifyHTMLMiddleware``,
To enable HTML compression add ``pipeline.middleware.MinifyHTMLMiddleware``,
to your ``MIDDLEWARE_CLASSES`` settings.
Ensure that it comes after any middleware which modify your HTML, like ``GZipMiddleware`` ::
MIDDLEWARE_CLASSES = (
'django.middleware.gzip.GZipMiddleware',
'compress.middleware.MinifyHTMLMiddleware',
'pipeline.middleware.MinifyHTMLMiddleware',
)
......@@ -26,14 +26,14 @@ MD5 version
To generate MD5 version strings, put this in your `settings.py` ::
COMPRESS_VERSIONING = 'compress.versioning.hash.MD5Versioning'
PIPELINE_VERSIONING = 'pipeline.versioning.hash.MD5Versioning'
SHA-1 version
-------------
To generate SHA-1 version strings, put this in your `settings.py`::
COMPRESS_VERSIONING = 'compress.versioning.hash.SHA1Versioning'
PIPELINE_VERSIONING = 'pipeline.versioning.hash.SHA1Versioning'
Git version
......@@ -52,7 +52,7 @@ Git revision version
To generate versions based on revision of every file in your source file list, put this in your `settings.py`::
COMPRESS_VERSIONING = 'compress.versioning.git.GitVersioningBase'
PIPELINE_VERSIONING = 'pipeline.versioning.git.GitVersioningBase'
Git HEAD last revision version
------------------------------
......@@ -60,7 +60,7 @@ Git HEAD last revision version
To generate versions based on the latest revision of HEAD in your git repository (which assumes all of your source files are in the
same repository), put this in your `settings.py`::
COMPRESS_VERSIONING = 'compress.versioning.git.GitHeadRevVersioning'
PIPELINE_VERSIONING = 'pipeline.versioning.git.GitHeadRevVersioning'
Write your own versioning class
===============================
......@@ -73,7 +73,7 @@ Example
For example, you want a short version string based on the SHA-1 version string.
You can do this by subclassing the SHA1Versioning class and overriding its get_version() method, like this::
from compress.versioning.hash import SHA1Versioning
from pipeline.versioning.hash import SHA1Versioning
class ShortSHA1Versioning(SHA1Versioning):
"""Custom SHA1Versioning class"""
......@@ -85,7 +85,7 @@ You can do this by subclassing the SHA1Versioning class and overriding its get_v
In your ``settings.py`` add::
COMPRESS_VERSIONING = 'app.module.ShortSHA1Versioning'
PIPELINE_VERSIONING = 'app.module.ShortSHA1Versioning'
.. note::
......@@ -100,7 +100,7 @@ Especially when calculating a hash on every request could be expensive.
To avoid this, make sure your source files are compressed before deployment,
and put the following settings in your production environment's ``settings.py``::
COMPRESS_AUTO = False
COMPRESS_VERSION = True
PIPELINE_AUTO = False
PIPELINE_VERSION = True
This way, the names of the compressed files will be looked up in the file system, instead of being evaluated and (if needed) regenerated on every request.
\ No newline at end of file
import os
import subprocess
from compress.conf import settings
from compress.storage import storage
from compress.utils import to_class
from pipeline.conf import settings
from pipeline.storage import storage
from pipeline.utils import to_class
class Compiler(object):
......@@ -11,7 +11,7 @@ class Compiler(object):
self.verbose = verbose
def compilers(self):
return [to_class(compiler) for compiler in settings.COMPRESS_COMPILERS]
return [to_class(compiler) for compiler in settings.PIPELINE_COMPILERS]
compilers = property(compilers)
def compile(self, paths):
......
from compress.conf import settings
from compress.compilers import SubProcessCompiler
from pipeline.conf import settings
from pipeline.compilers import SubProcessCompiler
class CoffeeScriptCompiler(SubProcessCompiler):
......@@ -9,7 +9,7 @@ class CoffeeScriptCompiler(SubProcessCompiler):
return path.endswith('.coffee')
def compile_file(self, content):
command = "%s -sc %s" % (settings.COMPRESS_COFFEE_SCRIPT_BINARY, settings.COMPRESS_COFFEE_SCRIPT_ARGUMENTS)
command = "%s -sc %s" % (settings.PIPELINE_COFFEE_SCRIPT_BINARY, settings.PIPELINE_COFFEE_SCRIPT_ARGUMENTS)
if self.verbose:
command += '--verbose'
return self.execute_command(command, content)
import os
import tempfile
from compress.conf import settings
from compress.compilers import CompilerBase
from pipeline.conf import settings
from pipeline.compilers import CompilerBase
class LessCompiler(CompilerBase):
......@@ -19,8 +19,8 @@ class LessCompiler(CompilerBase):
output_file = tempfile.NamedTemporaryFile(mode='w+b')
command = '%s %s %s %s' % (
settings.COMPRESS_LESS_BINARY, tmp_file.name,
settings.COMPRESS_LESS_ARGUMENTS, output_file.name
settings.PIPELINE_LESS_BINARY, tmp_file.name,
settings.PIPELINE_LESS_ARGUMENTS, output_file.name
)
command_output = os.popen(command).read()
......
from compress.conf import settings
from compress.compilers import SubProcessCompiler
from pipeline.conf import settings
from pipeline.compilers import SubProcessCompiler
class SASSCompiler(SubProcessCompiler):
......@@ -9,7 +9,7 @@ class SASSCompiler(SubProcessCompiler):
return filename.endswith('.scss')
def compile_file(self, content):
command = "%s --scss %s" % (settings.COMPRESS_SASS_BINARY, settings.COMPRESS_SASS_ARGUMENTS)
command = "%s --scss %s" % (settings.PIPELINE_SASS_BINARY, settings.PIPELINE_SASS_ARGUMENTS)
if self.verbose:
command += '--verbose'
return self.execute_command(command, content)
......@@ -4,9 +4,9 @@ import re
import subprocess
import urlparse
from compress.conf import settings
from compress.storage import storage
from compress.utils import to_class
from pipeline.conf import settings
from pipeline.storage import storage
from pipeline.utils import to_class
MAX_IMAGE_SIZE = 32700
......@@ -36,11 +36,11 @@ class Compressor(object):
self.verbose = verbose
def js_compressors(self):
return [to_class(compressor) for compressor in settings.COMPRESS_JS_COMPRESSORS]
return [to_class(compressor) for compressor in settings.PIPELINE_JS_COMPRESSORS]
js_compressors = property(js_compressors)
def css_compressors(self):
return [to_class(compressor) for compressor in settings.COMPRESS_CSS_COMPRESSORS]
return [to_class(compressor) for compressor in settings.PIPELINE_CSS_COMPRESSORS]
css_compressors = property(css_compressors)
def compress_js(self, paths, templates=None):
......@@ -66,7 +66,7 @@ class Compressor(object):
def compile_templates(self, paths):
compiled = ""
namespace = settings.COMPRESS_TEMPLATE_NAMESPACE
namespace = settings.PIPELINE_TEMPLATE_NAMESPACE
base_path = self.base_path(paths)
for path in paths:
contents = self.read_file(path)
......@@ -76,7 +76,7 @@ class Compressor(object):
compiled += "%s['%s'] = %s('%s');\n" % (
namespace,
name,
settings.COMPRESS_TEMPLATE_FUNC,
settings.PIPELINE_TEMPLATE_FUNC,
contents
)
return "\n".join([
......@@ -90,7 +90,7 @@ class Compressor(object):
name = os.path.basename(path)
if base:
name = re.sub(r"^%s\/(.*)%s$" % (
re.escape(base), re.escape(settings.COMPRESS_TEMPLATE_EXT)
re.escape(base), re.escape(settings.PIPELINE_TEMPLATE_EXT)
), r"\1", path)
return re.sub(r"[\/\\]", "_", name)
......@@ -135,7 +135,7 @@ class Compressor(object):
return "__EMBED__%s" % public_path
if not os.path.isabs(asset_path):
asset_path = self.relative_path(public_path)
return urlparse.urljoin(settings.COMPRESS_URL, asset_path[1:])
return urlparse.urljoin(settings.PIPELINE_URL, asset_path[1:])
def embeddable(self, path, variant):
name, ext = os.path.splitext(path)
......@@ -171,13 +171,13 @@ class Compressor(object):
def absolute_path(self, asset_path, css_path):
if os.path.isabs(asset_path):
path = os.path.join(settings.COMPRESS_ROOT, asset_path)
path = os.path.join(settings.PIPELINE_ROOT, asset_path)
else:
path = os.path.join(os.path.dirname(css_path), asset_path)
return os.path.normpath(path)
def relative_path(self, absolute_path):
compress_root = os.path.normpath(settings.COMPRESS_ROOT)
compress_root = os.path.normpath(settings.PIPELINE_ROOT)
return os.path.join('../', absolute_path.replace(compress_root, ''))
def read_file(self, path):
......
from compress.conf import settings
from compress.compressors import SubProcessCompressor
from pipeline.conf import settings
from pipeline.compressors import SubProcessCompressor
class ClosureCompressor(SubProcessCompressor):
def compress_js(self, js):
command = '%s %s' % (settings.COMPRESS_CLOSURE_BINARY, settings.COMPRESS_CLOSURE_ARGUMENTS)
command = '%s %s' % (settings.PIPELINE_CLOSURE_BINARY, settings.PIPELINE_CLOSURE_ARGUMENTS)
if self.verbose:
command += ' --verbose'
return self.execute_command(command, js)
......@@ -2,8 +2,8 @@ import os
import warnings
import tempfile
from compress.conf import settings
from compress.compressors import CompressorBase
from pipeline.conf import settings
from pipeline.compressors import CompressorBase
warnings.simplefilter('ignore', RuntimeWarning)
......@@ -17,8 +17,8 @@ class CSSTidyCompressor(CompressorBase):
output_file = tempfile.NamedTemporaryFile(mode='w+b')
command = '%s %s %s %s' % (
settings.COMPRESS_CSSTIDY_BINARY, tmp_file.name,
settings.COMPRESS_CSSTIDY_ARGUMENTS, output_file.name
settings.PIPELINE_CSSTIDY_BINARY, tmp_file.name,
settings.PIPELINE_CSSTIDY_ARGUMENTS, output_file.name
)
command_output = os.popen(command).read()
......
from compress.compressors import CompressorBase
from compress.compressors.jsmin.jsmin import jsmin
from pipeline.compressors import CompressorBase
from pipeline.compressors.jsmin.jsmin import jsmin
class JSMinCompressor(CompressorBase):
......
from compress.conf import settings
from compress.compressors import SubProcessCompressor
from pipeline.conf import settings
from pipeline.compressors import SubProcessCompressor
class UglifyJSCompressor(SubProcessCompressor):
def compress_js(self, js):
command = '%s -nc %s' % (settings.COMPRESS_UGLIFYJS_BINARY, settings.COMPRESS_UGLIFYJS_ARGUMENTS)
command = '%s -nc %s' % (settings.PIPELINE_UGLIFYJS_BINARY, settings.PIPELINE_UGLIFYJS_ARGUMENTS)
if self.verbose:
command += ' --verbose'
return self.execute_command(command, js)
from compress.conf import settings
from compress.compressors import SubProcessCompressor
from pipeline.conf import settings
from pipeline.compressors import SubProcessCompressor
class YUICompressor(SubProcessCompressor):
def compress_common(self, content, type_, arguments):
command = '%s --type=%s %s' % (settings.COMPRESS_YUI_BINARY, type_, arguments)
command = '%s --type=%s %s' % (settings.PIPELINE_YUI_BINARY, type_, arguments)
if self.verbose:
command += ' --verbose'
return self.execute_command(command, content)
def compress_js(self, js):
return self.compress_common(js, 'js', settings.COMPRESS_YUI_JS_ARGUMENTS)
return self.compress_common(js, 'js', settings.PIPELINE_YUI_JS_ARGUMENTS)
def compress_css(self, css):
return self.compress_common(css, 'css', settings.COMPRESS_YUI_CSS_ARGUMENTS)
return self.compress_common(css, 'css', settings.PIPELINE_YUI_CSS_ARGUMENTS)
from django.conf import settings
PIPELINE_ROOT = getattr(settings, 'PIPELINE_ROOT', settings.MEDIA_ROOT)
PIPELINE_URL = getattr(settings, 'PIPELINE_URL', settings.MEDIA_URL)
PIPELINE = getattr(settings, 'PIPELINE', not settings.DEBUG)
PIPELINE_SOURCE = getattr(settings, 'PIPELINE_SOURCE', settings.STATIC_ROOT)
PIPELINE_ROOT = getattr(settings, 'PIPELINE_ROOT', settings.STATIC_ROOT)
PIPELINE_URL = getattr(settings, 'PIPELINE_URL', settings.STATIC_URL)
PIPELINE_AUTO = getattr(settings, 'PIPELINE_AUTO', True)
PIPELINE_VERSION = getattr(settings, 'PIPELINE_VERSION', False)
PIPELINE_VERSION_PLACEHOLDER = getattr(settings, 'PIPELINE_VERSION_PLACEHOLDER', '?')
PIPELINE_VERSION_DEFAULT = getattr(settings, 'PIPELINE_VERSION_DEFAULT', '0')
PIPELINE_VERSION_REMOVE_OLD = getattr(settings, 'PIPELINE_VERSION_REMOVE_OLD', True)
PIPELINE_VERSIONING = getattr(settings, 'PIPELINE_VERSIONING', 'pipeline.versioning.mtime.MTimeVersioning')
PIPELINE_STORAGE = getattr(settings, 'PIPELINE_STORAGE',
'pipeline.storage.CompressStorage')
PIPELINE_CSS_COMPRESSORS = getattr(settings, 'PIPELINE_CSS_COMPRESSORS', [
'pipeline.compressors.yui.YUICompressor'
])
PIPELINE_JS_COMPRESSORS = getattr(settings, 'PIPELINE_JS_COMPRESSORS', [
'pipeline.compressors.yui.YUICompressor'
])
PIPELINE_COMPILERS = getattr(settings, 'PIPELINE_COMPILERS', [])
PIPELINE_CSS = getattr(settings, 'PIPELINE_CSS', {})
PIPELINE_JS = getattr(settings, 'PIPELINE_JS', {})
PIPELINE_TEMPLATE_NAMESPACE = getattr(settings, 'PIPELINE_TEMPLATE_NAMESPACE', "window.JST")
PIPELINE_TEMPLATE_EXT = getattr(settings, 'PIPELINE_TEMPLATE_EXT', ".jst")
PIPELINE_TEMPLATE_FUNC = getattr(settings, 'PIPELINE_TEMPLATE_FUNC', "_.template")
PIPELINE_CSSTIDY_BINARY = '/usr/local/bin/csstidy'
PIPELINE_CSSTIDY_ARGUMENTS = '--template=highest'
PIPELINE_YUI_BINARY = getattr(settings, 'PIPELINE_YUI_BINARY', '/usr/local/bin/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/local/bin/closure')
PIPELINE_CLOSURE_ARGUMENTS = getattr(settings, 'PIPELINE_CLOSURE_ARGUMENTS', '')
PIPELINE_UGLIFYJS_BINARY = getattr(settings, 'PIPELINE_UGLIFYJS_BINARY', '/usr/local/bin/uglifyjs')
PIPELINE_UGLIFYJS_ARGUMENTS = getattr(settings, 'PIPELINE_UGLIFYJS_ARGUMENTS', '')
PIPELINE_COFFEE_SCRIPT_BINARY = getattr(settings, 'PIPELINE_COFFEE_SCRIPT_BINARY', '/usr/local/bin/coffee')
PIPELINE_COFFEE_SCRIPT_ARGUMENTS = getattr(settings, 'PIPELINE_COFFEE_SCRIPT_ARGUMENTS', '')
PIPELINE_SASS_BINARY = getattr(settings, 'PIPELINE_SASS_BINARY', '/usr/local/bin/sass')
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 = []
from django.contrib.staticfiles.finders import BaseStorageFinder
from compress.storage import CompressStorage
from pipeline.storage import CompressStorage
class CompressFinder(BaseStorageFinder):
......
......@@ -15,7 +15,7 @@ class Command(NoArgsCommand):
args = ''
def handle_noargs(self, **options):
from compress.packager import Packager
from pipeline.packager import Packager
packager = Packager(
force=options.get('force', False),
verbose=int(options.get('verbosity', 1)) >= 2
......
......@@ -2,12 +2,12 @@ import glob
import os
import urlparse
from compress.conf import settings
from compress.compilers import Compiler
from compress.compressors import Compressor
from compress.signals import css_compressed, js_compressed
from compress.storage import storage
from compress.versioning import Versioning
from pipeline.conf import settings
from pipeline.compilers import Compiler
from pipeline.compressors import Compressor
from pipeline.signals import css_compressed, js_compressed
from pipeline.storage import storage
from pipeline.versioning import Versioning
class Packager(object):
......@@ -18,8 +18,8 @@ class Packager(object):
self.versioning = Versioning(verbose)
self.compiler = Compiler(verbose)
self.packages = {
'css': self.create_packages(settings.COMPRESS_CSS),
'js': self.create_packages(settings.COMPRESS_JS),
'css': self.create_packages(settings.PIPELINE_CSS),
'js': self.create_packages(settings.PIPELINE_JS),
}
def package_for(self, kind, package_name):
......@@ -33,7 +33,7 @@ class Packager(object):
)
def individual_url(self, filename):
return urlparse.urljoin(settings.COMPRESS_URL,
return urlparse.urljoin(settings.PIPELINE_URL,
self.compressor.relative_path(filename)[1:])
def pack_stylesheets(self, package):
......@@ -45,7 +45,7 @@ class Packager(object):
return self.compiler.compile(paths)
def pack(self, package, compress, signal, **kwargs):
if settings.COMPRESS_AUTO or self.force:
if settings.PIPELINE_AUTO or self.force:
need_update, version = self.versioning.need_update(
package['output'], package['paths'])
if need_update or self.force:
......@@ -86,13 +86,13 @@ class Packager(object):
continue
paths = []
for path in config[name]['source_filenames']:
full_path = os.path.join(settings.COMPRESS_ROOT, path)
full_path = os.path.join(settings.PIPELINE_ROOT, path)
for path in glob.glob(full_path):
path = os.path.normpath(path).replace(settings.COMPRESS_ROOT, '')
path = os.path.normpath(path).replace(settings.PIPELINE_ROOT, '')
if not path in paths:
paths.append(path)
packages[name]['paths'] = [path for path in paths if not path.endswith(settings.COMPRESS_TEMPLATE_EXT)]
packages[name]['templates'] = [path for path in paths if path.endswith(settings.COMPRESS_TEMPLATE_EXT)]
packages[name]['paths'] = [path for path in paths if not path.endswith(settings.PIPELINE_TEMPLATE_EXT)]
packages[name]['templates'] = [path for path in paths if path.endswith(settings.PIPELINE_TEMPLATE_EXT)]
packages[name]['output'] = config[name]['output_filename']
packages[name]['context'] = {}
if 'extra_context' in config[name]:
......
......@@ -5,15 +5,15 @@ from datetime import datetime
from django.core.files.storage import FileSystemStorage, get_storage_class
from django.utils.functional import LazyObject
from compress.conf import settings
from pipeline.conf import settings
class CompressStorage(FileSystemStorage):
def __init__(self, location=None, base_url=None, *args, **kwargs):
if location is None:
location = settings.COMPRESS_ROOT
location = settings.PIPELINE_ROOT
if base_url is None:
base_url = settings.COMPRESS_URL
base_url = settings.PIPELINE_URL
super(CompressStorage, self).__init__(location, base_url, *args, **kwargs)
def accessed_time(self, name):
......@@ -28,7 +28,7 @@ class CompressStorage(FileSystemStorage):
class DefaultStorage(LazyObject):
def _setup(self):
self._wrapped = get_storage_class(settings.COMPRESS_STORAGE)()
self._wrapped = get_storage_class(settings.PIPELINE_STORAGE)()
storage = DefaultStorage()
from django import template
from django.template.loader import render_to_string
from compress.conf import settings
from compress.packager import Packager, PackageNotFound
from pipeline.conf import settings
from pipeline.packager import Packager, PackageNotFound
register = template.Library()
......@@ -19,7 +19,7 @@ class CompressedCSSNode(template.Node):
except PackageNotFound:
return '' # fail silently, do not return anything if an invalid group is specified
if settings.COMPRESS:
if settings.PIPELINE:
compressed_path = self.packager.pack_stylesheets(package)
return self.render_css(package, compressed_path)
else:
......@@ -29,7 +29,7 @@ class CompressedCSSNode(template.Node):
def render_css(self, package, path):
context = {}
if not 'template' in package:
package['template'] = "compress/css.html"
package['template'] = "pipeline/css.html"
if not 'context' in package:
context = package['context']
context.update({
......@@ -57,7 +57,7 @@ class CompressedJSNode(template.Node):
if 'externals' in package:
return '\n'.join([self.render_external(package, url) for url in package['externals']])
if settings.COMPRESS:
if settings.PIPELINE:
compressed_path = self.packager.pack_javascripts(package)
return self.render_js(package, compressed_path)
else:
......@@ -68,7 +68,7 @@ class CompressedJSNode(template.Node):
def render_js(self, package, path):
context = {}
if not 'template' in package:
package['template'] = "compress/js.html"
package['template'] = "pipeline/js.html"
if not 'context' in package:
context = package['context']
context.update({
......@@ -78,7 +78,7 @@ class CompressedJSNode(template.Node):
def render_external(self, package, url):
if not 'template' in package:
package['template'] = "compress/js.html"
package['template'] = "pipeline/js.html"
return render_to_string(package['template'], {
'url': url
})
......@@ -90,7 +90,7 @@ class CompressedJSNode(template.Node):
context.update({
'source': js
})
return render_to_string("compress/inline_js.html", context)
return render_to_string("pipeline/inline_js.html", context)
def render_individual(self, package, templates=None):
tags = [self.render_js(package, js) for js in package['paths']]
......@@ -103,7 +103,7 @@ def compressed_css(parser, token):
try:
tag_name, name = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError, '%r requires exactly one argument: the name of a group in the COMPRESS_CSS setting' % token.split_contents()[0]
raise template.TemplateSyntaxError, '%r requires exactly one argument: the name of a group in the PIPELINE_CSS setting' % token.split_contents()[0]
return CompressedCSSNode(name)
compressed_css = register.tag(compressed_css)
......@@ -112,6 +112,6 @@ def compressed_js(parser, token):
try:
tag_name, name = token.split_contents()
except ValueError:
raise template.TemplateSyntaxError, '%r requires exactly one argument: the name of a group in the COMPRESS_JS setting' % token.split_contents()[0]
raise template.TemplateSyntaxError, '%r requires exactly one argument: the name of a group in the PIPELINE_JS setting' % token.split_contents()[0]
return CompressedJSNode(name)
compressed_js = register.tag(compressed_js)
import os
import re
from compress.conf import settings
from compress.storage import storage
from compress.utils import to_class
from pipeline.conf import settings
from pipeline.storage import storage
from pipeline.utils import to_class
class Versioning(object):
......@@ -11,14 +11,14 @@ class Versioning(object):
self.verbose = verbose
def versionner(self):
return to_class(settings.COMPRESS_VERSIONING)(self)
return to_class(settings.PIPELINE_VERSIONING)(self)
versionner = property(versionner)
def version(self, paths):
return getattr(self.versionner, 'version')(paths)
def version_from_file(self, path, filename):
filename = settings.COMPRESS_VERSION_PLACEHOLDER.join([re.escape(part) for part in filename.split(settings.COMPRESS_VERSION_PLACEHOLDER)])
filename = settings.PIPELINE_VERSION_PLACEHOLDER.join([re.escape(part) for part in filename.split(settings.PIPELINE_VERSION_PLACEHOLDER)])
regex = re.compile(r'^%s$' % self.output_filename(filename, r'([A-Za-z0-9]+)'))
versions = []
for f in sorted(storage.listdir(path), reverse=True):
......@@ -29,17 +29,17 @@ class Versioning(object):
return versions[-1]
def output_filename(self, filename, version):
if settings.COMPRESS_VERSION and version is not None:
output_filename = filename.replace(settings.COMPRESS_VERSION_PLACEHOLDER,
if settings.PIPELINE_VERSION and version is not None:
output_filename = filename.replace(settings.PIPELINE_VERSION_PLACEHOLDER,
version)
else:
output_filename = filename.replace(settings.COMPRESS_VERSION_PLACEHOLDER,
settings.COMPRESS_VERSION_DEFAULT)
output_path = os.path.join(settings.COMPRESS_ROOT, output_filename)
output_filename = filename.replace(settings.PIPELINE_VERSION_PLACEHOLDER,
settings.PIPELINE_VERSION_DEFAULT)
output_path = os.path.join(settings.PIPELINE_ROOT, output_filename)
return os.path.normpath(output_path)
def relative_path(self, filename):
return os.path.join(settings.COMPRESS_ROOT, filename)
return os.path.join(settings.PIPELINE_ROOT, filename)
def need_update(self, output_file, paths):
version = self.version(paths)
......@@ -49,10 +49,10 @@ class Versioning(object):
return getattr(self.versionner, 'need_update')(output_file, paths, version)
def cleanup(self, filename):
if not settings.COMPRESS_VERSION and not settings.COMPRESS_VERSION_REMOVE_OLD:
if not settings.PIPELINE_VERSION and not settings.PIPELINE_VERSION_REMOVE_OLD:
return # Nothing to delete here
path = os.path.dirname(filename)
filename = settings.COMPRESS_VERSION_PLACEHOLDER.join([re.escape(part) for part in filename.split(settings.COMPRESS_VERSION_PLACEHOLDER)])
filename = settings.PIPELINE_VERSION_PLACEHOLDER.join([re.escape(part) for part in filename.split(settings.PIPELINE_VERSION_PLACEHOLDER)])
regex = re.compile(r'^%s$' % os.path.basename(self.output_filename(filename, r'([A-Za-z0-9]+)')))
if storage.exists(path):
for f in storage.listdir(path)[1]:
......
from compress.conf import settings
from compress.versioning import VersioningBase, VersioningError
from pipeline.conf import settings
from pipeline.versioning import VersioningBase, VersioningError
from django.utils.hashcompat import sha_constructor
......@@ -12,7 +12,7 @@ except ImportError:
class GitVersioningBase(VersioningBase):
def need_update(self, output_file, paths, version):
output_file_name = self.output_filename(output_file, version)
placeholder = settings.COMPRESS_VERSION_PLACEHOLDER
placeholder = settings.PIPELINE_VERSION_PLACEHOLDER
try:
placeholder_index = output_file.index(placeholder)
old_version = output_file_name[placeholder_index:placeholder_index + len(placeholder) - len(output_file)]
......
import cStringIO
from hashlib import md5, sha1
from compress.conf import settings
from compress.storage import storage
from compress.versioning import VersioningBase
from pipeline.conf import settings
from pipeline.storage import storage
from pipeline.versioning import VersioningBase
class HashVersioningBase(VersioningBase):
......@@ -12,7 +12,7 @@ class HashVersioningBase(VersioningBase):
def need_update(self, output_file, paths, version):
output_file_name = self.output_filename(output_file, version)
placeholder = settings.COMPRESS_VERSION_PLACEHOLDER
placeholder = settings.PIPELINE_VERSION_PLACEHOLDER
try:
placeholder_index = output_file.index(placeholder)
old_version = output_file_name[placeholder_index:placeholder_index + len(placeholder) - len(output_file)]
......
import time
from compress.storage import storage
from compress.versioning import VersioningBase
from pipeline.storage import storage
from pipeline.versioning import VersioningBase
class MTimeVersioning(VersioningBase):
......
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
setup(
name='django-compress',
version='1.0.1',
description='django-compress provides an automated system for compressing CSS and JavaScript files',
author='Andreas Pelme',
author_email='Andreas Pelme <andreas@pelme.se>',
url='http://code.google.com/p/django-compress/',
name='django-pipeline',
version='1.1.0',
description='Pipeline is an asset packaging library for Django.',
long_description="""Pipeline is an asset packaging library for Django, providing
both CSS and JavaScript concatenation and compression, built-in JavaScript
template support, and optional data-URI image and font embedding.""",
author='Timothée Peignier',
author_email='timothee.peignier@tryphon.org',
url='https://github.com/cyberdelia/django-pipeline',
packages=find_packages(),
zip_safe=False,
include_package_data=True,
......
......@@ -8,10 +8,10 @@ TEST_DIR = os.path.dirname(os.path.abspath(__file__))
if not settings.configured:
settings.configure(
COMPRESS_CACHE_BACKEND='dummy://',
PIPELINE_CACHE_BACKEND='dummy://',
DATABASE_ENGINE='sqlite3',
INSTALLED_APPS=[
'compress',
'pipeline',
'tests',
],
MEDIA_URL='/media/',
......
......@@ -2,19 +2,19 @@ import os
from django.test import TestCase
from compress.conf import settings
from compress.compressors import Compressor
from pipeline.conf import settings
from pipeline.compressors import Compressor
class CompressorTest(TestCase):
def setUp(self):
self.old_compress_url = settings.COMPRESS_URL
settings.COMPRESS_URL = 'http://localhost/static/'
self.old_pipeline_url = settings.PIPELINE_URL
settings.PIPELINE_URL = 'http://localhost/static/'
def test_url_rewrite(self):
compressor = Compressor()
output = compressor.concatenate_and_rewrite([
os.path.join(settings.COMPRESS_ROOT, 'css/urls.css'),
os.path.join(settings.PIPELINE_ROOT, 'css/urls.css'),
])
self.assertEquals(""".relative-url {
background-image: url(http://localhost/static/images/sprite-buttons.png);
......@@ -27,4 +27,4 @@ class CompressorTest(TestCase):
}""", output)
def tearDown(self):
settings.COMPRESS_URL = self.old_compress_url
settings.PIPELINE_URL = self.old_pipeline_url
......@@ -2,19 +2,19 @@ import os
from django.test import TestCase
from compress.conf import settings
from compress.packager import Packager
from pipeline.conf import settings
from pipeline.packager import Packager
class PackagerTest(TestCase):
def setUp(self):
self.old_compress_url = settings.COMPRESS_URL
settings.COMPRESS_URL = 'http://localhost/static/'
self.old_pipeline_url = settings.PIPELINE_URL
settings.PIPELINE_URL = 'http://localhost/static/'
def test_individual_url(self):
"""Check that individual URL is correctly generated"""
packager = Packager()
filename = os.path.join(settings.COMPRESS_ROOT, u'js/application.js')
filename = os.path.join(settings.PIPELINE_ROOT, u'js/application.js')
individual_url = packager.individual_url(filename)
self.assertEqual(individual_url,
"http://localhost/static/js/application.js")
......@@ -37,9 +37,10 @@ class PackagerTest(TestCase):
'application': {
'context': {},
'output': 'application.r?.js',
'paths': ['js/application.js']
'paths': ['js/application.js'],
'templates': []
}
})
def tearDown(self):
settings.COMPRESS_URL = self.old_compress_url
settings.PIPELINE_URL = self.old_pipeline_url
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