Commit 8eb006ca by Timothée Peignier

fix external urls bug

parent b9ccb5a7
......@@ -77,9 +77,12 @@ class Packager(object):
for name in config:
packages[name] = {}
paths = []
if 'external_urls' in config[name]:
packages[name]['externals'] = config[name]['external_urls']
continue
for path in config[name]['source_filenames']:
full_path = os.path.join(settings.COMPRESS_ROOT, path)
paths.extend([os.path.normpath(path)
paths.extend([os.path.normpath(path).replace(settings.COMPRESS_ROOT, '')
for path in glob.glob(full_path)])
packages[name]['paths'] = paths
packages[name]['output'] = config[name]['output_filename']
......@@ -88,8 +91,6 @@ class Packager(object):
packages[name]['context'] = config[name]['extra_context']
if 'template_name' in config[name]:
packages[name]['template'] = config[name]['template_name']
if 'externals_urls' in config[name]:
packages[name]['externals'] = config[name]['external_urls']
return packages
......
......@@ -15,9 +15,9 @@ if not settings.configured:
'tests',
],
MEDIA_URL='/media/',
MEDIA_ROOT=os.path.join(TEST_DIR, 'media'),
MEDIA_ROOT=os.path.join(TEST_DIR, 'media/'),
STATIC_URL='/static/',
STATIC_ROOT=os.path.join(TEST_DIR, 'static'),
STATIC_ROOT=os.path.join(TEST_DIR, 'static/'),
TEMPLATE_DIRS=(
os.path.join(TEST_DIR, 'templates'),
),
......
......@@ -19,5 +19,27 @@ class PackagerTest(TestCase):
self.assertEqual(individual_url,
"http://localhost/static/js/application.js")
def test_external_urls(self):
packager = Packager()
packages = packager.create_packages({
'jquery': {
'external_urls': ('//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js',)
},
'application': {
'source_filenames': ('js/application.js',),
'output_filename': 'application.r?.js'
}
})
self.assertEqual(packages, {
'jquery': {
'externals': ('//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js',)
},
'application': {
'context': {},
'output': 'application.r?.js',
'paths': ['js/application.js']
}
})
def tearDown(self):
settings.COMPRESS_URL = self.old_compress_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