middleman-core 4.0.0.beta.2 → 4.0.0.rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/features/builder.feature +9 -1
- data/features/collections.feature +43 -2
- data/features/data.feature +7 -0
- data/features/extension_hooks.feature +13 -0
- data/features/front-matter-neighbor.feature +0 -11
- data/features/front-matter.feature +0 -22
- data/features/markdown_kramdown_in_slim.feature +42 -0
- data/fixtures/extension-hooks-app/config.rb +39 -0
- data/fixtures/extension-hooks-app/source/index.html.erb +9 -0
- data/fixtures/frontmatter-app/source/front-matter-line-2.html.erb +4 -1
- data/fixtures/frontmatter-neighbor-app/config.rb +3 -3
- data/fixtures/frontmatter-settings-neighbor-app/config.rb +4 -4
- data/fixtures/markdown-in-slim-app/config.rb +0 -0
- data/fixtures/markdown-in-slim-app/source/images/blank.gif +0 -0
- data/fixtures/markdown-in-slim-app/source/link_target.html.markdown +4 -0
- data/fixtures/more-traversal-app/source/layout.erb +1 -1
- data/fixtures/nested-data-app/data/examples/withcontent.yaml +11 -0
- data/fixtures/nested-data-app/source/extracontent.html.haml.erb +4 -0
- data/fixtures/traversal-app/source/layout.erb +1 -1
- data/lib/middleman-core/application.rb +7 -3
- data/lib/middleman-core/builder.rb +2 -1
- data/lib/middleman-core/configuration.rb +0 -1
- data/lib/middleman-core/contracts.rb +0 -10
- data/lib/middleman-core/core_extensions/collections.rb +30 -6
- data/lib/middleman-core/core_extensions/data.rb +4 -4
- data/lib/middleman-core/core_extensions/file_watcher.rb +1 -1
- data/lib/middleman-core/core_extensions/front_matter.rb +10 -104
- data/lib/middleman-core/core_extensions/show_exceptions.rb +1 -1
- data/lib/middleman-core/extension_manager.rb +2 -1
- data/lib/middleman-core/extensions/asset_hash.rb +2 -1
- data/lib/middleman-core/extensions/asset_host.rb +1 -1
- data/lib/middleman-core/extensions/external_pipeline.rb +4 -1
- data/lib/middleman-core/extensions/minify_css.rb +1 -1
- data/lib/middleman-core/extensions/minify_javascript.rb +1 -1
- data/lib/middleman-core/extensions/relative_assets.rb +1 -1
- data/lib/middleman-core/extensions.rb +1 -1
- data/lib/middleman-core/file_renderer.rb +6 -4
- data/lib/middleman-core/meta_pages/sitemap_resource.rb +1 -1
- data/lib/middleman-core/meta_pages/templates/config.html.erb +14 -14
- data/lib/middleman-core/meta_pages.rb +6 -1
- data/lib/middleman-core/preview_server.rb +21 -2
- data/lib/middleman-core/rack.rb +5 -3
- data/lib/middleman-core/renderers/haml.rb +22 -6
- data/lib/middleman-core/renderers/kramdown.rb +10 -3
- data/lib/middleman-core/renderers/liquid.rb +22 -3
- data/lib/middleman-core/renderers/redcarpet.rb +7 -5
- data/lib/middleman-core/renderers/sass.rb +1 -5
- data/lib/middleman-core/renderers/slim.rb +16 -12
- data/lib/middleman-core/sitemap/extensions/ignores.rb +2 -0
- data/lib/middleman-core/sitemap/extensions/on_disk.rb +2 -0
- data/lib/middleman-core/sitemap/extensions/proxies.rb +18 -3
- data/lib/middleman-core/sitemap/extensions/redirects.rb +2 -0
- data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +2 -0
- data/lib/middleman-core/sitemap/resource.rb +24 -17
- data/lib/middleman-core/sitemap/store.rb +1 -0
- data/lib/middleman-core/sources/source_watcher.rb +26 -1
- data/lib/middleman-core/step_definitions/builder_steps.rb +8 -8
- data/lib/middleman-core/step_definitions/middleman_steps.rb +8 -2
- data/lib/middleman-core/step_definitions/server_steps.rb +17 -18
- data/lib/middleman-core/step_definitions.rb +0 -1
- data/lib/middleman-core/template_context.rb +2 -2
- data/lib/middleman-core/util/data.rb +153 -0
- data/lib/middleman-core/util.rb +14 -45
- data/lib/middleman-core/version.rb +1 -1
- data/middleman-core.gemspec +3 -2
- data/spec/middleman-core/util_spec.rb +3 -23
- metadata +37 -26
- data/fixtures/frontmatter-app/source/json-front-matter-2.php.erb +0 -7
- data/fixtures/frontmatter-app/source/json-front-matter-encoding.html.erb +0 -7
- data/fixtures/frontmatter-app/source/json-front-matter-line-2.html.erb +0 -7
- data/fixtures/frontmatter-app/source/json-front-matter.html.erb +0 -6
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter-2.php.erb +0 -2
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter-2.php.erb.frontmatter +0 -4
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter.html.erb +0 -1
- data/fixtures/frontmatter-neighbor-app/source/json-front-matter.html.erb.frontmatter +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71268bae4249190ca97e9b59b2f57fcbabe51640
|
4
|
+
data.tar.gz: 0d27c4d829aff2c5d2a9683d92e41a36c7dfbfd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f09e7350b658d6734deaa92725ad54604fedb9e85ebc0d8d8b993b521625063fadca6fdc0a2053b29280cb5a328b7cd1f3cf3c8ddd84a208214891accc771c5
|
7
|
+
data.tar.gz: 63db8645b7888f204e71a0a19ca8d9a9dc2f1dee8d315100e4756969f58965a9362ee4e26562940d63d78e9bea0e7b234dbd5c60c4eac19b354ad0cf6a1e66ab
|
data/features/builder.feature
CHANGED
@@ -46,4 +46,12 @@ Feature: Builder
|
|
46
46
|
Scenario: Build alias (b)
|
47
47
|
Given a fixture app "large-build-app"
|
48
48
|
When I run `middleman b`
|
49
|
-
Then was successfully built
|
49
|
+
Then was successfully built
|
50
|
+
|
51
|
+
Scenario: Builded text file(ex: html, css, xml, txt)'s permission is 0644
|
52
|
+
Given a successfully built app at "large-build-app"
|
53
|
+
When I cd to "build"
|
54
|
+
Then the mode of filesystem object "index.html" should match "0644"
|
55
|
+
And the mode of filesystem object "stylesheets/static.css" should match "0644"
|
56
|
+
And the mode of filesystem object "feed.xml" should match "0644"
|
57
|
+
And the mode of filesystem object ".htaccess" should match "0644"
|
@@ -98,7 +98,7 @@ Feature: Collections
|
|
98
98
|
And a file named "source/index.html.erb" with:
|
99
99
|
"""
|
100
100
|
<% collection(:articles).each do |article| %>
|
101
|
-
Article: <%= article.data.title || article.
|
101
|
+
Article: <%= article.data.title || article.file_descriptor[:relative_path] %>
|
102
102
|
<% end %>
|
103
103
|
"""
|
104
104
|
Given the Server is running at "collections-app"
|
@@ -192,4 +192,45 @@ Feature: Collections
|
|
192
192
|
Then I should see 'Newer Article Content'
|
193
193
|
When I go to "2.html"
|
194
194
|
Then I should see 'Again'
|
195
|
-
|
195
|
+
|
196
|
+
Scenario: Arbitrary live datasets
|
197
|
+
Given a fixture app "collections-app"
|
198
|
+
And a file named "config.rb" with:
|
199
|
+
"""
|
200
|
+
live {
|
201
|
+
Dir["descriptions/*.txt"]
|
202
|
+
}.each do |description_name|
|
203
|
+
base = File.basename(description_name, '.txt')
|
204
|
+
proxy "#{base}.html", "/description_template.html", locals: {
|
205
|
+
contents: File.read(description_name)
|
206
|
+
}, ignore: true
|
207
|
+
end
|
208
|
+
"""
|
209
|
+
And a file named "source/description_template.html.erb" with:
|
210
|
+
"""
|
211
|
+
<%= contents %>
|
212
|
+
"""
|
213
|
+
And a file named "descriptions/test1.txt" with:
|
214
|
+
"""
|
215
|
+
Test1
|
216
|
+
"""
|
217
|
+
Given the Server is running at "collections-app"
|
218
|
+
When I go to "test1.html"
|
219
|
+
Then I should see 'Test1'
|
220
|
+
When I go to "test2.html"
|
221
|
+
Then I should see 'Not Found'
|
222
|
+
|
223
|
+
When the file "descriptions/test2.txt" has the contents
|
224
|
+
"""
|
225
|
+
Test2
|
226
|
+
"""
|
227
|
+
When I go to "test1.html"
|
228
|
+
Then I should see 'Test1'
|
229
|
+
When I go to "test2.html"
|
230
|
+
Then I should see 'Test2'
|
231
|
+
|
232
|
+
When the file "descriptions/test1.txt" is removed
|
233
|
+
When I go to "test1.html"
|
234
|
+
Then I should see 'Not Found'
|
235
|
+
When I go to "test2.html"
|
236
|
+
Then I should see 'Test2'
|
data/features/data.feature
CHANGED
@@ -51,3 +51,10 @@ Feature: Local Data API
|
|
51
51
|
Then I should see "title1:Hello"
|
52
52
|
Then I should see "title2:More"
|
53
53
|
Then I should see "title3:Stuff"
|
54
|
+
|
55
|
+
Scenario: Using data postscript
|
56
|
+
Given the Server is running at "nested-data-app"
|
57
|
+
When I go to "/extracontent.html"
|
58
|
+
Then I should see "<h1>With Content</h1>"
|
59
|
+
Then I should see '<h2 id="header-2">Header 2</h2>'
|
60
|
+
Then I should see "<p>Paragraph 1</p>"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: Extension author could use some hooks
|
2
|
+
|
3
|
+
Scenario: When build
|
4
|
+
Given a fixture app "extension-hooks-app"
|
5
|
+
When I run `middleman build`
|
6
|
+
Then the exit status should be 0
|
7
|
+
And the output should contain "/// after_configuration ///"
|
8
|
+
And the output should contain "/// ready ///"
|
9
|
+
And the output should contain "/// before_build ///"
|
10
|
+
And the output should contain "/// before ///"
|
11
|
+
And the output should contain "/// before_render ///"
|
12
|
+
And the output should contain "/// after_render ///"
|
13
|
+
And the output should contain "/// after_build ///"
|
@@ -30,17 +30,6 @@ Feature: Neighboring YAML Front Matter
|
|
30
30
|
Then I should not see "---"
|
31
31
|
When I go to "/front-matter-encoding.html.erb.frontmatter"
|
32
32
|
Then I should see "File Not Found"
|
33
|
-
|
34
|
-
Scenario: Rendering html (json)
|
35
|
-
Given the Server is running at "frontmatter-neighbor-app"
|
36
|
-
When I go to "/json-front-matter.html.erb.frontmatter"
|
37
|
-
Then I should see "File Not Found"
|
38
|
-
When I go to "/json-front-matter-2.php"
|
39
|
-
Then I should see "<h1>This is the title</h1>"
|
40
|
-
Then I should see "<?php"
|
41
|
-
Then I should not see ";;;"
|
42
|
-
When I go to "/json-front-matter-2.php.erb.frontmatter"
|
43
|
-
Then I should see "File Not Found"
|
44
33
|
|
45
34
|
Scenario: A template changes frontmatter during preview
|
46
35
|
Given the Server is running at "frontmatter-neighbor-app"
|
@@ -40,28 +40,6 @@ Feature: YAML Front Matter
|
|
40
40
|
When I go to "/front-matter-encoding.html"
|
41
41
|
Then I should see "<h1>This is the title</h1>"
|
42
42
|
Then I should not see "---"
|
43
|
-
|
44
|
-
Scenario: Rendering html (json)
|
45
|
-
Given the Server is running at "frontmatter-app"
|
46
|
-
When I go to "/json-front-matter.html"
|
47
|
-
Then I should see "<h1>This is the title</h1>"
|
48
|
-
Then I should not see ";;;"
|
49
|
-
When I go to "/json-front-matter-2.php"
|
50
|
-
Then I should see "<h1>This is the title</h1>"
|
51
|
-
Then I should see "<?php"
|
52
|
-
Then I should not see ";;;"
|
53
|
-
|
54
|
-
Scenario: JSON not on first line, no encoding
|
55
|
-
Given the Server is running at "frontmatter-app"
|
56
|
-
When I go to "/json-front-matter-line-2.html"
|
57
|
-
Then I should see "<h1></h1>"
|
58
|
-
Then I should see ";;;"
|
59
|
-
|
60
|
-
Scenario: JSON not on first line, with encoding
|
61
|
-
Given the Server is running at "frontmatter-app"
|
62
|
-
When I go to "/json-front-matter-encoding.html"
|
63
|
-
Then I should see "<h1>This is the title</h1>"
|
64
|
-
Then I should not see ";;;"
|
65
43
|
|
66
44
|
Scenario: A template changes frontmatter during preview
|
67
45
|
Given the Server is running at "frontmatter-app"
|
@@ -0,0 +1,42 @@
|
|
1
|
+
Feature: Markdown support in Slim (Kramdown)
|
2
|
+
In order to test support of the Slim markdown filter
|
3
|
+
|
4
|
+
Scenario: Markdown filter in Slim works (with Kramdown)
|
5
|
+
Given a fixture app "markdown-in-slim-app"
|
6
|
+
And a file named "config.rb" with:
|
7
|
+
"""
|
8
|
+
set :markdown_engine, :kramdown
|
9
|
+
activate :directory_indexes
|
10
|
+
"""
|
11
|
+
And a file named "source/markdown_filter.html.slim" with:
|
12
|
+
"""
|
13
|
+
markdown:
|
14
|
+
# H1
|
15
|
+
|
16
|
+
paragraph
|
17
|
+
"""
|
18
|
+
Given the Server is running at "markdown-in-slim-app"
|
19
|
+
When I go to "/markdown_filter/"
|
20
|
+
Then I should see ">H1</h1>"
|
21
|
+
Then I should see "<p>paragraph</p>"
|
22
|
+
|
23
|
+
|
24
|
+
Scenario: Markdown filter in Slim uses our link_to and image_tag helpers (with Kramdown)
|
25
|
+
Given a fixture app "markdown-in-slim-app"
|
26
|
+
And a file named "config.rb" with:
|
27
|
+
"""
|
28
|
+
set :markdown_engine, :kramdown
|
29
|
+
activate :directory_indexes
|
30
|
+
"""
|
31
|
+
And a file named "source/link_and_image.html.slim" with:
|
32
|
+
"""
|
33
|
+
markdown:
|
34
|
+
[A link](/link_target.html)
|
35
|
+
|
36
|
+
{: srcset="image_2x.jpg 2x"}
|
37
|
+
"""
|
38
|
+
Given the Server is running at "markdown-in-slim-app"
|
39
|
+
When I go to "/link_and_image/"
|
40
|
+
Then I should see "/link_target/"
|
41
|
+
Then I should see "/images/image_2x.jpg 2x"
|
42
|
+
Then I should see 'src="/images/blank.gif"'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
set :layout, false
|
2
|
+
|
3
|
+
class MyFeature < Middleman::Extension
|
4
|
+
def initialize(app, options_hash = {}, &block)
|
5
|
+
super
|
6
|
+
|
7
|
+
app.before do
|
8
|
+
puts '/// before ///'
|
9
|
+
end
|
10
|
+
|
11
|
+
app.ready do
|
12
|
+
puts '/// ready ///'
|
13
|
+
end
|
14
|
+
|
15
|
+
app.before_render do |body, path, locs, template_class|
|
16
|
+
puts "/// before_render ///"
|
17
|
+
end
|
18
|
+
|
19
|
+
app.after_render do |content, path, locs, template_class|
|
20
|
+
puts "/// after_render ///"
|
21
|
+
end
|
22
|
+
|
23
|
+
app.before_build do |builder|
|
24
|
+
puts "/// before_build ///"
|
25
|
+
end
|
26
|
+
|
27
|
+
app.after_build do |builder|
|
28
|
+
puts "/// after_build ///"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def after_configuration
|
33
|
+
puts '/// after_configuration ///'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
::Middleman::Extensions.register(:my_feature, MyFeature)
|
38
|
+
|
39
|
+
activate :my_feature
|
@@ -7,15 +7,15 @@ class NeighborFrontmatter < ::Middleman::Extension
|
|
7
7
|
|
8
8
|
def manipulate_resource_list(resources)
|
9
9
|
resources.each do |resource|
|
10
|
-
next unless resource.
|
10
|
+
next unless resource.file_descriptor
|
11
11
|
|
12
|
-
neighbor = "#{resource.
|
12
|
+
neighbor = "#{resource.file_descriptor[:relative_path]}.frontmatter"
|
13
13
|
|
14
14
|
file = app.files.find(:source, neighbor)
|
15
15
|
|
16
16
|
next unless file
|
17
17
|
|
18
|
-
fmdata =
|
18
|
+
fmdata = ::Middleman::Util::Data.parse(file[:full_path], :yaml).first
|
19
19
|
opts = fmdata.extract!(:layout, :layout_engine, :renderer_options, :directory_index, :content_type)
|
20
20
|
opts[:renderer_options].symbolize_keys! if opts.key?(:renderer_options)
|
21
21
|
ignored = fmdata.delete(:ignored)
|
@@ -12,12 +12,12 @@ class NeighborFrontmatter < ::Middleman::Extension
|
|
12
12
|
|
13
13
|
def manipulate_resource_list(resources)
|
14
14
|
resources.each do |resource|
|
15
|
-
next unless resource.
|
16
|
-
next if resource.
|
15
|
+
next unless resource.file_descriptor
|
16
|
+
next if resource.file_descriptor[:relative_path].extname == '.frontmatter'
|
17
17
|
|
18
18
|
[
|
19
19
|
"#{resource.url.sub(/^\//, '')}.frontmatter",
|
20
|
-
"#{resource.
|
20
|
+
"#{resource.file_descriptor[:relative_path]}.frontmatter"
|
21
21
|
].each do |n|
|
22
22
|
file = app.files.find(:source, n)
|
23
23
|
apply_neighbor_data(resource, file) if file
|
@@ -26,7 +26,7 @@ class NeighborFrontmatter < ::Middleman::Extension
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def apply_neighbor_data(resource, file)
|
29
|
-
fmdata =
|
29
|
+
fmdata = ::Middleman::Util::Data.parse(file[:full_path], :yaml).first
|
30
30
|
opts = fmdata.extract!(:layout, :layout_engine, :renderer_options, :directory_index, :content_type)
|
31
31
|
opts[:renderer_options].symbolize_keys! if opts.key?(:renderer_options)
|
32
32
|
ignored = fmdata.delete(:ignored)
|
File without changes
|
Binary file
|
@@ -92,13 +92,17 @@ module Middleman
|
|
92
92
|
# @return [String]
|
93
93
|
define_setting :source, 'source', 'Name of the source directory'
|
94
94
|
|
95
|
+
# If we should exit before ready event.
|
96
|
+
# @return [Boolean]
|
97
|
+
define_setting :exit_before_ready, false, 'If we should exit before ready event.'
|
98
|
+
|
95
99
|
# Middleman mode. Defaults to :server, set to :build by the build process
|
96
100
|
# @return [String]
|
97
|
-
define_setting :mode,
|
101
|
+
define_setting :mode, :server, 'Middleman mode. Defaults to :server'
|
98
102
|
|
99
103
|
# Middleman environment. Defaults to :development
|
100
104
|
# @return [String]
|
101
|
-
define_setting :environment, :development, 'Middleman environment. Defaults to :development'
|
105
|
+
define_setting :environment, ((ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :development), 'Middleman environment. Defaults to :development'
|
102
106
|
|
103
107
|
# Which file should be used for directory indexes
|
104
108
|
# @return [String]
|
@@ -274,7 +278,7 @@ module Middleman
|
|
274
278
|
execute_callbacks(:after_configuration)
|
275
279
|
|
276
280
|
# Everything is stable
|
277
|
-
execute_callbacks(:ready)
|
281
|
+
execute_callbacks(:ready) unless config[:exit_before_ready]
|
278
282
|
end
|
279
283
|
|
280
284
|
# Eval config
|
@@ -130,6 +130,7 @@ module Middleman
|
|
130
130
|
file.binmode
|
131
131
|
file.write(contents)
|
132
132
|
file.close
|
133
|
+
File.chmod(0644, file)
|
133
134
|
file
|
134
135
|
end
|
135
136
|
|
@@ -168,7 +169,7 @@ module Middleman
|
|
168
169
|
|
169
170
|
begin
|
170
171
|
if resource.binary?
|
171
|
-
export_file!(output_file, resource.
|
172
|
+
export_file!(output_file, resource.file_descriptor[:full_path])
|
172
173
|
else
|
173
174
|
response = @rack.get(URI.escape(resource.request_path))
|
174
175
|
|
@@ -33,7 +33,6 @@ module Middleman
|
|
33
33
|
# Set the value of a setting by key. Creates the setting if it doesn't exist.
|
34
34
|
# @param [Symbol] key
|
35
35
|
# @param [Object] val
|
36
|
-
# rubocop:disable UselessSetterCall
|
37
36
|
def []=(key, val)
|
38
37
|
setting_obj = setting(key) || define_setting(key)
|
39
38
|
setting_obj.value = val
|
@@ -18,16 +18,6 @@ if ENV['TEST'] || ENV['CONTRACTS'] == 'true'
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
class Frozen < CallableClass
|
22
|
-
def initialize(contract)
|
23
|
-
@contract = contract
|
24
|
-
end
|
25
|
-
|
26
|
-
def valid?(val)
|
27
|
-
(val.frozen? || val.nil? || [::TrueClass, ::FalseClass, ::Fixnum].include?(val.class)) && Contract.valid?(val, @contract)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
21
|
VectorOf = Contracts::CollectionOf::Factory.new(::Hamster::Vector)
|
32
22
|
ResourceList = Contracts::ArrayOf[IsA['Middleman::Sitemap::Resource']]
|
33
23
|
end
|
@@ -16,12 +16,13 @@ module Middleman
|
|
16
16
|
# gets a chance to modify any new resources that get added.
|
17
17
|
self.resource_list_manipulator_priority = 110
|
18
18
|
|
19
|
-
attr_accessor :
|
19
|
+
attr_accessor :leaves
|
20
20
|
|
21
21
|
# Expose `resources`, `data`, and `collection` to config.
|
22
22
|
expose_to_config resources: :sitemap_collector,
|
23
23
|
data: :data_collector,
|
24
|
-
collection: :register_collector
|
24
|
+
collection: :register_collector,
|
25
|
+
live: :live_collector
|
25
26
|
|
26
27
|
# Exposes `collection` to templates
|
27
28
|
expose_to_template collection: :collector_value
|
@@ -39,8 +40,7 @@ module Middleman
|
|
39
40
|
@collectors_by_name = {}
|
40
41
|
@values_by_name = {}
|
41
42
|
|
42
|
-
@
|
43
|
-
@data_collector = LazyCollectorRoot.new(self)
|
43
|
+
@collector_roots = []
|
44
44
|
end
|
45
45
|
|
46
46
|
def before_configuration
|
@@ -52,6 +52,28 @@ module Middleman
|
|
52
52
|
@collectors_by_name[label] = endpoint
|
53
53
|
end
|
54
54
|
|
55
|
+
Contract LazyCollectorRoot
|
56
|
+
def sitemap_collector
|
57
|
+
live_collector { |_, resources| resources }
|
58
|
+
end
|
59
|
+
|
60
|
+
Contract LazyCollectorRoot
|
61
|
+
def data_collector
|
62
|
+
live_collector { |app, _| app.data }
|
63
|
+
end
|
64
|
+
|
65
|
+
Contract Proc => LazyCollectorRoot
|
66
|
+
def live_collector(&block)
|
67
|
+
root = LazyCollectorRoot.new(self)
|
68
|
+
|
69
|
+
@collector_roots << {
|
70
|
+
root: root,
|
71
|
+
block: block
|
72
|
+
}
|
73
|
+
|
74
|
+
root
|
75
|
+
end
|
76
|
+
|
55
77
|
Contract Symbol => Any
|
56
78
|
def collector_value(label)
|
57
79
|
@values_by_name[label]
|
@@ -59,8 +81,10 @@ module Middleman
|
|
59
81
|
|
60
82
|
Contract ResourceList => ResourceList
|
61
83
|
def manipulate_resource_list(resources)
|
62
|
-
@
|
63
|
-
|
84
|
+
@collector_roots.each do |pair|
|
85
|
+
dataset = pair[:block].call(app, resources)
|
86
|
+
pair[:root].realize!(dataset)
|
87
|
+
end
|
64
88
|
|
65
89
|
ctx = StepContext.new
|
66
90
|
leaves = @leaves.dup
|
@@ -1,6 +1,5 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'active_support/json'
|
3
1
|
require 'middleman-core/contracts'
|
2
|
+
require 'middleman-core/util/data'
|
4
3
|
|
5
4
|
module Middleman
|
6
5
|
module CoreExtensions
|
@@ -100,9 +99,10 @@ module Middleman
|
|
100
99
|
basename = File.basename(data_path, extension)
|
101
100
|
|
102
101
|
if %w(.yaml .yml).include?(extension)
|
103
|
-
data = ::
|
102
|
+
data, postscript = ::Middleman::Util::Data.parse(file[:full_path], :yaml)
|
103
|
+
data[:postscript] = postscript if !postscript.nil? && data.is_a?(Hash)
|
104
104
|
elsif extension == '.json'
|
105
|
-
data = ::
|
105
|
+
data, _postscript = ::Middleman::Util::Data.parse(file[:full_path], :json)
|
106
106
|
else
|
107
107
|
return
|
108
108
|
end
|
@@ -30,7 +30,7 @@ module Middleman
|
|
30
30
|
# Setup source collection.
|
31
31
|
@sources = ::Middleman::Sources.new(app,
|
32
32
|
disable_watcher: app.config[:watcher_disable],
|
33
|
-
force_polling: app.config[:
|
33
|
+
force_polling: app.config[:watcher_force_polling],
|
34
34
|
latency: app.config[:watcher_latency])
|
35
35
|
|
36
36
|
# Add default ignores.
|