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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d02a12c78f163c9213f8fdfb955ccc033b311e5c
|
4
|
+
data.tar.gz: f832b54139abcf4d4629d436b7007f8f132266a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 437c1700d0578d22e68c6b153fec52f25fa09add4aba8521ce13d60605c32593ad4754e30f58c682c5b3b81af35497ba0061d65cd56ccc5024c639bb0b549389
|
7
|
+
data.tar.gz: 371e370f1e1aab80b8c1ef4ca6fcaba1f091469a56c6506c23244d8b67ec359c33be317b4a4c1d6b28a94da07ad2826c8a31b105b01d14e4bf1c25dc86b9cb1b
|
data/Rakefile
CHANGED
data/features/asset_hash.feature
CHANGED
@@ -107,25 +107,63 @@ Feature: Assets get file hashes appended to them and references to them are upda
|
|
107
107
|
And I should see 'src="images/100px-5fd6fb90.jpg"'
|
108
108
|
And I should see 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"'
|
109
109
|
|
110
|
-
Scenario: Enabling an asset host still produces hashed files and references
|
110
|
+
Scenario: Enabling an asset host still produces hashed files and references (hash first)
|
111
|
+
Given a fixture app "asset-hash-host-app"
|
112
|
+
And a file named "config.rb" with:
|
113
|
+
"""
|
114
|
+
activate :asset_hash
|
115
|
+
activate :directory_indexes
|
116
|
+
activate :asset_host, host: 'http://middlemanapp.com'
|
117
|
+
"""
|
118
|
+
Given the Server is running at "asset-hash-host-app"
|
119
|
+
When I go to "/"
|
120
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-4b64a653.css"'
|
121
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/fragment-a772891f.css"'
|
122
|
+
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
123
|
+
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?test"'
|
124
|
+
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test"'
|
125
|
+
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg#test"'
|
126
|
+
When I go to "/subdir/"
|
127
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-4b64a653.css"'
|
128
|
+
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
129
|
+
When I go to "/other/"
|
130
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-4b64a653.css"'
|
131
|
+
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
132
|
+
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?test"'
|
133
|
+
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test"'
|
134
|
+
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg#test"'
|
135
|
+
When I go to "/stylesheets/fragment-a772891f.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
|
+
|
141
|
+
Scenario: Enabling an asset host still produces hashed files and references (host first)
|
142
|
+
Given a fixture app "asset-hash-host-app"
|
143
|
+
And a file named "config.rb" with:
|
144
|
+
"""
|
145
|
+
activate :asset_host, host: 'http://middlemanapp.com'
|
146
|
+
activate :directory_indexes
|
147
|
+
activate :asset_hash
|
148
|
+
"""
|
111
149
|
Given the Server is running at "asset-hash-host-app"
|
112
150
|
When I go to "/"
|
113
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
114
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/fragment-
|
151
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-4b64a653.css"'
|
152
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/fragment-a772891f.css"'
|
115
153
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
116
154
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?test"'
|
117
155
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test"'
|
118
156
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg#test"'
|
119
157
|
When I go to "/subdir/"
|
120
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
158
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-4b64a653.css"'
|
121
159
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
122
160
|
When I go to "/other/"
|
123
|
-
Then I should see 'href="http://middlemanapp.com/stylesheets/site-
|
161
|
+
Then I should see 'href="http://middlemanapp.com/stylesheets/site-4b64a653.css"'
|
124
162
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg"'
|
125
163
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?test"'
|
126
164
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test"'
|
127
165
|
And I should see 'src="http://middlemanapp.com/images/100px-5fd6fb90.jpg#test"'
|
128
|
-
When I go to "/stylesheets/fragment-
|
166
|
+
When I go to "/stylesheets/fragment-a772891f.css"
|
129
167
|
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg")'
|
130
168
|
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg?test")'
|
131
169
|
And I should see 'url("http://middlemanapp.com/images/100px-5fd6fb90.jpg?#test")'
|
data/features/asset_host.feature
CHANGED
@@ -8,6 +8,7 @@ Feature: Alternate between multiple asset hosts
|
|
8
8
|
"""
|
9
9
|
And the Server is running
|
10
10
|
When I go to "/asset_host.html"
|
11
|
+
Then I should see "'.google-analytics.com/ga.js'"
|
11
12
|
Then I should see 'src="https://code.jquery.com/jquery-2.1.3.min.js"'
|
12
13
|
Then I should see content matching %r{http://assets1.example.com/}
|
13
14
|
Then I should not see content matching %r{http://assets1.example.com//}
|
@@ -2,15 +2,28 @@ Feature: Automatically detect and insert image dimensions into tags
|
|
2
2
|
In order to speed up development and appease YSlow
|
3
3
|
|
4
4
|
Scenario: Rendering an image with the feature disabled
|
5
|
-
Given
|
5
|
+
Given a fixture app "automatic-image-size-app"
|
6
|
+
And a file named "config.rb" with:
|
7
|
+
"""
|
8
|
+
"""
|
6
9
|
And the Server is running at "automatic-image-size-app"
|
7
10
|
When I go to "/auto-image-sizes.html"
|
8
11
|
Then I should not see "width="
|
9
12
|
And I should not see "height="
|
10
|
-
|
13
|
+
When I go to "/markdown-sizes.html"
|
14
|
+
Then I should not see "width="
|
15
|
+
And I should not see "height="
|
16
|
+
|
11
17
|
Scenario: Rendering an image with the feature enabled
|
12
|
-
Given
|
18
|
+
Given a fixture app "automatic-image-size-app"
|
19
|
+
And a file named "config.rb" with:
|
20
|
+
"""
|
21
|
+
activate :automatic_image_sizes
|
22
|
+
"""
|
13
23
|
And the Server is running at "automatic-image-size-app"
|
14
24
|
When I go to "/auto-image-sizes.html"
|
15
|
-
Then I should see
|
16
|
-
And I should see
|
25
|
+
Then I should see 'width="1"'
|
26
|
+
And I should see 'height="1"'
|
27
|
+
When I go to "/markdown-sizes.html"
|
28
|
+
Then I should see 'width="1"'
|
29
|
+
And I should see 'height="1"'
|
@@ -0,0 +1 @@
|
|
1
|
+
activate :asset_host, host: "http://assets1.example.com"
|
@@ -44,3 +44,12 @@
|
|
44
44
|
<a href="https://github.com/angular/angular.js">Angular.js</a>
|
45
45
|
|
46
46
|
<script>(function(a,b,c,d){})(window,document,'script','//www.example.com/script.js');</script>
|
47
|
+
|
48
|
+
<script>
|
49
|
+
(function() {
|
50
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
51
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') +
|
52
|
+
'.google-analytics.com/ga.js';
|
53
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
54
|
+
})();
|
55
|
+
</script>
|
@@ -0,0 +1 @@
|
|
1
|
+
![Alt text](/images/blank.gif)
|
@@ -70,27 +70,27 @@ module Middleman
|
|
70
70
|
|
71
71
|
# Which port preview should start on.
|
72
72
|
# @return [Fixnum]
|
73
|
-
|
73
|
+
define_setting :port, 4567, 'The preview server port'
|
74
74
|
|
75
75
|
# Which server name should be used
|
76
76
|
# @return [NilClass, String]
|
77
|
-
|
77
|
+
define_setting :server_name, nil, 'The server name of preview server'
|
78
78
|
|
79
79
|
# Which bind address the preview server should use
|
80
80
|
# @return [NilClass, String]
|
81
|
-
|
81
|
+
define_setting :bind_address, nil, 'The bind address of the preview server'
|
82
82
|
|
83
83
|
# Whether to serve the preview server over HTTPS.
|
84
84
|
# @return [Boolean]
|
85
|
-
|
85
|
+
define_setting :https, false, 'Serve the preview server over SSL/TLS'
|
86
86
|
|
87
87
|
# The (optional) path to the SSL cert to use for the preview server.
|
88
88
|
# @return [String]
|
89
|
-
|
89
|
+
define_setting :ssl_certificate, nil, 'Path to an X.509 certificate to use for the preview server'
|
90
90
|
|
91
91
|
# The (optional) private key for the certificate in :ssl_certificate.
|
92
92
|
# @return [String]
|
93
|
-
|
93
|
+
define_setting :ssl_private_key, nil, "Path to an RSA private key for the preview server's certificate"
|
94
94
|
|
95
95
|
# Name of the source directory
|
96
96
|
# @return [String]
|
@@ -170,7 +170,7 @@ module Middleman
|
|
170
170
|
ignored = false
|
171
171
|
|
172
172
|
file[:relative_path].ascend do |f|
|
173
|
-
if f.basename.to_s
|
173
|
+
if f.basename.to_s =~ %r{^_[^_]}
|
174
174
|
ignored = true
|
175
175
|
break
|
176
176
|
end
|
@@ -180,8 +180,7 @@ module Middleman
|
|
180
180
|
end,
|
181
181
|
|
182
182
|
layout: proc do |file, _sitemap_app|
|
183
|
-
file[:relative_path].to_s.start_with?('layout.')
|
184
|
-
file[:relative_path].to_s.start_with?('layouts/')
|
183
|
+
file[:relative_path].to_s.start_with?('layout.', 'layouts/')
|
185
184
|
end
|
186
185
|
}, 'Callbacks that can exclude paths from the sitemap'
|
187
186
|
|
@@ -210,43 +209,51 @@ module Middleman
|
|
210
209
|
# Search the root of the project for required files
|
211
210
|
$LOAD_PATH.unshift(root) unless $LOAD_PATH.include?(root)
|
212
211
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
212
|
+
::Middleman::Util.instrument 'application.setup' do
|
213
|
+
@callbacks = ::Middleman::CallbackManager.new
|
214
|
+
@callbacks.install_methods!(self, [
|
215
|
+
:initialized,
|
216
|
+
:configure,
|
217
|
+
:before_extensions,
|
218
|
+
:before_instance_block,
|
219
|
+
:before_sitemap,
|
220
|
+
:before_configuration,
|
221
|
+
:after_configuration,
|
222
|
+
:after_configuration_eval,
|
223
|
+
:ready,
|
224
|
+
:before_build,
|
225
|
+
:after_build,
|
226
|
+
:before_shutdown,
|
227
|
+
:before, # Before Rack requests
|
228
|
+
:before_render,
|
229
|
+
:after_render,
|
230
|
+
:before_server
|
231
|
+
])
|
232
|
+
|
233
|
+
@middleware = Set.new
|
234
|
+
@mappings = Set.new
|
235
|
+
|
236
|
+
@template_context_class = Class.new(Middleman::TemplateContext)
|
237
|
+
@generic_template_context = @template_context_class.new(self)
|
238
|
+
@config_context = ConfigContext.new(self, @template_context_class)
|
239
|
+
|
240
|
+
# Setup the default values from calls to set before initialization
|
241
|
+
@config = ::Middleman::Configuration::ConfigurationManager.new
|
242
|
+
@config.load_settings(self.class.config.all_settings)
|
243
|
+
|
244
|
+
config[:source] = ENV['MM_SOURCE'] if ENV['MM_SOURCE']
|
245
|
+
|
246
|
+
# TODO, make this less global
|
247
|
+
::Middleman::FileRenderer.cache.clear
|
248
|
+
::Middleman::TemplateRenderer.cache.clear
|
249
|
+
end
|
250
|
+
|
251
|
+
execute_callbacks(:before_extensions)
|
247
252
|
|
248
253
|
@extensions = ::Middleman::ExtensionManager.new(self)
|
249
254
|
|
255
|
+
execute_callbacks(:before_instance_block)
|
256
|
+
|
250
257
|
# Evaluate a passed block if given
|
251
258
|
config_context.instance_exec(&block) if block_given?
|
252
259
|
|
@@ -257,13 +264,6 @@ module Middleman
|
|
257
264
|
|
258
265
|
::Middleman::Extension.clear_after_extension_callbacks
|
259
266
|
|
260
|
-
after_configuration_eval(&method(:prune_tilt_templates))
|
261
|
-
|
262
|
-
start_lifecycle
|
263
|
-
end
|
264
|
-
|
265
|
-
# Boot the app.
|
266
|
-
def start_lifecycle
|
267
267
|
# Before config is parsed, before extensions get to it.
|
268
268
|
execute_callbacks(:initialized)
|
269
269
|
|
@@ -273,10 +273,6 @@ module Middleman
|
|
273
273
|
# Eval config.
|
274
274
|
evaluate_configuration!
|
275
275
|
|
276
|
-
if Object.const_defined?(:Encoding)
|
277
|
-
Encoding.default_external = config[:encoding]
|
278
|
-
end
|
279
|
-
|
280
276
|
# Run any `configure` blocks for the current environment.
|
281
277
|
execute_callbacks([:configure, config[:environment]])
|
282
278
|
|
@@ -286,6 +282,12 @@ module Middleman
|
|
286
282
|
# Post parsing, pre-extension callback
|
287
283
|
execute_callbacks(:after_configuration_eval)
|
288
284
|
|
285
|
+
if Object.const_defined?(:Encoding)
|
286
|
+
Encoding.default_external = config[:encoding]
|
287
|
+
end
|
288
|
+
|
289
|
+
prune_tilt_templates!
|
290
|
+
|
289
291
|
# After extensions have worked after_config
|
290
292
|
execute_callbacks(:after_configuration)
|
291
293
|
|
@@ -317,7 +319,7 @@ module Middleman
|
|
317
319
|
end
|
318
320
|
|
319
321
|
# Clean up missing Tilt exts
|
320
|
-
def prune_tilt_templates
|
322
|
+
def prune_tilt_templates!
|
321
323
|
::Tilt.mappings.each do |key, _|
|
322
324
|
begin
|
323
325
|
::Tilt[".#{key}"]
|
@@ -327,18 +329,26 @@ module Middleman
|
|
327
329
|
end
|
328
330
|
end
|
329
331
|
|
332
|
+
# Whether we're in a specific mode
|
333
|
+
# @param [Symbol] key
|
334
|
+
# @return [Boolean]
|
335
|
+
Contract Symbol => Bool
|
336
|
+
def mode?(key)
|
337
|
+
config[:mode] == key
|
338
|
+
end
|
339
|
+
|
330
340
|
# Whether we're in server mode
|
331
341
|
# @return [Boolean] If we're in dev mode
|
332
342
|
Contract Bool
|
333
343
|
def server?
|
334
|
-
|
344
|
+
mode?(:server)
|
335
345
|
end
|
336
346
|
|
337
347
|
# Whether we're in build mode
|
338
348
|
# @return [Boolean] If we're in dev mode
|
339
349
|
Contract Bool
|
340
350
|
def build?
|
341
|
-
|
351
|
+
mode?(:build)
|
342
352
|
end
|
343
353
|
|
344
354
|
# Whether we're in a specific environment
|
@@ -420,6 +430,6 @@ module Middleman
|
|
420
430
|
def to_s
|
421
431
|
"#<Middleman::Application:0x#{object_id}>"
|
422
432
|
end
|
423
|
-
|
433
|
+
alias inspect to_s # Ruby 2.0 calls inspect for NoMethodError instead of to_s
|
424
434
|
end
|
425
435
|
end
|
@@ -20,7 +20,7 @@ module Middleman
|
|
20
20
|
def_delegator :@app, :logger
|
21
21
|
|
22
22
|
# Sort order, images, fonts, js/css and finally everything else.
|
23
|
-
SORT_ORDER = %w(.png .jpeg .jpg .gif .bmp .svg .svgz .webp .ico .woff .woff2 .otf .ttf .eot .js .css)
|
23
|
+
SORT_ORDER = %w(.png .jpeg .jpg .gif .bmp .svg .svgz .webp .ico .woff .woff2 .otf .ttf .eot .js .css).freeze
|
24
24
|
|
25
25
|
# Create a new Builder instance.
|
26
26
|
# @param [Middleman::Application] app The app to build.
|
@@ -72,13 +72,17 @@ module Middleman
|
|
72
72
|
Contract ResourceList
|
73
73
|
def prerender_css
|
74
74
|
logger.debug '== Prerendering CSS'
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
|
76
|
+
css_files = @app.sitemap.resources
|
77
|
+
.select { |resource| resource.ext == '.css' }
|
78
|
+
.each(&method(:output_resource))
|
79
|
+
|
79
80
|
# Double-check for compass sprites
|
80
|
-
@app.files.find_new_files
|
81
|
-
|
81
|
+
if @app.files.find_new_files!.length > 0
|
82
|
+
logger.debug '== Checking for Compass sprites'
|
83
|
+
@app.sitemap.ensure_resource_list_updated!
|
84
|
+
end
|
85
|
+
|
82
86
|
css_files
|
83
87
|
end
|
84
88
|
|
@@ -89,10 +93,10 @@ module Middleman
|
|
89
93
|
logger.debug '== Building files'
|
90
94
|
|
91
95
|
@app.sitemap.resources
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
+
.sort_by { |resource| SORT_ORDER.index(resource.ext) || 100 }
|
97
|
+
.reject { |resource| resource.ext == '.css' }
|
98
|
+
.select { |resource| !@glob || File.fnmatch(@glob, resource.destination_path) }
|
99
|
+
.each(&method(:output_resource))
|
96
100
|
end
|
97
101
|
|
98
102
|
# Figure out the correct event mode.
|
@@ -115,9 +119,9 @@ module Middleman
|
|
115
119
|
Contract Pathname, String => Tempfile
|
116
120
|
def write_tempfile(output_file, contents)
|
117
121
|
file = Tempfile.new([
|
118
|
-
|
119
|
-
|
120
|
-
|
122
|
+
File.basename(output_file),
|
123
|
+
File.extname(output_file)
|
124
|
+
])
|
121
125
|
file.binmode
|
122
126
|
file.write(contents)
|
123
127
|
file.close
|
@@ -131,24 +135,26 @@ module Middleman
|
|
131
135
|
# @return [void]
|
132
136
|
Contract Pathname, Or[String, Pathname] => Any
|
133
137
|
def export_file!(output_file, source)
|
138
|
+
# ::Middleman::Util.instrument "write_file", output_file: output_file do
|
134
139
|
source = write_tempfile(output_file, source.to_s) if source.is_a? String
|
135
140
|
|
136
141
|
method, source_path = if source.is_a? Tempfile
|
137
|
-
[FileUtils.method(:mv), source.path]
|
142
|
+
[::FileUtils.method(:mv), source.path]
|
138
143
|
else
|
139
|
-
[FileUtils.method(:cp), source.to_s]
|
144
|
+
[::FileUtils.method(:cp), source.to_s]
|
140
145
|
end
|
141
146
|
|
142
147
|
mode = which_mode(output_file, source_path)
|
143
148
|
|
144
149
|
if mode == :created || mode == :updated
|
145
|
-
FileUtils.mkdir_p(output_file.dirname)
|
150
|
+
::FileUtils.mkdir_p(output_file.dirname)
|
146
151
|
method.call(source_path, output_file.to_s)
|
147
152
|
end
|
148
153
|
|
149
154
|
source.unlink if source.is_a? Tempfile
|
150
155
|
|
151
156
|
trigger(mode, output_file)
|
157
|
+
# end
|
152
158
|
end
|
153
159
|
|
154
160
|
# Try to output a resource and capture errors.
|
@@ -162,7 +168,7 @@ module Middleman
|
|
162
168
|
if resource.binary?
|
163
169
|
export_file!(output_file, resource.file_descriptor[:full_path])
|
164
170
|
else
|
165
|
-
response = @rack.get(URI.escape(resource.request_path))
|
171
|
+
response = @rack.get(::URI.escape(resource.request_path))
|
166
172
|
|
167
173
|
# If we get a response, save it to a tempfile.
|
168
174
|
if response.status == 200
|