Commit 5f205fc2 by Timothée Peignier

rename some package property

parent 6a37fce5
......@@ -92,7 +92,7 @@ Group options
For CSS, if you do not specify ``extra_context``/``media``, the default media in
the ``<link>`` output will be ``media="all"``.
``absolute_asset_paths``
``absolute_paths``
........................
**Optional**
......
......@@ -62,10 +62,10 @@ class Compressor(object):
return js
def compress_css(self, paths, variant=None, asset_url=None,
absolute_asset_paths=True, **kwargs):
absolute_paths=True, **kwargs):
"""Concatenate and compress CSS files"""
css = self.concatenate_and_rewrite(paths, variant,
absolute_asset_paths)
absolute_paths)
compressor = self.css_compressor
if compressor:
css = getattr(compressor(verbose=self.verbose), 'compress_css')(css)
......@@ -117,8 +117,7 @@ class Compressor(object):
), r"\1", path)
return re.sub(r"[\/\\]", "_", name)
def concatenate_and_rewrite(self, paths, variant=None,
absolute_asset_paths=True):
def concatenate_and_rewrite(self, paths, variant=None, absolute_paths=True):
"""Concatenate together files and rewrite urls"""
stylesheets = []
for path in paths:
......@@ -126,8 +125,8 @@ class Compressor(object):
asset_path = match.group(1)
if asset_path.startswith("http") or asset_path.startswith("//"):
return "url(%s)" % asset_path
asset_url = self.construct_asset_path(asset_path, path, variant,
absolute_asset_paths)
asset_url = self.construct_asset_path(asset_path, path,
variant, absolute_paths)
return "url(%s)" % asset_url
content = self.read_file(path)
content = re.sub(URL_DETECTOR, reconstruct, content)
......@@ -138,13 +137,12 @@ class Compressor(object):
"""Concatenate together a list of files"""
return '\n'.join([self.read_file(path) for path in paths])
def construct_asset_path(self, asset_path, css_path, variant=None,
absolute_asset_paths=True):
def construct_asset_path(self, asset_path, css_path, variant=None, absolute_paths=True):
"""Return a rewritten asset URL for a stylesheet"""
public_path = self.absolute_path(asset_path, os.path.dirname(css_path))
if self.embeddable(public_path, variant):
return "__EMBED__%s" % public_path
if not absolute_asset_paths:
if not absolute_paths:
return asset_path
if not os.path.isabs(asset_path):
asset_path = self.relative_path(public_path)
......
......@@ -26,7 +26,7 @@ class Package(object):
paths.append(str(path))
self._sources = paths
return self._sources
@property
def paths(self):
return [path for path in self.sources
......@@ -38,7 +38,7 @@ class Package(object):
if path.endswith(settings.PIPELINE_TEMPLATE_EXT)]
@property
def output(self):
def output_filename(self):
return self.config.get('output_filename')
@property
......@@ -59,7 +59,7 @@ class Package(object):
@property
def absolute_paths(self):
return self.config.get('absolute_asset_paths', True)
return self.config.get('absolute_paths', True)
class Packager(object):
......@@ -93,17 +93,15 @@ class Packager(object):
relative_url)
def pack_stylesheets(self, package, **kwargs):
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,
variant=package.variant, absolute_paths=package.absolute_paths,
**kwargs)
def compile(self, paths):
return self.compiler.compile(paths)
def pack(self, package, compress, signal, **kwargs):
output_filename = package.output
output_filename = package.output_filename
if self.verbose:
print "Saving: %s" % output_filename
paths = self.compile(package.paths)
......
......@@ -29,7 +29,7 @@ class CompressedCSSNode(template.Node):
return '' # fail silently, do not return anything if an invalid group is specified
if settings.PIPELINE:
return self.render_css(package, package.output)
return self.render_css(package, package.output_filename)
else:
paths = self.packager.compile(package.paths)
return self.render_individual(package, paths)
......@@ -64,7 +64,7 @@ class CompressedJSNode(template.Node):
return '' # fail silently, do not return anything if an invalid group is specified
if settings.PIPELINE:
return self.render_js(package, package.output)
return self.render_js(package, package.output_filename)
else:
paths = self.packager.compile(package.paths)
templates = self.packager.pack_templates(package)
......
......@@ -95,11 +95,11 @@ class CompressorTest(TestCase):
def test_construct_asset_path_relative(self):
asset_path = self.compressor.construct_asset_path("../../images/sprite.png",
"css/plugins/gallery.css",
absolute_asset_paths=False)
absolute_paths=False)
self.assertEquals(asset_path, "../../images/sprite.png")
asset_path = self.compressor.construct_asset_path("/images/sprite.png",
"css/plugins/gallery.css",
absolute_asset_paths=False)
absolute_paths=False)
self.assertEquals(asset_path, "/images/sprite.png")
def test_url_rewrite(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