middleman-core 4.3.2 → 4.3.3
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 +14 -0
- data/fixtures/asset-hash-remove-filename/config.rb +9 -0
- data/fixtures/asset-hash-remove-filename/source/index.html.erb +6 -0
- data/fixtures/asset-hash-remove-filename/source/javascripts/application.js +2 -0
- data/fixtures/asset-hash-remove-filename/source/javascripts/application.js.map +1 -0
- data/fixtures/asset-hash-remove-filename/source/layout.erb +17 -0
- data/lib/middleman-core/extensions/asset_hash.rb +15 -1
- data/lib/middleman-core/version.rb +1 -1
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61cbb0971519b39e43ab5691e5b7de36ef5c582c23378c667ab2cc059e3d006b
|
4
|
+
data.tar.gz: 277df7e8ba7b78e776212de95518611a920ca80a03fac4e373f8a5f1a7f75810
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31be3f47fc41353b3e58a70f4760baa81fc34f0ae1d8a6a08b88aefa9b1682e7b89bb3bb02409d916b945bf21b3e772cb39b911c7bdc26b2137d881181d9cc22
|
7
|
+
data.tar.gz: abd1e8c5ca18cb09484947d7241e44dccf93f02b0e20dec82b87e5d223c4e07a5839f9b7452994b98134f49f0a42514d06c8efd8e136f3dad4b477e9eccf098b
|
data/features/asset_hash.feature
CHANGED
@@ -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 @@
|
|
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
|
-
|
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
|
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.
|
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-
|
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
|