Merge pull request #893 from bhollis/master

Some small improvements
This commit is contained in:
Thomas Reynolds 2013-05-13 10:36:52 -07:00
commit 2f4f741c3c
3 changed files with 9 additions and 1 deletions

View file

@ -1,3 +1,5 @@
require 'padrino-helpers'
module Middleman module Middleman
module MetaPages module MetaPages
# View class for a sitemap resource # View class for a sitemap resource

View file

@ -15,10 +15,10 @@ module Middleman
begin begin
# Setup default helpers # Setup default helpers
require 'padrino-helpers'
require "middleman-more/core_extensions/default_helpers" require "middleman-more/core_extensions/default_helpers"
Middleman::CoreExtensions::DefaultHelpers.new(app) Middleman::CoreExtensions::DefaultHelpers.new(app)
rescue LoadError rescue LoadError
$stderr.puts "Default helpers not installed: #{$!}"
end end
require "i18n" require "i18n"
@ -40,6 +40,7 @@ module Middleman
require "middleman-more/core_extensions/compass" require "middleman-more/core_extensions/compass"
Middleman::CoreExtensions::Compass.new(app) Middleman::CoreExtensions::Compass.new(app)
rescue LoadError rescue LoadError
$stderr.puts "Compass not installed: #{$!}"
end end
### ###

View file

@ -23,12 +23,15 @@ class Middleman::Extensions::Gzip < ::Middleman::Extension
app.after_build do |builder| app.after_build do |builder|
paths = ::Middleman::Util.all_files_under(self.class.inst.build_dir) paths = ::Middleman::Util.all_files_under(self.class.inst.build_dir)
total_savings = 0
paths.each do |path| paths.each do |path|
next unless gzip_ext.options.exts.include? path.extname next unless gzip_ext.options.exts.include? path.extname
output_filename, old_size, new_size = gzip_ext.gzip_file(path.to_s) output_filename, old_size, new_size = gzip_ext.gzip_file(path.to_s)
if output_filename if output_filename
total_savings += (old_size - new_size)
size_change_word = (old_size - new_size) > 0 ? 'smaller' : 'larger' size_change_word = (old_size - new_size) > 0 ? 'smaller' : 'larger'
old_locale = I18n.locale old_locale = I18n.locale
I18n.locale = :en # use the english localizations for printing out file sizes to make sure the localizations exist I18n.locale = :en # use the english localizations for printing out file sizes to make sure the localizations exist
@ -36,6 +39,8 @@ class Middleman::Extensions::Gzip < ::Middleman::Extension
I18n.locale = old_locale I18n.locale = old_locale
end end
end end
builder.say_status :gzip, "Total gzip savings: #{number_to_human_size(total_savings)}", :blue
end end
end end