Skip to content

Commit 772ecd1

Browse files
committed
Merge branch 'release/1.3'
2 parents c9d5f43 + e299f91 commit 772ecd1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+454
-263
lines changed

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
build
2-
compressor/tests/media/CACHE
3-
compressor/tests/media/custom
4-
compressor/tests/media/js/066cd253eada.js
2+
compressor/tests/static/CACHE
3+
compressor/tests/static/custom
4+
compressor/tests/static/js/066cd253eada.js
55
dist
66
MANIFEST
77
*.pyc
88
*.egg-info
99
*.egg
1010
docs/_build/
1111
.sass-cache
12-
.coverage
12+
.coverage

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
language: python
22
python:
3-
- "2.5"
43
- "2.6"
54
- "2.7"
65
before_install:
@@ -14,8 +13,9 @@ install:
1413
script:
1514
- make test
1615
env:
17-
- DJANGO=1.3.1
18-
- DJANGO=1.4
16+
- DJANGO=1.3.7
17+
- DJANGO=1.4.5
18+
- DJANGO=1.5
1919
branches:
2020
only:
2121
- develop

AUTHORS

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,23 @@ Aaron Godfrey
1313
Adam "Cezar" Jenkins
1414
Adrian Holovaty
1515
Alen Mujezinovic
16+
Alex Kessinger
1617
Andreas Pelme
18+
Antti Hirvonen
1719
Apostolos Bessas
20+
Ashley Camba Garrido
1821
Atamert Ölçgen
1922
Aymeric Augustin
2023
Bartek Ciszkowski
2124
Ben Firshman
2225
Ben Spaulding
26+
Benjamin Gilbert
2327
Benjamin Wohlwend
2428
Bojan Mihelac
2529
Boris Shemigon
2630
Brad Whittington
2731
Bruno Renié
32+
Cassus Adam Banko
2833
Chris Adams
2934
Chris Streeter
3035
Clay McClure
@@ -34,7 +39,9 @@ Eugene Mirotin
3439
Fenn Bailey
3540
Francisco Souza
3641
Gert Van Gool
42+
Greg McGuire
3743
Harro van der Klauw
44+
Isaac Bythewood
3845
Iván Raskovsky
3946
Jaap Roes
4047
James Roe
@@ -45,6 +52,7 @@ Jervis Whitley
4552
John-Scott Atlakson
4653
Jonas von Poser
4754
Jonathan Lukens
55+
Julian Scheid
4856
Julien Phalip
4957
Justin Lilly
5058
Luis Nell
@@ -53,7 +61,9 @@ Lukasz Balcerzak
5361
Maciek Szczesniak
5462
Maor Ben-Dayan
5563
Mark Lavin
64+
Marsel Mavletkulov
5665
Matt Schick
66+
Matthew Tretter
5767
Mehmet S. Catalbas
5868
Michael van de Waeter
5969
Mike Yumatov
@@ -65,14 +75,18 @@ Peter Bengtsson
6575
Peter Lundberg
6676
Philipp Bosch
6777
Philipp Wollermann
78+
Rich Leland
6879
Sam Dornan
80+
Saul Shanabrook
6981
Selwin Ong
7082
Shabda Raaj
7183
Stefano Brentegani
7284
Sébastien Piquemal
7385
Thom Linton
86+
Thomas Schreiber
7487
Tino de Bruijn
7588
Ulrich Petri
89+
Ulysses V
7690
Vladislav Poluhin
7791
wesleyb
7892
Wilson Júnior

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
django_compressor
22
-----------------
3-
Copyright (c) 2009-2012 Django Compressor authors (see AUTHORS file)
3+
Copyright (c) 2009-2013 Django Compressor authors (see AUTHORS file)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
include AUTHORS
22
include README.rst
33
include LICENSE
4+
recursive-include docs *
45
recursive-include compressor/templates/compressor *.html
56
recursive-include compressor/tests/media *.js *.css *.png *.coffee
67
recursive-include compressor/tests/test_templates *.html

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ tool it will be fairly easy to implement a custom filter. Simply extend
4848
from one of the available base classes.
4949

5050
More documentation about the usage and settings of Django Compressor can be
51-
found on `django_compressor.readthedocs.org`_.
51+
found on `django-compressor.readthedocs.org`_.
5252

5353
The source code for Django Compressor can be found and contributed to on
5454
`github.com/jezdez/django_compressor`_. There you can also file tickets.
@@ -65,7 +65,7 @@ The `in-development version`_ of Django Compressor can be installed with
6565
.. _JSMin: http://www.crockford.com/javascript/jsmin.html
6666
.. _cssmin: https://github.com/zacharyvoase/cssmin
6767
.. _data URIs: http://en.wikipedia.org/wiki/Data_URI_scheme
68-
.. _django_compressor.readthedocs.org: http://django_compressor.readthedocs.org/
68+
.. _django-compressor.readthedocs.org: http://django-compressor.readthedocs.org/en/latest/
6969
.. _github.com/jezdez/django_compressor: https://github.com/jezdez/django_compressor
7070
.. _in-development version: http://github.com/jezdez/django_compressor/tarball/develop#egg=django_compressor-dev
7171

compressor/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# following PEP 386
2-
__version__ = "1.2"
2+
__version__ = "1.3"

compressor/base.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@
77
from django.template import Context
88
from django.template.loader import render_to_string
99
from django.utils.encoding import smart_unicode
10+
from django.utils.importlib import import_module
1011
from django.utils.safestring import mark_safe
1112

1213
from compressor.cache import get_hexdigest, get_mtime
1314

1415
from compressor.conf import settings
15-
from compressor.exceptions import CompressorError, UncompressableFileError
16+
from compressor.exceptions import (CompressorError, UncompressableFileError,
17+
FilterDoesNotExist)
1618
from compressor.filters import CompilerFilter
1719
from compressor.storage import default_storage, compressor_file_storage
1820
from compressor.signals import post_compress
19-
from compressor.utils import get_class, staticfiles
21+
from compressor.utils import get_class, get_mod_func, staticfiles
2022
from compressor.utils.decorators import cached_property
2123

2224
# Some constants for nicer handling.
@@ -199,15 +201,29 @@ def precompile(self, content, kind=None, elem=None, filename=None, **kwargs):
199201
attrs = self.parser.elem_attribs(elem)
200202
mimetype = attrs.get("type", None)
201203
if mimetype:
202-
command = self.all_mimetypes.get(mimetype)
203-
if command is None:
204+
filter_or_command = self.all_mimetypes.get(mimetype)
205+
if filter_or_command is None:
204206
if mimetype not in ("text/css", "text/javascript"):
205207
raise CompressorError("Couldn't find any precompiler in "
206208
"COMPRESS_PRECOMPILERS setting for "
207209
"mimetype '%s'." % mimetype)
208210
else:
209-
return True, CompilerFilter(content, filter_type=self.type,
210-
command=command, filename=filename).input(**kwargs)
211+
mod_name, cls_name = get_mod_func(filter_or_command)
212+
try:
213+
mod = import_module(mod_name)
214+
except ImportError:
215+
return True, CompilerFilter(content, filter_type=self.type,
216+
command=filter_or_command, filename=filename).input(
217+
**kwargs)
218+
try:
219+
precompiler_class = getattr(mod, cls_name)
220+
except AttributeError:
221+
raise FilterDoesNotExist('Could not find "%s".' %
222+
filter_or_command)
223+
else:
224+
return True, precompiler_class(content, attrs,
225+
filter_type=self.type, filename=filename).input(
226+
**kwargs)
211227
return False, content
212228

213229
def filter(self, content, method, **kwargs):

compressor/cache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import hashlib
12
import os
23
import socket
34
import time
@@ -7,7 +8,6 @@
78
from django.utils import simplejson
89
from django.utils.encoding import smart_str
910
from django.utils.functional import SimpleLazyObject
10-
from django.utils.hashcompat import md5_constructor
1111
from django.utils.importlib import import_module
1212

1313
from compressor.conf import settings
@@ -18,7 +18,7 @@
1818

1919

2020
def get_hexdigest(plaintext, length=None):
21-
digest = md5_constructor(smart_str(plaintext)).hexdigest()
21+
digest = hashlib.md5(smart_str(plaintext)).hexdigest()
2222
if length:
2323
return digest[:length]
2424
return digest

compressor/conf.py

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
from django import VERSION as DJANGO_VERSION
32
from django.conf import settings
43
from django.core.exceptions import ImproperlyConfigured
54

@@ -32,6 +31,7 @@ class CompressorConf(AppConf):
3231
# ('text/coffeescript', 'coffee --compile --stdio'),
3332
# ('text/less', 'lessc {infile} {outfile}'),
3433
# ('text/x-sass', 'sass {infile} {outfile}'),
34+
# ('text/stylus', 'stylus < {infile} > {outfile}'),
3535
# ('text/x-scss', 'sass --scss {infile} {outfile}'),
3636
)
3737
CLOSURE_COMPILER_BINARY = 'java -jar compiler.jar'
@@ -69,52 +69,35 @@ class Meta:
6969
prefix = 'compress'
7070

7171
def configure_root(self, value):
72+
# Uses Django's STATIC_ROOT by default
7273
if value is None:
73-
value = getattr(settings, 'STATIC_ROOT', None)
74-
if not value:
75-
value = settings.MEDIA_ROOT
74+
value = settings.STATIC_ROOT
7675
if value is None:
7776
raise ImproperlyConfigured("COMPRESS_ROOT setting must be set")
7877
return os.path.normcase(os.path.abspath(value))
7978

8079
def configure_url(self, value):
81-
# Uses Django 1.3's STATIC_URL by default or falls back to MEDIA_URL
80+
# Uses Django's STATIC_URL by default
8281
if value is None:
83-
value = getattr(settings, 'STATIC_URL', None)
84-
if not value:
85-
value = settings.MEDIA_URL
82+
value = settings.STATIC_URL
8683
if not value.endswith('/'):
8784
raise ImproperlyConfigured("URL settings (e.g. COMPRESS_URL) "
8885
"must have a trailing slash")
8986
return value
9087

9188
def configure_cache_backend(self, value):
9289
if value is None:
93-
# If we are on Django 1.3 AND using the new CACHES setting...
94-
if DJANGO_VERSION[:2] >= (1, 3) and hasattr(settings, 'CACHES'):
95-
value = 'default'
96-
else:
97-
# falling back to the old CACHE_BACKEND setting
98-
value = getattr(settings, 'CACHE_BACKEND', None)
99-
if not value:
100-
raise ImproperlyConfigured("Please specify a cache "
101-
"backend in your settings.")
90+
value = 'default'
10291
return value
10392

10493
def configure_offline_context(self, value):
10594
if not value:
106-
value = {'MEDIA_URL': settings.MEDIA_URL}
107-
# Adds the 1.3 STATIC_URL setting to the context if available
108-
if getattr(settings, 'STATIC_URL', None):
109-
value['STATIC_URL'] = settings.STATIC_URL
95+
value = {'STATIC_URL': settings.STATIC_URL}
11096
return value
11197

11298
def configure_template_filter_context(self, value):
11399
if not value:
114-
value = {'MEDIA_URL': settings.MEDIA_URL}
115-
# Adds the 1.3 STATIC_URL setting to the context if available
116-
if getattr(settings, 'STATIC_URL', None):
117-
value['STATIC_URL'] = settings.STATIC_URL
100+
value = {'STATIC_URL': settings.STATIC_URL}
118101
return value
119102

120103
def configure_precompilers(self, value):

0 commit comments

Comments
 (0)