From b8321a4db05ee5d7c0d7ff3b372619e90ffcfd8f Mon Sep 17 00:00:00 2001 From: Maxime Thirouin Date: Tue, 13 Mar 2012 21:53:03 +0100 Subject: [PATCH 1/4] Add ability to append stuffs after font urls --- lib/compass/sass_extensions/functions/font_files.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/compass/sass_extensions/functions/font_files.rb b/lib/compass/sass_extensions/functions/font_files.rb index f7f72d27..9dd4f48c 100644 --- a/lib/compass/sass_extensions/functions/font_files.rb +++ b/lib/compass/sass_extensions/functions/font_files.rb @@ -5,7 +5,8 @@ module Compass::SassExtensions::Functions::FontFiles :opentype => 'opentype', :ttf => 'truetype', :truetype => 'truetype', - :svg => 'svg' + :svg => 'svg', + :eot => 'embedded-opentype' } def font_files(*args) @@ -24,7 +25,8 @@ module Compass::SassExtensions::Functions::FontFiles if FONT_TYPES.key? type skip_next = true else - type = arg.to_s.split('.').last.gsub('"', '').to_sym + # let pass url like font.type?thing#stuff + type = arg.to_s.split('.').last.gsub(/(\?(.*))?(#(.*))?"/, '').to_sym end if FONT_TYPES.key? type From 788a34427842e11aabaf5adbadd6969192522a93 Mon Sep 17 00:00:00 2001 From: Maxime Thirouin Date: Tue, 13 Mar 2012 21:53:19 +0100 Subject: [PATCH 2/4] Update outdated doc --- .../examples/compass/css3/font-face/stylesheet.sass | 2 +- doc-src/content/reference/compass/helpers/font-files.haml | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/doc-src/content/examples/compass/css3/font-face/stylesheet.sass b/doc-src/content/examples/compass/css3/font-face/stylesheet.sass index 4256a548..3f737dfd 100644 --- a/doc-src/content/examples/compass/css3/font-face/stylesheet.sass +++ b/doc-src/content/examples/compass/css3/font-face/stylesheet.sass @@ -1,6 +1,6 @@ @import compass/css3 -+font-face("Blooming Grove", font-files("examples/bgrove.ttf", truetype, "examples/bgrove.otf", opentype)) ++font-face("Blooming Grove", font-files("examples/bgrove.ttf", "examples/bgrove.otf")) .example font-family: "Blooming Grove" diff --git a/doc-src/content/reference/compass/helpers/font-files.haml b/doc-src/content/reference/compass/helpers/font-files.haml index d055c900..be951708 100644 --- a/doc-src/content/reference/compass/helpers/font-files.haml +++ b/doc-src/content/reference/compass/helpers/font-files.haml @@ -16,13 +16,10 @@ documented_functions: #font-files.helper %h3 %a(href="#font-files") - font-files([$font, $format]*) + font-files([$font]*) .details %p - The font-files function takes any even number of arguments. - For each pair of arguments, the first is the path to the font file - relative to your project's font directory and the second is the format of - that font. + The font-files function takes a list of arguments containing the path to each font files relative to your project's font directory. %p This helper is used with the font-face mixin and is what makes it possible to pass any number of font files. From 11b3526b8548c3be5ee2c5ff00b315a5bd7c4422 Mon Sep 17 00:00:00 2001 From: Maxime Thirouin Date: Tue, 13 Mar 2012 21:54:07 +0100 Subject: [PATCH 3/4] Add tests about the new ability to append stuffs on font urls --- test/units/sass_extensions_test.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/units/sass_extensions_test.rb b/test/units/sass_extensions_test.rb index ba2d524d..99194ddd 100644 --- a/test/units/sass_extensions_test.rb +++ b/test/units/sass_extensions_test.rb @@ -126,6 +126,14 @@ class SassExtensionsTest < Test::Unit::TestCase evaluate("font-files('/font/name.woff')") end + assert_nothing_raised Sass::SyntaxError do + evaluate("font-files('/font/name.svg#fontId')") + end + + assert_nothing_raised Sass::SyntaxError do + evaluate("font-files('/font/name.eot?#iefix')") + end + assert_raises Sass::SyntaxError do evaluate("font-files('/font/name.ext')") end From 1fb9e7adba26a9c25dd1a425e7dd325aeedd4d6b Mon Sep 17 00:00:00 2001 From: Maxime Thirouin Date: Tue, 13 Mar 2012 22:20:19 +0100 Subject: [PATCH 4/4] Add one more test to make sure a more complex query param is handled --- test/units/sass_extensions_test.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/units/sass_extensions_test.rb b/test/units/sass_extensions_test.rb index 99194ddd..67ffb895 100644 --- a/test/units/sass_extensions_test.rb +++ b/test/units/sass_extensions_test.rb @@ -134,6 +134,10 @@ class SassExtensionsTest < Test::Unit::TestCase evaluate("font-files('/font/name.eot?#iefix')") end + assert_nothing_raised Sass::SyntaxError do + evaluate("font-files('/font/name.svg?mightbedynamic=something%20+escaped#fontId')") + end + assert_raises Sass::SyntaxError do evaluate("font-files('/font/name.ext')") end