From 7ea1704a64c77041402ee5f075344494078c4476 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 26 Apr 2011 23:03:25 -0700 Subject: [PATCH] remove explicit less.rb support. Switch to uglifyJS for compression. --- features/builder.feature | 1 - features/less-css.feature | 7 ------- .../test-app/views/stylesheets/test_less.css.less | 5 ----- lib/middleman/features/minify_javascript.rb | 12 ------------ lib/middleman/features/minify_javascript/rack.rb | 8 ++++---- middleman.gemspec | 2 +- 6 files changed, 5 insertions(+), 30 deletions(-) delete mode 100644 features/less-css.feature delete mode 100755 fixtures/test-app/views/stylesheets/test_less.css.less diff --git a/features/builder.feature b/features/builder.feature index ce99b3ee..d905831b 100644 --- a/features/builder.feature +++ b/features/builder.feature @@ -10,7 +10,6 @@ Feature: Builder Then "services/index.html" should exist and include "Services" Then "stylesheets/site.css" should exist and include "html, body, div, span" Then "stylesheets/site_scss.css" should exist and include "html, body, div, span" - Then "stylesheets/test_less.css" should exist and include "666" Then "stylesheets/static.css" should exist and include "body" Then "_partial.html" should not exist And cleanup built test app diff --git a/features/less-css.feature b/features/less-css.feature deleted file mode 100644 index 495b2825..00000000 --- a/features/less-css.feature +++ /dev/null @@ -1,7 +0,0 @@ -Feature: Support Less CSS - In order to offer an alternative when writing CSS - - Scenario: Rendering Less - Given the Server is running - When I go to "/stylesheets/test_less.css" - Then I should see "666" \ No newline at end of file diff --git a/fixtures/test-app/views/stylesheets/test_less.css.less b/fixtures/test-app/views/stylesheets/test_less.css.less deleted file mode 100755 index a57c304f..00000000 --- a/fixtures/test-app/views/stylesheets/test_less.css.less +++ /dev/null @@ -1,5 +0,0 @@ -@brand_color: #666666; - -#header { - color: @brand_color; -} \ No newline at end of file diff --git a/lib/middleman/features/minify_javascript.rb b/lib/middleman/features/minify_javascript.rb index bdbffb3e..a2670a56 100755 --- a/lib/middleman/features/minify_javascript.rb +++ b/lib/middleman/features/minify_javascript.rb @@ -3,22 +3,10 @@ module Middleman::Features::MinifyJavascript def registered(app) # Only do minification on build or prod mode return unless [:build, :production].include? app.environment - - Middleman::Features::MinifyJavascript::Haml::Javascript.send :include, ::Haml::Filters::Base require "middleman/features/minify_javascript/rack" app.use Middleman::Rack::MinifyJavascript end alias :included :registered end - - module Haml - module Javascript - def render_with_options(text, options) - compressor = ::YUI::JavaScriptCompressor.new(:munge => true) - data = compressor.compress(text) - %Q{} - end - end - end end \ No newline at end of file diff --git a/lib/middleman/features/minify_javascript/rack.rb b/lib/middleman/features/minify_javascript/rack.rb index b48b40ce..9177ddb0 100644 --- a/lib/middleman/features/minify_javascript/rack.rb +++ b/lib/middleman/features/minify_javascript/rack.rb @@ -1,7 +1,7 @@ begin - require "yui/compressor" + require 'uglifier' rescue LoadError - puts "YUI-Compressor not available. Install it with: gem install yui-compressor" + puts "UglifyJS not available. Install it with: gem install uglifier" end module Middleman @@ -16,14 +16,14 @@ module Middleman status, headers, response = @app.call(env) if env["PATH_INFO"].match(/\.js$/) - compressor = ::YUI::JavaScriptCompressor.new(:munge => true) + compressor = ::Uglifier.new if response.is_a?(::Rack::File) or response.is_a?(Sinatra::Helpers::StaticFile) uncompressed_source = File.read(response.path) else uncompressed_source = response.join end - minified = compressor.compress(uncompressed_source) + minified = compressor.compile(uncompressed_source) headers["Content-Length"] = ::Rack::Utils.bytesize(minified).to_s response = [minified] end diff --git a/middleman.gemspec b/middleman.gemspec index 0f6f8ad0..ef0de7b2 100644 --- a/middleman.gemspec +++ b/middleman.gemspec @@ -28,7 +28,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency("padrino-core", ["~> 0.9.23"]) s.add_runtime_dependency("padrino-helpers", ["~> 0.9.23"]) s.add_runtime_dependency("rack-test", ["~> 0.5.0"]) - s.add_runtime_dependency("yui-compressor", ["~> 0.9.0"]) + s.add_runtime_dependency("uglifier", ["~> 0.5.0"]) s.add_runtime_dependency("haml", ["~> 3.1.0"]) s.add_runtime_dependency("sass", ["~> 3.1.0"]) s.add_runtime_dependency("compass", ["~> 0.11.1"])