middleman-core 4.1.9 → 4.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bccc6ed0250ec6eca700de9c7a9fe08d002878d
4
- data.tar.gz: 74b10ad510adda189d3e9b4f138425b3243246f3
3
+ metadata.gz: 73f1ee44db78bc2bf335aac0e48af1ccc5915dd0
4
+ data.tar.gz: b6b8fae3d1af952639ed6b1c897a4d256f26e698
5
5
  SHA512:
6
- metadata.gz: a9a907fc76debe6f613ab50ed3e061db1aa2e4cb6f4841c92a2a0ca5674231e608f10da5dca677e683b1a53ac2e9f06d88f55c35e0fce6d824408ef35ba86709
7
- data.tar.gz: add958d204c4d9265d5407b5cb5f66e3e41fd8ea948bab1b4cf0d226343cfe65b61918df21ce55b87eeba34c1d5a03f1285c8dfb3deeb05712f0e58627826902
6
+ metadata.gz: 5e206d7f48ffcb3b24d394c4fa9ca52432fab4787bfa8ef64b50498bb45cb1ed19ea7db4aa2164818b9e70aa12bb59a71077f44745c1088c9272eac22462b54c
7
+ data.tar.gz: 391d5447bdfd1fcdde64dba7298fcd5085d360c1697b3027eea728eb326b721b5384f7c74c295f0ffd57603fc33dcd6047efdb394c065fca3096100d8ed4f676
@@ -308,3 +308,17 @@ Feature: Assets get file hashes appended to them and references to them are upda
308
308
  | javascripts/application.js.map |
309
309
 
310
310
  And the file "javascripts/application-4553338c.js" should contain "//# sourceMappingURL=application.js-22cc2b5f.map"
311
+
312
+ Scenario: Hashes can contain a prefix
313
+ Given a successfully built app at "asset-hash-prefix"
314
+ When I cd to "build"
315
+ Then the following files should exist:
316
+ | index.html |
317
+ | javascripts/application-myprefix-4553338c.js |
318
+ | javascripts/application.js-myprefix-22cc2b5f.map |
319
+ | index.html |
320
+ And the following files should not exist:
321
+ | javascripts/application.js |
322
+ | javascripts/application.js.map |
323
+
324
+ And the file "javascripts/application-myprefix-4553338c.js" should contain "//# sourceMappingURL=application.js-myprefix-22cc2b5f.map"
@@ -0,0 +1,7 @@
1
+
2
+ activate :asset_hash,
3
+ prefix: "myprefix-"
4
+
5
+ activate :relative_assets
6
+
7
+ activate :directory_indexes
@@ -0,0 +1,16 @@
1
+ class Middleware
2
+ def initialize(app)
3
+ @app = app
4
+ end
5
+
6
+ def call(env)
7
+ status, headers, response = @app.call(env)
8
+ body = ''
9
+ response.each {|part| body += part }
10
+ if (env["PATH_INFO"] =~ /css$/)
11
+ body += "\n/* Added by Rack filter */"
12
+ status, headers, response = Rack::Response.new(body, status, headers).finish
13
+ end
14
+ [status, headers, response]
15
+ end
16
+ end
@@ -0,0 +1,6 @@
1
+ <% content_for :head do %>
2
+ <title>The Middleman!</title>
3
+ <% end %>
4
+
5
+ <h1>Testing the sitemap hashing</h1>
6
+ <br /><br /><br />
@@ -0,0 +1,2 @@
1
+ function foo(){var message="HEY THERE FRIEND!";var para=document.createElement("p");para.innerHTML=message;var body=document.getElementsByTagName("body")[0];body.insertBefore(para,body.firstChild)}window.onload=foo;
2
+ //# sourceMappingURL=application.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["source/javascripts/application.js"],"names":["foo","message","para","document","createElement","innerHTML","body","getElementsByTagName","insertBefore","firstChild","window","onload"],"mappings":"AAAA,QAASA,OACP,GAAIC,SAAU,mBACd,IAAIC,MAAOC,SAASC,cAAc,IAClCF,MAAKG,UAAYJ,OACb,IAAIK,MAAOH,SAASI,qBAAqB,QAAQ,EAC/CD,MAAKE,aAAaN,KAAMI,KAAKG,YAGpCC,OAAOC,OAASX"}
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+
6
+ <%= javascript_include_tag "application" %>
7
+ <%= yield_content :head %>
8
+ </head>
9
+
10
+ <body class="<%= page_classes %>">
11
+
12
+ <div id="main" role="main">
13
+ <%= yield %>
14
+ </div>
15
+
16
+ </body>
17
+ </html>
@@ -6,6 +6,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
6
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
+ option :prefix, '', 'Prefix for hash'
9
10
 
10
11
  def initialize(app, options_hash={}, &block)
11
12
  super
@@ -92,7 +93,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
92
93
  ::Digest::SHA1.hexdigest(response.body)[0..7]
93
94
  end
94
95
 
95
- resource.destination_path = resource.destination_path.sub(/\.(\w+)$/) { |ext| "-#{digest}#{ext}" }
96
+ resource.destination_path = resource.destination_path.sub(/\.(\w+)$/) { |ext| "-#{options.prefix}#{digest}#{ext}" }
96
97
  resource
97
98
  end
98
99
 
@@ -11,9 +11,7 @@ class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
11
11
  def initialize(app, options_hash={}, &block)
12
12
  super
13
13
 
14
- if options[:helpers_only]
15
- return
16
- end
14
+ return if options[:helpers_only]
17
15
 
18
16
  app.rewrite_inline_urls id: :relative_assets,
19
17
  url_extensions: options.exts || app.config[:asset_extensions],
@@ -53,7 +51,7 @@ class Middleman::Extensions::RelativeAssets < ::Middleman::Extension
53
51
  end
54
52
 
55
53
  def asset_path(kind, source, options={})
56
- super(kind, source, app.extensions[:relative_assets].mark_as_relative(super, options, current_resource))
54
+ super(kind, source, app.extensions[:relative_assets].mark_as_relative(super, options, current_resource))
57
55
  end
58
56
  end
59
57
 
@@ -105,10 +105,8 @@ module Middleman
105
105
  end
106
106
  end
107
107
 
108
- SASS_MODULE = if defined?(::SassC)
109
- ::SassC
110
- else
111
- ::Sass
108
+ if defined?(::SassC)
109
+ ::SassC::Script::Functions.send :include, ::Middleman::Sass::Functions
110
+ elsif defined?(::Sass)
111
+ ::Sass::Script::Functions.send :include, ::Middleman::Sass::Functions
112
112
  end
113
-
114
- SASS_MODULE::Script::Functions.send :include, ::Middleman::Sass::Functions
@@ -53,8 +53,7 @@ module Middleman
53
53
  def render(*)
54
54
  url = ::Middleman::Util.url_for(@store.app, @request_path,
55
55
  relative: false,
56
- find_resource: true
57
- )
56
+ find_resource: true)
58
57
 
59
58
  if output
60
59
  output.call(path, url)
@@ -163,7 +163,7 @@ module Middleman
163
163
  wait_for_delay: 0.5
164
164
  }
165
165
 
166
- config[:latency] = @latency if @latency
166
+ config[:latency] = @latency.to_i if @latency
167
167
 
168
168
  @listener = ::Listen.to(@directory.to_s, config, &method(:on_listener_change))
169
169
 
@@ -138,18 +138,16 @@ module Middleman
138
138
  relative_dir_no_underscore = current_dir + Pathname(non_root_no_underscore)
139
139
  end
140
140
 
141
-
142
- lookup_stack.push [ relative_dir.to_s,
143
- { preferred_engine: resource.file_descriptor[:relative_path]
144
- .extname[1..-1].to_sym }] if relative_dir
145
- lookup_stack.push [ non_root ]
146
- lookup_stack.push [ non_root,
147
- { try_static: try_static }]
148
- lookup_stack.push [ relative_dir_no_underscore.to_s,
149
- { try_static: try_static }] if relative_dir_no_underscore
150
- lookup_stack.push [ non_root_no_underscore,
151
- { try_static: try_static }]
152
-
141
+ lookup_stack.push [relative_dir.to_s,
142
+ { preferred_engine: resource.file_descriptor[:relative_path]
143
+ .extname[1..-1].to_sym }] if relative_dir
144
+ lookup_stack.push [non_root]
145
+ lookup_stack.push [non_root,
146
+ { try_static: try_static }]
147
+ lookup_stack.push [relative_dir_no_underscore.to_s,
148
+ { try_static: try_static }] if relative_dir_no_underscore
149
+ lookup_stack.push [non_root_no_underscore,
150
+ { try_static: try_static }]
153
151
 
154
152
  lookup_stack.each do |args|
155
153
  partial_file = ::Middleman::TemplateRenderer.resolve_template(@app, *args)
@@ -47,14 +47,13 @@ module Middleman
47
47
  # @return [Boolean]
48
48
  Contract String => Bool
49
49
  def nonbinary_mime?(mime)
50
- case
51
- when mime.start_with?('text/')
50
+ if mime.start_with?('text/')
52
51
  true
53
- when mime.include?('xml') && !mime.include?('officedocument')
52
+ elsif mime.include?('xml') && !mime.include?('officedocument')
54
53
  true
55
- when mime.include?('json')
54
+ elsif mime.include?('json')
56
55
  true
57
- when mime.include?('javascript')
56
+ elsif mime.include?('javascript')
58
57
  true
59
58
  else
60
59
  false
@@ -94,7 +94,7 @@ module Middleman
94
94
  .transpose
95
95
  .map(&::Regexp.method(:union))
96
96
 
97
- match = /
97
+ /
98
98
  \A(?:[^\r\n]*coding:[^\r\n]*\r?\n)?
99
99
  (?<start>#{start_delims})[ ]*\r?\n
100
100
  (?<frontmatter>.*?)[ ]*\r?\n?
@@ -1,8 +1,8 @@
1
1
  # Core Pathname library used for traversal
2
2
  require 'pathname'
3
3
  require 'uri'
4
- require 'memoist'
5
4
  require 'addressable'
5
+ require 'memoist'
6
6
  require 'tilt'
7
7
 
8
8
  require 'middleman-core/contracts'
@@ -32,9 +32,9 @@ module Middleman
32
32
  # @return [String]
33
33
  Contract String => String
34
34
  def normalize_path(path)
35
- # The tr call works around a bug in Ruby's Unicode handling
35
+ # The tr call works around a bug in Ruby's Unicode handling
36
36
  ::URI.decode(path).sub(%r{^/}, '').tr('', '')
37
- end
37
+ end
38
38
  memoize :normalize_path
39
39
 
40
40
  # This is a separate method from normalize_path in case we
@@ -111,7 +111,7 @@ module Middleman
111
111
  raise ArgumentError, '#asset_url must be run in a context with current_resource if relative: true'
112
112
  end
113
113
 
114
- uri = URI(path)
114
+ uri = ::Middleman::Util.parse_uri(path)
115
115
  path = uri.path
116
116
 
117
117
  # Ensure the url we pass into find_resource_by_destination_path is not a
@@ -131,9 +131,15 @@ module Middleman
131
131
  end
132
132
  end
133
133
 
134
- final_result = ::URI.encode(relative_path_from_resource(options[:current_resource], result, options[:relative]))
134
+ final_result = ::Addressable::URI.encode(
135
+ relative_path_from_resource(
136
+ options[:current_resource],
137
+ result,
138
+ options[:relative]
139
+ )
140
+ )
135
141
 
136
- result_uri = URI(final_result)
142
+ result_uri = ::Middleman::Util.parse_uri(final_result)
137
143
  result_uri.query = uri.query
138
144
  result_uri.fragment = uri.fragment
139
145
  result_uri.to_s
@@ -158,14 +164,10 @@ module Middleman
158
164
 
159
165
  # Try to parse URL
160
166
  begin
161
- uri = URI(url)
162
- rescue ::URI::InvalidURIError
163
- begin
164
- uri = URI(::URI.encode(url))
165
- rescue ::URI::InvalidURIError
166
- # Nothing we can do with it, it's not really a URI
167
- return url
168
- end
167
+ uri = ::Middleman::Util.parse_uri(url)
168
+ rescue ::Addressable::URI::InvalidURIError
169
+ # Nothing we can do with it, it's not really a URI
170
+ return url
169
171
  end
170
172
 
171
173
  relative = options[:relative]
@@ -206,7 +208,13 @@ module Middleman
206
208
 
207
209
  if resource
208
210
  uri.path = if this_resource
209
- ::URI.encode(relative_path_from_resource(this_resource, resource_url, effective_relative))
211
+ ::Addressable::URI.encode(
212
+ relative_path_from_resource(
213
+ this_resource,
214
+ resource_url,
215
+ effective_relative
216
+ )
217
+ )
210
218
  else
211
219
  resource_url
212
220
  end
@@ -284,16 +292,15 @@ module Middleman
284
292
  # @return [Boolean] Whether the path matches the matcher
285
293
  Contract PATH_MATCHER, String => Bool
286
294
  def path_match(matcher, path)
287
- case
288
- when matcher.is_a?(String)
295
+ if matcher.is_a?(String)
289
296
  if matcher.include? '*'
290
297
  ::File.fnmatch(matcher, path)
291
298
  else
292
299
  path == matcher
293
300
  end
294
- when matcher.respond_to?(:match)
301
+ elsif matcher.respond_to?(:match)
295
302
  !!(path =~ matcher)
296
- when matcher.respond_to?(:call)
303
+ elsif matcher.respond_to?(:call)
297
304
  matcher.call(path)
298
305
  else
299
306
  ::File.fnmatch(matcher.to_s, path)
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  # Current Version
3
3
  # @return [String]
4
- VERSION = '4.1.9'.freeze unless const_defined?(:VERSION)
4
+ VERSION = '4.1.10'.freeze unless const_defined?(:VERSION)
5
5
  end
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.9
4
+ version: 4.1.10
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-05-31 00:00:00.000000000 Z
13
+ date: 2016-07-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -495,6 +495,12 @@ files:
495
495
  - fixtures/asset-hash-minified-app/source/images/100px.jpg
496
496
  - fixtures/asset-hash-minified-app/source/javascripts/jquery.min.js
497
497
  - fixtures/asset-hash-minified-app/source/stylesheets/test.css
498
+ - fixtures/asset-hash-prefix/config.rb
499
+ - fixtures/asset-hash-prefix/lib/middleware.rb
500
+ - fixtures/asset-hash-prefix/source/index.html.erb
501
+ - fixtures/asset-hash-prefix/source/javascripts/application.js
502
+ - fixtures/asset-hash-prefix/source/javascripts/application.js.map
503
+ - fixtures/asset-hash-prefix/source/layout.erb
498
504
  - fixtures/asset-hash-source-map/config.rb
499
505
  - fixtures/asset-hash-source-map/lib/middleware.rb
500
506
  - fixtures/asset-hash-source-map/source/index.html.erb
@@ -1695,6 +1701,12 @@ test_files:
1695
1701
  - fixtures/asset-hash-minified-app/source/images/100px.jpg
1696
1702
  - fixtures/asset-hash-minified-app/source/javascripts/jquery.min.js
1697
1703
  - fixtures/asset-hash-minified-app/source/stylesheets/test.css
1704
+ - fixtures/asset-hash-prefix/config.rb
1705
+ - fixtures/asset-hash-prefix/lib/middleware.rb
1706
+ - fixtures/asset-hash-prefix/source/index.html.erb
1707
+ - fixtures/asset-hash-prefix/source/javascripts/application.js
1708
+ - fixtures/asset-hash-prefix/source/javascripts/application.js.map
1709
+ - fixtures/asset-hash-prefix/source/layout.erb
1698
1710
  - fixtures/asset-hash-source-map/config.rb
1699
1711
  - fixtures/asset-hash-source-map/lib/middleware.rb
1700
1712
  - fixtures/asset-hash-source-map/source/index.html.erb