middleman-core 4.0.0.beta.2 → 4.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/features/builder.feature +9 -1
  3. data/features/collections.feature +43 -2
  4. data/features/data.feature +7 -0
  5. data/features/extension_hooks.feature +13 -0
  6. data/features/front-matter-neighbor.feature +0 -11
  7. data/features/front-matter.feature +0 -22
  8. data/features/markdown_kramdown_in_slim.feature +42 -0
  9. data/fixtures/extension-hooks-app/config.rb +39 -0
  10. data/fixtures/extension-hooks-app/source/index.html.erb +9 -0
  11. data/fixtures/frontmatter-app/source/front-matter-line-2.html.erb +4 -1
  12. data/fixtures/frontmatter-neighbor-app/config.rb +3 -3
  13. data/fixtures/frontmatter-settings-neighbor-app/config.rb +4 -4
  14. data/fixtures/markdown-in-slim-app/config.rb +0 -0
  15. data/fixtures/markdown-in-slim-app/source/images/blank.gif +0 -0
  16. data/fixtures/markdown-in-slim-app/source/link_target.html.markdown +4 -0
  17. data/fixtures/more-traversal-app/source/layout.erb +1 -1
  18. data/fixtures/nested-data-app/data/examples/withcontent.yaml +11 -0
  19. data/fixtures/nested-data-app/source/extracontent.html.haml.erb +4 -0
  20. data/fixtures/traversal-app/source/layout.erb +1 -1
  21. data/lib/middleman-core/application.rb +7 -3
  22. data/lib/middleman-core/builder.rb +2 -1
  23. data/lib/middleman-core/configuration.rb +0 -1
  24. data/lib/middleman-core/contracts.rb +0 -10
  25. data/lib/middleman-core/core_extensions/collections.rb +30 -6
  26. data/lib/middleman-core/core_extensions/data.rb +4 -4
  27. data/lib/middleman-core/core_extensions/file_watcher.rb +1 -1
  28. data/lib/middleman-core/core_extensions/front_matter.rb +10 -104
  29. data/lib/middleman-core/core_extensions/show_exceptions.rb +1 -1
  30. data/lib/middleman-core/extension_manager.rb +2 -1
  31. data/lib/middleman-core/extensions/asset_hash.rb +2 -1
  32. data/lib/middleman-core/extensions/asset_host.rb +1 -1
  33. data/lib/middleman-core/extensions/external_pipeline.rb +4 -1
  34. data/lib/middleman-core/extensions/minify_css.rb +1 -1
  35. data/lib/middleman-core/extensions/minify_javascript.rb +1 -1
  36. data/lib/middleman-core/extensions/relative_assets.rb +1 -1
  37. data/lib/middleman-core/extensions.rb +1 -1
  38. data/lib/middleman-core/file_renderer.rb +6 -4
  39. data/lib/middleman-core/meta_pages/sitemap_resource.rb +1 -1
  40. data/lib/middleman-core/meta_pages/templates/config.html.erb +14 -14
  41. data/lib/middleman-core/meta_pages.rb +6 -1
  42. data/lib/middleman-core/preview_server.rb +21 -2
  43. data/lib/middleman-core/rack.rb +5 -3
  44. data/lib/middleman-core/renderers/haml.rb +22 -6
  45. data/lib/middleman-core/renderers/kramdown.rb +10 -3
  46. data/lib/middleman-core/renderers/liquid.rb +22 -3
  47. data/lib/middleman-core/renderers/redcarpet.rb +7 -5
  48. data/lib/middleman-core/renderers/sass.rb +1 -5
  49. data/lib/middleman-core/renderers/slim.rb +16 -12
  50. data/lib/middleman-core/sitemap/extensions/ignores.rb +2 -0
  51. data/lib/middleman-core/sitemap/extensions/on_disk.rb +2 -0
  52. data/lib/middleman-core/sitemap/extensions/proxies.rb +18 -3
  53. data/lib/middleman-core/sitemap/extensions/redirects.rb +2 -0
  54. data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +2 -0
  55. data/lib/middleman-core/sitemap/resource.rb +24 -17
  56. data/lib/middleman-core/sitemap/store.rb +1 -0
  57. data/lib/middleman-core/sources/source_watcher.rb +26 -1
  58. data/lib/middleman-core/step_definitions/builder_steps.rb +8 -8
  59. data/lib/middleman-core/step_definitions/middleman_steps.rb +8 -2
  60. data/lib/middleman-core/step_definitions/server_steps.rb +17 -18
  61. data/lib/middleman-core/step_definitions.rb +0 -1
  62. data/lib/middleman-core/template_context.rb +2 -2
  63. data/lib/middleman-core/util/data.rb +153 -0
  64. data/lib/middleman-core/util.rb +14 -45
  65. data/lib/middleman-core/version.rb +1 -1
  66. data/middleman-core.gemspec +3 -2
  67. data/spec/middleman-core/util_spec.rb +3 -23
  68. metadata +37 -26
  69. data/fixtures/frontmatter-app/source/json-front-matter-2.php.erb +0 -7
  70. data/fixtures/frontmatter-app/source/json-front-matter-encoding.html.erb +0 -7
  71. data/fixtures/frontmatter-app/source/json-front-matter-line-2.html.erb +0 -7
  72. data/fixtures/frontmatter-app/source/json-front-matter.html.erb +0 -6
  73. data/fixtures/frontmatter-neighbor-app/source/json-front-matter-2.php.erb +0 -2
  74. data/fixtures/frontmatter-neighbor-app/source/json-front-matter-2.php.erb.frontmatter +0 -4
  75. data/fixtures/frontmatter-neighbor-app/source/json-front-matter.html.erb +0 -1
  76. 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: e102996c549a19735369428a6ca1fb6d2d9a735b
4
- data.tar.gz: bd3b7074ef91dbef4d80491e1b67c41117ff0699
3
+ metadata.gz: 71268bae4249190ca97e9b59b2f57fcbabe51640
4
+ data.tar.gz: 0d27c4d829aff2c5d2a9683d92e41a36c7dfbfd6
5
5
  SHA512:
6
- metadata.gz: 52f6338f6da3da3c1f113826597376f95f0bf7948f6f01a512a924949eb9f8efc7784f4a082f6f32b3892e9f88d3ad6258e662ac297f14bf0b98547faaea2909
7
- data.tar.gz: 44a55d6fcff77e9136d7701b15cfe4104eae02de1dc1f8d73698f02eddb5a5a089f2c201a7c2d36e680df845f2550edc9c6aa171258c61271856732fdb9fad32
6
+ metadata.gz: 7f09e7350b658d6734deaa92725ad54604fedb9e85ebc0d8d8b993b521625063fadca6fdc0a2053b29280cb5a328b7cd1f3cf3c8ddd84a208214891accc771c5
7
+ data.tar.gz: 63db8645b7888f204e71a0a19ca8d9a9dc2f1dee8d315100e4756969f58965a9362ee4e26562940d63d78e9bea0e7b234dbd5c60c4eac19b354ad0cf6a1e66ab
@@ -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.source_file[:relative_path] %>
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'
@@ -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
+ ![image](blank.gif){: 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
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <meta charset="utf-8">
4
+ <title>extension-hooks-app</title>
5
+ </head>
6
+ <body>
7
+ <h1>extension-hooks-app</h1>
8
+ </body>
9
+ </html>
@@ -1,7 +1,10 @@
1
1
  <h2> Test</h2>
2
+
3
+ <h1><%= current_page.data.title %></h1>
4
+
2
5
  ---
3
6
  layout: false
4
7
  title: This is the title
5
8
  ---
6
9
 
7
- <h1><%= current_page.data.title %></h1>
10
+ <div>Stuff</div>
@@ -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.source_file
10
+ next unless resource.file_descriptor
11
11
 
12
- neighbor = "#{resource.source_file[:relative_path]}.frontmatter"
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 = app.extensions[:front_matter].frontmatter_and_content(file[:full_path]).first
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.source_file
16
- next if resource.source_file[:relative_path].extname == '.frontmatter'
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.source_file[:relative_path]}.frontmatter"
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 = app.extensions[:front_matter].frontmatter_and_content(file[:full_path]).first
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
@@ -0,0 +1,4 @@
1
+ ---
2
+ layout: false
3
+ ---
4
+ Hello World
@@ -1,6 +1,6 @@
1
1
  Path: <%= current_page.path %>
2
2
 
3
- Source: <%= current_page.source_file[:full_path].sub(root + "/", "") %>
3
+ Source: <%= current_page.file_descriptor[:full_path].sub(root + "/", "") %>
4
4
 
5
5
  <% if current_page.parent %>
6
6
  Parent: <%= current_page.parent.path %>
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: "With Content"
3
+ ---
4
+
5
+ ## Header 2
6
+
7
+ Paragraph 1
8
+
9
+ Paragraph 2
10
+
11
+ ### Header 3
@@ -0,0 +1,4 @@
1
+ %h1= data.examples.withcontent.name
2
+
3
+ :markdown
4
+ <%= data.examples.withcontent.postscript.gsub("\n", "\n\s\s") %>
@@ -1,6 +1,6 @@
1
1
  Path: <%= current_page.path %>
2
2
 
3
- Source: <%= current_page.source_file[:full_path].sub(root + "/", "") %>
3
+ Source: <%= current_page.file_descriptor[:full_path].sub(root + "/", "") %>
4
4
 
5
5
  <% if current_page.parent %>
6
6
  Parent: <%= current_page.parent.path %>
@@ -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, ((ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :server), 'Middleman mode. Defaults to :server'
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.source_file[:full_path])
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 :sitemap_collector, :data_collector, :leaves
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
- @sitemap_collector = LazyCollectorRoot.new(self)
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
- @sitemap_collector.realize!(resources)
63
- @data_collector.realize!(app.data)
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 = ::YAML.load_file(file[:full_path])
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 = ::ActiveSupport::JSON.decode(file[:full_path].read)
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[:force_polling],
33
+ force_polling: app.config[:watcher_force_polling],
34
34
  latency: app.config[:watcher_latency])
35
35
 
36
36
  # Add default ignores.