Commit 6a37fce5 by Timothée Peignier

fix merge with master

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