middleman-core 4.1.0.rc.2 → 4.1.0
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/asset_hash.feature +30 -32
- data/features/asset_host.feature +2 -0
- data/features/gzip.feature +1 -1
- data/features/import_files.feature +0 -2
- data/features/nested_layouts.feature +20 -17
- data/fixtures/asset-host-app/source/javascripts/asset_host.js +2 -0
- data/fixtures/frontmatter-neighbor-app/config.rb +1 -1
- data/fixtures/frontmatter-settings-neighbor-app/config.rb +1 -1
- data/fixtures/nested-layout-app/source/layouts/inner.erb +5 -2
- data/fixtures/nested-layout-app/source/layouts/inner_haml.haml +6 -2
- data/fixtures/nested-layout-app/source/layouts/inner_slim.slim +6 -2
- data/fixtures/nested-layout-app/source/layouts/master.erb +7 -1
- data/fixtures/nested-layout-app/source/layouts/master_haml.haml +5 -1
- data/fixtures/nested-layout-app/source/layouts/master_slim.slim +5 -1
- data/fixtures/nested-layout-app/source/layouts/outer.erb +6 -2
- data/fixtures/nested-layout-app/source/layouts/outer_haml.haml +5 -1
- data/fixtures/nested-layout-app/source/layouts/outer_slim.slim +5 -1
- data/lib/middleman-core.rb +0 -3
- data/lib/middleman-core/application.rb +7 -9
- data/lib/middleman-core/builder.rb +88 -44
- data/lib/middleman-core/contracts.rb +102 -13
- data/lib/middleman-core/core_extensions/data.rb +15 -10
- data/lib/middleman-core/core_extensions/default_helpers.rb +15 -6
- data/lib/middleman-core/core_extensions/file_watcher.rb +2 -2
- data/lib/middleman-core/core_extensions/front_matter.rb +11 -3
- data/lib/middleman-core/core_extensions/i18n.rb +1 -1
- data/lib/middleman-core/core_extensions/inline_url_rewriter.rb +2 -2
- data/lib/middleman-core/extension.rb +1 -1
- data/lib/middleman-core/extensions.rb +1 -1
- data/lib/middleman-core/extensions/asset_hash.rb +1 -1
- data/lib/middleman-core/extensions/asset_host.rb +1 -1
- data/lib/middleman-core/extensions/automatic_image_sizes.rb +1 -1
- data/lib/middleman-core/extensions/cache_buster.rb +1 -1
- data/lib/middleman-core/extensions/external_pipeline.rb +2 -1
- data/lib/middleman-core/extensions/gzip.rb +2 -2
- 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/file_renderer.rb +12 -9
- data/lib/middleman-core/logger.rb +1 -0
- data/lib/middleman-core/preview_server.rb +14 -14
- data/lib/middleman-core/renderers/haml.rb +3 -1
- data/lib/middleman-core/renderers/less.rb +1 -1
- data/lib/middleman-core/renderers/liquid.rb +1 -1
- data/lib/middleman-core/renderers/sass.rb +7 -2
- data/lib/middleman-core/sitemap/extensions/ignores.rb +2 -2
- data/lib/middleman-core/sitemap/extensions/import.rb +3 -1
- data/lib/middleman-core/sitemap/resource.rb +7 -6
- data/lib/middleman-core/sources.rb +30 -13
- data/lib/middleman-core/sources/source_watcher.rb +50 -12
- data/lib/middleman-core/step_definitions/middleman_steps.rb +2 -2
- data/lib/middleman-core/template_context.rb +1 -1
- data/lib/middleman-core/template_renderer.rb +13 -4
- data/lib/middleman-core/util.rb +6 -606
- data/lib/middleman-core/util/binary.rb +79 -0
- data/lib/middleman-core/util/data.rb +37 -8
- data/lib/middleman-core/util/files.rb +134 -0
- data/lib/middleman-core/util/paths.rb +251 -0
- data/lib/middleman-core/util/rack.rb +52 -0
- data/lib/middleman-core/util/uri_templates.rb +97 -0
- data/lib/middleman-core/version.rb +1 -1
- data/middleman-core.gemspec +1 -0
- metadata +25 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c31c9e2ea6918f6d0842f1cb1e04dc8120e4b8c4
|
4
|
+
data.tar.gz: e2f48f74a4a98aafe83b2adaeabf9aeb8eaab409
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a5e0965f5bca9268cdc5f65af629c9e49fff7f7f7df3468f8d3232135d00dbb3d6b9b9f6d73ed3b70d1ca91827aefdcf111a9c9558c7b14c76b7ab19fb0c61d
|
7
|
+
data.tar.gz: b2e0745dc44d43ef904c448347ef46f70f62ad25a241ebd23d7d97c43ea080777a327ee2075dce1f967d83af3528a8b3cebb0d370ff08baf80f917c55f316ca4
|
data/features/asset_hash.feature
CHANGED
@@ -63,8 +63,8 @@ Feature: Assets get file hashes appended to them and references to them are upda
|
|
63
63
|
Given the Server is running at "asset-hash-app"
|
64
64
|
When I go to "/"
|
65
65
|
Then I should see 'href="apple-touch-icon.png"'
|
66
|
-
And I should see 'href="stylesheets/site-
|
67
|
-
And I should see 'href="stylesheets/fragment-
|
66
|
+
And I should see 'href="stylesheets/site-d1a750ca.css"'
|
67
|
+
And I should see 'href="stylesheets/fragment-99b76247.css"'
|
68
68
|
And I should see 'src="javascripts/application-1d8d5276.js"'
|
69
69
|
And I should see 'src="images/100px-5fd6fb90.jpg"'
|
70
70
|
And I should see 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"'
|
@@ -72,11 +72,11 @@ Feature: Assets get file hashes appended to them and references to them are upda
|
|
72
72
|
And I should see 'src="images/100px-5fd6fb90.jpg?#test"'
|
73
73
|
And I should see 'src="images/100px-5fd6fb90.jpg#test"'
|
74
74
|
When I go to "/subdir/"
|
75
|
-
Then I should see 'href="../stylesheets/site-
|
75
|
+
Then I should see 'href="../stylesheets/site-d1a750ca.css"'
|
76
76
|
And I should see 'src="../javascripts/application-1d8d5276.js"'
|
77
77
|
And I should see 'src="../images/100px-5fd6fb90.jpg"'
|
78
78
|
When I go to "/other/"
|
79
|
-
Then I should see 'href="../stylesheets/site-
|
79
|
+
Then I should see 'href="../stylesheets/site-d1a750ca.css"'
|
80
80
|
And I should see 'src="../javascripts/application-1d8d5276.js"'
|
81
81
|
And I should see 'src="../images/100px-5fd6fb90.jpg"'
|
82
82
|
And I should see 'src="../images/100px-5fd6fb90.jpg?test"'
|
@@ -84,8 +84,8 @@ Feature: Assets get file hashes appended to them and references to them are upda
|
|
84
84
|
And I should see 'src="../images/100px-5fd6fb90.jpg#test"'
|
85
85
|
When I go to "/javascripts/application-1d8d5276.js"
|
86
86
|
Then I should see "img.src = '/images/100px-5fd6fb90.jpg'"
|
87
|
-
When I go to "/stylesheets/site-
|
88
|
-
Then I should see 'background-image: url("../images/100px-5fd6fb90.jpg")'
|
87
|
+
When I go to "/stylesheets/site-d1a750ca.css"
|
88
|
+
Then I should see 'background-image: url("../images/100px-5fd6fb90.jpg");'
|
89
89
|
When I go to "/api.json"
|
90
90
|
Then I should see 'images/100px-5fd6fb90.gif'
|
91
91
|
And I should see 'images/100px-5fd6fb90.jpg'
|
@@ -94,11 +94,11 @@ Feature: Assets get file hashes appended to them and references to them are upda
|
|
94
94
|
Then I should see 'images/100px-5fd6fb90.gif'
|
95
95
|
And I should see 'images/100px-5fd6fb90.jpg'
|
96
96
|
And I should see 'images/100px-1242c368.png'
|
97
|
-
When I go to "/stylesheets/fragment-
|
98
|
-
And I should see 'url("../images/100px-5fd6fb90.jpg")'
|
99
|
-
And I should see 'url("../images/100px-5fd6fb90.jpg?test")'
|
100
|
-
And I should see 'url("../images/100px-5fd6fb90.jpg?#test")'
|
101
|
-
And I should see 'url("../images/100px-5fd6fb90.jpg#test")'
|
97
|
+
When I go to "/stylesheets/fragment-99b76247.css"
|
98
|
+
And I should see 'url("../images/100px-5fd6fb90.jpg");'
|
99
|
+
And I should see 'url("../images/100px-5fd6fb90.jpg?test");'
|
100
|
+
And I should see 'url("../images/100px-5fd6fb90.jpg?#test");'
|
101
|
+
And I should see 'url("../images/100px-5fd6fb90.jpg#test");'
|
102
102
|
|
103
103
|
Scenario: Hashed assets work with Slim
|
104
104
|
Given the Server is running at "asset-hash-app"
|
@@ -117,26 +117,26 @@ Feature: Assets get file hashes appended to them and references to them are upda
|
|
117
117
|
"""
|
118
118
|
Given the Server is running at "asset-hash-host-app"
|
119
119
|
When I go to "/"
|
120
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
121
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/fragment-
|
120
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-210612a0.css"'
|
121
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/fragment-7000b132.css"'
|
122
122
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
123
123
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?test"'
|
124
124
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test"'
|
125
125
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg#test"'
|
126
126
|
When I go to "/subdir/"
|
127
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
127
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-210612a0.css"'
|
128
128
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
129
129
|
When I go to "/other/"
|
130
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
130
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-210612a0.css"'
|
131
131
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
132
132
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?test"'
|
133
133
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test"'
|
134
134
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg#test"'
|
135
|
-
When I go to "/stylesheets/fragment-
|
136
|
-
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg")'
|
137
|
-
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg?test")'
|
138
|
-
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test")'
|
139
|
-
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg#test")'
|
135
|
+
When I go to "/stylesheets/fragment-7000b132.css"
|
136
|
+
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg");'
|
137
|
+
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg?test");'
|
138
|
+
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test");'
|
139
|
+
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg#test");'
|
140
140
|
|
141
141
|
Scenario: Enabling an asset host still produces hashed files and references (host first)
|
142
142
|
Given a fixture app "asset-hash-host-app"
|
@@ -148,22 +148,22 @@ Feature: Assets get file hashes appended to them and references to them are upda
|
|
148
148
|
"""
|
149
149
|
Given the Server is running at "asset-hash-host-app"
|
150
150
|
When I go to "/"
|
151
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
152
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/fragment-
|
151
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-210612a0.css"'
|
152
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/fragment-7000b132.css"'
|
153
153
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
154
154
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?test"'
|
155
155
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test"'
|
156
156
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg#test"'
|
157
157
|
When I go to "/subdir/"
|
158
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
158
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-210612a0.css"'
|
159
159
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
160
160
|
When I go to "/other/"
|
161
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
161
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-210612a0.css"'
|
162
162
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
163
163
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?test"'
|
164
164
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test"'
|
165
165
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg#test"'
|
166
|
-
When I go to "/stylesheets/fragment-
|
166
|
+
When I go to "/stylesheets/fragment-7000b132.css"
|
167
167
|
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg")'
|
168
168
|
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg?test")'
|
169
169
|
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test")'
|
@@ -177,14 +177,14 @@ Feature: Assets get file hashes appended to them and references to them are upda
|
|
177
177
|
font-size: 14px
|
178
178
|
"""
|
179
179
|
When I go to "/partials/"
|
180
|
-
Then I should see 'href="../stylesheets/uses_partials-
|
180
|
+
Then I should see 'href="../stylesheets/uses_partials-4d4e34e6.css'
|
181
181
|
And the file "source/stylesheets/_partial.sass" has the contents
|
182
182
|
"""
|
183
183
|
body
|
184
184
|
font-size: 18px !important
|
185
185
|
"""
|
186
186
|
When I go to "/partials/"
|
187
|
-
Then I should see 'href="../stylesheets/uses_partials-
|
187
|
+
Then I should see 'href="../stylesheets/uses_partials-ec347271.css'
|
188
188
|
|
189
189
|
Scenario: The asset hash should change when a Rack-based filter changes
|
190
190
|
Given a fixture app "asset-hash-app"
|
@@ -198,12 +198,10 @@ Feature: Assets get file hashes appended to them and references to them are upda
|
|
198
198
|
"""
|
199
199
|
Given the Server is running at "asset-hash-app"
|
200
200
|
When I go to "/"
|
201
|
-
Then I should see 'href="stylesheets/site-
|
202
|
-
When I go to "stylesheets/site-
|
203
|
-
Then I should see 'background-image'
|
201
|
+
Then I should see 'href="stylesheets/site-5ad7def0.css'
|
202
|
+
When I go to "stylesheets/site-5ad7def0.css"
|
203
|
+
Then I should see 'background-image: url("../images/100px-5fd6fb90.jpg")'
|
204
204
|
Then I should see 'Added by Rack filter'
|
205
|
-
When I go to "stylesheets/site-7474cadd.css"
|
206
|
-
Then I should see 'Not Found'
|
207
205
|
|
208
206
|
Scenario: Hashed-asset files are not produced for ignored paths
|
209
207
|
Given a fixture app "asset-hash-app"
|
data/features/asset_host.feature
CHANGED
@@ -17,6 +17,8 @@ Feature: Alternate between multiple asset hosts
|
|
17
17
|
When I go to "/stylesheets/asset_host.css"
|
18
18
|
Then I should see content matching %r{http://assets1.example.com/}
|
19
19
|
Then I should not see content matching %r{http://assets1.example.com//}
|
20
|
+
When I go to "/javascripts/asset_host.js"
|
21
|
+
Then I should not see content matching %r{http://assets1.example.com/}
|
20
22
|
|
21
23
|
Scenario: Set proc host with inline-option
|
22
24
|
Given a fixture app "asset-host-app"
|
data/features/gzip.feature
CHANGED
@@ -22,7 +22,7 @@ Feature: GZIP assets during build
|
|
22
22
|
Given a fixture app "gzip-app"
|
23
23
|
And a file named "config.rb" with:
|
24
24
|
"""
|
25
|
-
activate :gzip, exts: %w(.
|
25
|
+
activate :gzip, exts: %w(.htm .html .js .xhtml)
|
26
26
|
"""
|
27
27
|
And a successfully built app at "gzip-app"
|
28
28
|
Then the following files should exist:
|
@@ -5,37 +5,37 @@ Feature: Allow nesting of layouts
|
|
5
5
|
When I go to "/index.html"
|
6
6
|
Then I should see:
|
7
7
|
"""
|
8
|
-
Master
|
8
|
+
Master Erb
|
9
9
|
<h1>Index Title</h1>
|
10
|
-
Outer
|
11
|
-
Inner
|
10
|
+
I am Outer
|
11
|
+
I am Inner
|
12
12
|
Template
|
13
|
-
|
13
|
+
|
14
14
|
"""
|
15
15
|
When I go to "/another.html"
|
16
16
|
Then I should see:
|
17
17
|
"""
|
18
|
-
Master
|
18
|
+
Master Erb
|
19
19
|
<h1>New Article Title</h1>
|
20
|
-
Outer
|
21
|
-
Inner
|
20
|
+
I am Outer
|
21
|
+
I am Inner
|
22
22
|
<p>The Article Content</p>
|
23
23
|
"""
|
24
|
-
|
24
|
+
|
25
25
|
Scenario: A page uses an inner layout when uses an outer layout (slim)
|
26
26
|
Given the Server is running at "nested-layout-app"
|
27
27
|
When I go to "/slim-test.html"
|
28
|
-
Then I should see "<h1>Master</h1><p>New Article Title</p><div><h2>Outer</h2><h3>Inner</h3><p>The Article Content</p>"
|
29
|
-
|
28
|
+
Then I should see "<h1>Master Slim</h1><p>New Article Title</p><div><h2>I am Outer</h2><h3>I am Inner</h3><p>The Article Content</p>"
|
29
|
+
|
30
30
|
Scenario: A page uses an inner layout when uses an outer layout (haml)
|
31
31
|
Given the Server is running at "nested-layout-app"
|
32
32
|
When I go to "/haml-test.html"
|
33
33
|
Then I should see:
|
34
34
|
"""
|
35
|
-
Master
|
35
|
+
Master Haml
|
36
36
|
<h1>New Article Title</h1>
|
37
|
-
Outer
|
38
|
-
Inner
|
37
|
+
I am Outer
|
38
|
+
I am Inner
|
39
39
|
<p>The Article Content</p>
|
40
40
|
"""
|
41
41
|
|
@@ -43,13 +43,16 @@ Feature: Allow nesting of layouts
|
|
43
43
|
Given the Server is running at "nested-layout-app"
|
44
44
|
When I go to "/data-one.html"
|
45
45
|
Then I should see "Page Number One"
|
46
|
-
And I should see "
|
46
|
+
And I should see "Page #1"
|
47
|
+
And I should see "I am Inner"
|
48
|
+
And I should see "I am Outer"
|
49
|
+
And I should see "Master Erb"
|
47
50
|
When I go to "/data-two.html"
|
48
51
|
Then I should see "Page Number Two"
|
49
|
-
And I should not see "Inner"
|
52
|
+
And I should not see "I am Inner"
|
50
53
|
When I go to "/data-one.html"
|
51
54
|
Then I should see "Page Number One"
|
52
|
-
And I should see "Inner"
|
55
|
+
And I should see "I am Inner"
|
53
56
|
When I go to "/data-two.html"
|
54
57
|
Then I should see "Page Number Two"
|
55
|
-
And I should not see "Inner"
|
58
|
+
And I should not see "I am Inner"
|
@@ -15,7 +15,7 @@ class NeighborFrontmatter < ::Middleman::Extension
|
|
15
15
|
|
16
16
|
next unless file
|
17
17
|
|
18
|
-
fmdata = ::Middleman::Util::Data.parse(file
|
18
|
+
fmdata = ::Middleman::Util::Data.parse(file, app.config[:frontmatter_delims], :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)
|
@@ -26,7 +26,7 @@ class NeighborFrontmatter < ::Middleman::Extension
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def apply_neighbor_data(resource, file)
|
29
|
-
fmdata = ::Middleman::Util::Data.parse(file
|
29
|
+
fmdata = ::Middleman::Util::Data.parse(file, app.config[:frontmatter_delims], :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)
|
data/lib/middleman-core.rb
CHANGED
@@ -149,9 +149,13 @@ module Middleman
|
|
149
149
|
define_setting :http_prefix, '/', 'Default prefix for building paths'
|
150
150
|
|
151
151
|
# Default layout name
|
152
|
-
# @return [String
|
152
|
+
# @return [String]
|
153
153
|
define_setting :layout, :_auto_layout, 'Default layout name'
|
154
154
|
|
155
|
+
# Which file extensions have a layout by default.
|
156
|
+
# @return [Array.<String>]
|
157
|
+
define_setting :extensions_with_layout, %w(.htm .html .xhtml .php), 'Which file extensions have a layout by default.'
|
158
|
+
|
155
159
|
# Default string encoding for templates and output.
|
156
160
|
# @return [String]
|
157
161
|
define_setting :encoding, 'utf-8', 'Default string encoding for templates and output'
|
@@ -184,13 +188,7 @@ module Middleman
|
|
184
188
|
end
|
185
189
|
}, 'Callbacks that can exclude paths from the sitemap'
|
186
190
|
|
187
|
-
|
188
|
-
define_setting :frontmatter_delims, {
|
189
|
-
json: [%w(;;; ;;;)],
|
190
|
-
yaml: [%w(--- ---), %w(--- ...)]
|
191
|
-
}, 'Allowed frontmatter delimiters'
|
192
|
-
|
193
|
-
define_setting :skip_build_clean, proc { |p| [/\.git/].any? { |r| r.match(p) } }, 'Whether some paths should not be removed during a clean build.'
|
191
|
+
define_setting :skip_build_clean, proc { |p| [/\.git/].any? { |r| p =~ r } }, 'Whether some paths should not be removed during a clean build.'
|
194
192
|
|
195
193
|
define_setting :watcher_disable, false, 'If the Listen watcher should not run'
|
196
194
|
define_setting :watcher_force_polling, false, 'If the Listen watcher should run in polling mode'
|
@@ -320,7 +318,7 @@ module Middleman
|
|
320
318
|
|
321
319
|
# Clean up missing Tilt exts
|
322
320
|
def prune_tilt_templates!
|
323
|
-
::Tilt.mappings.
|
321
|
+
::Tilt.mappings.each_key do |key|
|
324
322
|
begin
|
325
323
|
::Tilt[".#{key}"]
|
326
324
|
rescue LoadError, NameError
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'fileutils'
|
3
3
|
require 'tempfile'
|
4
|
+
require 'parallel'
|
4
5
|
require 'middleman-core/rack'
|
5
6
|
require 'middleman-core/callback_manager'
|
6
7
|
require 'middleman-core/contracts'
|
@@ -36,6 +37,7 @@ module Middleman
|
|
36
37
|
|
37
38
|
@glob = opts.fetch(:glob)
|
38
39
|
@cleaning = opts.fetch(:clean)
|
40
|
+
@parallel = opts.fetch(:parallel, true)
|
39
41
|
|
40
42
|
rack_app = ::Middleman::Rack.new(@app).to_app
|
41
43
|
@rack = ::Rack::MockRequest.new(rack_app)
|
@@ -51,18 +53,33 @@ module Middleman
|
|
51
53
|
@has_error = false
|
52
54
|
@events = {}
|
53
55
|
|
54
|
-
|
56
|
+
::Middleman::Util.instrument 'builder.before' do
|
57
|
+
@app.execute_callbacks(:before_build, [self])
|
58
|
+
end
|
55
59
|
|
56
|
-
|
60
|
+
::Middleman::Util.instrument 'builder.queue' do
|
61
|
+
queue_current_paths if @cleaning
|
62
|
+
end
|
57
63
|
|
58
|
-
|
59
|
-
|
64
|
+
::Middleman::Util.instrument 'builder.prerender' do
|
65
|
+
prerender_css
|
66
|
+
end
|
60
67
|
|
61
|
-
|
68
|
+
::Middleman::Profiling.start
|
69
|
+
|
70
|
+
::Middleman::Util.instrument 'builder.output' do
|
71
|
+
output_files
|
72
|
+
end
|
62
73
|
|
63
74
|
::Middleman::Profiling.report('build')
|
64
75
|
|
65
|
-
|
76
|
+
::Middleman::Util.instrument 'builder.clean' do
|
77
|
+
clean! if @cleaning
|
78
|
+
end
|
79
|
+
|
80
|
+
::Middleman::Util.instrument 'builder.after' do
|
81
|
+
@app.execute_callbacks(:after_build, [self])
|
82
|
+
end
|
66
83
|
|
67
84
|
!@has_error
|
68
85
|
end
|
@@ -73,14 +90,17 @@ module Middleman
|
|
73
90
|
def prerender_css
|
74
91
|
logger.debug '== Prerendering CSS'
|
75
92
|
|
76
|
-
css_files =
|
77
|
-
|
78
|
-
|
93
|
+
css_files = ::Middleman::Util.instrument 'builder.prerender.output' do
|
94
|
+
resources = @app.sitemap.resources.select { |resource| resource.ext == '.css' }
|
95
|
+
output_resources(resources)
|
96
|
+
end
|
79
97
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
98
|
+
::Middleman::Util.instrument 'builder.prerender.check-files' do
|
99
|
+
# Double-check for compass sprites
|
100
|
+
if @app.files.find_new_files!.length > 0
|
101
|
+
logger.debug '== Checking for Compass sprites'
|
102
|
+
@app.sitemap.ensure_resource_list_updated!
|
103
|
+
end
|
84
104
|
end
|
85
105
|
|
86
106
|
css_files
|
@@ -92,11 +112,43 @@ module Middleman
|
|
92
112
|
def output_files
|
93
113
|
logger.debug '== Building files'
|
94
114
|
|
95
|
-
@app.sitemap.resources
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
115
|
+
resources = @app.sitemap.resources
|
116
|
+
.reject { |resource| resource.ext == '.css' }
|
117
|
+
.sort_by { |resource| SORT_ORDER.index(resource.ext) || 100 }
|
118
|
+
|
119
|
+
if @glob
|
120
|
+
resources = resources.select { |resource| File.fnmatch(@glob, resource.destination_path) }
|
121
|
+
end
|
122
|
+
|
123
|
+
output_resources(resources)
|
124
|
+
end
|
125
|
+
|
126
|
+
Contract ResourceList => ResourceList
|
127
|
+
def output_resources(resources)
|
128
|
+
results = if @parallel
|
129
|
+
::Parallel.map(resources, &method(:output_resource))
|
130
|
+
else
|
131
|
+
resources.map(&method(:output_resource))
|
132
|
+
end
|
133
|
+
|
134
|
+
@has_error = true if results.any? { |r| r == false }
|
135
|
+
|
136
|
+
if @cleaning && !@has_error
|
137
|
+
results.each do |p|
|
138
|
+
next unless p.exist?
|
139
|
+
|
140
|
+
# handle UTF-8-MAC filename on MacOS
|
141
|
+
cleaned_name = if RUBY_PLATFORM =~ /darwin/
|
142
|
+
p.to_s.encode('UTF-8', 'UTF-8-MAC')
|
143
|
+
else
|
144
|
+
p
|
145
|
+
end
|
146
|
+
|
147
|
+
@to_clean.delete(Pathname(cleaned_name))
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
resources
|
100
152
|
end
|
101
153
|
|
102
154
|
# Figure out the correct event mode.
|
@@ -160,40 +212,32 @@ module Middleman
|
|
160
212
|
# Try to output a resource and capture errors.
|
161
213
|
# @param [Middleman::Sitemap::Resource] resource The resource.
|
162
214
|
# @return [void]
|
163
|
-
Contract IsA['Middleman::Sitemap::Resource'] =>
|
215
|
+
Contract IsA['Middleman::Sitemap::Resource'] => Or[Pathname, Bool]
|
164
216
|
def output_resource(resource)
|
165
|
-
|
166
|
-
|
167
|
-
begin
|
168
|
-
if resource.binary?
|
169
|
-
export_file!(output_file, resource.file_descriptor[:full_path])
|
170
|
-
else
|
171
|
-
response = @rack.get(::URI.escape(resource.request_path))
|
217
|
+
::Middleman::Util.instrument 'builder.output.resource', path: File.basename(resource.destination_path) do
|
218
|
+
output_file = @build_dir + resource.destination_path.gsub('%20', ' ')
|
172
219
|
|
173
|
-
|
174
|
-
if
|
175
|
-
export_file!(output_file,
|
220
|
+
begin
|
221
|
+
if resource.binary?
|
222
|
+
export_file!(output_file, resource.file_descriptor[:full_path])
|
176
223
|
else
|
177
|
-
|
178
|
-
|
224
|
+
response = @rack.get(::URI.escape(resource.request_path))
|
225
|
+
|
226
|
+
# If we get a response, save it to a tempfile.
|
227
|
+
if response.status == 200
|
228
|
+
export_file!(output_file, binary_encode(response.body))
|
229
|
+
else
|
230
|
+
trigger(:error, output_file, response.body)
|
231
|
+
return false
|
232
|
+
end
|
179
233
|
end
|
234
|
+
rescue => e
|
235
|
+
trigger(:error, output_file, "#{e}\n#{e.backtrace.join("\n")}")
|
236
|
+
return false
|
180
237
|
end
|
181
|
-
rescue => e
|
182
|
-
@has_error = true
|
183
|
-
trigger(:error, output_file, "#{e}\n#{e.backtrace.join("\n")}")
|
184
|
-
end
|
185
238
|
|
186
|
-
return unless @cleaning
|
187
|
-
return unless output_file.exist?
|
188
|
-
|
189
|
-
# handle UTF-8-MAC filename on MacOS
|
190
|
-
cleaned_name = if RUBY_PLATFORM =~ /darwin/
|
191
|
-
output_file.to_s.encode('UTF-8', 'UTF-8-MAC')
|
192
|
-
else
|
193
239
|
output_file
|
194
240
|
end
|
195
|
-
|
196
|
-
@to_clean.delete(Pathname(cleaned_name))
|
197
241
|
end
|
198
242
|
|
199
243
|
# Get a list of all the paths in the destination folder and save them
|