update minify css extension, unindent other exts
This commit is contained in:
parent
3da3a2acc8
commit
11a3507528
9 changed files with 508 additions and 559 deletions
|
@ -55,10 +55,8 @@ module Middleman
|
||||||
end
|
end
|
||||||
|
|
||||||
# MinifyCss compresses CSS
|
# MinifyCss compresses CSS
|
||||||
Middleman::Extensions.register(:minify_css) do
|
|
||||||
require "middleman-more/extensions/minify_css"
|
require "middleman-more/extensions/minify_css"
|
||||||
Middleman::Extensions::MinifyCss
|
Middleman::Extensions::MinifyCss.register
|
||||||
end
|
|
||||||
|
|
||||||
# MinifyJavascript compresses JS
|
# MinifyJavascript compresses JS
|
||||||
Middleman::Extensions.register(:minify_javascript) do
|
Middleman::Extensions.register(:minify_javascript) do
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
module Middleman
|
class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
||||||
module Extensions
|
|
||||||
class 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 :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"
|
option :ignore, [], "Regexes of filenames to skip adding asset hashes to"
|
||||||
|
|
||||||
def initialize(app, options_hash={})
|
def initialize(app, options_hash={}, &block)
|
||||||
super
|
super
|
||||||
|
|
||||||
require 'digest/sha1'
|
require 'digest/sha1'
|
||||||
|
@ -47,7 +45,6 @@ module Middleman
|
||||||
resource.destination_path = resource.destination_path.sub(/\.(\w+)$/) { |ext| "-#{digest}#{ext}" }
|
resource.destination_path = resource.destination_path.sub(/\.(\w+)$/) { |ext| "-#{digest}#{ext}" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
# The asset hash middleware is responsible for rewriting references to
|
# The asset hash middleware is responsible for rewriting references to
|
||||||
# assets to include their new, hashed name.
|
# assets to include their new, hashed name.
|
||||||
|
@ -100,9 +97,8 @@ module Middleman
|
||||||
[status, headers, response]
|
[status, headers, response]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
# =================Temp Generate Test data==============================
|
# =================Temp Generate Test data==============================
|
||||||
# ["jpg", "png", "gif"].each do |ext|
|
# ["jpg", "png", "gif"].each do |ext|
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
# Extensions namespace
|
|
||||||
module Middleman
|
|
||||||
module Extensions
|
|
||||||
|
|
||||||
# Asset Host module
|
# 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'
|
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)
|
def initialize(app, options_hash={}, &block)
|
||||||
|
@ -50,6 +47,4 @@ module Middleman
|
||||||
File.join(asset_prefix, original_output)
|
File.join(asset_prefix, original_output)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
# Extensions namespace
|
# Automatic Image Sizes extension
|
||||||
module Middleman
|
class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
|
||||||
module Extensions
|
|
||||||
|
|
||||||
# Automatic Image Sizes extension
|
|
||||||
class AutomaticImageSizes < ::Middleman::Extension
|
|
||||||
|
|
||||||
def initialize(app, options_hash={}, &block)
|
def initialize(app, options_hash={}, &block)
|
||||||
super
|
super
|
||||||
|
@ -43,6 +39,4 @@ module Middleman
|
||||||
super(path, params)
|
super(path, params)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
# Extension namespace
|
# The Cache Buster extension
|
||||||
module Middleman
|
class Middleman::Extensions::CacheBuster < ::Middleman::Extension
|
||||||
module Extensions
|
|
||||||
|
|
||||||
# The Cache Buster extension
|
|
||||||
class CacheBuster < ::Middleman::Extension
|
|
||||||
|
|
||||||
def initialize(app, options_hash={}, &block)
|
def initialize(app, options_hash={}, &block)
|
||||||
super
|
super
|
||||||
|
@ -57,6 +53,4 @@ module Middleman
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
# Extensions namespace
|
# Directory Indexes extension
|
||||||
module Middleman
|
class Middleman::Extensions::DirectoryIndexes < ::Middleman::Extension
|
||||||
module Extensions
|
|
||||||
|
|
||||||
# Directory Indexes extension
|
|
||||||
class DirectoryIndexes < ::Middleman::Extension
|
|
||||||
# Update the main sitemap resource list
|
# Update the main sitemap resource list
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def manipulate_resource_list(resources)
|
def manipulate_resource_list(resources)
|
||||||
|
@ -25,6 +21,4 @@ module Middleman
|
||||||
resource.destination_path = resource.destination_path.chomp(File.extname(index_file)) + new_index_path
|
resource.destination_path = resource.destination_path.chomp(File.extname(index_file)) + new_index_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
module Middleman::Extensions
|
# This extension Gzips assets and pages when building.
|
||||||
|
# Gzipped assets and pages can be served directly by Apache or
|
||||||
# This extension Gzips assets and pages when building.
|
# Nginx with the proper configuration, and pre-zipping means that we
|
||||||
# Gzipped assets and pages can be served directly by Apache or
|
# can use a more agressive compression level at no CPU cost per request.
|
||||||
# Nginx with the proper configuration, and pre-zipping means that we
|
#
|
||||||
# can use a more agressive compression level at no CPU cost per request.
|
# Use Nginx's gzip_static directive, or AddEncoding and mod_rewrite in Apache
|
||||||
#
|
# to serve your Gzipped files whenever the normal (non-.gz) filename is requested.
|
||||||
# Use Nginx's gzip_static directive, or AddEncoding and mod_rewrite in Apache
|
#
|
||||||
# to serve your Gzipped files whenever the normal (non-.gz) filename is requested.
|
# Pass the :exts options to customize which file extensions get zipped (defaults
|
||||||
#
|
# to .html, .htm, .js and .css.
|
||||||
# Pass the :exts options to customize which file extensions get zipped (defaults
|
#
|
||||||
# to .html, .htm, .js and .css.
|
class Middleman::Extensions::Gzip < ::Middleman::Extension
|
||||||
#
|
|
||||||
class Gzip < ::Middleman::Extension
|
|
||||||
option :exts, %w(.js .css .html .htm), 'File extensions to Gzip when building.'
|
option :exts, %w(.js .css .html .htm), 'File extensions to Gzip when building.'
|
||||||
|
|
||||||
def initialize(app, options_hash={})
|
def initialize(app, options_hash={})
|
||||||
|
@ -69,5 +67,4 @@ module Middleman::Extensions
|
||||||
|
|
||||||
[output_filename, old_size, new_size]
|
[output_filename, old_size, new_size]
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
# Extension namespace
|
class Middleman::Extensions::Lorem < ::Middleman::Extension
|
||||||
module Middleman
|
|
||||||
module Extensions
|
|
||||||
|
|
||||||
# Lorem helper
|
|
||||||
class Lorem < ::Middleman::Extension
|
|
||||||
helpers do
|
helpers do
|
||||||
# Access to the Lorem object
|
# Access to the Lorem object
|
||||||
# @return [Middleman::Extensions::Lorem::LoremObject]
|
# @return [Middleman::Extensions::Lorem::LoremObject]
|
||||||
|
@ -178,6 +173,4 @@ module Middleman
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,32 +1,22 @@
|
||||||
# Extensions namespace
|
# Minify CSS Extension
|
||||||
module Middleman
|
class Middleman::Extensions::MinifyCss < ::Middleman::Extension
|
||||||
module Extensions
|
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'
|
||||||
|
|
||||||
# Minify CSS Extension
|
def initialize(app, options_hash={}, &block)
|
||||||
module MinifyCss
|
super
|
||||||
|
|
||||||
# Setup extension
|
|
||||||
class << self
|
|
||||||
|
|
||||||
# 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'
|
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
|
end
|
||||||
|
|
||||||
|
def after_configuration
|
||||||
|
chosen_compressor = app.config[:css_compressor] || options[:compressor] || SassCompressor
|
||||||
|
|
||||||
# Setup Rack middleware to minify CSS
|
# Setup Rack middleware to minify CSS
|
||||||
use Rack, :compressor => chosen_compressor,
|
app.use Rack, :compressor => chosen_compressor,
|
||||||
:ignore => ignore,
|
:ignore => options[:ignore] + [/\.min\./],
|
||||||
:inline => inline
|
:inline => options[:inline]
|
||||||
end
|
|
||||||
end
|
|
||||||
alias :included :registered
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class SassCompressor
|
class SassCompressor
|
||||||
|
@ -84,6 +74,4 @@ module Middleman
|
||||||
[status, headers, response]
|
[status, headers, response]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue