Commit 49c46d90 by Timothée Peignier

improved support for font-face CSS hacks

parent b1e2da20
......@@ -11,7 +11,7 @@ from pipeline.utils import to_class
MAX_IMAGE_SIZE = 32700
EMBEDDABLE = r'[/]?embed/'
URL_DETECTOR = r'url\([\'"]?([^\s)]+\.[a-z]+[#?]?[^\s)]*)[\'"]?\)'
URL_DETECTOR = r'url\([\'"]?([^\s)]+\.[a-z]+[\?\#\d\w]*)[\'"]?\)'
URL_REPLACER = r'url\(__EMBED__(.+?)(\?\d+)?\)'
MHTML_START = "/*\r\nContent-Type: multipart/related; boundary=\"MHTML_MARK\"\r\n\r\n"
......@@ -126,10 +126,7 @@ class Compressor(object):
return "__EMBED__%s" % public_path
if not os.path.isabs(asset_path):
asset_path = self.relative_path(public_path)
return urlparse.urljoin(
settings.PIPELINE_URL,
asset_path[1:]
)
return settings.PIPELINE_URL + asset_path[1:]
def embeddable(self, path, variant):
"""Is the asset embeddable ?"""
......
@font-face {
font-family: 'Pipeline';
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;
......
......@@ -86,8 +86,9 @@ class CompressorTest(TestCase):
])
self.assertMultiLineEqual("""@font-face {
font-family: 'Pipeline';
src: url(http://localhost/static/fonts/pipeline.eot');
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(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');
font-weight: normal;
font-style: normal;
}
......
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