middleman-core 4.1.10 → 4.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/asset_host.feature +2 -1
- data/lib/middleman-core/application.rb +3 -2
- data/lib/middleman-core/core_extensions/file_watcher.rb +8 -4
- data/lib/middleman-core/extensions/minify_css.rb +1 -1
- data/lib/middleman-core/extensions/minify_javascript.rb +1 -1
- data/lib/middleman-core/file_renderer.rb +4 -4
- data/lib/middleman-core/rack.rb +9 -3
- data/lib/middleman-core/renderers/redcarpet.rb +1 -1
- data/lib/middleman-core/sitemap/extensions/ignores.rb +47 -21
- data/lib/middleman-core/sitemap/extensions/proxies.rb +1 -1
- data/lib/middleman-core/sitemap/resource.rb +7 -0
- data/lib/middleman-core/sources.rb +6 -4
- data/lib/middleman-core/sources/source_watcher.rb +33 -10
- data/lib/middleman-core/template_renderer.rb +1 -3
- data/lib/middleman-core/version.rb +1 -1
- data/middleman-core.gemspec +4 -4
- metadata +16 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28e12dac8535ed4c817265c3aec998f827b74a78
|
4
|
+
data.tar.gz: a938f8e9d0e39de8f453776e83338fac6c625b19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca37b7bed14ef6f64fbfb8ae3838e96ed73c748fee71706ee0ad1da6d4f6f6d88b45b0c9205721d767a3a748a637c58fb24e19f8fa3e6c948afaabebc0c3582f
|
7
|
+
data.tar.gz: 8db10682e0568d35753d05c7e9dfd8cbf2a11e5760b0e0e7d57df1c6e97aa8f63d2ba3b1f1f4aec13119f987cd6fd8c799dff209bc1482012d9bb3383de1d056
|
data/features/asset_host.feature
CHANGED
@@ -25,7 +25,8 @@ Feature: Alternate between multiple asset hosts
|
|
25
25
|
And a file named "config.rb" with:
|
26
26
|
"""
|
27
27
|
activate :asset_host, host: Proc.new { |asset|
|
28
|
-
|
28
|
+
hash = Digest::MD5.digest(asset).bytes.map!(&:ord).reduce(&:+)
|
29
|
+
"http://assets%d.example.com" % (hash % 4)
|
29
30
|
}
|
30
31
|
"""
|
31
32
|
And the Server is running
|
@@ -203,6 +203,7 @@ module Middleman
|
|
203
203
|
define_setting :watcher_disable, false, 'If the Listen watcher should not run'
|
204
204
|
define_setting :watcher_force_polling, false, 'If the Listen watcher should run in polling mode'
|
205
205
|
define_setting :watcher_latency, nil, 'The Listen watcher latency'
|
206
|
+
define_setting :watcher_wait_for_delay, 0.5, 'The Listen watcher delay between calls when changes exist'
|
206
207
|
|
207
208
|
# Delegate convenience methods off to their implementations
|
208
209
|
def_delegator :"::Middleman::Logger", :singleton, :logger
|
@@ -344,11 +345,11 @@ module Middleman
|
|
344
345
|
|
345
346
|
# Clean up missing Tilt exts
|
346
347
|
def prune_tilt_templates!
|
347
|
-
::Tilt.
|
348
|
+
::Tilt.default_mapping.lazy_map.each_key do |key|
|
348
349
|
begin
|
349
350
|
::Tilt[".#{key}"]
|
350
351
|
rescue LoadError, NameError
|
351
|
-
::Tilt.
|
352
|
+
::Tilt.default_mapping.lazy_map.delete(key)
|
352
353
|
end
|
353
354
|
end
|
354
355
|
end
|
@@ -28,10 +28,7 @@ module Middleman
|
|
28
28
|
super
|
29
29
|
|
30
30
|
# Setup source collection.
|
31
|
-
@sources = ::Middleman::Sources.new(app
|
32
|
-
disable_watcher: app.config[:watcher_disable],
|
33
|
-
force_polling: app.config[:watcher_force_polling],
|
34
|
-
latency: app.config[:watcher_latency])
|
31
|
+
@sources = ::Middleman::Sources.new(app)
|
35
32
|
|
36
33
|
# Add default ignores.
|
37
34
|
IGNORES.each do |key, value|
|
@@ -55,6 +52,13 @@ module Middleman
|
|
55
52
|
# @return [void]
|
56
53
|
Contract Any
|
57
54
|
def after_configuration
|
55
|
+
@watcher.update_config(
|
56
|
+
disable_watcher: app.config[:watcher_disable],
|
57
|
+
force_polling: app.config[:watcher_force_polling],
|
58
|
+
latency: app.config[:watcher_latency],
|
59
|
+
wait_for_delay: app.config[:watcher_wait_for_delay]
|
60
|
+
)
|
61
|
+
|
58
62
|
if @original_source_dir != app.config[:source]
|
59
63
|
@watcher.update_path(app.config[:source])
|
60
64
|
end
|
@@ -3,8 +3,8 @@ require 'active_support/core_ext/string/output_safety'
|
|
3
3
|
require 'active_support/core_ext/module/delegation'
|
4
4
|
require 'middleman-core/contracts'
|
5
5
|
|
6
|
-
::Tilt.
|
7
|
-
::Tilt.
|
6
|
+
::Tilt.default_mapping.lazy_map.delete('html')
|
7
|
+
::Tilt.default_mapping.lazy_map.delete('csv')
|
8
8
|
|
9
9
|
module Middleman
|
10
10
|
class FileRenderer
|
@@ -123,8 +123,8 @@ module Middleman
|
|
123
123
|
# Find all the engines which handle this extension in tilt. Look for
|
124
124
|
# config variables of that name and merge it
|
125
125
|
extension_class = ::Middleman::Util.tilt_class(ext)
|
126
|
-
|
127
|
-
|
126
|
+
|
127
|
+
::Tilt.default_mapping.extensions_for(extension_class).each do |mapping_ext|
|
128
128
|
engine_options = @app.config[mapping_ext.to_sym] || {}
|
129
129
|
options.merge!(engine_options)
|
130
130
|
end
|
data/lib/middleman-core/rack.rb
CHANGED
@@ -133,9 +133,15 @@ module Middleman
|
|
133
133
|
|
134
134
|
# Immediately send static file
|
135
135
|
def send_file(resource, env)
|
136
|
-
file
|
137
|
-
|
138
|
-
|
136
|
+
file = ::Rack::File.new nil
|
137
|
+
path = resource.file_descriptor[:full_path]
|
138
|
+
if !file.respond_to?(:path=)
|
139
|
+
request = ::Rack::Request.new(env)
|
140
|
+
response = file.serving(request, path)
|
141
|
+
else
|
142
|
+
file.path = path
|
143
|
+
response = file.serving(env)
|
144
|
+
end
|
139
145
|
status = response[0]
|
140
146
|
response[1]['Content-Encoding'] = 'gzip' if %w(.svgz .gz).include?(resource.ext)
|
141
147
|
# Do not set Content-Type if status is 1xx, 204, 205 or 304, otherwise
|
@@ -3,7 +3,7 @@ require 'active_support/core_ext/module/attribute_accessors'
|
|
3
3
|
|
4
4
|
module Middleman
|
5
5
|
module Renderers
|
6
|
-
class RedcarpetTemplate < ::Tilt::RedcarpetTemplate
|
6
|
+
class RedcarpetTemplate < ::Tilt::RedcarpetTemplate
|
7
7
|
# because tilt has decided to convert these
|
8
8
|
# in the wrong direction
|
9
9
|
ALIASES = {
|
@@ -14,16 +14,31 @@ module Middleman
|
|
14
14
|
Contract Or[String, Regexp, Proc] => RespondTo[:execute_descriptor]
|
15
15
|
def ignore(path=nil, &block)
|
16
16
|
@app.sitemap.invalidate_resources_not_ignored_cache!
|
17
|
-
|
17
|
+
|
18
|
+
if path.is_a? Regexp
|
19
|
+
RegexpIgnoreDescriptor.new(path)
|
20
|
+
elsif path.is_a? String
|
21
|
+
path_clean = ::Middleman::Util.normalize_path(path)
|
22
|
+
|
23
|
+
if path_clean.include?('*') # It's a glob
|
24
|
+
GlobIgnoreDescriptor.new(path_clean)
|
25
|
+
else
|
26
|
+
StringIgnoreDescriptor.new(path_clean)
|
27
|
+
end
|
28
|
+
elsif block
|
29
|
+
BlockIgnoreDescriptor.new(nil, block)
|
30
|
+
else
|
31
|
+
IgnoreDescriptor.new(path, block)
|
32
|
+
end
|
18
33
|
end
|
19
34
|
|
20
35
|
IgnoreDescriptor = Struct.new(:path, :block) do
|
21
36
|
def execute_descriptor(_app, resources)
|
22
37
|
resources.map do |r|
|
23
38
|
# Ignore based on the source path (without template extensions)
|
24
|
-
if ignored?(r.
|
39
|
+
if ignored?(r.normalized_path)
|
25
40
|
r.ignore!
|
26
|
-
elsif !r.is_a?(ProxyResource) && r.file_descriptor && ignored?(r.file_descriptor
|
41
|
+
elsif !r.is_a?(ProxyResource) && r.file_descriptor && ignored?(r.file_descriptor.normalized_relative_path)
|
27
42
|
# This allows files to be ignored by their source file name (with template extensions)
|
28
43
|
r.ignore!
|
29
44
|
end
|
@@ -33,27 +48,38 @@ module Middleman
|
|
33
48
|
end
|
34
49
|
|
35
50
|
def ignored?(match_path)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
elsif block
|
53
|
-
block.call(match_path)
|
51
|
+
raise NotImplementedError
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
class RegexpIgnoreDescriptor < IgnoreDescriptor
|
56
|
+
def ignored?(match_path)
|
57
|
+
match_path =~ path
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class GlobIgnoreDescriptor < IgnoreDescriptor
|
62
|
+
def ignored?(match_path)
|
63
|
+
if defined?(::File::FNM_EXTGLOB)
|
64
|
+
::File.fnmatch(path, match_path, ::File::FNM_EXTGLOB)
|
65
|
+
else
|
66
|
+
::File.fnmatch(path, match_path)
|
54
67
|
end
|
55
68
|
end
|
56
69
|
end
|
70
|
+
|
71
|
+
class StringIgnoreDescriptor < IgnoreDescriptor
|
72
|
+
def ignored?(match_path)
|
73
|
+
match_path == path
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class BlockIgnoreDescriptor
|
78
|
+
def ignored?(match_path)
|
79
|
+
block.call(match_path)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
57
83
|
end
|
58
84
|
end
|
59
85
|
end
|
@@ -197,6 +197,13 @@ module Middleman
|
|
197
197
|
options[:content_type] || ::Rack::Mime.mime_type(ext, nil)
|
198
198
|
end
|
199
199
|
|
200
|
+
# The normalized source path of this resource (relative to the source directory,
|
201
|
+
# without template extensions)
|
202
|
+
# @return [String]
|
203
|
+
def normalized_path
|
204
|
+
@normalized_path ||= ::Middleman::Util.normalize_path @path
|
205
|
+
end
|
206
|
+
|
200
207
|
def to_s
|
201
208
|
"#<#{self.class} path=#{@path}>"
|
202
209
|
end
|
@@ -8,6 +8,10 @@ module Middleman
|
|
8
8
|
::Middleman::Sources.file_cache[full_path] ||= {}
|
9
9
|
::Middleman::Sources.file_cache[full_path][version] ||= ::File.read(full_path)
|
10
10
|
end
|
11
|
+
|
12
|
+
def normalized_relative_path
|
13
|
+
@normalized_relative_path ||= ::Middleman::Util.normalize_path relative_path.to_s
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
# Sources handle multiple on-disk collections of files which make up
|
@@ -52,15 +56,13 @@ module Middleman
|
|
52
56
|
# @param [Hash] options Global options.
|
53
57
|
# @param [Array] watchers Default watchers.
|
54
58
|
Contract IsA['Middleman::Application'], Maybe[Hash], Maybe[Array] => Any
|
55
|
-
def initialize(app,
|
59
|
+
def initialize(app, _options={}, watchers=[])
|
56
60
|
@app = app
|
57
61
|
@watchers = watchers
|
58
62
|
@sorted_watchers = @watchers.dup.freeze
|
59
63
|
|
60
64
|
::Middleman::Sources.file_cache = {}
|
61
65
|
|
62
|
-
@options = options
|
63
|
-
|
64
66
|
# Set of procs wanting to be notified of changes
|
65
67
|
@on_change_callbacks = ::Hamster::Vector.empty
|
66
68
|
|
@@ -168,7 +170,7 @@ module Middleman
|
|
168
170
|
# @return [Middleman::Sources]
|
169
171
|
Contract Symbol => ::Middleman::Sources
|
170
172
|
def by_type(type)
|
171
|
-
self.class.new @app,
|
173
|
+
self.class.new @app, nil, watchers.select { |d| d.type == type }
|
172
174
|
end
|
173
175
|
|
174
176
|
# Get all files for this collection of watchers.
|
@@ -75,9 +75,10 @@ module Middleman
|
|
75
75
|
@ignored = options.fetch(:ignored, proc { false })
|
76
76
|
@only = Array(options.fetch(:only, []))
|
77
77
|
|
78
|
-
@disable_watcher = app.build?
|
79
|
-
@force_polling =
|
80
|
-
@latency =
|
78
|
+
@disable_watcher = app.build?
|
79
|
+
@force_polling = false
|
80
|
+
@latency = nil
|
81
|
+
@wait_for_delay = nil
|
81
82
|
|
82
83
|
@listener = nil
|
83
84
|
|
@@ -95,13 +96,20 @@ module Middleman
|
|
95
96
|
def update_path(directory)
|
96
97
|
@directory = Pathname(File.expand_path(directory, app.root))
|
97
98
|
|
98
|
-
|
99
|
-
|
100
|
-
|
99
|
+
without_listener_running do
|
100
|
+
update([], @files.values.map { |source_file| source_file[:full_path] })
|
101
|
+
end
|
101
102
|
|
102
103
|
poll_once!
|
104
|
+
end
|
103
105
|
|
104
|
-
|
106
|
+
def update_config(options={})
|
107
|
+
without_listener_running do
|
108
|
+
@disable_watcher = options.fetch(:disable_watcher, false)
|
109
|
+
@force_polling = options.fetch(:force_polling, false)
|
110
|
+
@latency = options.fetch(:latency, nil)
|
111
|
+
@wait_for_delay = options.fetch(:wait_for_delay, nil)
|
112
|
+
end
|
105
113
|
end
|
106
114
|
|
107
115
|
# Stop watching.
|
@@ -160,10 +168,10 @@ module Middleman
|
|
160
168
|
|
161
169
|
config = {
|
162
170
|
force_polling: @force_polling,
|
163
|
-
wait_for_delay: 0.5
|
164
171
|
}
|
165
172
|
|
166
|
-
config[:
|
173
|
+
config[:wait_for_delay] = @wait_for_delay.try(:to_f) || 0.5
|
174
|
+
config[:latency] = @latency.to_f if @latency
|
167
175
|
|
168
176
|
@listener = ::Listen.to(@directory.to_s, config, &method(:on_listener_change))
|
169
177
|
|
@@ -199,7 +207,7 @@ module Middleman
|
|
199
207
|
Contract ArrayOf[Pathname]
|
200
208
|
def poll_once!
|
201
209
|
updated = ::Middleman::Util.all_files_under(@directory.to_s, &method(:should_not_recurse?))
|
202
|
-
removed = @files.keys
|
210
|
+
removed = @files.keys - updated
|
203
211
|
|
204
212
|
result = update(updated, removed)
|
205
213
|
|
@@ -343,5 +351,20 @@ module Middleman
|
|
343
351
|
@only.any? { |reg| file[:relative_path].to_s =~ reg }
|
344
352
|
end
|
345
353
|
end
|
354
|
+
|
355
|
+
private
|
356
|
+
|
357
|
+
def without_listener_running
|
358
|
+
listener_running = @listener && @listener.processing?
|
359
|
+
|
360
|
+
stop_listener! if listener_running
|
361
|
+
|
362
|
+
yield
|
363
|
+
|
364
|
+
if listener_running
|
365
|
+
poll_once!
|
366
|
+
listen!
|
367
|
+
end
|
368
|
+
end
|
346
369
|
end
|
347
370
|
end
|
@@ -64,9 +64,7 @@ module Middleman
|
|
64
64
|
extension_class = ::Middleman::Util.tilt_class(options[:preferred_engine])
|
65
65
|
|
66
66
|
# Get a list of extensions for a preferred engine
|
67
|
-
preferred_engines += ::Tilt.
|
68
|
-
engines.include? extension_class
|
69
|
-
end.keys
|
67
|
+
preferred_engines += ::Tilt.default_mapping.extensions_for(extension_class)
|
70
68
|
end
|
71
69
|
|
72
70
|
preferred_engines << '*'
|
data/middleman-core.gemspec
CHANGED
@@ -16,12 +16,12 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.files = `git ls-files -z`.split("\0")
|
17
17
|
s.test_files = `git ls-files -z -- {fixtures,features}/*`.split("\0")
|
18
18
|
s.require_path = 'lib'
|
19
|
-
s.required_ruby_version = '>= 2.
|
19
|
+
s.required_ruby_version = '>= 2.2.0'
|
20
20
|
|
21
21
|
# Core
|
22
22
|
s.add_dependency('bundler', ['~> 1.1'])
|
23
|
-
s.add_dependency('rack', ['>= 1.4.5', '<
|
24
|
-
s.add_dependency('tilt', ['~>
|
23
|
+
s.add_dependency('rack', ['>= 1.4.5', '< 3'])
|
24
|
+
s.add_dependency('tilt', ['~> 2.0'])
|
25
25
|
s.add_dependency('erubis')
|
26
26
|
s.add_dependency('fast_blank')
|
27
27
|
s.add_dependency('parallel')
|
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
s.add_dependency('dotenv')
|
30
30
|
|
31
31
|
# Helpers
|
32
|
-
s.add_dependency('activesupport', ['
|
32
|
+
s.add_dependency('activesupport', ['>= 4.2', '< 5.1'])
|
33
33
|
s.add_dependency('padrino-helpers', ['~> 0.13.0'])
|
34
34
|
s.add_dependency("addressable", ["~> 2.3"])
|
35
35
|
s.add_dependency('memoist', ['~> 0.14'])
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Reynolds
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-11-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -35,7 +35,7 @@ dependencies:
|
|
35
35
|
version: 1.4.5
|
36
36
|
- - "<"
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version: '
|
38
|
+
version: '3'
|
39
39
|
type: :runtime
|
40
40
|
prerelease: false
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -45,21 +45,21 @@ dependencies:
|
|
45
45
|
version: 1.4.5
|
46
46
|
- - "<"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '3'
|
49
49
|
- !ruby/object:Gem::Dependency
|
50
50
|
name: tilt
|
51
51
|
requirement: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version:
|
55
|
+
version: '2.0'
|
56
56
|
type: :runtime
|
57
57
|
prerelease: false
|
58
58
|
version_requirements: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: '2.0'
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
64
|
name: erubis
|
65
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,16 +134,22 @@ dependencies:
|
|
134
134
|
name: activesupport
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
|
-
- - "
|
137
|
+
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '4.2'
|
140
|
+
- - "<"
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '5.1'
|
140
143
|
type: :runtime
|
141
144
|
prerelease: false
|
142
145
|
version_requirements: !ruby/object:Gem::Requirement
|
143
146
|
requirements:
|
144
|
-
- - "
|
147
|
+
- - ">="
|
145
148
|
- !ruby/object:Gem::Version
|
146
149
|
version: '4.2'
|
150
|
+
- - "<"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '5.1'
|
147
153
|
- !ruby/object:Gem::Dependency
|
148
154
|
name: padrino-helpers
|
149
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -1550,7 +1556,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1550
1556
|
requirements:
|
1551
1557
|
- - ">="
|
1552
1558
|
- !ruby/object:Gem::Version
|
1553
|
-
version: 2.
|
1559
|
+
version: 2.2.0
|
1554
1560
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1555
1561
|
requirements:
|
1556
1562
|
- - ">="
|
@@ -1558,7 +1564,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1558
1564
|
version: '0'
|
1559
1565
|
requirements: []
|
1560
1566
|
rubyforge_project:
|
1561
|
-
rubygems_version: 2.
|
1567
|
+
rubygems_version: 2.5.1
|
1562
1568
|
signing_key:
|
1563
1569
|
specification_version: 4
|
1564
1570
|
summary: Hand-crafted frontend development
|
@@ -2616,4 +2622,3 @@ test_files:
|
|
2616
2622
|
- fixtures/wildcard-directory-index-app/source/index.html.erb
|
2617
2623
|
- fixtures/wildcard-directory-index-app/source/layouts/admin.erb
|
2618
2624
|
- fixtures/wildcard-directory-index-app/source/layouts/layout.erb
|
2619
|
-
has_rdoc:
|