From c994004aaaadb16917496281d77192d7a09ab960 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Mon, 18 Mar 2013 14:11:48 -0700 Subject: [PATCH 1/4] bump tilt requirement, unregister plaintext template. fixes #824 --- Gemfile | 4 ++-- .../lib/middleman-core/core_extensions/rendering.rb | 2 ++ middleman-core/middleman-core-x86-mingw32.gemspec | 2 +- middleman-core/middleman-core.gemspec | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 141836c1..863e8082 100644 --- a/Gemfile +++ b/Gemfile @@ -21,12 +21,12 @@ gem "less", "~> 2.2", :require => false gem "stylus", :require => false platforms :ruby do - gem "therubyracer", "0.10.2" + gem "therubyracer"#, "0.10.2" gem "redcarpet" end platforms :jruby do - gem "therubyrhino", "1.73.5" + gem "therubyrhino" end # Middleman itself diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index 51d29e34..58cb792f 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -22,6 +22,8 @@ module Middleman app.define_hook :before_render app.define_hook :after_render + ::Tilt.mappings.delete('html') # WTF, Tilt? + # Activate custom renderers require "middleman-core/renderers/erb" app.register Middleman::Renderers::ERb diff --git a/middleman-core/middleman-core-x86-mingw32.gemspec b/middleman-core/middleman-core-x86-mingw32.gemspec index 3cd01660..216f6fce 100644 --- a/middleman-core/middleman-core-x86-mingw32.gemspec +++ b/middleman-core/middleman-core-x86-mingw32.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |s| # Core s.add_dependency("bundler", ["~> 1.1"]) s.add_dependency("rack", ["~> 1.4.1"]) - s.add_dependency("tilt", ["~> 1.3.1"]) + s.add_dependency("tilt", ["~> 1.3.6"]) # Builder s.add_dependency("rack-test", ["~> 0.6.1"]) diff --git a/middleman-core/middleman-core.gemspec b/middleman-core/middleman-core.gemspec index 9915ef22..e0f3f7b7 100644 --- a/middleman-core/middleman-core.gemspec +++ b/middleman-core/middleman-core.gemspec @@ -20,7 +20,7 @@ Gem::Specification.new do |s| # Core s.add_dependency("bundler", ["~> 1.1"]) s.add_dependency("rack", ["~> 1.4.1"]) - s.add_dependency("tilt", ["~> 1.3.1"]) + s.add_dependency("tilt", ["~> 1.3.6"]) # Builder s.add_dependency("rack-test", ["~> 0.6.1"]) From 77fe264788a5b08309079f6bf9b46b03fc606ef7 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 19 Mar 2013 15:55:41 -0700 Subject: [PATCH 2/4] prep --- middleman-core/lib/middleman-core/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/middleman-core/lib/middleman-core/version.rb b/middleman-core/lib/middleman-core/version.rb index 25de5b18..8bc3f1be 100644 --- a/middleman-core/lib/middleman-core/version.rb +++ b/middleman-core/lib/middleman-core/version.rb @@ -1,5 +1,5 @@ module Middleman # Current Version # @return [String] - VERSION = '3.0.12' unless const_defined?(:VERSION) + VERSION = '3.0.13' unless const_defined?(:VERSION) end From fc30e0570b7f043c9b19e8bee90ffd24d1e36926 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 19 Mar 2013 16:09:58 -0700 Subject: [PATCH 3/4] changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 768b0492..2c1863c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +3.0.13 +=== + +* Require Tilt 1.3.6 (older versions have errant .csv template type) +* Unregister Tilt HTML handler +* Fix dynamic multi-byte utf-8 files rebuilding. #806 +* Force locale to english for number_to_human_size in the gzip extension. #804 +* Don't use the logger from a trap context. Ruby 2.0.0 support. #801. +* Serve extensionless files or dotfiles with text/plain MIME type + 3.0.12 === From 1c7308fceaa7f51b92011ff9ae59bff11a05f1ec Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Tue, 19 Mar 2013 16:21:49 -0700 Subject: [PATCH 4/4] Remove Rainpress pure ruby CSS compressor and simply use SCSS :) --- .../middleman-more/extensions/minify_css.rb | 11 +- .../extensions/minify_css/rainpress.rb | 168 ------------------ 2 files changed, 9 insertions(+), 170 deletions(-) delete mode 100644 middleman-more/lib/middleman-more/extensions/minify_css/rainpress.rb diff --git a/middleman-more/lib/middleman-more/extensions/minify_css.rb b/middleman-more/lib/middleman-more/extensions/minify_css.rb index ac4b9644..a5c8154b 100644 --- a/middleman-more/lib/middleman-more/extensions/minify_css.rb +++ b/middleman-more/lib/middleman-more/extensions/minify_css.rb @@ -17,8 +17,7 @@ module Middleman app.after_configuration do chosen_compressor = css_compressor || options[:compressor] || begin - require "middleman-more/extensions/minify_css/rainpress" - ::Rainpress + ::Middleman::Extensions::MinifyCss::SassCompressor end # Setup Rack middleware to minify CSS @@ -30,6 +29,14 @@ module Middleman alias :included :registered end + class SassCompressor + def self.compress(style, options = {}) + root_node = ::Sass::SCSS::CssParser.new(style, 'jammit-combined-input').parse + root_node.options = { :style => :compressed } + root_node.render.strip + end + end + # Rack middleware to look for CSS and compress it class Rack diff --git a/middleman-more/lib/middleman-more/extensions/minify_css/rainpress.rb b/middleman-more/lib/middleman-more/extensions/minify_css/rainpress.rb deleted file mode 100644 index c355e0c0..00000000 --- a/middleman-more/lib/middleman-more/extensions/minify_css/rainpress.rb +++ /dev/null @@ -1,168 +0,0 @@ -# == Information -# -# This is the main class of Rainpress, create an instance of it to compress -# your CSS-styles. -# -# Author:: Uwe L. Korn -# -# Options: -# -# * :comments - if set to false, comments will not be removed -# * :newlines - if set to false, newlines will not be removed -# * :spaces - if set to false, spaces will not be removed -# * :colors - if set to false, colors will not be modified -# * :misc - if set to false, miscellaneous compression parts will be skipped -class Rainpress - # Quick-compress the styles. - # This eliminates the need to create an instance of the class - def self.compress(style, options = {}) - self.new(style, options).compress! - end - - def initialize(style, opts = {}) - @style = style - @opts = { - :comments => true, - :newlines => true, - :spaces => true, - :colors => false, - :misc => true - } - @opts.merge! opts - end - - # Run the compressions and return the newly compressed text - def compress! - remove_comments! if @opts[:comments] - remove_newlines! if @opts[:newlines] - remove_spaces! if @opts[:spaces] - shorten_colors! if @opts[:colors] - do_misc! if @opts[:misc] - @style - end - - # Remove all comments out of the CSS-Document - # - # Only /* text */ comments are supported. - # Attention: If you are doing css hacks for IE using the comment tricks, - # they will be removed using this function. Please consider for IE css style - # corrections the usage of conditionals comments in your (X)HTML document. - def remove_comments! - input = @style - @style = '' - - while input.length > 0 do - pos = input.index("/*"); - - # No more comments - if pos == nil - @style += input - input = ''; - else # Comment beginning at pos - @style += input[0..(pos-1)] if pos > 0 # only append text if there is some - input = input[(pos+2)..-1] - # Comment ending at pos - pos = input.index("*/") - input = input[(pos+2)..-1] - end - end - end - - # Remove all newline characters - # - # We take care of Windows(\r\n), Unix(\n) and Mac(\r) newlines. - def remove_newlines! - @style.gsub! /\n|\r/, '' - end - - # Remove unneeded spaces - # - # 1. Turn mutiple spaces into a single - # 2. Remove spaces around ;:{}, - # 3. Remove tabs - def remove_spaces! - @style.gsub! /\s*(\s|;|:|\}|\{|,)\s*/, '\1' - @style.gsub! "\t", '' - end - - # Replace color values with their shorter equivalent - # - # 1. Turn rgb(,,)-colors into #-values - # 2. Shorten #AABBCC down to #ABC - # 3. Replace names with their shorter hex-equivalent - # * white -> #fff - # * black -> #000 - # 4. Replace #-values with their shorter name - # * #f00 -> red - def shorten_colors! - # rgb(50,101,152) to #326598 - @style.gsub! /rgb\s*\(\s*([0-9,\s]+)\s*\)/ do |match| - out = '#' - $1.split(',').each do |num| - out += '0' if num.to_i < 16 - out += num.to_i.to_s(16) # convert to hex - end - out - end - # Convert #AABBCC to #ABC, keep if preceed by a '=' - @style.gsub! /([^\"'=\s])(\s*)#([\da-f])\3([\da-f])\4([\da-f])\5/i, '\1#\3\4\5' - - # At the moment we assume that colours only appear before ';' or '}' and - # after a ':', if there could be an occurence of a color before or after - # an other character, submit either a bug report or, better, a patch that - # enables Rainpress to take care of this. - - # shorten several names to numbers - ## shorten white -> #fff - @style.gsub! /:\s*white\s*(;|\})/, ':#fff\1' - - ## shorten black -> #000 - @style.gsub! /:\s*black\s*(;|\})/, ':#000\1' - - # shotern several numbers to names - ## shorten #f00 or #ff0000 -> red - @style.gsub! /:\s*#f{1,2}0{2,4}(;|\})/i, ':red\1' - end - - # Do miscellaneous compression methods on the style. - def do_misc! - # Replace 0(pt,px,em,%) with 0 but only when preceded by : or a white-space - @style.gsub! /([\s:]+)(0)(px|em|%|in|cm|mm|pc|pt|ex)/i, '\1\2' - - # Replace :0 0 0 0(;|}) with :0(;|}) - @style.gsub! /:0 0 0 0(;|\})/, ':0\1' - - # Replace :0 0 0(;|}) with :0(;|}) - @style.gsub! /:0 0 0(;|\})/, ':0\1' - - # Replace :0 0(;|}) with :0(;|}) - @style.gsub! /:0 0(;|\})/, ':0\1' - - # Replace background-position:0; with background-position:0 0; - @style.gsub! 'background-position:0;', 'background-position:0 0;' - - # Replace 0.6 to .6, but only when preceded by : or a white-space - @style.gsub! /[:\s]0+\.(\d+)/ do |match| - match.sub '0', '' # only first '0' !! - end - - # Replace multiple ';' with a single ';' - @style.gsub! /[;]+/, ';' - - # Replace ;} with } - @style.gsub! ';}', '}' - - # Replace font-weight:normal; with 400 - @style.gsub! /font-weight[\s]*:[\s]*normal[\s]*(;|\})/i,'font-weight:400\1' - @style.gsub! /font[\s]*:[\s]*normal[\s;\}]*/ do |match| - match.sub 'normal', '400' - end - - # Replace font-weight:bold; with 700 - @style.gsub! /font-weight[\s]*:[\s]*bold[\s]*(;|\})/,'font-weight:700\1' - @style.gsub! /font[\s]*:[\s]*bold[\s;\}]*/ do |match| - match.sub 'bold', '700' - end - end - -end