Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install django-auto-minify

How to install django-auto-minify

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install django-auto-minify
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.2 Available View build log
0.1 Available View build log
Windows (64-bit)
0.2 Available View build log
0.1 Available View build log
Mac OS X (10.5+)
0.2 Available View build log
0.1 Available View build log
Linux (32-bit)
0.2 Available View build log
0.1 Available View build log
Linux (64-bit)
0.2 Available View build log
0.1 Available View build log
 
License
BSD
Lastest release
version 0.2 on Sep 20th, 2011

Features

  • Javascript and CSS minification using ANY program you desire!
  • Shortcut template tags that will minify and include Javascript and CSS files.

  • The minified files will be cached and only be automatically refreshed if the source files have been modified.

  • Easy integration into any Django project.

Requirements

Django, of course!

Other than that the only main requirements are properly configured JS/CSS minification commands.

The only contraint is that they must contain %(input)s and %(output)s placeholders.

That means the minification programs can conform to nearly any input specification:

cat %(input)s | python cssmin.py > %(output)s

or:

java -jar compiler.jar --js %(input)s --js_output_file %(output)s

etc.

Installation

You can download django-auto-minify using any of the following methods:

Checkout from Mercurial

Use the following command:

hg clone https://bitbucket.org/dschaefer/django-auto-minify

Then run:

python setup.py install
Install via PyPi

Use one of the following commands:

pip install django-auto-minify
easy_install django-auto-minify

Configuration

INSTALLED_APPS

First you must add auto_minify to your INSTALLED_APPS in settings.py:

INSTALLED_APPS = (
    ...
    'auto_minify',
    ...
)
Settings
  • AUTO_MINIFY_ENABLED
    • Enable auto minify? (default: not settings.DEBUG)
  • AUTO_MINIFY_JS_CMD
    • The program for minifying Javascript files. Reqs: %(input)s and %(output)s must be present. (default: None)
    • Ex: 'java -jar compiler --js %(input)s --js_output_file %(output)s'
  • AUTO_MINIFY_CSS_CMD
    • The program for minifying CSS files. Reqs: %(input)s and %(output)s must be present. (default: None)
    • Ex: 'java -jar yuicompressor.jar %(input)s -o %(output)s --type css'
  • AUTO_MINIFY_JS_ROOT:
    • The absolute path to your Django project's Javascript files.
  • AUTO_MINIFY_CSS_ROOT:
    • The absolute path to your Django project's CSS files.
  • AUTO_MINIFY_MIN_DIR_NAME:
    • The name of the directory that the minified files will be placed in. (default: min)
  • AUTO_MINIFY_JS_MIN_ROOT
    • The absolute path to the directory where the minified JavaScript files will be stored. (default: os.path.join(AUTO_MINIFY_JS_ROOT, AUTO_MINIFY_MIN_DIR_NAME))
  • AUTO_MINIFY_CSS_MIN_ROOT
    • The absolute path to the directory where the minified CSS files will be stored. (default: os.path.join(AUTO_MINIFY_CSS_ROOT, AUTO_MINIFY_MIN_DIR_NAME))
  • AUTO_MINIFY_JS_URL
    • The relative URL to your Django project's Javascript files. (default: os.path.join(settings.MEDIA_URL, 'js'))
  • AUTO_MINIFY_CSS_URL
    • The relative URL to your Django project's CSS files. (default: os.path.join(settings.MEDIA_URL, 'css'))

Usage

Template Tags
  • {% js_inline %} ... {% end_js_inline %}
    • Directly includes all Javascript code between the start and end tags. Does not minify.
  • {% js_include filename.js %}
    • Creates a <script> tag that links to an internal Javascript file. This tag minifies.
  • {% js_combine filename1.js filename2.js ... as cache1.js %}
    • Combines several Javascript files into a single file which is then included as a <script> tag. This tag minifies.
  • {% js_external http://.../filename.js %}
    • Creates a <script> tag to an off-site Javascript file.
  • {% css_inline %} ... {% end_css_inline %}
    • Directly includes all CSS code between the start and end tags. Does not minify.
  • {% css_include filename.css %}
    • Creates a <link /> tag that links to an internal CSS file. This tag minifies.
  • {% css_combine filename1.css filename2.css ... as cache1.css %}
    • Combines several CSS files into a single file which is then included as a <link /> rag. This tag minifies.
  • {% css_external http://.../filename.css %}
    • Creates a <link /> tag to an off-site CSS file.
Examples

Please see the sample_project/templates/base.html template for examples.

Help & Contributing

Please contact me with any questions or comments about the project. If you are interested in contributing, reporting a bug, or requesting a feature, the official tracker is located at https://bitbucket.org/dschaefer/django-auto-minify

Thanks!

Subscribe to package updates

Last updated Sep 20th, 2011

Download Stats

Last month:2

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.