Commit 14f1960f by Timothée Peignier

ensure we play nicely with font-face

parent 5a3b861c
......@@ -4,8 +4,6 @@ import re
import subprocess
import urlparse
from django.utils.encoding import filepath_to_uri
from pipeline.conf import settings
from pipeline.storage import storage
from pipeline.utils import to_class
......@@ -13,7 +11,7 @@ from pipeline.utils import to_class
MAX_IMAGE_SIZE = 32700
EMBEDDABLE = r'[/]?embed/'
URL_DETECTOR = r'url\([\'"]?([^\s)]+\.[a-z]+)[\'"]?\)'
URL_DETECTOR = r'url\([\'"]?([^\s)]+\.[a-z]+[#?]?[^\s)]*)[\'"]?\)'
URL_REPLACER = r'url\(__EMBED__(.+?)(\?\d+)?\)'
MHTML_START = "/*\r\nContent-Type: multipart/related; boundary=\"MHTML_MARK\"\r\n\r\n"
......@@ -130,7 +128,7 @@ class Compressor(object):
asset_path = self.relative_path(public_path)
return urlparse.urljoin(
settings.PIPELINE_URL,
filepath_to_uri(asset_path[1:])
asset_path[1:]
)
def embeddable(self, path, variant):
......
@font-face {
font-family: 'Pipeline';
src: url('../fonts/pipeline.eot');
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(../images/sprite-buttons.png);
}
......
......@@ -79,10 +79,18 @@ class CompressorTest(TestCase):
self.assertEquals(asset_path, "http://localhost/static/images/sprite.png")
def test_url_rewrite(self):
self.maxDiff = None
output = self.compressor.concatenate_and_rewrite([
'css/urls.css',
])
self.assertMultiLineEqual(""".relative-url {
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');
font-weight: normal;
font-style: normal;
}
.relative-url {
background-image: url(http://localhost/static/images/sprite-buttons.png);
}
.absolute-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