Commit 05e0a940 by Timothée Peignier

ensuring that absolute path stay absolute. close #3

parent 4cd6026f
...@@ -207,7 +207,7 @@ class Compressor(object): ...@@ -207,7 +207,7 @@ class Compressor(object):
def relative_path(self, absolute_path): def relative_path(self, absolute_path):
"""Rewrite paths relative to the output stylesheet path""" """Rewrite paths relative to the output stylesheet path"""
compress_root = os.path.normpath(settings.PIPELINE_ROOT) compress_root = os.path.normpath(settings.PIPELINE_ROOT)
return os.path.join('../', absolute_path.replace(compress_root, '')) return os.path.join(os.sep, absolute_path.replace(compress_root, ''))
def read_file(self, path): def read_file(self, path):
"""Read file content in binary mode""" """Read file content in binary mode"""
......
from django.conf import settings from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
PIPELINE_ROOT = getattr(settings, 'PIPELINE_ROOT', settings.MEDIA_ROOT) PIPELINE_ROOT = getattr(settings, 'PIPELINE_ROOT', settings.MEDIA_ROOT)
...@@ -57,3 +58,7 @@ PIPELINE_LESS_ARGUMENTS = getattr(settings, 'PIPELINE_LESS_ARGUMENTS', '-x') ...@@ -57,3 +58,7 @@ PIPELINE_LESS_ARGUMENTS = getattr(settings, 'PIPELINE_LESS_ARGUMENTS', '-x')
if PIPELINE_COMPILERS is None: if PIPELINE_COMPILERS is None:
PIPELINE_COMPILERS = [] PIPELINE_COMPILERS = []
if not PIPELINE_URL:
raise ImproperlyConfigured("You're using the pipeline app "
"without having set the required STATIC_URL setting.")
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
background-image: url(../images/sprite-buttons.png); background-image: url(../images/sprite-buttons.png);
} }
.absolute-url { .absolute-url {
background-image: url(/images/sprite-buttons.png);
}
.absolute-full-url {
background-image: url(http://localhost/images/sprite-buttons.png); background-image: url(http://localhost/images/sprite-buttons.png);
} }
.no-protocol-url { .no-protocol-url {
......
...@@ -82,10 +82,13 @@ class CompressorTest(TestCase): ...@@ -82,10 +82,13 @@ class CompressorTest(TestCase):
output = self.compressor.concatenate_and_rewrite([ output = self.compressor.concatenate_and_rewrite([
'css/urls.css', 'css/urls.css',
]) ])
self.assertEquals(""".relative-url { self.assertMultiLineEqual(""".relative-url {
background-image: url(http://localhost/static/images/sprite-buttons.png); background-image: url(http://localhost/static/images/sprite-buttons.png);
} }
.absolute-url { .absolute-url {
background-image: url(http://localhost/static/images/sprite-buttons.png);
}
.absolute-full-url {
background-image: url(http://localhost/images/sprite-buttons.png); background-image: url(http://localhost/images/sprite-buttons.png);
} }
.no-protocol-url { .no-protocol-url {
......
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