Permalink
Browse files

good django-compressor defaults, r=kumar

  • Loading branch information...
1 parent 951d95e commit 8c945106c5529433e98f51b81c314dd1b42284b7 @peterbe peterbe committed May 29, 2012
Showing with 32 additions and 1 deletion.
  1. +6 −0 funfactory/helpers.py
  2. +5 −0 funfactory/monkeypatches.py
  3. +21 −1 funfactory/settings_base.py
View
6 funfactory/helpers.py
@@ -4,6 +4,7 @@
import urlparse
from django.conf import settings
+from django.contrib.staticfiles.storage import staticfiles_storage
from django.template import defaultfilters
from django.utils.encoding import smart_str
from django.utils.html import strip_tags
@@ -64,3 +65,8 @@ def _urlencode(items):
def urlencode(txt):
"""Url encode a path."""
return urllib.quote_plus(txt)
+
+
+@register.function
+def static(path):
+ return staticfiles_storage.url(path)
View
5 funfactory/monkeypatches.py
@@ -31,6 +31,11 @@ def patch():
from . import admin
admin.monkeypatch()
+ if 'compressor' in settings.INSTALLED_APPS:
+ import jingo
+ from compressor.contrib.jinja2ext import CompressorExtension
+ jingo.env.add_extension(CompressorExtension)
+
logging.debug("Note: funfactory monkey patches executed in %s" % __file__)
# prevent it from being run again later
View
22 funfactory/settings_base.py
@@ -188,6 +188,25 @@ def lazy_langs():
path('templates'),
)
+# Storage of static files
+COMPRESS_ROOT = STATIC_ROOT
+COMPRESS_CSS_FILTERS = (
+ 'compressor.filters.css_default.CssAbsoluteFilter',
+ 'compressor.filters.cssmin.CSSMinFilter'
+)
+COMPRESS_PRECOMPILERS = (
+ #('text/coffeescript', 'coffee --compile --stdio'),
+ ('text/less', 'lessc {infile} {outfile}'),
+ #('text/x-sass', 'sass {infile} {outfile}'),
+ #('text/x-scss', 'sass --scss {infile} {outfile}'),
+)
+
+STATICFILES_FINDERS = (
+ 'django.contrib.staticfiles.finders.FileSystemFinder',
+ 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+ 'compressor.finders.CompressorFinder',
+)
+
def JINJA_CONFIG():
import jinja2
from django.conf import settings
@@ -225,7 +244,8 @@ def JINJA_CONFIG():
INSTALLED_APPS = (
# Local apps
'funfactory', # Content common to most playdoh-based apps.
- 'jingo_minify',
+ 'compressor',
+
'tower', # for ./manage.py extract (L10n)
'cronjobs', # for ./manage.py cron * cmd line tasks
'django_browserid',

3 comments on commit 8c94510

@kumar303
Mozilla member

I take it compressor is coming to playdoh-lib next? the funfactory tests are failing without it.

@peterbe

@kumar303 yes. My Playdoh PR is awaiting a review from you :)
When that's done, I'll finish up by doing the playdoh-lib last.
Maybe it was a bad idea to push till all other PR requests were r+'ed.

@kumar303
Mozilla member

I didn't see one for the playdoh-lib change (they all say do not merge) but go ahead and push the lib change to add compressor and remove jingo-minify, no review needed. It's part of this same feature.

Please sign in to comment.