middleman-core 4.1.0.rc.1 → 4.1.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/features/asset_hash.feature +44 -6
- data/features/asset_host.feature +1 -0
- data/features/automatic_image_sizes.feature +18 -5
- data/fixtures/asset-hash-host-app/source/index.html.erb +1 -1
- data/fixtures/asset-host-app/config.rb +1 -0
- data/fixtures/asset-host-app/source/asset_host.html.erb +9 -0
- data/fixtures/automatic-image-size-app/source/markdown-sizes.html.markdown +1 -0
- data/lib/middleman-core/application.rb +68 -58
- data/lib/middleman-core/builder.rb +24 -18
- data/lib/middleman-core/callback_manager.rb +8 -1
- data/lib/middleman-core/contracts.rb +13 -102
- data/lib/middleman-core/core_extensions.rb +6 -0
- data/lib/middleman-core/core_extensions/collections/lazy_step.rb +1 -1
- data/lib/middleman-core/core_extensions/data.rb +3 -2
- data/lib/middleman-core/core_extensions/default_helpers.rb +5 -5
- data/lib/middleman-core/core_extensions/external_helpers.rb +6 -11
- data/lib/middleman-core/core_extensions/file_watcher.rb +1 -1
- data/lib/middleman-core/core_extensions/front_matter.rb +1 -0
- data/lib/middleman-core/core_extensions/i18n.rb +4 -4
- data/lib/middleman-core/core_extensions/inline_url_rewriter.rb +150 -0
- data/lib/middleman-core/core_extensions/routing.rb +22 -28
- data/lib/middleman-core/core_extensions/show_exceptions.rb +1 -7
- data/lib/middleman-core/extension.rb +19 -2
- data/lib/middleman-core/extension_manager.rb +2 -0
- data/lib/middleman-core/extensions.rb +12 -0
- data/lib/middleman-core/extensions/asset_hash.rb +21 -20
- data/lib/middleman-core/extensions/asset_host.rb +9 -10
- data/lib/middleman-core/extensions/automatic_image_sizes.rb +1 -1
- data/lib/middleman-core/extensions/cache_buster.rb +6 -12
- data/lib/middleman-core/extensions/gzip.rb +2 -2
- data/lib/middleman-core/extensions/lorem.rb +1 -1
- data/lib/middleman-core/extensions/minify_css.rb +2 -2
- data/lib/middleman-core/extensions/minify_javascript.rb +2 -2
- data/lib/middleman-core/extensions/relative_assets.rb +6 -12
- data/lib/middleman-core/preview_server.rb +11 -9
- data/lib/middleman-core/preview_server/server_hostname.rb +2 -2
- data/lib/middleman-core/rack.rb +1 -1
- data/lib/middleman-core/renderers/kramdown.rb +1 -1
- data/lib/middleman-core/renderers/less.rb +3 -4
- data/lib/middleman-core/renderers/markdown.rb +2 -8
- data/lib/middleman-core/renderers/redcarpet.rb +1 -1
- data/lib/middleman-core/renderers/sass.rb +8 -11
- data/lib/middleman-core/renderers/stylus.rb +1 -5
- data/lib/middleman-core/sitemap/extensions/ignores.rb +5 -4
- data/lib/middleman-core/sitemap/extensions/import.rb +12 -15
- data/lib/middleman-core/sitemap/extensions/move_file.rb +3 -3
- data/lib/middleman-core/sitemap/extensions/proxies.rb +4 -4
- data/lib/middleman-core/sitemap/extensions/redirects.rb +16 -28
- data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +17 -35
- data/lib/middleman-core/sitemap/extensions/traversal.rb +5 -5
- data/lib/middleman-core/sitemap/resource.rb +16 -16
- data/lib/middleman-core/sitemap/store.rb +42 -31
- data/lib/middleman-core/sources.rb +9 -9
- data/lib/middleman-core/sources/source_watcher.rb +14 -10
- data/lib/middleman-core/step_definitions/server_steps.rb +12 -4
- data/lib/middleman-core/template_context.rb +1 -1
- data/lib/middleman-core/template_renderer.rb +74 -75
- data/lib/middleman-core/util.rb +19 -16
- data/lib/middleman-core/util/data.rb +86 -82
- data/lib/middleman-core/version.rb +1 -1
- data/middleman-core.gemspec +1 -0
- metadata +19 -39
- data/features/cli/preview_server-hook.feature +0 -17
- data/features/cli/preview_server.feature +0 -536
- data/features/cli_extension.feature +0 -14
- data/features/cli_init.feature +0 -89
- data/fixtures/asset-hash-host-app/config.rb +0 -4
- data/fixtures/preview-server-app/bin/dns_server.rb +0 -33
- data/fixtures/preview-server-app/config.rb +0 -0
- data/fixtures/preview-server-app/source/index.html.erb +0 -1
- data/fixtures/preview-server-app/source/layout.erb +0 -9
- data/fixtures/preview-server-app/source/layouts/custom.erb +0 -8
- data/fixtures/preview-server-app/source/real.html +0 -1
- data/fixtures/preview-server-app/source/real/index.html.erb +0 -5
- data/fixtures/preview-server-app/source/should_be_ignored.html +0 -1
- data/fixtures/preview-server-app/source/should_be_ignored2.html +0 -1
- data/fixtures/preview-server-app/source/should_be_ignored3.html +0 -1
- data/fixtures/preview-server-app/source/static.html +0 -1
- data/fixtures/preview-server-hook-app/config.rb +0 -19
- data/fixtures/preview-server-hook-app/source/index.html.erb +0 -9
- data/lib/middleman-core/middleware/inline_url_rewriter.rb +0 -109
@@ -1,7 +1,7 @@
|
|
1
1
|
# Routing extension
|
2
2
|
module Middleman
|
3
3
|
module CoreExtensions
|
4
|
-
class Routing <
|
4
|
+
class Routing < ConfigExtension
|
5
5
|
# This should always run late, but not as late as :directory_indexes,
|
6
6
|
# so it can add metadata to any pages generated by other extensions
|
7
7
|
self.resource_list_manipulator_priority = 10
|
@@ -9,24 +9,28 @@ module Middleman
|
|
9
9
|
# Expose the `page` method to config.
|
10
10
|
expose_to_config :page
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
PageDescriptor = Struct.new(:path, :metadata) do
|
13
|
+
def execute_descriptor(app, resources)
|
14
|
+
normalized_path = path.dup
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
resources.each do |resource|
|
22
|
-
@page_configs.each do |p|
|
23
|
-
resource.add_metadata(p[:metadata]) if Middleman::Util.path_match(p[:path], "/#{resource.path}")
|
16
|
+
if normalized_path.is_a?(String) && !normalized_path.include?('*')
|
17
|
+
# Normalize path
|
18
|
+
normalized_path = ::Middleman::Util.normalize_path(normalized_path)
|
19
|
+
if normalized_path.end_with?('/') || app.files.by_type(:source).watchers.any? { |w| (w.directory + Pathname(normalized_path)).directory? }
|
20
|
+
normalized_path = ::File.join(normalized_path, app.config[:index_file])
|
21
|
+
end
|
24
22
|
end
|
23
|
+
|
24
|
+
normalized_path = '/' + ::Middleman::Util.strip_leading_slash(normalized_path) if normalized_path.is_a?(String)
|
25
|
+
|
26
|
+
resources
|
27
|
+
.select { |r| ::Middleman::Util.path_match(normalized_path, "/#{r.path}") }
|
28
|
+
.each { |r| r.add_metadata(metadata) }
|
29
|
+
|
30
|
+
resources
|
25
31
|
end
|
26
32
|
end
|
27
33
|
|
28
|
-
PageDescriptor = Struct.new(:path, :metadata)
|
29
|
-
|
30
34
|
# The page method allows options to be set for a given source path, regex, or glob.
|
31
35
|
# Options that may be set include layout, locals, andx ignore.
|
32
36
|
#
|
@@ -44,28 +48,18 @@ module Middleman
|
|
44
48
|
# @option opts [Hash] locals Local variables for the template. These will be available when the template renders.
|
45
49
|
# @option opts [Hash] data Extra metadata to add to the page. This is the same as frontmatter, though frontmatter will take precedence over metadata defined here. Available via {Resource#data}.
|
46
50
|
# @return [void]
|
47
|
-
Contract Or[String, Regexp], Hash =>
|
51
|
+
Contract Or[String, Regexp], Hash => PageDescriptor
|
48
52
|
def page(path, opts={})
|
49
53
|
options = opts.dup
|
50
54
|
|
51
55
|
# Default layout
|
52
56
|
metadata = {
|
53
|
-
options: options,
|
54
57
|
locals: options.delete(:locals) || {},
|
55
|
-
page: options.delete(:data) || {}
|
58
|
+
page: options.delete(:data) || {},
|
59
|
+
options: options
|
56
60
|
}
|
57
61
|
|
58
|
-
|
59
|
-
# Normalize path
|
60
|
-
path = Middleman::Util.normalize_path(path)
|
61
|
-
if path.end_with?('/') || app.files.by_type(:source).watchers.any? { |w| (w.directory + Pathname(path)).directory? }
|
62
|
-
path = File.join(path, @app.config[:index_file])
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
path = '/' + Util.strip_leading_slash(path) if path.is_a?(String)
|
67
|
-
|
68
|
-
@page_configs << PageDescriptor.new(path, metadata)
|
62
|
+
PageDescriptor.new(path, metadata)
|
69
63
|
end
|
70
64
|
end
|
71
65
|
end
|
@@ -3,13 +3,7 @@ require 'rack/showexceptions'
|
|
3
3
|
# Support rack/showexceptions during development
|
4
4
|
module Middleman::CoreExtensions
|
5
5
|
class ShowExceptions < ::Middleman::Extension
|
6
|
-
|
7
|
-
super
|
8
|
-
|
9
|
-
return if app.config.defines_setting? :show_exceptions
|
10
|
-
|
11
|
-
app.config.define_setting :show_exceptions, ENV['TEST'] ? false : true, 'Whether to catch and display exceptions'
|
12
|
-
end
|
6
|
+
define_setting :show_exceptions, ENV['TEST'] ? false : true, 'Whether to catch and display exceptions'
|
13
7
|
|
14
8
|
def ready
|
15
9
|
app.use ::Rack::ShowExceptions if !app.build? && app.config[:show_exceptions]
|
@@ -135,6 +135,23 @@ module Middleman
|
|
135
135
|
config.define_setting(key, default, description, options)
|
136
136
|
end
|
137
137
|
|
138
|
+
# @api private
|
139
|
+
# @return [Middleman::Configuration::ConfigurationManager] The defined global options for this extension.
|
140
|
+
def global_config
|
141
|
+
@_global_config ||= ::Middleman::Configuration::ConfigurationManager.new
|
142
|
+
end
|
143
|
+
|
144
|
+
# Add an global option to this extension.
|
145
|
+
# @see Middleman::Configuration::ConfigurationManager#define_setting
|
146
|
+
# @example
|
147
|
+
# option :compress, false, 'Whether to compress the output'
|
148
|
+
# @param [Symbol] key The name of the option
|
149
|
+
# @param [Object] default The default value for the option
|
150
|
+
# @param [String] description A human-readable description of what the option does
|
151
|
+
def define_setting(key, default=nil, description=nil, options={})
|
152
|
+
global_config.define_setting(key, default, description, options)
|
153
|
+
end
|
154
|
+
|
138
155
|
# Short-hand for simple Sitemap manipulation
|
139
156
|
# @example A generator which returns an array of resources
|
140
157
|
# resources :make_resources
|
@@ -479,8 +496,8 @@ module Middleman
|
|
479
496
|
@descriptors[k] = []
|
480
497
|
|
481
498
|
define_singleton_method(:"__original_#{v}", &method(v))
|
482
|
-
define_singleton_method(v) do |*args, &
|
483
|
-
@descriptors[k] << method(:"__original_#{v}").call(*args, &
|
499
|
+
define_singleton_method(v) do |*args, &b|
|
500
|
+
@descriptors[k] << method(:"__original_#{v}").call(*args, &b)
|
484
501
|
@app.sitemap.rebuild_resource_list!(:"first_run_change_#{v}")
|
485
502
|
end
|
486
503
|
end
|
@@ -120,6 +120,18 @@ module Middleman
|
|
120
120
|
app.extensions.activate descriptor[:name]
|
121
121
|
end
|
122
122
|
end
|
123
|
+
|
124
|
+
def load_settings(app)
|
125
|
+
registered.each do |name, _|
|
126
|
+
begin
|
127
|
+
ext = load(name)
|
128
|
+
unless ext.global_config.all_settings.empty?
|
129
|
+
app.config.load_settings(ext.global_config.all_settings)
|
130
|
+
end
|
131
|
+
rescue LoadError
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
123
135
|
end
|
124
136
|
end
|
125
137
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'addressable/uri'
|
2
1
|
require 'middleman-core/util'
|
3
2
|
require 'middleman-core/rack'
|
4
3
|
|
5
4
|
class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
5
|
+
option :sources, %w(.htm .html .php .css .js), 'List of extensions that are searched for hashable assets.'
|
6
6
|
option :exts, %w(.jpg .jpeg .png .gif .webp .js .css .otf .woff .woff2 .eot .ttf .svg .svgz), 'List of extensions that get asset hashes appended to them.'
|
7
7
|
option :ignore, [], 'Regexes of filenames to skip adding asset hashes to'
|
8
8
|
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for path rewrites'
|
@@ -10,29 +10,26 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
|
10
10
|
def initialize(app, options_hash={}, &block)
|
11
11
|
super
|
12
12
|
|
13
|
+
require 'addressable/uri'
|
13
14
|
require 'digest/sha1'
|
14
15
|
require 'rack/mock'
|
15
|
-
require 'middleman-core/middleware/inline_url_rewriter'
|
16
|
-
end
|
17
16
|
|
18
|
-
def after_configuration
|
19
17
|
# Allow specifying regexes to ignore, plus always ignore apple touch icons
|
20
18
|
@ignore = Array(options.ignore) + [/^apple-touch-icon/]
|
21
19
|
|
22
|
-
app.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
proc: method(:rewrite_url)
|
20
|
+
app.rewrite_inline_urls id: :asset_hash,
|
21
|
+
url_extensions: options.exts.sort.reverse,
|
22
|
+
source_extensions: options.sources,
|
23
|
+
ignore: @ignore,
|
24
|
+
rewrite_ignore: options.rewrite_ignore,
|
25
|
+
proc: method(:rewrite_url),
|
26
|
+
after: :asset_host
|
30
27
|
end
|
31
28
|
|
32
29
|
Contract String, Or[String, Pathname], Any => Maybe[String]
|
33
30
|
def rewrite_url(asset_path, dirpath, _request_path)
|
34
31
|
uri = ::Addressable::URI.parse(asset_path)
|
35
|
-
relative_path = uri.path
|
32
|
+
relative_path = !uri.path.start_with?('/')
|
36
33
|
|
37
34
|
full_asset_path = if relative_path
|
38
35
|
dirpath.join(asset_path).to_s
|
@@ -77,15 +74,19 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
|
77
74
|
return if ignored_resource?(resource)
|
78
75
|
return if resource.ignored?
|
79
76
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
77
|
+
digest = if resource.binary?
|
78
|
+
::Digest::SHA1.file(resource.source_file).hexdigest[0..7]
|
79
|
+
else
|
80
|
+
# Render through the Rack interface so middleware and mounted apps get a shot
|
81
|
+
response = @rack_client.get(
|
82
|
+
::URI.escape(resource.destination_path),
|
83
|
+
'bypass_inline_url_rewriter_asset_hash' => 'true'
|
84
|
+
)
|
85
85
|
|
86
|
-
|
86
|
+
raise "#{resource.path} should be in the sitemap!" unless response.status == 200
|
87
87
|
|
88
|
-
|
88
|
+
::Digest::SHA1.hexdigest(response.body)[0..7]
|
89
|
+
end
|
89
90
|
|
90
91
|
resource.destination_path = resource.destination_path.sub(/\.(\w+)$/) { |ext| "-#{digest}#{ext}" }
|
91
92
|
resource
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'addressable/uri'
|
2
|
-
require 'middleman-core/middleware/inline_url_rewriter'
|
3
2
|
|
4
3
|
class Middleman::Extensions::AssetHost < ::Middleman::Extension
|
5
4
|
option :host, nil, 'The asset host to use or a Proc to determine asset host', required: true
|
@@ -8,15 +7,15 @@ class Middleman::Extensions::AssetHost < ::Middleman::Extension
|
|
8
7
|
option :ignore, [], 'Regexes of filenames to skip adding query strings to'
|
9
8
|
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for host rewrites'
|
10
9
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
10
|
+
def initialize(app, options_hash={}, &block)
|
11
|
+
super
|
12
|
+
|
13
|
+
app.rewrite_inline_urls id: :asset_host,
|
14
|
+
url_extensions: options.exts,
|
15
|
+
source_extensions: options.sources,
|
16
|
+
ignore: options.ignore,
|
17
|
+
rewrite_ignore: options.rewrite_ignore,
|
18
|
+
proc: method(:rewrite_url)
|
20
19
|
end
|
21
20
|
|
22
21
|
Contract String, Or[String, Pathname], Any => String
|
@@ -19,7 +19,7 @@ class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
|
|
19
19
|
real_path = path.dup
|
20
20
|
real_path = File.join(config[:images_dir], real_path) unless real_path.start_with?('/')
|
21
21
|
|
22
|
-
file = app.files.find(:source, real_path)
|
22
|
+
file = app.files.find(:source, real_path) || app.files.find(:source, real_path.gsub(/^\//, ''))
|
23
23
|
|
24
24
|
if file && file[:full_path].exist?
|
25
25
|
begin
|
@@ -8,18 +8,12 @@ class Middleman::Extensions::CacheBuster < ::Middleman::Extension
|
|
8
8
|
def initialize(app, options_hash={}, &block)
|
9
9
|
super
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
url_extensions: options.exts,
|
18
|
-
source_extensions: options.sources,
|
19
|
-
ignore: options.ignore,
|
20
|
-
rewrite_ignore: options.rewrite_ignore,
|
21
|
-
middleman_app: app,
|
22
|
-
proc: method(:rewrite_url)
|
11
|
+
app.rewrite_inline_urls id: :cache_buster,
|
12
|
+
url_extensions: options.exts,
|
13
|
+
source_extensions: options.sources,
|
14
|
+
ignore: options.ignore,
|
15
|
+
rewrite_ignore: options.rewrite_ignore,
|
16
|
+
proc: method(:rewrite_url)
|
23
17
|
end
|
24
18
|
|
25
19
|
Contract String, Or[String, Pathname], Any => String
|
@@ -64,10 +64,10 @@ class Middleman::Extensions::Gzip < ::Middleman::Extension
|
|
64
64
|
|
65
65
|
total_savings += (old_size - new_size)
|
66
66
|
size_change_word = (old_size - new_size) > 0 ? 'smaller' : 'larger'
|
67
|
-
builder.trigger :
|
67
|
+
builder.trigger :created, "#{output_filename} (#{NumberHelpers.new.number_to_human_size((old_size - new_size).abs)} #{size_change_word})"
|
68
68
|
end
|
69
69
|
|
70
|
-
builder.trigger :gzip, "Total gzip savings: #{NumberHelpers.new.number_to_human_size(total_savings)}"
|
70
|
+
builder.trigger :gzip, '', "Total gzip savings: #{NumberHelpers.new.number_to_human_size(total_savings)}"
|
71
71
|
I18n.locale = old_locale
|
72
72
|
end
|
73
73
|
|
@@ -44,7 +44,7 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension
|
|
44
44
|
module LoremObject
|
45
45
|
class << self
|
46
46
|
# Words for use in lorem text
|
47
|
-
WORDS = %w(alias consequatur aut perferendis sit voluptatem accusantium doloremque aperiam eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo aspernatur aut odit aut fugit sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt neque dolorem ipsum quia dolor sit amet consectetur adipisci velit sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem ut enim ad minima veniam quis nostrum exercitationem ullam corporis nemo enim ipsam voluptatem quia voluptas sit suscipit laboriosam nisi ut aliquid ex ea commodi consequatur quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae et iusto odio dignissimos ducimus qui blanditiis praesentium laudantium totam rem voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident sed ut perspiciatis unde omnis iste natus error similique sunt in culpa qui officia deserunt mollitia animi id est laborum et dolorum fuga et harum quidem rerum facilis est et expedita distinctio nam libero tempore cum soluta nobis est eligendi optio cumque nihil impedit quo porro quisquam est qui minus id quod maxime placeat facere possimus omnis voluptas assumenda est omnis dolor repellendus temporibus autem quibusdam et aut consequatur vel illum qui dolorem eum fugiat quo voluptas nulla pariatur at vero eos et accusamus officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae itaque earum rerum hic tenetur a sapiente delectus ut aut reiciendis voluptatibus maiores doloribus asperiores repellat)
|
47
|
+
WORDS = %w(alias consequatur aut perferendis sit voluptatem accusantium doloremque aperiam eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo aspernatur aut odit aut fugit sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt neque dolorem ipsum quia dolor sit amet consectetur adipisci velit sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem ut enim ad minima veniam quis nostrum exercitationem ullam corporis nemo enim ipsam voluptatem quia voluptas sit suscipit laboriosam nisi ut aliquid ex ea commodi consequatur quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae et iusto odio dignissimos ducimus qui blanditiis praesentium laudantium totam rem voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident sed ut perspiciatis unde omnis iste natus error similique sunt in culpa qui officia deserunt mollitia animi id est laborum et dolorum fuga et harum quidem rerum facilis est et expedita distinctio nam libero tempore cum soluta nobis est eligendi optio cumque nihil impedit quo porro quisquam est qui minus id quod maxime placeat facere possimus omnis voluptas assumenda est omnis dolor repellendus temporibus autem quibusdam et aut consequatur vel illum qui dolorem eum fugiat quo voluptas nulla pariatur at vero eos et accusamus officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae itaque earum rerum hic tenetur a sapiente delectus ut aut reiciendis voluptatibus maiores doloribus asperiores repellat).freeze
|
48
48
|
|
49
49
|
# Get one placeholder word
|
50
50
|
# @return [String]
|
@@ -36,11 +36,11 @@ class Middleman::Extensions::MinifyCss < ::Middleman::Extension
|
|
36
36
|
# Init
|
37
37
|
# @param [Class] app
|
38
38
|
# @param [Hash] options
|
39
|
-
Contract RespondTo[:call],
|
39
|
+
Contract RespondTo[:call], {
|
40
40
|
ignore: ArrayOf[PATH_MATCHER],
|
41
41
|
inline: Bool,
|
42
42
|
compressor: Or[Proc, RespondTo[:to_proc], RespondTo[:compress]]
|
43
|
-
}
|
43
|
+
} => Any
|
44
44
|
def initialize(app, options={})
|
45
45
|
@app = app
|
46
46
|
@ignore = options.fetch(:ignore)
|
@@ -28,11 +28,11 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
|
|
28
28
|
# Init
|
29
29
|
# @param [Class] app
|
30
30
|
# @param [Hash] options
|
31
|
-
Contract RespondTo[:call],
|
31
|
+
Contract RespondTo[:call], {
|
32
32
|
ignore: ArrayOf[PATH_MATCHER],
|
33
33
|
inline: Bool,
|
34
34
|
compressor: Or[Proc, RespondTo[:to_proc], RespondTo[:compress]]
|
35
|
-
}
|
35
|
+
} => Any
|
36
36
|
def initialize(app, options={})
|
37
37
|
@app = app
|
38
38
|
@ignore = options.fetch(:ignore)
|
@@ -10,18 +10,12 @@ class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
|
|
10
10
|
def initialize(app, options_hash={}, &block)
|
11
11
|
super
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
url_extensions: options.exts,
|
20
|
-
source_extensions: options.sources,
|
21
|
-
ignore: options.ignore,
|
22
|
-
rewrite_ignore: options.rewrite_ignore,
|
23
|
-
middleman_app: app,
|
24
|
-
proc: method(:rewrite_url)
|
13
|
+
app.rewrite_inline_urls id: :asset_hash,
|
14
|
+
url_extensions: options.exts,
|
15
|
+
source_extensions: options.sources,
|
16
|
+
ignore: options.ignore,
|
17
|
+
rewrite_ignore: options.rewrite_ignore,
|
18
|
+
proc: method(:rewrite_url)
|
25
19
|
end
|
26
20
|
|
27
21
|
helpers do
|
@@ -163,14 +163,16 @@ module Middleman
|
|
163
163
|
path: root,
|
164
164
|
only: match_against
|
165
165
|
|
166
|
-
|
167
|
-
|
166
|
+
unless config[:watcher_disable]
|
167
|
+
# Hack around node_modules in root.
|
168
|
+
watcher.listener.ignore(/^node_modules/)
|
168
169
|
|
169
|
-
|
170
|
-
|
170
|
+
# Hack around sass cache in root.
|
171
|
+
watcher.listener.ignore(/^\.sass-cache/)
|
171
172
|
|
172
|
-
|
173
|
-
|
173
|
+
# Hack around bundler cache in root.
|
174
|
+
watcher.listener.ignore(/^vendor\/bundle/)
|
175
|
+
end
|
174
176
|
end
|
175
177
|
end
|
176
178
|
|
@@ -247,10 +249,10 @@ module Middleman
|
|
247
249
|
end
|
248
250
|
end
|
249
251
|
|
250
|
-
if is_logging
|
251
|
-
|
252
|
+
http_opts[:Logger] = if is_logging
|
253
|
+
FilteredWebrickLog.new
|
252
254
|
else
|
253
|
-
|
255
|
+
::WEBrick::Log.new(nil, 0)
|
254
256
|
end
|
255
257
|
|
256
258
|
begin
|
@@ -10,7 +10,7 @@ module Middleman
|
|
10
10
|
true
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
alias to_browser to_s
|
14
14
|
end
|
15
15
|
|
16
16
|
class ServerPlainHostname < SimpleDelegator
|
@@ -24,7 +24,7 @@ module Middleman
|
|
24
24
|
# rubocop:enable Style/CaseEquality
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
alias to_browser to_s
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.new(string)
|
data/lib/middleman-core/rack.rb
CHANGED
@@ -138,7 +138,7 @@ module Middleman
|
|
138
138
|
response[1]['Content-Encoding'] = 'gzip' if %w(.svgz .gz).include?(resource.ext)
|
139
139
|
# Do not set Content-Type if status is 1xx, 204, 205 or 304, otherwise
|
140
140
|
# Rack will throw an error (500)
|
141
|
-
if !(100..199).
|
141
|
+
if !(100..199).cover?(status) && ![204, 205, 304].include?(status)
|
142
142
|
response[1]['Content-Type'] = resource.content_type || 'application/octet-stream'
|
143
143
|
end
|
144
144
|
halt response
|