From 9880f0f6dc6d58f0b0e53960c03bf9b748b8d838 Mon Sep 17 00:00:00 2001 From: tdreyno Date: Tue, 17 Nov 2009 11:02:31 -0800 Subject: [PATCH] fix css minify --- Rakefile | 0 lib/middleman.rb | 0 lib/middleman/features/minify_css.rb | 12 +++++++---- spec/fixtures/sample/init.rb | 6 +++++- .../sample/views/inline-css.html.haml | 4 ++++ spec/minify_css_spec.rb | 20 +++++++++++++++++++ vendor/gems/environment.rb | 0 7 files changed, 37 insertions(+), 5 deletions(-) mode change 100755 => 100644 Rakefile mode change 100755 => 100644 lib/middleman.rb create mode 100755 spec/fixtures/sample/views/inline-css.html.haml create mode 100755 spec/minify_css_spec.rb mode change 100755 => 100644 vendor/gems/environment.rb diff --git a/Rakefile b/Rakefile old mode 100755 new mode 100644 diff --git a/lib/middleman.rb b/lib/middleman.rb old mode 100755 new mode 100644 diff --git a/lib/middleman/features/minify_css.rb b/lib/middleman/features/minify_css.rb index 735132ca..9cb974c5 100755 --- a/lib/middleman/features/minify_css.rb +++ b/lib/middleman/features/minify_css.rb @@ -1,5 +1,9 @@ -# Otherwise use YUI -# Fine a way to minify inline/css -::Compass.configuration do |config| - config.output_style = :compressed +class Middleman::Base + after_feature_init do + ::Compass.configuration do |config| + config.output_style = :compressed + end + + ::Compass.configure_sass_plugin! + end end \ No newline at end of file diff --git a/spec/fixtures/sample/init.rb b/spec/fixtures/sample/init.rb index 33b25cde..3f4df292 100755 --- a/spec/fixtures/sample/init.rb +++ b/spec/fixtures/sample/init.rb @@ -1,9 +1,13 @@ # enable :maruku + +get "/inline-css.html" do + haml :"inline-css.html", :layout => false +end + get "/inline-js.html" do haml :"inline-js.html", :layout => false end - get "/page-class.html" do haml :"page-classes.html", :layout => false end diff --git a/spec/fixtures/sample/views/inline-css.html.haml b/spec/fixtures/sample/views/inline-css.html.haml new file mode 100755 index 00000000..36c2c8e4 --- /dev/null +++ b/spec/fixtures/sample/views/inline-css.html.haml @@ -0,0 +1,4 @@ +:sass + body + test: style + good: deal \ No newline at end of file diff --git a/spec/minify_css_spec.rb b/spec/minify_css_spec.rb new file mode 100755 index 00000000..3576da4c --- /dev/null +++ b/spec/minify_css_spec.rb @@ -0,0 +1,20 @@ +require File.join(File.dirname(__FILE__), "spec_helper") + +base = ::Middleman::Base +base.set :root, File.join(File.dirname(__FILE__), "fixtures", "sample") + +describe "Minify Javascript Feature" do + it "should not minify inline css if off" do + base.disable :minify_css + browser = Rack::Test::Session.new(Rack::MockSession.new(base.new)) + browser.get("/inline-css.html") + browser.last_response.body.chomp.split($/).length.should == 3 + end + + it "should minify inline css if on" do + base.enable :minify_css + browser = Rack::Test::Session.new(Rack::MockSession.new(base.new)) + browser.get("/inline-css.html") + browser.last_response.body.chomp.split($/).length.should == 1 + end +end \ No newline at end of file diff --git a/vendor/gems/environment.rb b/vendor/gems/environment.rb old mode 100755 new mode 100644