Permalink
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...
1 parent 8279b90 commit 9c64b478e2569eb9001fb31655389d5a76b60101 @diox diox committed Oct 8, 2012
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. BIN compressor/tests/{media → static}/img/add.png
  17. BIN 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
@@ -1,12 +1,12 @@
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
*.egg-info
*.egg
docs/_build/
.sass-cache
-.coverage
+.coverage
View
@@ -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,52 +68,35 @@ 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")
return 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):
@@ -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'),
)
@@ -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',
@@ -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.
"""
@@ -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
@@ -1 +0,0 @@
-p { background: url('/media/images/image.gif') }
@@ -0,0 +1 @@
+p { background: url('/static/images/image.gif') }
@@ -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])
Oops, something went wrong.

0 comments on commit 9c64b47

Please sign in to comment.