Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

1.2 is not unsupported, remove all references to MEDIA_* (users shoul…

…d have moved to STATIC_* by now) as well as 1.2 stuff in the documentation.
  • Loading branch information...
commit 9c64b478e2569eb9001fb31655389d5a76b60101 1 parent 8279b90
@diox diox authored
Showing with 152 additions and 182 deletions.
  1. +4 −4 .gitignore
  2. +7 −25 compressor/conf.py
  3. +1 −1  compressor/management/commands/compress.py
  4. +1 −1  compressor/management/commands/mtime_cache.py
  5. +6 −6 compressor/templatetags/compress.py
  6. +2 −3 compressor/test_settings.py
  7. +0 −1  compressor/tests/media/css/url/test.css
  8. 0  compressor/tests/{media → static}/css/datauri.css
  9. 0  compressor/tests/{media → static}/css/nonasc.css
  10. 0  compressor/tests/{media → static}/css/one.css
  11. 0  compressor/tests/{media → static}/css/two.css
  12. 0  compressor/tests/{media → static}/css/url/2/url2.css
  13. 0  compressor/tests/{media → static}/css/url/nonasc.css
  14. +1 −0  compressor/tests/static/css/url/test.css
  15. 0  compressor/tests/{media → static}/css/url/url1.css
  16. 0  compressor/tests/{media → static}/img/add.png
  17. 0  compressor/tests/{media → static}/img/python.png
  18. 0  compressor/tests/{media → static}/js/nonasc-latin1.js
  19. 0  compressor/tests/{media → static}/js/nonasc.js
  20. 0  compressor/tests/{media → static}/js/one.coffee
  21. 0  compressor/tests/{media → static}/js/one.js
  22. +19 −19 compressor/tests/test_base.py
  23. +24 −24 compressor/tests/test_filters.py
  24. +23 −23 compressor/tests/test_jinja2ext.py
  25. +6 −6 compressor/tests/test_offline.py
  26. +5 −5 compressor/tests/test_parsers.py
  27. +5 −5 compressor/tests/test_signals.py
  28. +4 −4 compressor/tests/test_storages.py
  29. +38 −38 compressor/tests/test_templatetags.py
  30. +1 −1  docs/quickstart.txt
  31. +1 −1  docs/remote-storages.txt
  32. +3 −13 docs/settings.txt
  33. +1 −2  docs/usage.txt
View
8 .gitignore
@@ -1,7 +1,7 @@
build
-compressor/tests/media/CACHE
-compressor/tests/media/custom
-compressor/tests/media/js/066cd253eada.js
+compressor/tests/static/CACHE
+compressor/tests/static/custom
+compressor/tests/static/js/066cd253eada.js
dist
MANIFEST
*.pyc
@@ -9,4 +9,4 @@ MANIFEST
*.egg
docs/_build/
.sass-cache
-.coverage
+.coverage
View
32 compressor/conf.py
@@ -1,5 +1,4 @@
import os
-from django import VERSION as DJANGO_VERSION
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
@@ -69,20 +68,17 @@ class Meta:
prefix = 'compress'
def configure_root(self, value):
+ # Uses Django's STATIC_ROOT by default
if value is None:
- value = getattr(settings, 'STATIC_ROOT', None)
- if not value:
- value = settings.MEDIA_ROOT
+ value = settings.STATIC_ROOT
if value is None:
raise ImproperlyConfigured("COMPRESS_ROOT setting must be set")
return os.path.normcase(os.path.abspath(value))
def configure_url(self, value):
- # Uses Django 1.3's STATIC_URL by default or falls back to MEDIA_URL
+ # Uses Django's STATIC_URL by default
if value is None:
- value = getattr(settings, 'STATIC_URL', None)
- if not value:
- value = settings.MEDIA_URL
+ value = settings.STATIC_URL
if not value.endswith('/'):
raise ImproperlyConfigured("URL settings (e.g. COMPRESS_URL) "
"must have a trailing slash")
@@ -90,31 +86,17 @@ def configure_url(self, value):
def configure_cache_backend(self, value):
if value is None:
- # If we are on Django 1.3 AND using the new CACHES setting...
- if DJANGO_VERSION[:2] >= (1, 3) and hasattr(settings, 'CACHES'):
- value = 'default'
- else:
- # falling back to the old CACHE_BACKEND setting
- value = getattr(settings, 'CACHE_BACKEND', None)
- if not value:
- raise ImproperlyConfigured("Please specify a cache "
- "backend in your settings.")
+ value = 'default'
return value
def configure_offline_context(self, value):
if not value:
- value = {'MEDIA_URL': settings.MEDIA_URL}
- # Adds the 1.3 STATIC_URL setting to the context if available
- if getattr(settings, 'STATIC_URL', None):
- value['STATIC_URL'] = settings.STATIC_URL
+ value = {'STATIC_URL': settings.STATIC_URL}
return value
def configure_template_filter_context(self, value):
if not value:
- value = {'MEDIA_URL': settings.MEDIA_URL}
- # Adds the 1.3 STATIC_URL setting to the context if available
- if getattr(settings, 'STATIC_URL', None):
- value['STATIC_URL'] = settings.STATIC_URL
+ value = {'STATIC_URL': settings.STATIC_URL}
return value
def configure_precompilers(self, value):
View
2  compressor/management/commands/compress.py
@@ -115,7 +115,7 @@ class Command(NoArgsCommand):
"COMPRESS_ENABLED setting is not True.", dest='force'),
make_option('--follow-links', default=False, action='store_true',
help="Follow symlinks when traversing the COMPRESS_ROOT "
- "(which defaults to MEDIA_ROOT). Be aware that using this "
+ "(which defaults to STATIC_ROOT). Be aware that using this "
"can lead to infinite recursion if a link points to a parent "
"directory of itself.", dest='follow_links'),
)
View
2  compressor/management/commands/mtime_cache.py
@@ -22,7 +22,7 @@ class Command(NoArgsCommand):
"'.*' and '*~'."),
make_option('--follow-links', dest='follow_links', action='store_true',
help="Follow symlinks when traversing the COMPRESS_ROOT "
- "(which defaults to MEDIA_ROOT). Be aware that using this "
+ "(which defaults to STATIC_ROOT). Be aware that using this "
"can lead to infinite recursion if a link points to a parent "
"directory of itself."),
make_option('-c', '--clean', dest='clean', action='store_true',
View
12 compressor/templatetags/compress.py
@@ -161,27 +161,27 @@ def compress(parser, token):
Examples::
{% compress css %}
- <link rel="stylesheet" href="/media/css/one.css" type="text/css" charset="utf-8">
+ <link rel="stylesheet" href="/static/css/one.css" type="text/css" charset="utf-8">
<style type="text/css">p { border:5px solid green;}</style>
- <link rel="stylesheet" href="/media/css/two.css" type="text/css" charset="utf-8">
+ <link rel="stylesheet" href="/static/css/two.css" type="text/css" charset="utf-8">
{% endcompress %}
Which would be rendered something like::
- <link rel="stylesheet" href="/media/CACHE/css/f7c661b7a124.css" type="text/css" media="all" charset="utf-8">
+ <link rel="stylesheet" href="/static/CACHE/css/f7c661b7a124.css" type="text/css" media="all" charset="utf-8">
or::
{% compress js %}
- <script src="/media/js/one.js" type="text/javascript" charset="utf-8"></script>
+ <script src="/static/js/one.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">obj.value = "value";</script>
{% endcompress %}
Which would be rendered something like::
- <script type="text/javascript" src="/media/CACHE/js/3f33b9146e12.js" charset="utf-8"></script>
+ <script type="text/javascript" src="/static/CACHE/js/3f33b9146e12.js" charset="utf-8"></script>
- Linked files must be on your COMPRESS_URL (which defaults to MEDIA_URL).
+ Linked files must be on your COMPRESS_URL (which defaults to STATIC_URL).
If DEBUG is true off-site files will throw exceptions. If DEBUG is false
they will be silently stripped.
"""
View
5 compressor/test_settings.py
@@ -19,11 +19,10 @@
'compressor',
]
-MEDIA_URL = '/media/'
-STATIC_URL = MEDIA_URL
+STATIC_URL = '/static/'
-MEDIA_ROOT = os.path.join(TEST_DIR, 'media')
+STATIC_ROOT = os.path.join(TEST_DIR, 'static')
TEMPLATE_DIRS = (
# Specifically choose a name that will not be considered
View
1  compressor/tests/media/css/url/test.css
@@ -1 +0,0 @@
-p { background: url('/media/images/image.gif') }
View
0  compressor/tests/media/css/datauri.css → compressor/tests/static/css/datauri.css
File renamed without changes
View
0  compressor/tests/media/css/nonasc.css → compressor/tests/static/css/nonasc.css
File renamed without changes
View
0  compressor/tests/media/css/one.css → compressor/tests/static/css/one.css
File renamed without changes
View
0  compressor/tests/media/css/two.css → compressor/tests/static/css/two.css
File renamed without changes
View
0  compressor/tests/media/css/url/2/url2.css → compressor/tests/static/css/url/2/url2.css
File renamed without changes
View
0  compressor/tests/media/css/url/nonasc.css → compressor/tests/static/css/url/nonasc.css
File renamed without changes
View
1  compressor/tests/static/css/url/test.css
@@ -0,0 +1 @@
+p { background: url('/static/images/image.gif') }
View
0  compressor/tests/media/css/url/url1.css → compressor/tests/static/css/url/url1.css
File renamed without changes
View
0  compressor/tests/media/img/add.png → compressor/tests/static/img/add.png
File renamed without changes
View
0  compressor/tests/media/img/python.png → compressor/tests/static/img/python.png
File renamed without changes
View
0  compressor/tests/media/js/nonasc-latin1.js → compressor/tests/static/js/nonasc-latin1.js
File renamed without changes
View
0  compressor/tests/media/js/nonasc.js → compressor/tests/static/js/nonasc.js
File renamed without changes
View
0  compressor/tests/media/js/one.coffee → compressor/tests/static/js/one.coffee
File renamed without changes
View
0  compressor/tests/media/js/one.js → compressor/tests/static/js/one.js
File renamed without changes
View
38 compressor/tests/test_base.py
@@ -39,21 +39,21 @@ def setUp(self):
settings.COMPRESS_PRECOMPILERS = {}
settings.COMPRESS_DEBUG_TOGGLE = 'nocompress'
self.css = """\
-<link rel="stylesheet" href="/media/css/one.css" type="text/css" />
+<link rel="stylesheet" href="/static/css/one.css" type="text/css" />
<style type="text/css">p { border:5px solid green;}</style>
-<link rel="stylesheet" href="/media/css/two.css" type="text/css" />"""
+<link rel="stylesheet" href="/static/css/two.css" type="text/css" />"""
self.css_node = CssCompressor(self.css)
self.js = """\
-<script src="/media/js/one.js" type="text/javascript"></script>
+<script src="/static/js/one.js" type="text/javascript"></script>
<script type="text/javascript">obj.value = "value";</script>"""
self.js_node = JsCompressor(self.js)
def test_css_split(self):
out = [
- (SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css', u'one.css'), u'css/one.css', u'<link rel="stylesheet" href="/media/css/one.css" type="text/css" />'),
+ (SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css', u'one.css'), u'css/one.css', u'<link rel="stylesheet" href="/static/css/one.css" type="text/css" />'),
(SOURCE_HUNK, u'p { border:5px solid green;}', None, u'<style type="text/css">p { border:5px solid green;}</style>'),
- (SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css', u'two.css'), u'css/two.css', u'<link rel="stylesheet" href="/media/css/two.css" type="text/css" />'),
+ (SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css', u'two.css'), u'css/two.css', u'<link rel="stylesheet" href="/static/css/two.css" type="text/css" />'),
]
split = self.css_node.split_contents()
split = [(x[0], x[1], x[2], self.css_node.parser.elem_str(x[3])) for x in split]
@@ -84,12 +84,12 @@ def test_cachekey(self):
"cachekey is returning something that doesn't look like r'\w{12}'")
def test_css_return_if_on(self):
- output = css_tag('/media/CACHE/css/e41ba2cc6982.css')
+ output = css_tag('/static/CACHE/css/e41ba2cc6982.css')
self.assertEqual(output, self.css_node.output().strip())
def test_js_split(self):
out = [
- (SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'js', u'one.js'), u'js/one.js', '<script src="/media/js/one.js" type="text/javascript"></script>'),
+ (SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'js', u'one.js'), u'js/one.js', '<script src="/static/js/one.js" type="text/javascript"></script>'),
(SOURCE_HUNK, u'obj.value = "value";', None, '<script type="text/javascript">obj.value = "value";</script>'),
]
split = self.js_node.split_contents()
@@ -101,17 +101,17 @@ def test_js_hunks(self):
self.assertEqual(out, list(self.js_node.hunks()))
def test_js_output(self):
- out = u'<script type="text/javascript" src="/media/CACHE/js/066cd253eada.js"></script>'
+ out = u'<script type="text/javascript" src="/static/CACHE/js/066cd253eada.js"></script>'
self.assertEqual(out, self.js_node.output())
def test_js_override_url(self):
self.js_node.context.update({'url': u'This is not a url, just a text'})
- out = u'<script type="text/javascript" src="/media/CACHE/js/066cd253eada.js"></script>'
+ out = u'<script type="text/javascript" src="/static/CACHE/js/066cd253eada.js"></script>'
self.assertEqual(out, self.js_node.output())
def test_css_override_url(self):
self.css_node.context.update({'url': u'This is not a url, just a text'})
- output = css_tag('/media/CACHE/css/e41ba2cc6982.css')
+ output = css_tag('/static/CACHE/css/e41ba2cc6982.css')
self.assertEqual(output, self.css_node.output().strip())
def test_js_return_if_off(self):
@@ -126,20 +126,20 @@ def test_js_return_if_off(self):
settings.COMPRESS_PRECOMPILERS = precompilers
def test_js_return_if_on(self):
- output = u'<script type="text/javascript" src="/media/CACHE/js/066cd253eada.js"></script>'
+ output = u'<script type="text/javascript" src="/static/CACHE/js/066cd253eada.js"></script>'
self.assertEqual(output, self.js_node.output())
def test_custom_output_dir(self):
try:
old_output_dir = settings.COMPRESS_OUTPUT_DIR
settings.COMPRESS_OUTPUT_DIR = 'custom'
- output = u'<script type="text/javascript" src="/media/custom/js/066cd253eada.js"></script>'
+ output = u'<script type="text/javascript" src="/static/custom/js/066cd253eada.js"></script>'
self.assertEqual(output, JsCompressor(self.js).output())
settings.COMPRESS_OUTPUT_DIR = ''
- output = u'<script type="text/javascript" src="/media/js/066cd253eada.js"></script>'
+ output = u'<script type="text/javascript" src="/static/js/066cd253eada.js"></script>'
self.assertEqual(output, JsCompressor(self.js).output())
settings.COMPRESS_OUTPUT_DIR = '/custom/nested/'
- output = u'<script type="text/javascript" src="/media/custom/nested/js/066cd253eada.js"></script>'
+ output = u'<script type="text/javascript" src="/static/custom/nested/js/066cd253eada.js"></script>'
self.assertEqual(output, JsCompressor(self.js).output())
finally:
settings.COMPRESS_OUTPUT_DIR = old_output_dir
@@ -175,9 +175,9 @@ def test_nonexistent_precompiler_class_error(self):
class CssMediaTestCase(TestCase):
def setUp(self):
self.css = """\
-<link rel="stylesheet" href="/media/css/one.css" type="text/css" media="screen">
+<link rel="stylesheet" href="/static/css/one.css" type="text/css" media="screen">
<style type="text/css" media="print">p { border:5px solid green;}</style>
-<link rel="stylesheet" href="/media/css/two.css" type="text/css" media="all">
+<link rel="stylesheet" href="/static/css/two.css" type="text/css" media="all">
<style type="text/css">h1 { border:5px solid green;}</style>"""
def test_css_output(self):
@@ -201,12 +201,12 @@ def test_passthough_when_compress_disabled(self):
('text/foobar', 'python %s {infile} {outfile}' % os.path.join(test_dir, 'precompiler.py')),
)
css = """\
-<link rel="stylesheet" href="/media/css/one.css" type="text/css" media="screen">
-<link rel="stylesheet" href="/media/css/two.css" type="text/css" media="screen">
+<link rel="stylesheet" href="/static/css/one.css" type="text/css" media="screen">
+<link rel="stylesheet" href="/static/css/two.css" type="text/css" media="screen">
<style type="text/foobar" media="screen">h1 { border:5px solid green;}</style>"""
css_node = CssCompressor(css)
output = BeautifulSoup(css_node.output()).findAll(['link', 'style'])
- self.assertEqual([u'/media/css/one.css', u'/media/css/two.css', None],
+ self.assertEqual([u'/static/css/one.css', u'/static/css/two.css', None],
[l.get('href', None) for l in output])
self.assertEqual([u'screen', u'screen', u'screen'],
[l.get('media', None) for l in output])
View
48 compressor/tests/test_filters.py
@@ -37,7 +37,7 @@ def test_tidy(self):
class PrecompilerTestCase(TestCase):
def setUp(self):
- self.filename = os.path.join(test_dir, 'media/css/one.css')
+ self.filename = os.path.join(test_dir, 'static/css/one.css')
with open(self.filename) as f:
self.content = f.read()
self.test_precompiler = os.path.join(test_dir, 'precompiler.py')
@@ -93,11 +93,11 @@ def setUp(self):
self.old_url = settings.COMPRESS_URL
self.old_hashing_method = settings.COMPRESS_CSS_HASHING_METHOD
settings.COMPRESS_ENABLED = True
- settings.COMPRESS_URL = '/media/'
+ settings.COMPRESS_URL = '/static/'
settings.COMPRESS_CSS_HASHING_METHOD = self.hashing_method
self.css = """
- <link rel="stylesheet" href="/media/css/url/url1.css" type="text/css">
- <link rel="stylesheet" href="/media/css/url/2/url2.css" type="text/css">
+ <link rel="stylesheet" href="/static/css/url/url1.css" type="text/css">
+ <link rel="stylesheet" href="/static/css/url/2/url2.css" type="text/css">
"""
self.css_node = CssCompressor(self.css)
@@ -117,7 +117,7 @@ def test_css_absolute_filter(self):
"p { filter: Alpha(src='%(url)simg/python.png?%(hash)s') }") % params
filter = CssAbsoluteFilter(self.content)
self.assertEqual(output, filter.input(filename=filename, basename='css/url/test.css'))
- settings.COMPRESS_URL = params['url'] = 'http://media.example.com/'
+ settings.COMPRESS_URL = params['url'] = 'http://static.example.com/'
filter = CssAbsoluteFilter(self.content)
filename = os.path.join(settings.COMPRESS_ROOT, 'css/url/test.css')
output = ("p { background: url('%(url)simg/python.png?%(hash)s') }"
@@ -135,7 +135,7 @@ def test_css_absolute_filter_https(self):
"p { filter: Alpha(src='%(url)simg/python.png?%(hash)s') }") % params
filter = CssAbsoluteFilter(self.content)
self.assertEqual(output, filter.input(filename=filename, basename='css/url/test.css'))
- settings.COMPRESS_URL = params['url'] = 'https://media.example.com/'
+ settings.COMPRESS_URL = params['url'] = 'https://static.example.com/'
filter = CssAbsoluteFilter(self.content)
filename = os.path.join(settings.COMPRESS_ROOT, 'css/url/test.css')
output = ("p { background: url('%(url)simg/python.png?%(hash)s') }"
@@ -143,7 +143,7 @@ def test_css_absolute_filter_https(self):
self.assertEqual(output, filter.input(filename=filename, basename='css/url/test.css'))
def test_css_absolute_filter_relative_path(self):
- filename = os.path.join(settings.TEST_DIR, 'whatever', '..', 'media', 'whatever/../css/url/test.css')
+ filename = os.path.join(settings.TEST_DIR, 'whatever', '..', 'static', 'whatever/../css/url/test.css')
imagefilename = os.path.join(settings.COMPRESS_ROOT, 'img/python.png')
params = {
'url': settings.COMPRESS_URL,
@@ -153,7 +153,7 @@ def test_css_absolute_filter_relative_path(self):
"p { filter: Alpha(src='%(url)simg/python.png?%(hash)s') }") % params
filter = CssAbsoluteFilter(self.content)
self.assertEqual(output, filter.input(filename=filename, basename='css/url/test.css'))
- settings.COMPRESS_URL = params['url'] = 'https://media.example.com/'
+ settings.COMPRESS_URL = params['url'] = 'https://static.example.com/'
filter = CssAbsoluteFilter(self.content)
output = ("p { background: url('%(url)simg/python.png?%(hash)s') }"
"p { filter: Alpha(src='%(url)simg/python.png?%(hash)s') }") % params
@@ -165,22 +165,22 @@ def test_css_hunks(self):
'hash2': self.hashing_func(os.path.join(settings.COMPRESS_ROOT, 'img/add.png')),
}
self.assertEqual([u"""\
-p { background: url('/media/img/python.png?%(hash1)s'); }
-p { background: url('/media/img/python.png?%(hash1)s'); }
-p { background: url('/media/img/python.png?%(hash1)s'); }
-p { background: url('/media/img/python.png?%(hash1)s'); }
-p { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/media/img/python.png?%(hash1)s'); }
+p { background: url('/static/img/python.png?%(hash1)s'); }
+p { background: url('/static/img/python.png?%(hash1)s'); }
+p { background: url('/static/img/python.png?%(hash1)s'); }
+p { background: url('/static/img/python.png?%(hash1)s'); }
+p { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/static/img/python.png?%(hash1)s'); }
""" % hash_dict,
u"""\
-p { background: url('/media/img/add.png?%(hash2)s'); }
-p { background: url('/media/img/add.png?%(hash2)s'); }
-p { background: url('/media/img/add.png?%(hash2)s'); }
-p { background: url('/media/img/add.png?%(hash2)s'); }
-p { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/media/img/add.png?%(hash2)s'); }
+p { background: url('/static/img/add.png?%(hash2)s'); }
+p { background: url('/static/img/add.png?%(hash2)s'); }
+p { background: url('/static/img/add.png?%(hash2)s'); }
+p { background: url('/static/img/add.png?%(hash2)s'); }
+p { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/static/img/add.png?%(hash2)s'); }
""" % hash_dict], list(self.css_node.hunks()))
def test_guess_filename(self):
- for base_url in ('/media/', 'http://media.example.com/'):
+ for base_url in ('/static/', 'http://static.example.com/'):
settings.COMPRESS_URL = base_url
url = '%s/img/python.png' % settings.COMPRESS_URL.rstrip('/')
path = os.path.join(settings.COMPRESS_ROOT, 'img/python.png')
@@ -196,8 +196,8 @@ class CssAbsolutizingTestCaseWithHash(CssAbsolutizingTestCase):
def setUp(self):
super(CssAbsolutizingTestCaseWithHash, self).setUp()
self.css = """
- <link rel="stylesheet" href="/media/css/url/url1.css" type="text/css" charset="utf-8">
- <link rel="stylesheet" href="/media/css/url/2/url2.css" type="text/css" charset="utf-8">
+ <link rel="stylesheet" href="/static/css/url/url1.css" type="text/css" charset="utf-8">
+ <link rel="stylesheet" href="/static/css/url/2/url2.css" type="text/css" charset="utf-8">
"""
self.css_node = CssCompressor(self.css)
@@ -209,10 +209,10 @@ def setUp(self):
'compressor.filters.css_default.CssAbsoluteFilter',
'compressor.filters.datauri.CssDataUriFilter',
]
- settings.COMPRESS_URL = '/media/'
+ settings.COMPRESS_URL = '/static/'
settings.COMPRESS_CSS_HASHING_METHOD = 'mtime'
self.css = """
- <link rel="stylesheet" href="/media/css/datauri.css" type="text/css">
+ <link rel="stylesheet" href="/static/css/datauri.css" type="text/css">
"""
self.css_node = CssCompressor(self.css)
@@ -220,7 +220,7 @@ def test_data_uris(self):
datauri_hash = get_hashed_mtime(os.path.join(settings.COMPRESS_ROOT, 'img/python.png'))
out = [u'''.add { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJvSURBVDjLpZPrS5NhGIf9W7YvBYOkhlkoqCklWChv2WyKik7blnNris72bi6dus0DLZ0TDxW1odtopDs4D8MDZuLU0kXq61CijSIIasOvv94VTUfLiB74fXngup7nvrnvJABJ/5PfLnTTdcwOj4RsdYmo5glBWP6iOtzwvIKSWstI0Wgx80SBblpKtE9KQs/We7EaWoT/8wbWP61gMmCH0lMDvokT4j25TiQU/ITFkek9Ow6+7WH2gwsmahCPdwyw75uw9HEO2gUZSkfyI9zBPCJOoJ2SMmg46N61YO/rNoa39Xi41oFuXysMfh36/Fp0b7bAfWAH6RGi0HglWNCbzYgJaFjRv6zGuy+b9It96N3SQvNKiV9HvSaDfFEIxXItnPs23BzJQd6DDEVM0OKsoVwBG/1VMzpXVWhbkUM2K4oJBDYuGmbKIJ0qxsAbHfRLzbjcnUbFBIpx/qH3vQv9b3U03IQ/HfFkERTzfFj8w8jSpR7GBE123uFEYAzaDRIqX/2JAtJbDat/COkd7CNBva2cMvq0MGxp0PRSCPF8BXjWG3FgNHc9XPT71Ojy3sMFdfJRCeKxEsVtKwFHwALZfCUk3tIfNR8XiJwc1LmL4dg141JPKtj3WUdNFJqLGFVPC4OkR4BxajTWsChY64wmCnMxsWPCHcutKBxMVp5mxA1S+aMComToaqTRUQknLTH62kHOVEE+VQnjahscNCy0cMBWsSI0TCQcZc5ALkEYckL5A5noWSBhfm2AecMAjbcRWV0pUTh0HE64TNf0mczcnnQyu/MilaFJCae1nw2fbz1DnVOxyGTlKeZft/Ff8x1BRssfACjTwQAAAABJRU5ErkJggg=="); }
.add-with-hash { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAJvSURBVDjLpZPrS5NhGIf9W7YvBYOkhlkoqCklWChv2WyKik7blnNris72bi6dus0DLZ0TDxW1odtopDs4D8MDZuLU0kXq61CijSIIasOvv94VTUfLiB74fXngup7nvrnvJABJ/5PfLnTTdcwOj4RsdYmo5glBWP6iOtzwvIKSWstI0Wgx80SBblpKtE9KQs/We7EaWoT/8wbWP61gMmCH0lMDvokT4j25TiQU/ITFkek9Ow6+7WH2gwsmahCPdwyw75uw9HEO2gUZSkfyI9zBPCJOoJ2SMmg46N61YO/rNoa39Xi41oFuXysMfh36/Fp0b7bAfWAH6RGi0HglWNCbzYgJaFjRv6zGuy+b9It96N3SQvNKiV9HvSaDfFEIxXItnPs23BzJQd6DDEVM0OKsoVwBG/1VMzpXVWhbkUM2K4oJBDYuGmbKIJ0qxsAbHfRLzbjcnUbFBIpx/qH3vQv9b3U03IQ/HfFkERTzfFj8w8jSpR7GBE123uFEYAzaDRIqX/2JAtJbDat/COkd7CNBva2cMvq0MGxp0PRSCPF8BXjWG3FgNHc9XPT71Ojy3sMFdfJRCeKxEsVtKwFHwALZfCUk3tIfNR8XiJwc1LmL4dg141JPKtj3WUdNFJqLGFVPC4OkR4BxajTWsChY64wmCnMxsWPCHcutKBxMVp5mxA1S+aMComToaqTRUQknLTH62kHOVEE+VQnjahscNCy0cMBWsSI0TCQcZc5ALkEYckL5A5noWSBhfm2AecMAjbcRWV0pUTh0HE64TNf0mczcnnQyu/MilaFJCae1nw2fbz1DnVOxyGTlKeZft/Ff8x1BRssfACjTwQAAAABJRU5ErkJggg=="); }
-.python { background-image: url("/media/img/python.png?%s"); }
+.python { background-image: url("/static/img/python.png?%s"); }
.datauri { background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9YGARc5KB0XV+IAAAAddEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIFRoZSBHSU1Q72QlbgAAAF1JREFUGNO9zL0NglAAxPEfdLTs4BZM4DIO4C7OwQg2JoQ9LE1exdlYvBBeZ7jqch9//q1uH4TLzw4d6+ErXMMcXuHWxId3KOETnnXXV6MJpcq2MLaI97CER3N0 vr4MkhoXe0rZigAAAABJRU5ErkJggg=="); }
''' % datauri_hash]
self.assertEqual(out, list(self.css_node.hunks()))
View
46 compressor/tests/test_jinja2ext.py
@@ -55,61 +55,61 @@ def test_compress_is_disabled(self):
def test_empty_tag(self):
template = self.env.from_string(u"""{% compress js %}{% block js %}
{% endblock %}{% endcompress %}""")
- context = {'MEDIA_URL': settings.COMPRESS_URL}
+ context = {'STATIC_URL': settings.COMPRESS_URL}
self.assertEqual(u'', template.render(context))
def test_css_tag(self):
template = self.env.from_string(u"""{% compress css -%}
- <link rel="stylesheet" href="{{ MEDIA_URL }}css/one.css" type="text/css" charset="utf-8">
+ <link rel="stylesheet" href="{{ STATIC_URL }}css/one.css" type="text/css" charset="utf-8">
<style type="text/css">p { border:5px solid green;}</style>
- <link rel="stylesheet" href="{{ MEDIA_URL }}css/two.css" type="text/css" charset="utf-8">
+ <link rel="stylesheet" href="{{ STATIC_URL }}css/two.css" type="text/css" charset="utf-8">
{% endcompress %}""")
- context = {'MEDIA_URL': settings.COMPRESS_URL}
- out = css_tag("/media/CACHE/css/e41ba2cc6982.css")
+ context = {'STATIC_URL': settings.COMPRESS_URL}
+ out = css_tag("/static/CACHE/css/e41ba2cc6982.css")
self.assertEqual(out, template.render(context))
def test_nonascii_css_tag(self):
template = self.env.from_string(u"""{% compress css -%}
- <link rel="stylesheet" href="{{ MEDIA_URL }}css/nonasc.css" type="text/css" charset="utf-8">
+ <link rel="stylesheet" href="{{ STATIC_URL }}css/nonasc.css" type="text/css" charset="utf-8">
<style type="text/css">p { border:5px solid green;}</style>
{% endcompress %}""")
- context = {'MEDIA_URL': settings.COMPRESS_URL}
- out = css_tag("/media/CACHE/css/799f6defe43c.css")
+ context = {'STATIC_URL': settings.COMPRESS_URL}
+ out = css_tag("/static/CACHE/css/799f6defe43c.css")
self.assertEqual(out, template.render(context))
def test_js_tag(self):
template = self.env.from_string(u"""{% compress js -%}
- <script src="{{ MEDIA_URL }}js/one.js" type="text/javascript" charset="utf-8"></script>
+ <script src="{{ STATIC_URL }}js/one.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">obj.value = "value";</script>
{% endcompress %}""")
- context = {'MEDIA_URL': settings.COMPRESS_URL}
- out = u'<script type="text/javascript" src="/media/CACHE/js/066cd253eada.js"></script>'
+ context = {'STATIC_URL': settings.COMPRESS_URL}
+ out = u'<script type="text/javascript" src="/static/CACHE/js/066cd253eada.js"></script>'
self.assertEqual(out, template.render(context))
def test_nonascii_js_tag(self):
template = self.env.from_string(u"""{% compress js -%}
- <script src="{{ MEDIA_URL }}js/nonasc.js" type="text/javascript" charset="utf-8"></script>
+ <script src="{{ STATIC_URL }}js/nonasc.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">var test_value = "\u2014";</script>
{% endcompress %}""")
- context = {'MEDIA_URL': settings.COMPRESS_URL}
- out = u'<script type="text/javascript" src="/media/CACHE/js/e214fe629b28.js"></script>'
+ context = {'STATIC_URL': settings.COMPRESS_URL}
+ out = u'<script type="text/javascript" src="/static/CACHE/js/e214fe629b28.js"></script>'
self.assertEqual(out, template.render(context))
def test_nonascii_latin1_js_tag(self):
template = self.env.from_string(u"""{% compress js -%}
- <script src="{{ MEDIA_URL }}js/nonasc-latin1.js" type="text/javascript" charset="latin-1"></script>
+ <script src="{{ STATIC_URL }}js/nonasc-latin1.js" type="text/javascript" charset="latin-1"></script>
<script type="text/javascript">var test_value = "\u2014";</script>
{% endcompress %}""")
- context = {'MEDIA_URL': settings.COMPRESS_URL}
- out = u'<script type="text/javascript" src="/media/CACHE/js/be9e078b5ca7.js"></script>'
+ context = {'STATIC_URL': settings.COMPRESS_URL}
+ out = u'<script type="text/javascript" src="/static/CACHE/js/be9e078b5ca7.js"></script>'
self.assertEqual(out, template.render(context))
def test_css_inline(self):
template = self.env.from_string(u"""{% compress css, inline -%}
- <link rel="stylesheet" href="{{ MEDIA_URL }}css/one.css" type="text/css" charset="utf-8">
+ <link rel="stylesheet" href="{{ STATIC_URL }}css/one.css" type="text/css" charset="utf-8">
<style type="text/css">p { border:5px solid green;}</style>
{% endcompress %}""")
- context = {'MEDIA_URL': settings.COMPRESS_URL}
+ context = {'STATIC_URL': settings.COMPRESS_URL}
out = '\n'.join([
'<style type="text/css">body { background:#990; }',
'p { border:5px solid green;}</style>',
@@ -118,10 +118,10 @@ def test_css_inline(self):
def test_js_inline(self):
template = self.env.from_string(u"""{% compress js, inline -%}
- <script src="{{ MEDIA_URL }}js/one.js" type="text/css" type="text/javascript" charset="utf-8"></script>
+ <script src="{{ STATIC_URL }}js/one.js" type="text/css" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">obj.value = "value";</script>
{% endcompress %}""")
- context = {'MEDIA_URL': settings.COMPRESS_URL}
+ context = {'STATIC_URL': settings.COMPRESS_URL}
out = '<script type="text/javascript">obj={};obj.value="value";</script>'
self.assertEqual(out, template.render(context))
@@ -132,7 +132,7 @@ def test_nonascii_inline_css(self):
u'<style type="text/css">'
u'/* русский текст */'
u'</style>{% endcompress %}')
- out = u'<link rel="stylesheet" href="/media/CACHE/css/b2cec0f8cb24.css" type="text/css" />'
+ out = u'<link rel="stylesheet" href="/static/CACHE/css/b2cec0f8cb24.css" type="text/css" />'
settings.COMPRESS_ENABLED = org_COMPRESS_ENABLED
- context = {'MEDIA_URL': settings.COMPRESS_URL}
+ context = {'STATIC_URL': settings.COMPRESS_URL}
self.assertEqual(out, template.render(context))
View
12 compressor/tests/test_offline.py
@@ -55,7 +55,7 @@ def test_offline(self):
count, result = CompressCommand().compress(log=self.log, verbosity=self.verbosity)
self.assertEqual(1, count)
self.assertEqual([
- u'<script type="text/javascript" src="/media/CACHE/js/%s.js"></script>' % (self.expected_hash, ),
+ u'<script type="text/javascript" src="/static/CACHE/js/%s.js"></script>' % (self.expected_hash, ),
], result)
rendered_template = self.template.render(Context(settings.COMPRESS_OFFLINE_CONTEXT))
self.assertEqual(rendered_template, "".join(result) + "\n")
@@ -97,8 +97,8 @@ def test_offline(self):
count, result = CompressCommand().compress(log=self.log, verbosity=self.verbosity)
self.assertEqual(2, count)
self.assertEqual([
- u'<script type="text/javascript" src="/media/CACHE/js/ced14aec5856.js"></script>',
- u'<script type="text/javascript" src="/media/CACHE/js/7c02d201f69d.js"></script>'
+ u'<script type="text/javascript" src="/static/CACHE/js/ced14aec5856.js"></script>',
+ u'<script type="text/javascript" src="/static/CACHE/js/7c02d201f69d.js"></script>'
], result)
rendered_template = self.template.render(Context(settings.COMPRESS_OFFLINE_CONTEXT))
self.assertEqual(rendered_template, "".join(result) + "\n")
@@ -156,8 +156,8 @@ class OfflineGenerationTestCaseErrors(OfflineTestCaseMixin, TestCase):
def test_offline(self):
count, result = CompressCommand().compress(log=self.log, verbosity=self.verbosity)
self.assertEqual(2, count)
- self.assertIn(u'<script type="text/javascript" src="/media/CACHE/js/3872c9ae3f42.js"></script>', result)
- self.assertIn(u'<script type="text/javascript" src="/media/CACHE/js/cd8870829421.js"></script>', result)
+ self.assertIn(u'<script type="text/javascript" src="/static/CACHE/js/3872c9ae3f42.js"></script>', result)
+ self.assertIn(u'<script type="text/javascript" src="/static/CACHE/js/cd8870829421.js"></script>', result)
class OfflineGenerationTestCaseWithError(OfflineTestCaseMixin, TestCase):
@@ -209,7 +209,7 @@ def test_deleting_manifest_does_not_affect_rendering(self):
default_storage.delete(manifest_path)
self.assertEqual(1, count)
self.assertEqual([
- u'<script type="text/javascript" src="/media/CACHE/js/%s.js"></script>' % (self.expected_hash, ),
+ u'<script type="text/javascript" src="/static/CACHE/js/%s.js"></script>' % (self.expected_hash, ),
], result)
rendered_template = self.template.render(Context(settings.COMPRESS_OFFLINE_CONTEXT))
self.assertEqual(rendered_template, "".join(result) + "\n")
View
10 compressor/tests/test_parsers.py
@@ -47,16 +47,16 @@ def setUp(self):
super(Html5LibParserTests, self).setUp()
# special version of the css since the parser sucks
self.css = """\
-<link href="/media/css/one.css" rel="stylesheet" type="text/css">
+<link href="/static/css/one.css" rel="stylesheet" type="text/css">
<style type="text/css">p { border:5px solid green;}</style>
-<link href="/media/css/two.css" rel="stylesheet" type="text/css">"""
+<link href="/static/css/two.css" rel="stylesheet" type="text/css">"""
self.css_node = CssCompressor(self.css)
def test_css_split(self):
out = [
- (SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css', u'one.css'), u'css/one.css', u'<link href="/media/css/one.css" rel="stylesheet" type="text/css">'),
+ (SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css', u'one.css'), u'css/one.css', u'<link href="/static/css/one.css" rel="stylesheet" type="text/css">'),
(SOURCE_HUNK, u'p { border:5px solid green;}', None, u'<style type="text/css">p { border:5px solid green;}</style>'),
- (SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css', u'two.css'), u'css/two.css', u'<link href="/media/css/two.css" rel="stylesheet" type="text/css">'),
+ (SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'css', u'two.css'), u'css/two.css', u'<link href="/static/css/two.css" rel="stylesheet" type="text/css">'),
]
split = self.css_node.split_contents()
split = [(x[0], x[1], x[2], self.css_node.parser.elem_str(x[3])) for x in split]
@@ -64,7 +64,7 @@ def test_css_split(self):
def test_js_split(self):
out = [
- (SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'js', u'one.js'), u'js/one.js', u'<script src="/media/js/one.js" type="text/javascript"></script>'),
+ (SOURCE_FILE, os.path.join(settings.COMPRESS_ROOT, u'js', u'one.js'), u'js/one.js', u'<script src="/static/js/one.js" type="text/javascript"></script>'),
(SOURCE_HUNK, u'obj.value = "value";', None, u'<script type="text/javascript">obj.value = "value";</script>'),
]
split = self.js_node.split_contents()
View
10 compressor/tests/test_signals.py
@@ -14,13 +14,13 @@ def setUp(self):
settings.COMPRESS_PRECOMPILERS = {}
settings.COMPRESS_DEBUG_TOGGLE = 'nocompress'
self.css = """\
-<link rel="stylesheet" href="/media/css/one.css" type="text/css" />
+<link rel="stylesheet" href="/static/css/one.css" type="text/css" />
<style type="text/css">p { border:5px solid green;}</style>
-<link rel="stylesheet" href="/media/css/two.css" type="text/css" />"""
+<link rel="stylesheet" href="/static/css/two.css" type="text/css" />"""
self.css_node = CssCompressor(self.css)
self.js = """\
-<script src="/media/js/one.js" type="text/javascript"></script>
+<script src="/static/js/one.js" type="text/javascript"></script>
<script type="text/javascript">obj.value = "value";</script>"""
self.js_node = JsCompressor(self.js)
@@ -55,9 +55,9 @@ def listener(sender, **kwargs):
def test_css_signal_multiple_media_attributes(self):
css = """\
-<link rel="stylesheet" href="/media/css/one.css" media="handheld" type="text/css" />
+<link rel="stylesheet" href="/static/css/one.css" media="handheld" type="text/css" />
<style type="text/css" media="print">p { border:5px solid green;}</style>
-<link rel="stylesheet" href="/media/css/two.css" type="text/css" />"""
+<link rel="stylesheet" href="/static/css/two.css" type="text/css" />"""
css_node = CssCompressor(css)
def listener(sender, **kwargs):
View
8 compressor/tests/test_storages.py
@@ -24,13 +24,13 @@ def tearDown(self):
def test_css_tag_with_storage(self):
template = u"""{% load compress %}{% compress css %}
- <link rel="stylesheet" href="{{ MEDIA_URL }}css/one.css" type="text/css">
+ <link rel="stylesheet" href="{{ STATIC_URL }}css/one.css" type="text/css">
<style type="text/css">p { border:5px solid white;}</style>
- <link rel="stylesheet" href="{{ MEDIA_URL }}css/two.css" type="text/css">
+ <link rel="stylesheet" href="{{ STATIC_URL }}css/two.css" type="text/css">
{% endcompress %}
"""
- context = {'MEDIA_URL': settings.COMPRESS_URL}
- out = css_tag("/media/CACHE/css/1d4424458f88.css")
+ context = {'STATIC_URL': settings.COMPRESS_URL}
+ out = css_tag("/static/CACHE/css/1d4424458f88.css")
self.assertEqual(out, render(template, context))
def test_race_condition_handling(self):
View
76 compressor/tests/test_templatetags.py
@@ -28,7 +28,7 @@ class TemplatetagTestCase(TestCase):
def setUp(self):
self.old_enabled = settings.COMPRESS_ENABLED
settings.COMPRESS_ENABLED = True
- self.context = {'MEDIA_URL': settings.COMPRESS_URL}
+ self.context = {'STATIC_URL': settings.COMPRESS_URL}
def tearDown(self):
settings.COMPRESS_ENABLED = self.old_enabled
@@ -40,58 +40,58 @@ def test_empty_tag(self):
def test_css_tag(self):
template = u"""{% load compress %}{% compress css %}
-<link rel="stylesheet" href="{{ MEDIA_URL }}css/one.css" type="text/css">
+<link rel="stylesheet" href="{{ STATIC_URL }}css/one.css" type="text/css">
<style type="text/css">p { border:5px solid green;}</style>
-<link rel="stylesheet" href="{{ MEDIA_URL }}css/two.css" type="text/css">
+<link rel="stylesheet" href="{{ STATIC_URL }}css/two.css" type="text/css">
{% endcompress %}"""
- out = css_tag("/media/CACHE/css/e41ba2cc6982.css")
+ out = css_tag("/static/CACHE/css/e41ba2cc6982.css")
self.assertEqual(out, render(template, self.context))
maxDiff = None
def test_uppercase_rel(self):
template = u"""{% load compress %}{% compress css %}
-<link rel="StyleSheet" href="{{ MEDIA_URL }}css/one.css" type="text/css">
+<link rel="StyleSheet" href="{{ STATIC_URL }}css/one.css" type="text/css">
<style type="text/css">p { border:5px solid green;}</style>
-<link rel="StyleSheet" href="{{ MEDIA_URL }}css/two.css" type="text/css">
+<link rel="StyleSheet" href="{{ STATIC_URL }}css/two.css" type="text/css">
{% endcompress %}"""
- out = css_tag("/media/CACHE/css/e41ba2cc6982.css")
+ out = css_tag("/static/CACHE/css/e41ba2cc6982.css")
self.assertEqual(out, render(template, self.context))
def test_nonascii_css_tag(self):
template = u"""{% load compress %}{% compress css %}
- <link rel="stylesheet" href="{{ MEDIA_URL }}css/nonasc.css" type="text/css">
+ <link rel="stylesheet" href="{{ STATIC_URL }}css/nonasc.css" type="text/css">
<style type="text/css">p { border:5px solid green;}</style>
{% endcompress %}
"""
- out = css_tag("/media/CACHE/css/799f6defe43c.css")
+ out = css_tag("/static/CACHE/css/799f6defe43c.css")
self.assertEqual(out, render(template, self.context))
def test_js_tag(self):
template = u"""{% load compress %}{% compress js %}
- <script src="{{ MEDIA_URL }}js/one.js" type="text/javascript"></script>
+ <script src="{{ STATIC_URL }}js/one.js" type="text/javascript"></script>
<script type="text/javascript">obj.value = "value";</script>
{% endcompress %}
"""
- out = u'<script type="text/javascript" src="/media/CACHE/js/066cd253eada.js"></script>'
+ out = u'<script type="text/javascript" src="/static/CACHE/js/066cd253eada.js"></script>'
self.assertEqual(out, render(template, self.context))
def test_nonascii_js_tag(self):
template = u"""{% load compress %}{% compress js %}
- <script src="{{ MEDIA_URL }}js/nonasc.js" type="text/javascript"></script>
+ <script src="{{ STATIC_URL }}js/nonasc.js" type="text/javascript"></script>
<script type="text/javascript">var test_value = "\u2014";</script>
{% endcompress %}
"""
- out = u'<script type="text/javascript" src="/media/CACHE/js/e214fe629b28.js"></script>'
+ out = u'<script type="text/javascript" src="/static/CACHE/js/e214fe629b28.js"></script>'
self.assertEqual(out, render(template, self.context))
def test_nonascii_latin1_js_tag(self):
template = u"""{% load compress %}{% compress js %}
- <script src="{{ MEDIA_URL }}js/nonasc-latin1.js" type="text/javascript" charset="latin-1"></script>
+ <script src="{{ STATIC_URL }}js/nonasc-latin1.js" type="text/javascript" charset="latin-1"></script>
<script type="text/javascript">var test_value = "\u2014";</script>
{% endcompress %}
"""
- out = u'<script type="text/javascript" src="/media/CACHE/js/be9e078b5ca7.js"></script>'
+ out = u'<script type="text/javascript" src="/static/CACHE/js/be9e078b5ca7.js"></script>'
self.assertEqual(out, render(template, self.context))
def test_compress_tag_with_illegal_arguments(self):
@@ -102,7 +102,7 @@ def test_compress_tag_with_illegal_arguments(self):
def test_debug_toggle(self):
template = u"""{% load compress %}{% compress js %}
- <script src="{{ MEDIA_URL }}js/one.js" type="text/javascript"></script>
+ <script src="{{ STATIC_URL }}js/one.js" type="text/javascript"></script>
<script type="text/javascript">obj.value = "value";</script>
{% endcompress %}
"""
@@ -111,7 +111,7 @@ class MockDebugRequest(object):
GET = {settings.COMPRESS_DEBUG_TOGGLE: 'true'}
context = dict(self.context, request=MockDebugRequest())
- out = u"""<script src="/media/js/one.js" type="text/javascript"></script>
+ out = u"""<script src="/static/js/one.js" type="text/javascript"></script>
<script type="text/javascript">obj.value = "value";</script>"""
self.assertEqual(out, render(template, context))
@@ -144,7 +144,7 @@ def setUp(self):
('text/coffeescript', '%s %s' % (python, precompiler)),
('text/less', '%s %s' % (python, precompiler)),
)
- self.context = {'MEDIA_URL': settings.COMPRESS_URL}
+ self.context = {'STATIC_URL': settings.COMPRESS_URL}
def tearDown(self):
settings.COMPRESS_ENABLED = self.old_enabled
@@ -154,7 +154,7 @@ def test_compress_coffeescript_tag(self):
template = u"""{% load compress %}{% compress js %}
<script type="text/coffeescript"># this is a comment.</script>
{% endcompress %}"""
- out = script(src="/media/CACHE/js/e920d58f166d.js")
+ out = script(src="/static/CACHE/js/e920d58f166d.js")
self.assertEqual(out, render(template, self.context))
def test_compress_coffeescript_tag_and_javascript_tag(self):
@@ -162,7 +162,7 @@ def test_compress_coffeescript_tag_and_javascript_tag(self):
<script type="text/coffeescript"># this is a comment.</script>
<script type="text/javascript"># this too is a comment.</script>
{% endcompress %}"""
- out = script(src="/media/CACHE/js/ef6b32a54575.js")
+ out = script(src="/static/CACHE/js/ef6b32a54575.js")
self.assertEqual(out, render(template, self.context))
def test_coffeescript_and_js_tag_with_compress_enabled_equals_false(self):
@@ -197,11 +197,11 @@ def test_compress_coffeescript_file_tag_compress_enabled_is_false(self):
try:
template = u"""
{% load compress %}{% compress js %}
- <script type="text/coffeescript" src="{{ MEDIA_URL }}js/one.coffee">
+ <script type="text/coffeescript" src="{{ STATIC_URL }}js/one.coffee">
</script>
{% endcompress %}"""
- out = script(src="/media/CACHE/js/one.95cfb869eead.js")
+ out = script(src="/static/CACHE/js/one.95cfb869eead.js")
self.assertEqual(out, render(template, self.context))
finally:
settings.COMPRESS_ENABLED = self.old_enabled
@@ -212,16 +212,16 @@ def test_multiple_file_order_conserved(self):
try:
template = u"""
{% load compress %}{% compress js %}
- <script type="text/coffeescript" src="{{ MEDIA_URL }}js/one.coffee">
+ <script type="text/coffeescript" src="{{ STATIC_URL }}js/one.coffee">
</script>
- <script src="{{ MEDIA_URL }}js/one.js"></script>
- <script type="text/coffeescript" src="{{ MEDIA_URL }}js/one.js">
+ <script src="{{ STATIC_URL }}js/one.js"></script>
+ <script type="text/coffeescript" src="{{ STATIC_URL }}js/one.js">
</script>
{% endcompress %}"""
- out = '\n'.join([script(src="/media/CACHE/js/one.95cfb869eead.js"),
- script(scripttype="", src="/media/js/one.js"),
- script(src="/media/CACHE/js/one.81a2cd965815.js")])
+ out = '\n'.join([script(src="/static/CACHE/js/one.95cfb869eead.js"),
+ script(scripttype="", src="/static/js/one.js"),
+ script(src="/static/CACHE/js/one.81a2cd965815.js")])
self.assertEqual(out, render(template, self.context))
finally:
@@ -234,12 +234,12 @@ def test_css_multiple_files_disabled_compression(self):
try:
template = u"""
{% load compress %}{% compress css %}
- <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/one.css"></link>
- <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/two.css"></link>
+ <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/one.css"></link>
+ <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/two.css"></link>
{% endcompress %}"""
- out = ''.join(['<link rel="stylesheet" type="text/css" href="/media/css/one.css" />',
- '<link rel="stylesheet" type="text/css" href="/media/css/two.css" />'])
+ out = ''.join(['<link rel="stylesheet" type="text/css" href="/static/css/one.css" />',
+ '<link rel="stylesheet" type="text/css" href="/static/css/two.css" />'])
self.assertEqual(out, render(template, self.context))
finally:
@@ -252,14 +252,14 @@ def test_css_multiple_files_mixed_precompile_disabled_compression(self):
try:
template = u"""
{% load compress %}{% compress css %}
- <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/one.css"/>
- <link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/two.css"/>
- <link rel="stylesheet" type="text/less" href="{{ MEDIA_URL }}css/url/test.css"/>
+ <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/one.css"/>
+ <link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}css/two.css"/>
+ <link rel="stylesheet" type="text/less" href="{{ STATIC_URL }}css/url/test.css"/>
{% endcompress %}"""
- out = ''.join(['<link rel="stylesheet" type="text/css" href="/media/css/one.css" />',
- '<link rel="stylesheet" type="text/css" href="/media/css/two.css" />',
- '<link rel="stylesheet" href="/media/CACHE/css/test.c4f8a285c249.css" type="text/css" />'])
+ out = ''.join(['<link rel="stylesheet" type="text/css" href="/static/css/one.css" />',
+ '<link rel="stylesheet" type="text/css" href="/static/css/two.css" />',
+ '<link rel="stylesheet" href="/static/CACHE/css/test.5dddc6c2fb5a.css" type="text/css" />'])
self.assertEqual(out, render(template, self.context))
finally:
settings.COMPRESS_ENABLED = self.old_enabled
View
2  docs/quickstart.txt
@@ -18,7 +18,7 @@ Installation
* See the list of :ref:`settings` to modify Django Compressor's
default behaviour and make adjustments for your website.
-* In case you use Django 1.3's staticfiles_ contrib app (or its standalone
+* In case you use Django's staticfiles_ contrib app (or its standalone
counterpart django-staticfiles_) you have to add Django Compressor's file
finder to the ``STATICFILES_FINDERS`` setting, for example with
``django.contrib.staticfiles``:
View
2  docs/remote-storages.txt
@@ -39,7 +39,7 @@ The storage backend to save the compressed files needs to be changed, too::
Using staticfiles
^^^^^^^^^^^^^^^^^
-If you are using Django 1.3's staticfiles_ contrib app or the standalone
+If you are using Django's staticfiles_ contrib app or the standalone
app django-staticfiles_, you'll need to use a temporary filesystem cache
for Django Compressor to know which files to compress. Since staticfiles
provides a management command to collect static files from various
View
16 docs/settings.txt
@@ -43,30 +43,20 @@ Base settings
.. attribute:: COMPRESS_URL
- :Default: ``STATIC_URL`` (``MEDIA_URL`` for older Django versions)
+ :Default: ``STATIC_URL``
Controls the URL that linked files will be read from and compressed files
will be written to.
- .. note::
-
- This setting defaults to ``MEDIA_URL`` in case ``STATIC_URL``
- is not given or empty, e.g. on older Django versions (< 1.3).
-
.. attribute:: COMPRESS_ROOT
- :Default: ``STATIC_ROOT`` (``MEDIA_ROOT`` for older Django versions)
+ :Default: ``STATIC_ROOT``
Controls the absolute file path that linked static will be read from and
compressed static will be written to when using the default
:attr:`~django.conf.settings.COMPRESS_STORAGE`
``compressor.storage.CompressorFileStorage``.
- .. note::
-
- This setting defaults to ``MEDIA_ROOT`` in case ``STATIC_ROOT``
- is not given, e.g. on older Django versions (< 1.3).
-
.. attribute:: COMPRESS_OUTPUT_DIR
:Default: ``'CACHE'``
@@ -422,7 +412,7 @@ Offline settings
.. attribute:: COMPRESS_OFFLINE_CONTEXT
- :Default: ``{'MEDIA_URL': settings.MEDIA_URL}``
+ :Default: ``{'STATIC_URL': settings.STATIC_URL}``
The context to be used by the ``compress`` management command when rendering
the contents of ``{% compress %}`` template tags and saving the result in the
View
3  docs/usage.txt
@@ -145,8 +145,7 @@ command::
}
If not specified, the ``COMPRESS_OFFLINE_CONTEXT`` will by default contain
-the commonly used setting to refer to saved files ``MEDIA_URL`` and
-``STATIC_URL`` (if specified in the settings).
+the commonly used setting to refer to saved files ``STATIC_URL``.
The result of running the ``compress`` management command will be cached
in a file called ``manifest.json`` using the :attr:`configured storage
Please sign in to comment.
Something went wrong with that request. Please try again.