Add lessCSS filters for django-compress.
Review Request #2659 — Created Oct. 14, 2011 and submitted — Latest diff uploaded
Add lessCSS filters for django-compress. This introduces a lessCSS filter that can be used with django-compress. It's compatible with our MEDIA_SERIAL versioning (which we may want to just migrate over to proper django-compress versioning later). Our lessCSS filter uses http://blesscss.cloudfoundry.com/min/ as the default service for generating the CSS. It can be optionally used in conjunction with other filters, though typically this one will need to be first. The one tricky part is imports. django-compress will combine all the files in a given package into one blob of content to filter, with no information on filenames or anything, making it difficult to handle imports in a way that will work with both COMPRESS=True and False (since, when False, the stylesheets are included directly). What we do is make use of a settings.LESSCSS_IMPORT_PATHS that defines a list of directories (relative to MEDIA_ROOT) to check for imported files. We then process the file, looking for #import "foo" and try to find that file to import. We can then just include that directly instead of the #import statement. We ship our own compress template files that know how to deal with standard CSS and lessCSS stylesheets, and our MEDIA_SERIAL stuff. It's currently up to the developer to provide MEDIA_SERIAL in a COMPRESS_CSS package's "extra_context", and to include the lesscss.js file when COMPRESS is False. I may end up making this a bit easier later, but this gets us going for now.
Tested with my accompanying Review Board change in DEBUG and non-DEBUG modes, with COMPRESS set to True and to False, and with manage.py synccompress.