commit
2f4f741c3c
3 changed files with 9 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
|||
require 'padrino-helpers'
|
||||
|
||||
module Middleman
|
||||
module MetaPages
|
||||
# View class for a sitemap resource
|
||||
|
|
|
@ -15,10 +15,10 @@ module Middleman
|
|||
|
||||
begin
|
||||
# Setup default helpers
|
||||
require 'padrino-helpers'
|
||||
require "middleman-more/core_extensions/default_helpers"
|
||||
Middleman::CoreExtensions::DefaultHelpers.new(app)
|
||||
rescue LoadError
|
||||
$stderr.puts "Default helpers not installed: #{$!}"
|
||||
end
|
||||
|
||||
require "i18n"
|
||||
|
@ -40,6 +40,7 @@ module Middleman
|
|||
require "middleman-more/core_extensions/compass"
|
||||
Middleman::CoreExtensions::Compass.new(app)
|
||||
rescue LoadError
|
||||
$stderr.puts "Compass not installed: #{$!}"
|
||||
end
|
||||
|
||||
###
|
||||
|
|
|
@ -23,12 +23,15 @@ class Middleman::Extensions::Gzip < ::Middleman::Extension
|
|||
|
||||
app.after_build do |builder|
|
||||
paths = ::Middleman::Util.all_files_under(self.class.inst.build_dir)
|
||||
total_savings = 0
|
||||
|
||||
paths.each do |path|
|
||||
next unless gzip_ext.options.exts.include? path.extname
|
||||
|
||||
output_filename, old_size, new_size = gzip_ext.gzip_file(path.to_s)
|
||||
|
||||
if output_filename
|
||||
total_savings += (old_size - new_size)
|
||||
size_change_word = (old_size - new_size) > 0 ? 'smaller' : 'larger'
|
||||
old_locale = I18n.locale
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
builder.say_status :gzip, "Total gzip savings: #{number_to_human_size(total_savings)}", :blue
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue