Commit 6a37fce5 by Timothée Peignier

fix merge with master

parent 74e58842
import os
import urlparse
from django.core.files.base import ContentFile
......@@ -56,6 +57,10 @@ class Package(object):
def manifest(self):
return self.config.get('manifest', True)
@property
def absolute_paths(self):
return self.config.get('absolute_asset_paths', True)
class Packager(object):
def __init__(self, verbose=False, css_packages=None, js_packages=None):
......@@ -88,8 +93,8 @@ class Packager(object):
relative_url)
def pack_stylesheets(self, package, **kwargs):
variant = package.get('variant', None)
absolute_asset_paths = package.get('absolute_asset_paths', True)
variant = package.variant
absolute_asset_paths = package.absolute_paths
return self.pack(package, self.compressor.compress_css, css_compressed,
variant=variant, absolute_asset_paths=absolute_asset_paths,
**kwargs)
......
......@@ -13,7 +13,7 @@ SITE_ID = 1
INSTALLED_APPS = [
'django.contrib.contenttypes',
'django.contrib.sites',
'django.contrib.staticfiles',
'staticfiles',
'django.contrib.auth',
'django.contrib.admin',
'pipeline',
......@@ -31,8 +31,8 @@ STATICFILES_DIRS = (
local_path('assets/'),
)
STATICFILES_FINDERS = (
'pipeline.finders.PipelineFinder',
'django.contrib.staticfiles.finders.FileSystemFinder'
'staticfiles.finders.FileSystemFinder',
'staticfiles.finders.AppDirectoriesFinder'
)
PIPELINE_ROOT = local_path('assets/')
......
......@@ -87,10 +87,10 @@ class CompressorTest(TestCase):
def test_construct_asset_path(self):
asset_path = self.compressor.construct_asset_path("../../images/sprite.png",
"css/plugins/gallery.css")
self.assertEquals(asset_path, "http://localhost/static/images/sprite.png")
self.assertEquals(asset_path, "images/sprite.png")
asset_path = self.compressor.construct_asset_path("/images/sprite.png",
"css/plugins/gallery.css")
self.assertEquals(asset_path, "http://localhost/static/images/sprite.png")
self.assertEquals(asset_path, "images/sprite.png")
def test_construct_asset_path_relative(self):
asset_path = self.compressor.construct_asset_path("../../images/sprite.png",
......@@ -109,17 +109,17 @@ class CompressorTest(TestCase):
])
self.assertMultiLineEqual("""@font-face {
font-family: 'Pipeline';
src: url(http://localhost/static/fonts/pipeline.eot);
src: url(http://localhost/static/fonts/pipeline.eot?#iefix) format('embedded-opentype');
src: local('☺'), url(http://localhost/static/fonts/pipeline.woff) format('woff'), url(http://localhost/static/fonts/pipeline.ttf) format('truetype'), url(http://localhost/static/fonts/pipeline.svg#IyfZbseF) format('svg');
src: url(fonts/pipeline.eot);
src: url(fonts/pipeline.eot?#iefix) format('embedded-opentype');
src: local('☺'), url(fonts/pipeline.woff) format('woff'), url(fonts/pipeline.ttf) format('truetype'), url(fonts/pipeline.svg#IyfZbseF) format('svg');
font-weight: normal;
font-style: normal;
}
.relative-url {
background-image: url(http://localhost/static/images/sprite-buttons.png);
background-image: url(images/sprite-buttons.png);
}
.absolute-url {
background-image: url(http://localhost/static/images/sprite-buttons.png);
background-image: url(images/sprite-buttons.png);
}
.absolute-full-url {
background-image: url(http://localhost/images/sprite-buttons.png);
......
......@@ -14,7 +14,7 @@ class PackagerTest(TestCase):
'source_filenames': (
'js/application.js',
),
'output_filename': 'application.r?.js'
'output_filename': 'application.js'
}
})
try:
......@@ -34,26 +34,17 @@ class PackagerTest(TestCase):
'source_filenames': (
'templates/photo/list.jst',
),
'output_filename': 'templates.r?.js',
}
})
self.assertEqual(packages, {
'templates': {
'templates': ['templates/photo/list.jst'],
'manifest': True,
'paths': [],
'context': {},
'output': 'templates.r?.js'
'output_filename': 'templates.js',
}
})
self.assertEqual(packages['templates'].templates, ['templates/photo/list.jst'])
def test_individual_url(self):
"""Check that individual URL is correctly generated"""
packager = Packager()
filename = os.path.join(settings.PIPELINE_ROOT, u'js/application.js')
individual_url = packager.individual_url(filename)
self.assertEqual(individual_url,
"http://localhost/static/js/application.js")
self.assertEqual(individual_url, "/static/js/application.js")
def test_periods_safe_individual_url(self):
"""Check that the periods in file names do not get replaced by individual_url when
......@@ -63,5 +54,4 @@ class PackagerTest(TestCase):
packager = Packager()
filename = os.path.join(settings.PIPELINE_ROOT, u'js/application.js')
individual_url = packager.individual_url(filename)
self.assertEqual(individual_url,
"http://localhost/static/js/application.js")
self.assertEqual(individual_url, "/static/js/application.js")
......@@ -12,7 +12,7 @@ class StorageTest(TestCase):
'css/first.css',
),
'manifest': False,
'output_filename': 'testing.r?.css',
'output_filename': 'testing.css',
}
}
self.storage = PipelineStorage()
......@@ -28,7 +28,9 @@ class StorageTest(TestCase):
])
self.assertEqual(processed_files, [
'css/first.css',
'images/arrow.png'
'images/arrow.png',
'testing.css',
'scripts.css'
])
def tearDown(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