Commit b19ed0f1 by andreas.pelme

Added default configuration options


git-svn-id: https://django-compress.googlecode.com/svn/trunk@7 98d35234-f74b-0410-9e22-51d878bdf110
parent 31b4db9f
from django.conf import settings
from compress.conf import settings
from compress.utils import needs_update, filter_css, filter_js
if settings.COMPRESS:
......
from django.conf import settings
COMPRESS = getattr(settings, 'COMPRESS', not settings.DEBUG)
COMPRESS_CSS_FILTERS = getattr(settings, 'COMPRESS_CSS_FILTERS', ('compress.filters.csstidy.CSSTidyFilter', ))
COMPRESS_JS_FILTERS = getattr(settings, 'COMPRESS_JS_FILTERS', ('compress.filters.jsmin.JSMinFilter',))
COMPRESS_CSS = getattr(settings, 'COMPRESS_CSS', {})
COMPRESS_JS = getattr(settings, 'COMPRESS_JS', {})
if COMPRESS_CSS_FILTERS is None:
COMPRESS_CSS_FILTERS = ()
if COMPRESS_JS_FILTERS is None:
COMPRESS_JS_FILTERS = ()
\ No newline at end of file
import os
import warnings
from django.conf import settings
from compress.utils import *
from compress.filter_base import FilterBase
from compress.utils import write_tmpfile, read_tmpfile
DEFAULT_ARGUMENTS = '--template=highest'
DEFAULT_BINARY = 'csstidy'
BINARY = getattr(settings, 'CSSTIDY_BINARY', 'csstidy')
ARGUMENTS = getattr(settings, 'CSSTIDY_ARGUMENTS', '--template=highest')
import warnings
warnings.simplefilter('ignore', RuntimeWarning)
from compress.filter_base import FilterBase
class CSSTidyFilter(FilterBase):
def filter_css(self, css):
try:
binary = settings.COMPRESS_CSS_CSSTIDY_BINARY
except AttributeError:
binary = DEFAULT_BINARY
try:
arguments = settings.COMPRESS_CSS_CSSTIDY_ARGUMENTS
except AttributeError:
arguments = DEFAULT_ARGUMENTS
tmp_filename = write_tmpfile(css)
try:
output_filename = os.tmpnam()
except RuntimeWarning:
pass
output_filename = os.tmpnam()
command = '%s %s %s %s' % (binary, tmp_filename, arguments, output_filename)
command = '%s %s %s %s' % (BINARY, tmp_filename, ARGUMENTS, output_filename)
output = os.popen(command).read()
if self.verbose:
print output
......
import os
from django import template
from django.conf import settings
from django.conf import settings as django_settings
from compress.conf import settings
from compress.utils import media_root
register = template.Library()
......@@ -12,9 +15,9 @@ def render_common(template_name, obj, filename):
else:
context = {}
url = settings.MEDIA_URL + filename
url = django_settings.MEDIA_URL + filename
if settings.COMPRESS and 'bump_filename' in obj and obj['bump_filename']:
url += '?%d' % os.stat(settings.MEDIA_ROOT + '/'+(filename)).st_mtime
url += '?%d' % os.stat(media_root(filename)).st_mtime
context.update(url=url)
return template.loader.render_to_string(template_name, context)
......
import os
from django.conf import settings
from compress.conf import settings
from django.conf import settings as django_settings
def get_filter(compressor_class):
"""
......@@ -55,10 +54,10 @@ def needs_update(compressed_file, source_files):
return False
def media_root(filename):
return os.path.join(settings.MEDIA_ROOT, filename)
return os.path.join(django_settings.MEDIA_ROOT, filename)
def media_url(filename):
return settings.MEDIA_URL + filename
return django_settings.MEDIA_URL + filename
def write_tmpfile(content):
try:
......
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