middleman-core 4.1.3 → 4.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/asset_hash.feature +7 -0
- data/features/dynamic_pages.feature +15 -12
- data/fixtures/asset-hash-minified-app/source/images/100px.jpg +0 -0
- data/fixtures/asset-hash-minified-app/source/stylesheets/test.css +3 -0
- data/fixtures/dynamic-pages-app/config.rb +4 -0
- data/fixtures/dynamic-pages-app/source/should_be_ignored9.html +1 -0
- data/lib/middleman-core/application.rb +21 -0
- data/lib/middleman-core/extensions/asset_hash.rb +7 -3
- data/lib/middleman-core/extensions/asset_host.rb +2 -2
- data/lib/middleman-core/extensions/cache_buster.rb +2 -2
- data/lib/middleman-core/extensions/directory_indexes.rb +1 -1
- data/lib/middleman-core/extensions/external_pipeline.rb +9 -1
- data/lib/middleman-core/extensions/relative_assets.rb +2 -2
- data/lib/middleman-core/preview_server.rb +19 -13
- data/lib/middleman-core/template_context.rb +1 -1
- data/lib/middleman-core/util/files.rb +30 -12
- data/lib/middleman-core/util/paths.rb +5 -1
- data/lib/middleman-core/util/rack.rb +1 -1
- data/lib/middleman-core/version.rb +1 -1
- data/spec/middleman-core/util_spec.rb +14 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c11a191bebfe7ff3fc0a2418fc2334f38373f01
|
4
|
+
data.tar.gz: 45c019a96a431a716864f3ee952614022c6ad374
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 234bf4823fc4870dd79df4605b8cee91efbe7037b6a2403ce0bb2c2c33f9f4ff736349eae87aecdfbe964a28f0a4ff51434bb7511cb529523a410006904fa855
|
7
|
+
data.tar.gz: eae2a780c9486f90aa2230a4b8e756e463a330af7088e710d5818e2bcec852d43267fcbce0a4a00f97da1a5717ae59278c606b773b78d789e694c3e4bb7beb74
|
data/features/asset_hash.feature
CHANGED
@@ -283,8 +283,15 @@ Feature: Assets get file hashes appended to them and references to them are upda
|
|
283
283
|
When I cd to "build"
|
284
284
|
Then the following files should exist:
|
285
285
|
| javascripts/jquery.min-276c87ff.js |
|
286
|
+
| stylesheets/test-7de2ad06.css |
|
286
287
|
And the following files should not exist:
|
287
288
|
| javascripts/jquery.min.js |
|
289
|
+
And the file "stylesheets/test-7de2ad06.css" should contain:
|
290
|
+
"""
|
291
|
+
.no-bug{background-image:url(/images/100px-5fd6fb90.jpg)}
|
292
|
+
.bug{content:"";background-image:url(/images/100px-5fd6fb90.jpg)}
|
293
|
+
.no-bug{content:""; background-image:url(/images/100px-5fd6fb90.jpg)}
|
294
|
+
"""
|
288
295
|
|
289
296
|
Scenario: Source map paths include the hash
|
290
297
|
Given a successfully built app at "asset-hash-source-map"
|
@@ -31,7 +31,8 @@ Feature: Dynamic Pages
|
|
31
31
|
| should_be_ignored6.html |
|
32
32
|
| should_be_ignored7.html |
|
33
33
|
| should_be_ignored8.html |
|
34
|
-
|
34
|
+
| should_be_ignored9.html |
|
35
|
+
|
35
36
|
Scenario: Preview basic proxy
|
36
37
|
Given the Server is running at "dynamic-pages-app"
|
37
38
|
When I go to "/fake.html"
|
@@ -42,46 +43,46 @@ Feature: Dynamic Pages
|
|
42
43
|
Then I should see "I am real"
|
43
44
|
When I go to "/fake4.html"
|
44
45
|
Then I should see "I am real"
|
45
|
-
|
46
|
+
|
46
47
|
Scenario: Preview proxy with variable one
|
47
48
|
Given the Server is running at "dynamic-pages-app"
|
48
49
|
When I go to "/fake/one.html"
|
49
50
|
Then I should see "I am real: one"
|
50
51
|
Then I should see "Global: I am one glob"
|
51
52
|
Then I should see "All: I am all glob"
|
52
|
-
|
53
|
+
|
53
54
|
When I go to "/fake2/one.html"
|
54
55
|
Then I should see "I am real: one"
|
55
56
|
Then I should see "Global: I am two glob"
|
56
57
|
Then I should see "All: I am all glob"
|
57
|
-
|
58
|
+
|
58
59
|
When I go to "/fake3/one.html"
|
59
60
|
Then I should see "I am real: one"
|
60
61
|
Then I should see "Global: I am three glob"
|
61
62
|
Then I should see "All: I am all glob"
|
62
|
-
|
63
|
+
|
63
64
|
When I go to "/fake4/one.html"
|
64
65
|
Then I should see "I am real: one"
|
65
66
|
Then I should see "Global: I am four glob"
|
66
67
|
Then I should see "All: I am all glob"
|
67
|
-
|
68
|
+
|
68
69
|
Scenario: Preview proxy with variable two
|
69
70
|
Given the Server is running at "dynamic-pages-app"
|
70
71
|
When I go to "/fake/two.html"
|
71
72
|
Then I should see "I am real: two"
|
72
73
|
Then I should see "Global: I am one glob"
|
73
74
|
Then I should see "All: I am all glob"
|
74
|
-
|
75
|
+
|
75
76
|
When I go to "/fake2/two.html"
|
76
77
|
Then I should see "I am real: two"
|
77
78
|
Then I should see "Global: I am two glob"
|
78
79
|
Then I should see "All: I am all glob"
|
79
|
-
|
80
|
+
|
80
81
|
When I go to "/fake3/two.html"
|
81
82
|
Then I should see "I am real: two"
|
82
83
|
Then I should see "Global: I am three glob"
|
83
84
|
Then I should see "All: I am all glob"
|
84
|
-
|
85
|
+
|
85
86
|
When I go to "/fake4/two.html"
|
86
87
|
Then I should see "I am real: two"
|
87
88
|
Then I should see "Global: I am four glob"
|
@@ -101,7 +102,7 @@ Feature: Dynamic Pages
|
|
101
102
|
Then the file "fake3/one.html" should contain "I am real: one"
|
102
103
|
Then the file "fake3/one.html" should contain "Global: I am three glob"
|
103
104
|
Then the file "fake3/one.html" should contain "All: I am all glob"
|
104
|
-
|
105
|
+
|
105
106
|
Scenario: Target ignore
|
106
107
|
Given the Server is running at "dynamic-pages-app"
|
107
108
|
When I go to "/target_ignore.html"
|
@@ -112,7 +113,7 @@ Feature: Dynamic Pages
|
|
112
113
|
Then I should see "Ignore me! 7"
|
113
114
|
When I go to "/target_ignore4.html"
|
114
115
|
Then I should see "Ignore me! 8"
|
115
|
-
|
116
|
+
|
116
117
|
Scenario: Preview ignored paths
|
117
118
|
Given the Server is running at "dynamic-pages-app"
|
118
119
|
When I go to "/should_be_ignored.html"
|
@@ -130,4 +131,6 @@ Feature: Dynamic Pages
|
|
130
131
|
When I go to "/should_be_ignored7.html"
|
131
132
|
Then I should see "File Not Found"
|
132
133
|
When I go to "/should_be_ignored8.html"
|
133
|
-
Then I should see "File Not Found"
|
134
|
+
Then I should see "File Not Found"
|
135
|
+
When I go to "/should_be_ignored9.html"
|
136
|
+
Then I should see "File Not Found"
|
Binary file
|
@@ -28,3 +28,7 @@ page "fake/*", locals: { glob_var: "I am one glob" }
|
|
28
28
|
page "fake2/*", locals: { glob_var: "I am two glob" }
|
29
29
|
page "fake3/*", locals: { glob_var: "I am three glob" }
|
30
30
|
page "fake4/*", locals: { glob_var: "I am four glob" }
|
31
|
+
|
32
|
+
["tom", "dick", "harry"].each do |name|
|
33
|
+
proxy "/about/#{name}.html", "/should_be_ignored9.html", locals: { person_name: name }, ignore: true
|
34
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>Ignore me! 9</h1>
|
@@ -160,6 +160,10 @@ module Middleman
|
|
160
160
|
# @return [Array.<String>]
|
161
161
|
define_setting :extensions_with_layout, %w(.htm .html .xhtml .php), 'Which file extensions have a layout by default.'
|
162
162
|
|
163
|
+
# Which file extensions are "assets."
|
164
|
+
# @return [Array.<String>]
|
165
|
+
define_setting :asset_extensions, %w(.css .png .jpg .jpeg .webp .svg .svgz .js .gif .ttf .otf .woff .woff2 .eot .ico .map), 'Which file extensions are treated as assets.'
|
166
|
+
|
163
167
|
# Default string encoding for templates and output.
|
164
168
|
# @return [String]
|
165
169
|
define_setting :encoding, 'utf-8', 'Default string encoding for templates and output'
|
@@ -194,6 +198,8 @@ module Middleman
|
|
194
198
|
|
195
199
|
define_setting :skip_build_clean, proc { |p| [/\.git/].any? { |r| p =~ r } }, 'Whether some paths should not be removed during a clean build.'
|
196
200
|
|
201
|
+
define_setting :cli_options, {}, 'Options from the Command Line.'
|
202
|
+
|
197
203
|
define_setting :watcher_disable, false, 'If the Listen watcher should not run'
|
198
204
|
define_setting :watcher_force_polling, false, 'If the Listen watcher should run in polling mode'
|
199
205
|
define_setting :watcher_latency, nil, 'The Listen watcher latency'
|
@@ -269,6 +275,8 @@ module Middleman
|
|
269
275
|
# Before config is parsed, before extensions get to it.
|
270
276
|
execute_callbacks(:initialized)
|
271
277
|
|
278
|
+
apply_cli_options
|
279
|
+
|
272
280
|
# Before config is parsed. Mostly used for extensions.
|
273
281
|
execute_callbacks(:before_configuration)
|
274
282
|
|
@@ -281,6 +289,8 @@ module Middleman
|
|
281
289
|
# Run any `configure` blocks for the current mode.
|
282
290
|
execute_callbacks([:configure, config[:mode]])
|
283
291
|
|
292
|
+
apply_cli_options
|
293
|
+
|
284
294
|
# Post parsing, pre-extension callback
|
285
295
|
execute_callbacks(:after_configuration_eval)
|
286
296
|
|
@@ -297,6 +307,17 @@ module Middleman
|
|
297
307
|
execute_callbacks(:ready) unless config[:exit_before_ready]
|
298
308
|
end
|
299
309
|
|
310
|
+
def apply_cli_options
|
311
|
+
config[:cli_options].each do |k, v|
|
312
|
+
setting = config.setting(k.to_sym)
|
313
|
+
next unless setting
|
314
|
+
|
315
|
+
v = setting.options[:import].call(v) if setting.options[:import]
|
316
|
+
|
317
|
+
config[k.to_sym] = v
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
300
321
|
# Eval config
|
301
322
|
def evaluate_configuration!
|
302
323
|
# Check for and evaluate local configuration in `config.rb`
|
@@ -3,7 +3,7 @@ require 'middleman-core/rack'
|
|
3
3
|
|
4
4
|
class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
5
5
|
option :sources, %w(.css .htm .html .js .php .xhtml), 'List of extensions that are searched for hashable assets.'
|
6
|
-
option :exts,
|
6
|
+
option :exts, nil, 'List of extensions that get asset hashes appended to them.'
|
7
7
|
option :ignore, [], 'Regexes of filenames to skip adding asset hashes to'
|
8
8
|
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for path rewrites'
|
9
9
|
|
@@ -17,8 +17,12 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
|
17
17
|
# Allow specifying regexes to ignore, plus always ignore apple touch icons
|
18
18
|
@ignore = Array(options.ignore) + [/^apple-touch-icon/]
|
19
19
|
|
20
|
+
# Exclude .ico from the default list because browsers expect it
|
21
|
+
# to be named "favicon.ico"
|
22
|
+
@exts = options.exts || (app.config[:asset_extensions] - %w(.ico))
|
23
|
+
|
20
24
|
app.rewrite_inline_urls id: :asset_hash,
|
21
|
-
url_extensions:
|
25
|
+
url_extensions: @exts.sort.reverse,
|
22
26
|
source_extensions: options.sources,
|
23
27
|
ignore: @ignore,
|
24
28
|
rewrite_ignore: options.rewrite_ignore,
|
@@ -70,7 +74,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
|
|
70
74
|
|
71
75
|
Contract IsA['Middleman::Sitemap::Resource'] => Maybe[IsA['Middleman::Sitemap::Resource']]
|
72
76
|
def manipulate_single_resource(resource)
|
73
|
-
return unless
|
77
|
+
return unless @exts.include?(resource.ext)
|
74
78
|
return if ignored_resource?(resource)
|
75
79
|
return if resource.ignored?
|
76
80
|
|
@@ -2,7 +2,7 @@ require 'addressable/uri'
|
|
2
2
|
|
3
3
|
class Middleman::Extensions::AssetHost < ::Middleman::Extension
|
4
4
|
option :host, nil, 'The asset host to use or a Proc to determine asset host', required: true
|
5
|
-
option :exts,
|
5
|
+
option :exts, nil, 'List of extensions that get cache busters strings appended to them.'
|
6
6
|
option :sources, %w(.css .htm .html .js .php .xhtml), 'List of extensions that are searched for bustable assets.'
|
7
7
|
option :ignore, [], 'Regexes of filenames to skip adding query strings to'
|
8
8
|
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for host rewrites'
|
@@ -11,7 +11,7 @@ class Middleman::Extensions::AssetHost < ::Middleman::Extension
|
|
11
11
|
super
|
12
12
|
|
13
13
|
app.rewrite_inline_urls id: :asset_host,
|
14
|
-
url_extensions: options.exts,
|
14
|
+
url_extensions: options.exts || app.config[:asset_extensions],
|
15
15
|
source_extensions: options.sources,
|
16
16
|
ignore: options.ignore,
|
17
17
|
rewrite_ignore: options.rewrite_ignore,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The Cache Buster extension
|
2
2
|
class Middleman::Extensions::CacheBuster < ::Middleman::Extension
|
3
|
-
option :exts,
|
3
|
+
option :exts, nil, 'List of extensions that get cache busters strings appended to them.'
|
4
4
|
option :sources, %w(.css .htm .html .js .php .xhtml), 'List of extensions that are searched for bustable assets.'
|
5
5
|
option :ignore, [], 'Regexes of filenames to skip adding query strings to'
|
6
6
|
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for path rewrites'
|
@@ -9,7 +9,7 @@ class Middleman::Extensions::CacheBuster < ::Middleman::Extension
|
|
9
9
|
super
|
10
10
|
|
11
11
|
app.rewrite_inline_urls id: :cache_buster,
|
12
|
-
url_extensions: options.exts,
|
12
|
+
url_extensions: options.exts || app.config[:asset_extensions],
|
13
13
|
source_extensions: options.sources,
|
14
14
|
ignore: options.ignore,
|
15
15
|
rewrite_ignore: options.rewrite_ignore,
|
@@ -11,7 +11,7 @@ class Middleman::Extensions::DirectoryIndexes < ::Middleman::Extension
|
|
11
11
|
index_file = app.config[:index_file]
|
12
12
|
new_index_path = "/#{index_file}"
|
13
13
|
|
14
|
-
extensions = %w(.htm .html .php)
|
14
|
+
extensions = %w(.htm .html .php .xhtml)
|
15
15
|
|
16
16
|
resources.each do |resource|
|
17
17
|
# Check if it would be pointless to reroute
|
@@ -10,10 +10,18 @@ class Middleman::Extensions::ExternalPipeline < ::Middleman::Extension
|
|
10
10
|
def initialize(app, config={}, &block)
|
11
11
|
super
|
12
12
|
|
13
|
+
return if app.mode?(:config)
|
14
|
+
|
13
15
|
require 'thread'
|
16
|
+
require 'fileutils'
|
17
|
+
|
18
|
+
source_path = File.expand_path(options[:source], app.root)
|
19
|
+
|
20
|
+
# Make sure it exists, or `listen` will explode.
|
21
|
+
::FileUtils.mkdir_p(source_path)
|
14
22
|
|
15
23
|
@watcher = app.files.watch :source,
|
16
|
-
path:
|
24
|
+
path: source_path,
|
17
25
|
latency: options[:latency],
|
18
26
|
frontmatter: false
|
19
27
|
|
@@ -2,7 +2,7 @@ require 'addressable/uri'
|
|
2
2
|
|
3
3
|
# Relative Assets extension
|
4
4
|
class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
|
5
|
-
option :exts,
|
5
|
+
option :exts, nil, 'List of extensions that get cache busters strings appended to them.'
|
6
6
|
option :sources, %w(.css .htm .html .xhtml), 'List of extensions that are searched for relative assets.'
|
7
7
|
option :ignore, [], 'Regexes of filenames to skip adding query strings to'
|
8
8
|
option :rewrite_ignore, [], 'Regexes of filenames to skip processing for path rewrites'
|
@@ -11,7 +11,7 @@ class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
|
|
11
11
|
super
|
12
12
|
|
13
13
|
app.rewrite_inline_urls id: :asset_hash,
|
14
|
-
url_extensions: options.exts,
|
14
|
+
url_extensions: options.exts || app.config[:asset_extensions],
|
15
15
|
source_extensions: options.sources,
|
16
16
|
ignore: options.ignore,
|
17
17
|
rewrite_ignore: options.rewrite_ignore,
|
@@ -140,13 +140,8 @@ module Middleman
|
|
140
140
|
)
|
141
141
|
|
142
142
|
app = ::Middleman::Application.new do
|
143
|
-
cli_options.
|
144
|
-
|
145
|
-
next unless setting
|
146
|
-
|
147
|
-
v = setting.options[:import].call(v) if setting.options[:import]
|
148
|
-
|
149
|
-
config[k.to_sym] = v
|
143
|
+
config[:cli_options] = cli_options.each_with_object({}) do |(k, v), sum|
|
144
|
+
sum[k] = v unless v == :undefined
|
150
145
|
end
|
151
146
|
|
152
147
|
ready do
|
@@ -176,18 +171,21 @@ module Middleman
|
|
176
171
|
end
|
177
172
|
|
178
173
|
# store configured port to make a check later on possible
|
179
|
-
configured_port = app.config
|
174
|
+
configured_port = possible_from_cli(:port, app.config)
|
180
175
|
|
181
176
|
# Use configuration values to set `bind_address` etc. in
|
182
177
|
# `server_information`
|
183
|
-
server_information.use app.config
|
178
|
+
server_information.use(bind_address: possible_from_cli(:bind_address, app.config),
|
179
|
+
port: possible_from_cli(:port, app.config),
|
180
|
+
server_name: possible_from_cli(:server_name, app.config),
|
181
|
+
https: possible_from_cli(:https, app.config))
|
184
182
|
|
185
|
-
app.logger.warn format('== The Middleman uses a different port "%s" then the configured one "%s" because some other server is listening on that port.', server_information.port, configured_port) unless
|
183
|
+
app.logger.warn format('== The Middleman uses a different port "%s" then the configured one "%s" because some other server is listening on that port.', server_information.port, configured_port) unless server_information.port == configured_port
|
186
184
|
|
187
|
-
@environment = app.config
|
185
|
+
@environment = possible_from_cli(:environment, app.config)
|
188
186
|
|
189
|
-
@ssl_certificate = app.config
|
190
|
-
@ssl_private_key = app.config
|
187
|
+
@ssl_certificate = possible_from_cli(:ssl_certificate, app.config)
|
188
|
+
@ssl_private_key = possible_from_cli(:ssl_private_key, app.config)
|
191
189
|
|
192
190
|
app.files.on_change :reload do
|
193
191
|
$mm_reload = true
|
@@ -203,6 +201,14 @@ module Middleman
|
|
203
201
|
app
|
204
202
|
end
|
205
203
|
|
204
|
+
def possible_from_cli(key, config)
|
205
|
+
if @cli_options[key] && @cli_options[key] != :undefined
|
206
|
+
@cli_options[key]
|
207
|
+
else
|
208
|
+
config[key]
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
206
212
|
# Trap some interupt signals and shut down smoothly
|
207
213
|
# @return [void]
|
208
214
|
def register_signal_handlers
|
@@ -23,7 +23,7 @@ module Middleman
|
|
23
23
|
attr_accessor :current_engine
|
24
24
|
|
25
25
|
# Shorthand references to global values on the app instance.
|
26
|
-
def_delegators :@app, :config, :logger, :sitemap, :server?, :build?, :environment?, :data, :extensions, :root
|
26
|
+
def_delegators :@app, :config, :logger, :sitemap, :server?, :build?, :environment?, :environment, :data, :extensions, :root
|
27
27
|
|
28
28
|
# Initialize a context with the current app and predefined locals and options hashes.
|
29
29
|
#
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'set'
|
2
|
+
|
1
3
|
module Middleman
|
2
4
|
module Util
|
3
5
|
include Contracts
|
@@ -52,9 +54,15 @@ module Middleman
|
|
52
54
|
result.encode('UTF-8', 'UTF-8-MAC')
|
53
55
|
end
|
54
56
|
|
57
|
+
Contract String => Bool
|
58
|
+
def tilt_recognizes?(path)
|
59
|
+
@@tilt_lookup_cache ||= {}
|
60
|
+
@@tilt_lookup_cache[path] ||= ::Tilt[path]
|
61
|
+
end
|
62
|
+
|
55
63
|
Contract String => String
|
56
64
|
def step_through_extensions(path)
|
57
|
-
while
|
65
|
+
while tilt_recognizes?(path)
|
58
66
|
ext = ::File.extname(path)
|
59
67
|
yield ext if block_given?
|
60
68
|
|
@@ -80,13 +88,18 @@ module Middleman
|
|
80
88
|
# @return [String]
|
81
89
|
Contract String => ArrayOf[String]
|
82
90
|
def collect_extensions(path)
|
83
|
-
|
91
|
+
@@extensions_cache ||= {}
|
84
92
|
|
85
|
-
|
93
|
+
base_name = ::File.basename(path)
|
94
|
+
@@extensions_cache[base_name] ||= begin
|
95
|
+
result = []
|
86
96
|
|
87
|
-
|
97
|
+
unless base_name.start_with?('.')
|
98
|
+
step_through_extensions(base_name) { |e| result << e }
|
99
|
+
end
|
88
100
|
|
89
|
-
|
101
|
+
result
|
102
|
+
end
|
90
103
|
end
|
91
104
|
|
92
105
|
# Finds files which should also be considered to be dirty when
|
@@ -99,8 +112,9 @@ module Middleman
|
|
99
112
|
def find_related_files(app, files)
|
100
113
|
return [] if files.empty?
|
101
114
|
|
102
|
-
|
115
|
+
file_set = ::Set.new(files)
|
103
116
|
|
117
|
+
all_extensions = files.flat_map { |f| collect_extensions(f.to_s) }
|
104
118
|
sass_type_aliasing = ['.scss', '.sass']
|
105
119
|
erb_type_aliasing = ['.erb', '.haml', '.slim']
|
106
120
|
|
@@ -109,14 +123,18 @@ module Middleman
|
|
109
123
|
|
110
124
|
all_extensions.uniq!
|
111
125
|
|
112
|
-
app.sitemap.resources.select
|
113
|
-
|
114
|
-
|
115
|
-
|
126
|
+
app.sitemap.resources.select { |r|
|
127
|
+
if r.file_descriptor
|
128
|
+
local_extensions = collect_extensions(r.file_descriptor[:full_path].to_s)
|
129
|
+
local_extensions |= sass_type_aliasing unless (local_extensions & sass_type_aliasing).empty?
|
130
|
+
local_extensions |= erb_type_aliasing unless (local_extensions & erb_type_aliasing).empty?
|
116
131
|
|
117
|
-
|
132
|
+
local_extensions.uniq!
|
118
133
|
|
119
|
-
|
134
|
+
!(all_extensions & local_extensions).empty? && !file_set.include?(r.file_descriptor[:full_path])
|
135
|
+
else
|
136
|
+
false
|
137
|
+
end
|
120
138
|
}.map(&:file_descriptor)
|
121
139
|
end
|
122
140
|
end
|
@@ -77,7 +77,11 @@ module Middleman
|
|
77
77
|
uri = URI(path)
|
78
78
|
path = uri.path
|
79
79
|
|
80
|
-
|
80
|
+
# Ensure the url we pass into find_resource_by_destination_path is not a
|
81
|
+
# relative path, since it only takes absolute url paths.
|
82
|
+
dest_path = url_for(app, path, options.merge(relative: false))
|
83
|
+
|
84
|
+
result = if resource = app.sitemap.find_resource_by_destination_path(dest_path)
|
81
85
|
resource.url
|
82
86
|
else
|
83
87
|
path = ::File.join(prefix, path)
|
@@ -22,7 +22,7 @@ module Middleman
|
|
22
22
|
|
23
23
|
Contract String, String, ArrayOf[String], Proc => String
|
24
24
|
def rewrite_paths(body, _path, exts, &_block)
|
25
|
-
matcher = /([\'\"\(,]\s*|# sourceMappingURL=)([^\s\'\"\)>]+(#{::Regexp.union(exts)}))/
|
25
|
+
matcher = /([\'\"\(,]\s*|# sourceMappingURL=)([^\s\'\"\)\(>]+(#{::Regexp.union(exts)}))/
|
26
26
|
|
27
27
|
url_fn_prefix = 'url('
|
28
28
|
|
@@ -120,6 +120,20 @@ describe Middleman::Util do
|
|
120
120
|
relative: true ) ).to eq '../images/blank.gif'
|
121
121
|
end
|
122
122
|
|
123
|
+
context "when the asset is stored in the same directory as current_resource" do
|
124
|
+
before do
|
125
|
+
Given.file 'source/a-path/index.html', ''
|
126
|
+
Given.file 'source/a-path/blank.gif', ''
|
127
|
+
@mm = Middleman::Application.new
|
128
|
+
end
|
129
|
+
|
130
|
+
it "returns path relative to the provided current_resource" do
|
131
|
+
current_resource = @mm.sitemap.find_resource_by_path('a-path/index.html')
|
132
|
+
expect( Middleman::Util.asset_url( @mm, 'blank.gif', 'images', current_resource: current_resource,
|
133
|
+
relative: true) ).to eq 'blank.gif'
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
123
137
|
it "raises error if not given a current_resource" do
|
124
138
|
expect{
|
125
139
|
Middleman::Util.asset_url( @mm, 'blank.gif', 'images', relative: true )
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Reynolds
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-03-
|
13
|
+
date: 2016-03-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -446,7 +446,9 @@ files:
|
|
446
446
|
- fixtures/asset-hash-host-app/source/stylesheets/site.css.scss
|
447
447
|
- fixtures/asset-hash-host-app/source/subdir/index.html.erb
|
448
448
|
- fixtures/asset-hash-minified-app/config.rb
|
449
|
+
- fixtures/asset-hash-minified-app/source/images/100px.jpg
|
449
450
|
- fixtures/asset-hash-minified-app/source/javascripts/jquery.min.js
|
451
|
+
- fixtures/asset-hash-minified-app/source/stylesheets/test.css
|
450
452
|
- fixtures/asset-hash-source-map/config.rb
|
451
453
|
- fixtures/asset-hash-source-map/lib/middleware.rb
|
452
454
|
- fixtures/asset-hash-source-map/source/index.html.erb
|
@@ -592,6 +594,7 @@ files:
|
|
592
594
|
- fixtures/dynamic-pages-app/source/should_be_ignored6.html
|
593
595
|
- fixtures/dynamic-pages-app/source/should_be_ignored7.html
|
594
596
|
- fixtures/dynamic-pages-app/source/should_be_ignored8.html
|
597
|
+
- fixtures/dynamic-pages-app/source/should_be_ignored9.html
|
595
598
|
- fixtures/ember-cli-app/config.rb
|
596
599
|
- fixtures/ember-cli-app/source/javascripts/file.js
|
597
600
|
- fixtures/ember-cli-app/test-app/.bowerrc
|
@@ -1601,7 +1604,9 @@ test_files:
|
|
1601
1604
|
- fixtures/asset-hash-host-app/source/stylesheets/site.css.scss
|
1602
1605
|
- fixtures/asset-hash-host-app/source/subdir/index.html.erb
|
1603
1606
|
- fixtures/asset-hash-minified-app/config.rb
|
1607
|
+
- fixtures/asset-hash-minified-app/source/images/100px.jpg
|
1604
1608
|
- fixtures/asset-hash-minified-app/source/javascripts/jquery.min.js
|
1609
|
+
- fixtures/asset-hash-minified-app/source/stylesheets/test.css
|
1605
1610
|
- fixtures/asset-hash-source-map/config.rb
|
1606
1611
|
- fixtures/asset-hash-source-map/lib/middleware.rb
|
1607
1612
|
- fixtures/asset-hash-source-map/source/index.html.erb
|
@@ -1747,6 +1752,7 @@ test_files:
|
|
1747
1752
|
- fixtures/dynamic-pages-app/source/should_be_ignored6.html
|
1748
1753
|
- fixtures/dynamic-pages-app/source/should_be_ignored7.html
|
1749
1754
|
- fixtures/dynamic-pages-app/source/should_be_ignored8.html
|
1755
|
+
- fixtures/dynamic-pages-app/source/should_be_ignored9.html
|
1750
1756
|
- fixtures/ember-cli-app/config.rb
|
1751
1757
|
- fixtures/ember-cli-app/source/javascripts/file.js
|
1752
1758
|
- fixtures/ember-cli-app/test-app/.bowerrc
|