update minify css extension, unindent other exts

This commit is contained in:
Thomas Reynolds 2013-04-20 14:27:25 -07:00
parent 3da3a2acc8
commit 11a3507528
9 changed files with 508 additions and 559 deletions

View file

@ -55,10 +55,8 @@ module Middleman
end
# MinifyCss compresses CSS
Middleman::Extensions.register(:minify_css) do
require "middleman-more/extensions/minify_css"
Middleman::Extensions::MinifyCss
end
Middleman::Extensions::MinifyCss.register
# MinifyJavascript compresses JS
Middleman::Extensions.register(:minify_javascript) do

View file

@ -1,10 +1,8 @@
module Middleman
module Extensions
class AssetHash < ::Middleman::Extension
class Middleman::Extensions::AssetHash < ::Middleman::Extension
option :exts, %w(.jpg .jpeg .png .gif .js .css .otf .woff .eot .ttf .svg), "List of extensions that get asset hashes appended to them."
option :ignore, [], "Regexes of filenames to skip adding asset hashes to"
def initialize(app, options_hash={})
def initialize(app, options_hash={}, &block)
super
require 'digest/sha1'
@ -47,7 +45,6 @@ module Middleman
resource.destination_path = resource.destination_path.sub(/\.(\w+)$/) { |ext| "-#{digest}#{ext}" }
end
end
end
# The asset hash middleware is responsible for rewriting references to
# assets to include their new, hashed name.
@ -100,9 +97,8 @@ module Middleman
[status, headers, response]
end
end
end
end
end
# =================Temp Generate Test data==============================
# ["jpg", "png", "gif"].each do |ext|

View file

@ -1,9 +1,6 @@
# Extensions namespace
module Middleman
module Extensions
# Asset Host module
class AssetHost < ::Middleman::Extension
class Middleman::Extensions::AssetHost < ::Middleman::Extension
option :host, nil, 'The asset host to use, or false for no asset host, or a Proc to determine asset host'
def initialize(app, options_hash={}, &block)
@ -51,5 +48,3 @@ module Middleman
end
end
end
end
end

View file

@ -1,9 +1,5 @@
# Extensions namespace
module Middleman
module Extensions
# Automatic Image Sizes extension
class AutomaticImageSizes < ::Middleman::Extension
class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
def initialize(app, options_hash={}, &block)
super
@ -44,5 +40,3 @@ module Middleman
end
end
end
end
end

View file

@ -1,9 +1,5 @@
# Extension namespace
module Middleman
module Extensions
# The Cache Buster extension
class CacheBuster < ::Middleman::Extension
class Middleman::Extensions::CacheBuster < ::Middleman::Extension
def initialize(app, options_hash={}, &block)
super
@ -58,5 +54,3 @@ module Middleman
end
end
end
end
end

View file

@ -1,9 +1,5 @@
# Extensions namespace
module Middleman
module Extensions
# Directory Indexes extension
class DirectoryIndexes < ::Middleman::Extension
class Middleman::Extensions::DirectoryIndexes < ::Middleman::Extension
# Update the main sitemap resource list
# @return [void]
def manipulate_resource_list(resources)
@ -26,5 +22,3 @@ module Middleman
end
end
end
end
end

View file

@ -1,5 +1,3 @@
module Middleman::Extensions
# This extension Gzips assets and pages when building.
# Gzipped assets and pages can be served directly by Apache or
# Nginx with the proper configuration, and pre-zipping means that we
@ -11,7 +9,7 @@ module Middleman::Extensions
# Pass the :exts options to customize which file extensions get zipped (defaults
# to .html, .htm, .js and .css.
#
class Gzip < ::Middleman::Extension
class Middleman::Extensions::Gzip < ::Middleman::Extension
option :exts, %w(.js .css .html .htm), 'File extensions to Gzip when building.'
def initialize(app, options_hash={})
@ -70,4 +68,3 @@ module Middleman::Extensions
[output_filename, old_size, new_size]
end
end
end

View file

@ -1,9 +1,4 @@
# Extension namespace
module Middleman
module Extensions
# Lorem helper
class Lorem < ::Middleman::Extension
class Middleman::Extensions::Lorem < ::Middleman::Extension
helpers do
# Access to the Lorem object
# @return [Middleman::Extensions::Lorem::LoremObject]
@ -179,5 +174,3 @@ module Middleman
end
end
end
end
end

View file

@ -1,32 +1,22 @@
# Extensions namespace
module Middleman
module Extensions
# Minify CSS Extension
module MinifyCss
class Middleman::Extensions::MinifyCss < ::Middleman::Extension
option :compressor, nil, 'Set the CSS compressor to use.'
option :inline, false, 'Whether to minify CSS inline within HTML files'
option :ignore, [], 'Patterns to avoid minifying'
# Setup extension
class << self
def initialize(app, options_hash={}, &block)
super
# Once registered
def registered(app, options={})
app.config.define_setting :css_compressor, nil, 'Set the CSS compressor to use. Deprecated in favor of the :compressor option when activating :minify_css'
ignore = Array(options[:ignore]) << /\.min\./
inline = options[:inline] || false
app.after_configuration do
chosen_compressor = config[:css_compressor] || options[:compressor] || begin
::Middleman::Extensions::MinifyCss::SassCompressor
end
def after_configuration
chosen_compressor = app.config[:css_compressor] || options[:compressor] || SassCompressor
# Setup Rack middleware to minify CSS
use Rack, :compressor => chosen_compressor,
:ignore => ignore,
:inline => inline
end
end
alias :included :registered
app.use Rack, :compressor => chosen_compressor,
:ignore => options[:ignore] + [/\.min\./],
:inline => options[:inline]
end
class SassCompressor
@ -85,5 +75,3 @@ module Middleman
end
end
end
end
end