middleman-core 4.3.2 → 4.3.3

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
  SHA256:
3
- metadata.gz: fb75ea4ac0afae1968d76af0348066991e0fe4d6be8b7554cb0fd57744da8ae5
4
- data.tar.gz: a01a7220b19626efe15591e61c98b7698b6ab92d9be9734f6044e1a3fe7ae52e
3
+ metadata.gz: 61cbb0971519b39e43ab5691e5b7de36ef5c582c23378c667ab2cc059e3d006b
4
+ data.tar.gz: 277df7e8ba7b78e776212de95518611a920ca80a03fac4e373f8a5f1a7f75810
5
5
  SHA512:
6
- metadata.gz: fde264ab5c1cfce6903ebe2cd32e461ce6aef586085cf10b3c1bb2d2bc7fb7c1423094032c7f4a2fbea57ef3f0037ff2cb7e354ccacff80bee87a4b77aff6cda
7
- data.tar.gz: ad5160848a55cc8353856d0ad556d6e14dbac20f62f29c71886fa67d29334412d892fcdf070e0d3ec6ea4541f1c58efefff9e5371c085968206e80ecfded7d2c
6
+ metadata.gz: 31be3f47fc41353b3e58a70f4760baa81fc34f0ae1d8a6a08b88aefa9b1682e7b89bb3bb02409d916b945bf21b3e772cb39b911c7bdc26b2137d881181d9cc22
7
+ data.tar.gz: abd1e8c5ca18cb09484947d7241e44dccf93f02b0e20dec82b87e5d223c4e07a5839f9b7452994b98134f49f0a42514d06c8efd8e136f3dad4b477e9eccf098b
@@ -322,3 +322,17 @@ Feature: Assets get file hashes appended to them and references to them are upda
322
322
  | javascripts/application.js.map |
323
323
 
324
324
  And the file "javascripts/application-myprefix-4553338c.js" should contain "//# sourceMappingURL=application.js-myprefix-22cc2b5f.map"
325
+
326
+ Scenario: Filenames can be removed by option
327
+ Given a successfully built app at "asset-hash-remove-filename"
328
+ When I cd to "build"
329
+ Then the following files should exist:
330
+ | index.html |
331
+ | javascripts/4553338c.js |
332
+ | javascripts/22cc2b5f.map |
333
+ | index.html |
334
+ And the following files should not exist:
335
+ | javascripts/application.js |
336
+ | javascripts/application.js.map |
337
+
338
+ And the file "javascripts/4553338c.js" should contain "//# sourceMappingURL=22cc2b5f.map"
@@ -0,0 +1,9 @@
1
+
2
+ activate :asset_hash,
3
+ rename_proc: lambda { |path, _basename, digest, extension, _options|
4
+ "#{path}#{digest}#{extension}"
5
+ }
6
+
7
+ activate :relative_assets
8
+
9
+ activate :directory_indexes
@@ -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>
@@ -7,6 +7,9 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
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
  option :prefix, '', 'Prefix for hash'
10
+ option :rename_proc, proc { |path, basename, digest, extension, options|
11
+ "#{path}#{basename}-#{options.prefix}#{digest}#{extension}"
12
+ }, 'Accepts path parameters and returns path name'
10
13
 
11
14
  def initialize(app, options_hash={}, &block)
12
15
  super
@@ -93,7 +96,8 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
93
96
  ::Digest::SHA1.hexdigest(response.body)[0..7]
94
97
  end
95
98
 
96
- resource.destination_path = resource.destination_path.sub(/\.(\w+)$/) { |ext| "-#{options.prefix}#{digest}#{ext}" }
99
+ path, basename, extension = split_path(resource.destination_path)
100
+ resource.destination_path = options.rename_proc.call(path, basename, digest, extension, options)
97
101
  resource
98
102
  end
99
103
 
@@ -103,4 +107,14 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
103
107
  Middleman::Util.path_match(ignore, resource.destination_path)
104
108
  end
105
109
  end
110
+
111
+ private
112
+
113
+ # Splits resource path into path, basename and extension
114
+ # (e.g. "/images/landscape.png" => ["/images/", "landscape", ".png]
115
+ def split_path(filepath)
116
+ basename = File.basename(filepath, extension = File.extname(filepath))
117
+ path = filepath.chomp(basename + extension)
118
+ [path, basename, extension]
119
+ end
106
120
  end
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  # Current Version
3
3
  # @return [String]
4
- VERSION = '4.3.2'.freeze unless const_defined?(:VERSION)
4
+ VERSION = '4.3.3'.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.3.2
4
+ version: 4.3.3
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: 2019-01-16 00:00:00.000000000 Z
13
+ date: 2019-02-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -492,6 +492,11 @@ files:
492
492
  - fixtures/asset-hash-prefix/source/javascripts/application.js
493
493
  - fixtures/asset-hash-prefix/source/javascripts/application.js.map
494
494
  - fixtures/asset-hash-prefix/source/layout.erb
495
+ - fixtures/asset-hash-remove-filename/config.rb
496
+ - fixtures/asset-hash-remove-filename/source/index.html.erb
497
+ - fixtures/asset-hash-remove-filename/source/javascripts/application.js
498
+ - fixtures/asset-hash-remove-filename/source/javascripts/application.js.map
499
+ - fixtures/asset-hash-remove-filename/source/layout.erb
495
500
  - fixtures/asset-hash-source-map/config.rb
496
501
  - fixtures/asset-hash-source-map/lib/middleware.rb
497
502
  - fixtures/asset-hash-source-map/source/index.html.erb
@@ -1696,6 +1701,11 @@ test_files:
1696
1701
  - fixtures/asset-hash-prefix/source/javascripts/application.js
1697
1702
  - fixtures/asset-hash-prefix/source/javascripts/application.js.map
1698
1703
  - fixtures/asset-hash-prefix/source/layout.erb
1704
+ - fixtures/asset-hash-remove-filename/config.rb
1705
+ - fixtures/asset-hash-remove-filename/source/index.html.erb
1706
+ - fixtures/asset-hash-remove-filename/source/javascripts/application.js
1707
+ - fixtures/asset-hash-remove-filename/source/javascripts/application.js.map
1708
+ - fixtures/asset-hash-remove-filename/source/layout.erb
1699
1709
  - fixtures/asset-hash-source-map/config.rb
1700
1710
  - fixtures/asset-hash-source-map/lib/middleware.rb
1701
1711
  - fixtures/asset-hash-source-map/source/index.html.erb