middleman-core 4.3.2 → 4.3.7

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: a62bb451348c77bfb582a6fd7a97f8913c30e1602e256bb307672e022bfcc314
4
+ data.tar.gz: 83fe52a59f84380ad4eb754d00c79754eeb546ed3f15fa15f47603d0740e72b5
5
5
  SHA512:
6
- metadata.gz: fde264ab5c1cfce6903ebe2cd32e461ce6aef586085cf10b3c1bb2d2bc7fb7c1423094032c7f4a2fbea57ef3f0037ff2cb7e354ccacff80bee87a4b77aff6cda
7
- data.tar.gz: ad5160848a55cc8353856d0ad556d6e14dbac20f62f29c71886fa67d29334412d892fcdf070e0d3ec6ea4541f1c58efefff9e5371c085968206e80ecfded7d2c
6
+ metadata.gz: 33de280861e5d60ef103a6abb8fd1602dc7c36899dc08731a63975049c96961c5e0e8bda083b14a40d1638f08c614dcd903799d15ffa550a39d3e276287f74ae
7
+ data.tar.gz: 5e42f113d14f5dcd70276bfb548ed6c2f8d38ce889e1fbd4f35f6407d906827b46132e156c152f80c77de4b93afc8df65f6f381c4292fd569d0922145cc50c8e
@@ -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,11 @@
1
+ Feature: Add an empty alt tag for images that don't have alt tags specified
2
+
3
+ Scenario: Image does not have alt tag specified
4
+ Given the Server is running at "default-alt-tags-app"
5
+ When I go to "/empty-alt-tag.html"
6
+ Then I should see 'alt=""'
7
+
8
+ Scenario: Image has alt tag specified
9
+ Given the Server is running at "default-alt-tags-app"
10
+ When I go to "/meaningful-alt-tag.html"
11
+ Then I should see 'alt="Meaningful alt text"'
@@ -178,6 +178,7 @@ Feature: i18n Paths
178
178
 
179
179
  Current: <%= url_for "/article.html" %>
180
180
  Other: <%= url_for "/article.html", locale: ::I18n.locale == :en ? :es : :en %>
181
+ Current with anchor: <%= url_for "/article.html", :anchor => "test-anchor" %>
181
182
  """
182
183
  And a file named "source/localizable/article.es.html.erb" with:
183
184
  """
@@ -185,6 +186,7 @@ Feature: i18n Paths
185
186
 
186
187
  Current: <%= url_for "/article.html" %>
187
188
  Other: <%= url_for "/article.html", locale: :en %>
189
+ Current with anchor: <%= url_for "/article.html", :anchor => "test-anchor" %>
188
190
  """
189
191
  And a file named "config.rb" with:
190
192
  """
@@ -203,7 +205,9 @@ Feature: i18n Paths
203
205
  Then I should see "Page Lang: Default"
204
206
  Then I should see 'Current: /article.html'
205
207
  Then I should see 'Other: /es/article.html'
208
+ Then I should see 'Current with anchor: /article.html#test-anchor'
206
209
  When I go to "/es/article.html"
207
210
  Then I should see "Page Lang: Spanish"
208
211
  Then I should see 'Current: /es/article.html'
209
212
  Then I should see 'Other: /article.html'
213
+ Then I should see 'Current with anchor: /es/article.html#test-anchor'
@@ -7,11 +7,12 @@ Feature: Ignoring paths
7
7
  ignore 'plain.html'
8
8
  """
9
9
  And a successfully built app at "ignore-app"
10
+ When I cd to "build"
10
11
  Then the following files should exist:
11
- | build/index.html |
12
+ | index.html |
12
13
  And the following files should not exist:
13
- | build/plain.html |
14
- | build/about.html |
14
+ | plain.html |
15
+ | about.html |
15
16
 
16
17
  Scenario: Ignore a single path (server)
17
18
  Given a fixture app "ignore-app"
@@ -66,16 +67,17 @@ Feature: Ignoring paths
66
67
  ignore 'images/**/*.png'
67
68
  """
68
69
  And a successfully built app at "ignore-app"
70
+ When I cd to "build"
69
71
  Then the following files should exist:
70
- | build/plain.html |
71
- | build/images/portrait.jpg |
72
- | build/images/pic.png |
72
+ | plain.html |
73
+ | images/portrait.jpg |
74
+ | images/pic.png |
73
75
  And the following files should not exist:
74
- | build/about.html |
75
- | build/index.html |
76
- | build/reports/index.html |
77
- | build/reports/another.html |
78
- | build/images/icons/messages.png |
76
+ | about.html |
77
+ | index.html |
78
+ | reports/index.html |
79
+ | reports/another.html |
80
+ | images/icons/messages.png |
79
81
 
80
82
  Scenario: Ignore a globbed path (server)
81
83
  Given a fixture app "ignore-app"
@@ -148,3 +150,57 @@ Feature: Ignoring paths
148
150
  Then I should see "File Not Found"
149
151
  When I go to "/images/icons/messages.png"
150
152
  Then I should see "File Not Found"
153
+
154
+ Scenario: Ignore localized templates (build)
155
+ Given a fixture app "i18n-test-app"
156
+ And a file named "config.rb" with:
157
+ """
158
+ activate :i18n
159
+ ignore 'localizable/hello.html.erb'
160
+ ignore /morning/
161
+ ignore 'localizable/*.md'
162
+ """
163
+ And a successfully built app at "i18n-test-app"
164
+ When I cd to "build"
165
+ Then the following files should exist:
166
+ | index.html |
167
+ | es/index.html |
168
+ And the following files should not exist:
169
+ | hello.html |
170
+ | morning.html |
171
+ | one.html |
172
+ | es/hola.html |
173
+ | es/manana.html |
174
+ | es/una.html |
175
+ | es/hello.html |
176
+ | es/morning.html |
177
+ | es/one.html |
178
+ And the file "index.html" should contain "Howdy"
179
+ And the file "es/index.html" should contain "Como Esta?"
180
+
181
+ Scenario: Ignore localized templates (server)
182
+ Given a fixture app "i18n-test-app"
183
+ And a file named "config.rb" with:
184
+ """
185
+ activate :i18n
186
+ ignore 'localizable/hello.html.erb'
187
+ ignore /morning/
188
+ ignore 'localizable/*.md'
189
+ """
190
+ And the Server is running
191
+ When I go to "/index.html"
192
+ Then I should not see "File Not Found"
193
+ When I go to "/es/index.html"
194
+ Then I should not see "File Not Found"
195
+ When I go to "/hello.html"
196
+ Then I should see "File Not Found"
197
+ When I go to "/morning.html"
198
+ Then I should see "File Not Found"
199
+ When I go to "/one.html"
200
+ Then I should see "File Not Found"
201
+ When I go to "/es/hola.html"
202
+ Then I should see "File Not Found"
203
+ When I go to "/es/manana.html"
204
+ Then I should see "File Not Found"
205
+ When I go to "/es/una.html"
206
+ Then I should see "File Not Found"
@@ -36,3 +36,20 @@ Feature: Markdown (Kramdown) support
36
36
  And I should see 'src="/images/blank.gif"'
37
37
  And I should see 'src="/images/blank.gif"'
38
38
  And I should see "&#109;&#097;&#105;&#108;&#064;&#109;&#097;&#105;&#108;&#046;&#099;&#111;&#109;"
39
+
40
+ Scenario: Kramdown uses our link_to with options parameter
41
+ Given a fixture app "markdown-app"
42
+ And a file named "config.rb" with:
43
+ """
44
+ set :markdown_engine, :kramdown
45
+ activate :directory_indexes
46
+ """
47
+ And a file named "source/links.html.markdown" with:
48
+ """
49
+ [A link](/smarty_pants.html)
50
+ [A second link](/smarty_pants.html){: anchor="test-anchor"}
51
+ """
52
+ Given the Server is running at "markdown-app"
53
+ When I go to "/links/"
54
+ Then I should see "/smarty_pants/"
55
+ And I should see "/smarty_pants/#test-anchor"
@@ -131,7 +131,7 @@ Feature: Relative Assets
131
131
  """
132
132
  And the Server is running at "relative-assets-app"
133
133
  When I go to "/sub/image_tag.html"
134
- Then I should see '<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />'
134
+ Then I should see '<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="" />'
135
135
 
136
136
  Scenario: URLs are not rewritten for rewrite ignored paths
137
137
  Given a fixture app "relative-assets-app"
@@ -87,7 +87,7 @@ Feature: Relative Assets (Helpers Only)
87
87
  """
88
88
  And the Server is running at "relative-assets-app"
89
89
  When I go to "/sub/image_tag.html"
90
- Then I should see '<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" />'
90
+ Then I should see '<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" alt="" />'
91
91
 
92
92
  @wip
93
93
  Scenario: URLs are not rewritten for rewrite ignored paths
@@ -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>
@@ -0,0 +1 @@
1
+ <%= image_tag "blank.gif" %>
@@ -0,0 +1 @@
1
+ <%= image_tag "blank.gif", alt: "Meaningful alt text" %>
@@ -282,6 +282,8 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
282
282
  params[:srcset] = images_sources.join(', ')
283
283
  end
284
284
 
285
+ params[:alt] ||= ''
286
+
285
287
  super(path, params)
286
288
  end
287
289
 
@@ -74,8 +74,12 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
74
74
  opts = options.dup
75
75
 
76
76
  should_relativize = opts.key?(:relative) ? opts[:relative] : config[:relative_links]
77
+ anchor = opts[:anchor]
77
78
 
79
+ # The first call to `super()` is only to find the correct URL. The next
80
+ # call will relativize and add the anchor.
78
81
  opts[:relative] = false
82
+ opts[:anchor] = nil
79
83
 
80
84
  href = super(path_or_resource, opts)
81
85
 
@@ -87,6 +91,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
87
91
  end
88
92
 
89
93
  opts[:relative] = should_relativize
94
+ opts[:anchor] = anchor
90
95
 
91
96
  begin
92
97
  super(final_path, opts)
@@ -155,6 +160,8 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
155
160
 
156
161
  # If it's a "localizable template"
157
162
  localizable_folder_resources.each do |resource|
163
+ next if resource.ignored?
164
+
158
165
  page_id = File.basename(resource.path, File.extname(resource.path))
159
166
  locales.each do |locale|
160
167
  # Remove folder name
@@ -174,6 +181,8 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
174
181
 
175
182
  # If it uses file extension localization
176
183
  file_extension_resources.each do |resource|
184
+ next if resource.ignored?
185
+
177
186
  result = parse_locale_extension(resource.path)
178
187
  ext_locale, path, page_id = result
179
188
  new_resources << build_resource(path, resource.path, page_id, ext_locale)
@@ -123,6 +123,11 @@ module Middleman
123
123
  end
124
124
  end
125
125
 
126
+ # Rewriting might have changed Content-Length, so we need
127
+ # to reset it to the actual result. The rewritten result is
128
+ # always a String, not an Array or Enumerable.
129
+ headers['Content-Length'] = rewritten.bytesize.to_s
130
+
126
131
  ::Rack::Response.new(
127
132
  rewritten,
128
133
  status,
@@ -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
@@ -45,6 +45,10 @@ module Middleman
45
45
  attr = el.attr.dup
46
46
  link = attr.delete('href')
47
47
 
48
+ # options to link_to are expected to be symbols, but in Markdown
49
+ # everything is a string.
50
+ attr.transform_keys!(&:to_sym)
51
+
48
52
  scope.link_to(content, link, attr)
49
53
  end
50
54
  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.7'.freeze unless const_defined?(:VERSION)
5
5
  end
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
29
29
  s.add_dependency('dotenv')
30
30
 
31
31
  # Helpers
32
- s.add_dependency('activesupport', ['>= 4.2', '< 5.1'])
32
+ s.add_dependency('activesupport', ['>= 4.2', '< 6.0'])
33
33
  s.add_dependency('padrino-helpers', ['~> 0.13.0'])
34
34
  s.add_dependency("addressable", ["~> 2.3"])
35
35
  s.add_dependency('memoist', ['~> 0.14'])
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.7
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: 2020-05-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -139,7 +139,7 @@ dependencies:
139
139
  version: '4.2'
140
140
  - - "<"
141
141
  - !ruby/object:Gem::Version
142
- version: '5.1'
142
+ version: '6.0'
143
143
  type: :runtime
144
144
  prerelease: false
145
145
  version_requirements: !ruby/object:Gem::Requirement
@@ -149,7 +149,7 @@ dependencies:
149
149
  version: '4.2'
150
150
  - - "<"
151
151
  - !ruby/object:Gem::Version
152
- version: '5.1'
152
+ version: '6.0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: padrino-helpers
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -370,6 +370,7 @@ files:
370
370
  - features/custom_layouts.feature
371
371
  - features/data.feature
372
372
  - features/default-layout.feature
373
+ - features/default_alt_tag.feature
373
374
  - features/directory_index.feature
374
375
  - features/dynamic_pages.feature
375
376
  - features/encoding_option.feature
@@ -492,6 +493,11 @@ files:
492
493
  - fixtures/asset-hash-prefix/source/javascripts/application.js
493
494
  - fixtures/asset-hash-prefix/source/javascripts/application.js.map
494
495
  - fixtures/asset-hash-prefix/source/layout.erb
496
+ - fixtures/asset-hash-remove-filename/config.rb
497
+ - fixtures/asset-hash-remove-filename/source/index.html.erb
498
+ - fixtures/asset-hash-remove-filename/source/javascripts/application.js
499
+ - fixtures/asset-hash-remove-filename/source/javascripts/application.js.map
500
+ - fixtures/asset-hash-remove-filename/source/layout.erb
495
501
  - fixtures/asset-hash-source-map/config.rb
496
502
  - fixtures/asset-hash-source-map/lib/middleware.rb
497
503
  - fixtures/asset-hash-source-map/source/index.html.erb
@@ -653,6 +659,10 @@ files:
653
659
  - fixtures/data-app/data/pages.yml
654
660
  - fixtures/data-app/source/index.html.erb
655
661
  - fixtures/data-app/source/layout.erb
662
+ - fixtures/default-alt-tags-app/config.rb
663
+ - fixtures/default-alt-tags-app/source/empty-alt-tag.html.erb
664
+ - fixtures/default-alt-tags-app/source/images/blank.gif
665
+ - fixtures/default-alt-tags-app/source/meaningful-alt-tag.html.erb
656
666
  - fixtures/different-engine-layout/config.rb
657
667
  - fixtures/different-engine-layout/source/index.haml
658
668
  - fixtures/different-engine-layout/source/index.html.str
@@ -1548,7 +1558,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1548
1558
  - !ruby/object:Gem::Version
1549
1559
  version: '0'
1550
1560
  requirements: []
1551
- rubygems_version: 3.0.2
1561
+ rubygems_version: 3.0.6
1552
1562
  signing_key:
1553
1563
  specification_version: 4
1554
1564
  summary: Hand-crafted frontend development
@@ -1574,6 +1584,7 @@ test_files:
1574
1584
  - features/custom_layouts.feature
1575
1585
  - features/data.feature
1576
1586
  - features/default-layout.feature
1587
+ - features/default_alt_tag.feature
1577
1588
  - features/directory_index.feature
1578
1589
  - features/dynamic_pages.feature
1579
1590
  - features/encoding_option.feature
@@ -1696,6 +1707,11 @@ test_files:
1696
1707
  - fixtures/asset-hash-prefix/source/javascripts/application.js
1697
1708
  - fixtures/asset-hash-prefix/source/javascripts/application.js.map
1698
1709
  - fixtures/asset-hash-prefix/source/layout.erb
1710
+ - fixtures/asset-hash-remove-filename/config.rb
1711
+ - fixtures/asset-hash-remove-filename/source/index.html.erb
1712
+ - fixtures/asset-hash-remove-filename/source/javascripts/application.js
1713
+ - fixtures/asset-hash-remove-filename/source/javascripts/application.js.map
1714
+ - fixtures/asset-hash-remove-filename/source/layout.erb
1699
1715
  - fixtures/asset-hash-source-map/config.rb
1700
1716
  - fixtures/asset-hash-source-map/lib/middleware.rb
1701
1717
  - fixtures/asset-hash-source-map/source/index.html.erb
@@ -1857,6 +1873,10 @@ test_files:
1857
1873
  - fixtures/data-app/data/pages.yml
1858
1874
  - fixtures/data-app/source/index.html.erb
1859
1875
  - fixtures/data-app/source/layout.erb
1876
+ - fixtures/default-alt-tags-app/config.rb
1877
+ - fixtures/default-alt-tags-app/source/empty-alt-tag.html.erb
1878
+ - fixtures/default-alt-tags-app/source/images/blank.gif
1879
+ - fixtures/default-alt-tags-app/source/meaningful-alt-tag.html.erb
1860
1880
  - fixtures/different-engine-layout/config.rb
1861
1881
  - fixtures/different-engine-layout/source/index.haml
1862
1882
  - fixtures/different-engine-layout/source/index.html.str