Commit f5ec70b4 by Timothée Peignier

fix absolute path generation

parent 8c16870f
...@@ -122,7 +122,7 @@ class Compressor(object): ...@@ -122,7 +122,7 @@ class Compressor(object):
def construct_asset_path(self, asset_path, css_path, variant=None): def construct_asset_path(self, asset_path, css_path, variant=None):
"""Return a rewritten asset URL for a stylesheet""" """Return a rewritten asset URL for a stylesheet"""
public_path = self.absolute_path(asset_path, css_path) public_path = self.absolute_path(asset_path, os.path.dirname(css_path))
if self.embeddable(public_path, variant): if self.embeddable(public_path, variant):
return "__EMBED__%s" % public_path return "__EMBED__%s" % public_path
if not os.path.isabs(asset_path): if not os.path.isabs(asset_path):
...@@ -195,7 +195,7 @@ class Compressor(object): ...@@ -195,7 +195,7 @@ class Compressor(object):
if os.path.isabs(path): if os.path.isabs(path):
path = os.path.join(settings.PIPELINE_ROOT, path) path = os.path.join(settings.PIPELINE_ROOT, path)
else: else:
path = os.path.join(os.path.dirname(start), path) path = os.path.join(start, path)
return os.path.normpath(path) return os.path.normpath(path)
def relative_path(self, absolute_path): def relative_path(self, absolute_path):
......
...@@ -16,9 +16,9 @@ if not settings.configured: ...@@ -16,9 +16,9 @@ if not settings.configured:
'tests' 'tests'
], ],
MEDIA_URL='/media/', MEDIA_URL='/media/',
MEDIA_ROOT=os.path.join(TEST_DIR, 'media/'), MEDIA_ROOT=os.path.join(TEST_DIR, 'media'),
STATIC_URL='/static/', STATIC_URL='/static/',
STATIC_ROOT=os.path.join(TEST_DIR, 'static/'), STATIC_ROOT=os.path.join(TEST_DIR, 'static'),
TEMPLATE_DIRS=( TEMPLATE_DIRS=(
os.path.join(TEST_DIR, 'templates'), os.path.join(TEST_DIR, 'templates'),
), ),
......
...@@ -52,10 +52,10 @@ class CompressorTest(TestCase): ...@@ -52,10 +52,10 @@ class CompressorTest(TestCase):
def test_absolute_path(self): def test_absolute_path(self):
absolute_path = self.compressor.absolute_path('../../images/sprite.png', absolute_path = self.compressor.absolute_path('../../images/sprite.png',
'css/plugins/gallery.css') 'css/plugins/')
self.assertEquals(absolute_path, 'images/sprite.png') self.assertEquals(absolute_path, 'images/sprite.png')
absolute_path = self.compressor.absolute_path('/images/sprite.png', absolute_path = self.compressor.absolute_path('/images/sprite.png',
'css/plugins/gallery.css') 'css/plugins/')
self.assertEquals(absolute_path, '/images/sprite.png') self.assertEquals(absolute_path, '/images/sprite.png')
def test_template_name(self): def test_template_name(self):
......
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