middleman-core 3.3.12 → 3.4.0

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.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/cucumber.yml +2 -0
  4. data/features/asset_hash.feature +9 -0
  5. data/features/chained_templates.feature +4 -1
  6. data/features/cli/preview_server.feature +532 -0
  7. data/features/i18n_link_to.feature +209 -0
  8. data/features/javascript-testing.feature +18 -0
  9. data/features/redirects.feature +1 -0
  10. data/features/relative_assets.feature +11 -0
  11. data/features/support/env.rb +3 -0
  12. data/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff +0 -0
  13. data/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff2 +0 -0
  14. data/fixtures/asset-hash-app/source/stylesheets/uses_fonts.css +4 -0
  15. data/fixtures/chained-app/source/test.erb.combobreaker.str.erb +8 -0
  16. data/fixtures/javascript-app/config.rb +0 -0
  17. data/fixtures/javascript-app/source/index.html +17 -0
  18. data/fixtures/preview-server-app/bin/dns_server.rb +33 -0
  19. data/fixtures/preview-server-app/config-complications.rb +11 -0
  20. data/fixtures/preview-server-app/config-empty.rb +0 -0
  21. data/fixtures/preview-server-app/config.rb +11 -0
  22. data/fixtures/preview-server-app/source/index.html.erb +1 -0
  23. data/fixtures/preview-server-app/source/layout.erb +9 -0
  24. data/fixtures/preview-server-app/source/layouts/custom.erb +8 -0
  25. data/fixtures/preview-server-app/source/real.html +1 -0
  26. data/fixtures/preview-server-app/source/real/index.html.erb +5 -0
  27. data/fixtures/preview-server-app/source/should_be_ignored.html +1 -0
  28. data/fixtures/preview-server-app/source/should_be_ignored2.html +1 -0
  29. data/fixtures/preview-server-app/source/should_be_ignored3.html +1 -0
  30. data/fixtures/preview-server-app/source/static.html +1 -0
  31. data/fixtures/relative-assets-app/source/absolute_image_relative_css.html.erb +9 -0
  32. data/fixtures/relative-assets-app/source/javascripts/app.js +3 -0
  33. data/fixtures/relative-assets-app/source/relative_image.html.erb +1 -0
  34. data/fixtures/relative-assets-app/source/relative_image_absolute_css.html.erb +9 -0
  35. data/lib/middleman-core/application.rb +11 -5
  36. data/lib/middleman-core/cli/build.rb +3 -1
  37. data/lib/middleman-core/cli/bundler.rb +1 -1
  38. data/lib/middleman-core/cli/extension.rb +2 -2
  39. data/lib/middleman-core/cli/init.rb +3 -3
  40. data/lib/middleman-core/cli/server.rb +9 -1
  41. data/lib/middleman-core/configuration.rb +0 -2
  42. data/lib/middleman-core/core_extensions/data.rb +2 -2
  43. data/lib/middleman-core/core_extensions/external_helpers.rb +2 -1
  44. data/lib/middleman-core/core_extensions/file_watcher.rb +7 -0
  45. data/lib/middleman-core/core_extensions/front_matter.rb +13 -4
  46. data/lib/middleman-core/core_extensions/rendering.rb +20 -6
  47. data/lib/middleman-core/core_extensions/request.rb +2 -2
  48. data/lib/middleman-core/dns_resolver.rb +73 -0
  49. data/lib/middleman-core/dns_resolver/basic_network_resolver.rb +52 -0
  50. data/lib/middleman-core/dns_resolver/hosts_resolver.rb +63 -0
  51. data/lib/middleman-core/dns_resolver/local_link_resolver.rb +44 -0
  52. data/lib/middleman-core/dns_resolver/network_resolver.rb +42 -0
  53. data/lib/middleman-core/extension.rb +0 -1
  54. data/lib/middleman-core/meta_pages.rb +1 -1
  55. data/lib/middleman-core/preview_server.rb +94 -37
  56. data/lib/middleman-core/preview_server/checks.rb +81 -0
  57. data/lib/middleman-core/preview_server/information.rb +273 -0
  58. data/lib/middleman-core/preview_server/network_interface_inventory.rb +65 -0
  59. data/lib/middleman-core/preview_server/server_hostname.rb +39 -0
  60. data/lib/middleman-core/preview_server/server_information.rb +144 -0
  61. data/lib/middleman-core/preview_server/server_information_validator.rb +18 -0
  62. data/lib/middleman-core/preview_server/server_ip_address.rb +55 -0
  63. data/lib/middleman-core/preview_server/server_url.rb +50 -0
  64. data/lib/middleman-core/preview_server/tcp_port_prober.rb +29 -0
  65. data/lib/middleman-core/sitemap.rb +4 -4
  66. data/lib/middleman-core/sitemap/extensions/ignores.rb +5 -1
  67. data/lib/middleman-core/sitemap/extensions/proxies.rb +0 -1
  68. data/lib/middleman-core/sitemap/extensions/redirects.rb +2 -1
  69. data/lib/middleman-core/sitemap/queryable.rb +2 -1
  70. data/lib/middleman-core/sitemap/store.rb +3 -3
  71. data/lib/middleman-core/step_definitions.rb +1 -0
  72. data/lib/middleman-core/step_definitions/builder_steps.rb +7 -7
  73. data/lib/middleman-core/step_definitions/commandline_steps.rb +88 -0
  74. data/lib/middleman-core/step_definitions/server_steps.rb +25 -28
  75. data/lib/middleman-core/templates/extension/Gemfile +0 -1
  76. data/lib/middleman-core/templates/extension/Rakefile +1 -1
  77. data/lib/middleman-core/util.rb +24 -0
  78. data/lib/middleman-core/version.rb +1 -1
  79. data/lib/middleman-more/core_extensions/default_helpers.rb +49 -8
  80. data/lib/middleman-more/core_extensions/i18n.rb +101 -27
  81. data/lib/middleman-more/extensions/asset_hash.rb +1 -1
  82. data/lib/middleman-more/extensions/asset_host.rb +1 -1
  83. data/lib/middleman-more/extensions/automatic_image_sizes.rb +7 -0
  84. data/lib/middleman-more/extensions/cache_buster.rb +1 -1
  85. data/lib/middleman-more/extensions/lorem.rb +2 -2
  86. data/lib/middleman-more/extensions/minify_javascript.rb +6 -4
  87. data/lib/middleman-more/extensions/relative_assets.rb +4 -8
  88. data/middleman-core.gemspec +3 -3
  89. data/spec/middleman-core/dns_resolver_spec.rb +118 -0
  90. data/spec/middleman-core/preview_server/server_hostname_spec.rb +39 -0
  91. data/spec/middleman-core/preview_server/server_ip_address_spec.rb +43 -0
  92. data/spec/spec_helper.rb +26 -0
  93. metadata +81 -17
@@ -13,7 +13,6 @@ end
13
13
 
14
14
  group :test do
15
15
  gem 'cucumber'
16
- gem 'fivemat'
17
16
  gem 'aruba'
18
17
  gem 'rspec'
19
18
  end
@@ -4,7 +4,7 @@ Bundler::GemHelper.install_tasks
4
4
  require 'cucumber/rake/task'
5
5
 
6
6
  Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
7
- t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
7
+ t.cucumber_opts = "--color --tags ~@wip --strict"
8
8
  end
9
9
 
10
10
  require 'rake/clean'
@@ -222,6 +222,30 @@ module Middleman
222
222
  end
223
223
  end
224
224
 
225
+ # Glob a directory and try to keep path encoding consistent.
226
+ #
227
+ # @param [String] path The glob path.
228
+ # @return [Array<String>]
229
+ def glob_directory(path)
230
+ results = ::Dir[path]
231
+
232
+ return results unless RUBY_PLATFORM =~ /darwin/
233
+
234
+ results.map { |r| r.encode('UTF-8', 'UTF-8-MAC') }
235
+ end
236
+
237
+ # Get the PWD and try to keep path encoding consistent.
238
+ #
239
+ # @param [String] path The glob path.
240
+ # @return [Array<String>]
241
+ def current_directory
242
+ result = ::Dir.pwd
243
+
244
+ return result unless RUBY_PLATFORM =~ /darwin/
245
+
246
+ result.encode('UTF-8', 'UTF-8-MAC')
247
+ end
248
+
225
249
  private
226
250
 
227
251
  # Is mime type known to be non-binary?
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  # Current Version
3
3
  # @return [String]
4
- VERSION = '3.3.12' unless const_defined?(:VERSION)
4
+ VERSION = '3.4.0' unless const_defined?(:VERSION)
5
5
  end
@@ -8,7 +8,8 @@ class Padrino::Helpers::OutputHelpers::ErbHandler
8
8
  # Force Erb capture not to use safebuffer
9
9
  # rubocop:disable UnderscorePrefixedVariableName
10
10
  def capture_from_template(*args, &block)
11
- self.output_buffer, _buf_was = '', output_buffer
11
+ self.output_buffer = ''
12
+ _buf_was = output_buffer
12
13
  raw = block.call(*args)
13
14
  captured = template.instance_variable_get(:@_out_buf)
14
15
  self.output_buffer = _buf_was
@@ -98,6 +99,36 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
98
99
  end
99
100
  end
100
101
 
102
+ # Override helper to add `relative` opt-out.
103
+ def stylesheet_link_tag(*sources)
104
+ options = {
105
+ rel: 'stylesheet'
106
+ }.update(sources.extract_options!.symbolize_keys)
107
+
108
+ path_options = {}
109
+ path_options[:relative] = options.delete(:relative) if options.key?(:relative)
110
+
111
+ sources.flatten.inject(ActiveSupport::SafeBuffer.new) do |all, source|
112
+ all << tag(:link, {
113
+ href: asset_path(:css, source, path_options)
114
+ }.update(options))
115
+ end
116
+ end
117
+
118
+ # Override helper to add `relative` opt-out.
119
+ def javascript_include_tag(*sources)
120
+ options = sources.extract_options!.symbolize_keys
121
+
122
+ path_options = {}
123
+ path_options[:relative] = options.delete(:relative) if options.key?(:relative)
124
+
125
+ sources.flatten.inject(::ActiveSupport::SafeBuffer.new) do |all, source|
126
+ all << content_tag(:script, nil, {
127
+ src: asset_path(:js, source, path_options)
128
+ }.update(options))
129
+ end
130
+ end
131
+
101
132
  # Output a stylesheet link tag based on the current path
102
133
  #
103
134
  # @param [Symbol] asset_ext The type of asset
@@ -152,8 +183,9 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
152
183
  #
153
184
  # @param [Symbol] kind The type of file
154
185
  # @param [String] source The path to the file
186
+ # @param [Hash] options Additional options.
155
187
  # @return [String]
156
- def asset_path(kind, source)
188
+ def asset_path(kind, source, options={})
157
189
  return source if source.to_s.include?('//') || source.to_s.start_with?('data:')
158
190
  asset_folder = case kind
159
191
  when :css
@@ -173,29 +205,38 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
173
205
  source << ".#{kind}" unless ignore_extension || source.end_with?(".#{kind}")
174
206
  asset_folder = '' if source.start_with?('/') # absolute path
175
207
 
176
- asset_url(source, asset_folder)
208
+ asset_url(source, asset_folder, options)
177
209
  end
178
210
 
179
211
  # Get the URL of an asset given a type/prefix
180
212
  #
181
213
  # @param [String] path The path (such as "photo.jpg")
182
214
  # @param [String] prefix The type prefix (such as "images")
215
+ # @param [Hash] options Additional options.
183
216
  # @return [String] The fully qualified asset url
184
- def asset_url(path, prefix='')
217
+ def asset_url(path, prefix='', options={})
185
218
  # Don't touch assets which already have a full path
186
- if path.include?('//') || path.start_with?('data:')
219
+ if path.include?('//') || path.start_with?('data:') || !current_resource
187
220
  path
188
221
  else # rewrite paths to use their destination path
189
- if resource = sitemap.find_resource_by_destination_path(url_for(path))
222
+ result = if resource = sitemap.find_resource_by_destination_path(url_for(path))
190
223
  resource.url
191
224
  else
192
225
  path = File.join(prefix, path)
226
+
193
227
  if resource = sitemap.find_resource_by_path(path)
194
228
  resource.url
195
229
  else
196
230
  File.join(config[:http_prefix], path)
197
231
  end
198
232
  end
233
+
234
+ if options[:relative] != true
235
+ result
236
+ else
237
+ current_dir = Pathname('/' + current_resource.destination_path)
238
+ Pathname(result).relative_path_from(current_dir.dirname).to_s
239
+ end
199
240
  end
200
241
  end
201
242
 
@@ -255,12 +296,12 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
255
296
  url = url_for(url, options)
256
297
  super
257
298
  end
258
-
299
+
259
300
  # Modified Padrino image_tag so that it finds the paths for srcset
260
301
  # using asset_path for the images listed in the srcset param
261
302
  def image_tag(path, params={})
262
303
  params.symbolize_keys!
263
-
304
+
264
305
  if params.key?(:srcset)
265
306
  images_sources = params[:srcset].split(',').map do |src_def|
266
307
  if src_def.include?('//')
@@ -7,9 +7,13 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
7
7
  option :mount_at_root, nil, 'Mount a specific language at the root of the site'
8
8
  option :data, 'locales', 'The directory holding your locale configurations'
9
9
 
10
+ attr_reader :lookup
11
+
10
12
  def initialize(app, options_hash={}, &block)
11
13
  super
12
14
 
15
+ @lookup = {}
16
+
13
17
  # TODO
14
18
  # If :directory_indexes is already active,
15
19
  # throw a warning explaining the bug and telling the use
@@ -23,13 +27,15 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
23
27
 
24
28
  app.config.define_setting :locales_dir, 'locales', 'The directory holding your locale configurations'
25
29
 
30
+ ::Middleman::Sitemap::Resource.send :attr_accessor, :locale_root_path
31
+
26
32
  app.send :include, LocaleHelpers
27
33
  end
28
34
 
29
35
  def after_configuration
30
- app.files.reload_path(app.config[:locals_dir] || options[:data])
36
+ app.files.reload_path(app.config[:locales_dir] || options[:data])
31
37
 
32
- @locales_glob = File.join(app.config[:locals_dir] || options[:data], '**', '*.{rb,yml,yaml}')
38
+ @locales_glob = File.join(app.config[:locales_dir] || options[:data], '**', '*.{rb,yml,yaml}')
33
39
  @locales_regex = convert_glob_to_regex(@locales_glob)
34
40
 
35
41
  @maps = {}
@@ -53,6 +59,33 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
53
59
  def t(*args)
54
60
  ::I18n.t(*args)
55
61
  end
62
+
63
+ def url_for(path_or_resource, options={})
64
+ locale = options.delete(:locale) || ::I18n.locale
65
+
66
+ opts = options.dup
67
+
68
+ should_relativize = opts.key?(:relative) ? opts[:relative] : config[:relative_links]
69
+
70
+ opts[:relative] = false
71
+
72
+ href = super(path_or_resource, opts)
73
+
74
+ final_path = if result = extensions[:i18n].localized_path(href, locale)
75
+ result
76
+ else
77
+ # Should we log the missing file?
78
+ href
79
+ end
80
+
81
+ opts[:relative] = should_relativize
82
+
83
+ begin
84
+ super(final_path, opts)
85
+ rescue RuntimeError
86
+ super(path_or_resource, options)
87
+ end
88
+ end
56
89
  end
57
90
 
58
91
  delegate :logger, to: :app
@@ -68,24 +101,45 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
68
101
 
69
102
  new_resources = []
70
103
 
71
- resources.each do |resource|
72
- # If it uses file extension localization
73
- if parse_locale_extension(resource.path)
74
- result = parse_locale_extension(resource.path)
75
- ext_lang, path, page_id = result
76
- new_resources << build_resource(path, resource.path, page_id, ext_lang)
77
- # If it's a "localizable template"
78
- elsif File.fnmatch?(File.join(options[:templates_dir], '**'), resource.path)
79
- page_id = File.basename(resource.path, File.extname(resource.path))
80
- langs.each do |lang|
81
- # Remove folder name
82
- path = resource.path.sub(options[:templates_dir], '')
83
- new_resources << build_resource(path, resource.path, page_id, lang)
84
- end
104
+ file_extension_resources = resources.select do |resource|
105
+ parse_locale_extension(resource.path)
106
+ end
107
+
108
+ localizable_folder_resources = resources.select do |resource|
109
+ !file_extension_resources.include?(resource) && File.fnmatch?(File.join(options[:templates_dir], '**'), resource.path)
110
+ end
111
+
112
+ # If it's a "localizable template"
113
+ localizable_folder_resources.map do |resource|
114
+ page_id = File.basename(resource.path, File.extname(resource.path))
115
+ langs.each do |lang|
116
+ # Remove folder name
117
+ path = resource.path.sub(options[:templates_dir], '')
118
+ new_resources << build_resource(path, resource.path, page_id, lang)
85
119
  end
86
120
  end
87
121
 
88
- resources + new_resources
122
+ # If it uses file extension localization
123
+ file_extension_resources.map do |resource|
124
+ result = parse_locale_extension(resource.path)
125
+ ext_lang, path, page_id = result
126
+ new_resources << build_resource(path, resource.path, page_id, ext_lang)
127
+ end
128
+
129
+ @lookup = new_resources.each_with_object({}) do |desc, sum|
130
+ abs_path = desc.source_path.sub(options[:templates_dir], '')
131
+ sum[abs_path] ||= {}
132
+ sum[abs_path][desc.lang] = '/' + desc.path
133
+ end
134
+
135
+ resources + new_resources.map { |r| r.to_resource(app) }
136
+ end
137
+
138
+ def localized_path(path, lang)
139
+ lookup_path = path.dup
140
+ lookup_path << app.config[:index_file] if lookup_path.end_with?('/')
141
+
142
+ @lookup[lookup_path] && @lookup[lookup_path][lang]
89
143
  end
90
144
 
91
145
  private
@@ -104,7 +158,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
104
158
  end
105
159
 
106
160
  def configure_i18n
107
- ::I18n.load_path += Dir[File.join(app.root, @locales_glob)]
161
+ ::I18n.load_path += ::Middleman::Util.glob_directory(File.join(app.root, @locales_glob))
108
162
  ::I18n.reload!
109
163
 
110
164
  ::I18n.default_locale = @mount_at_root
@@ -147,9 +201,9 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
147
201
  p.to_s.match(@locales_regex) && (p.to_s.split(File::SEPARATOR).length == 2)
148
202
  end
149
203
 
150
- known_langs.map { |p|
204
+ known_langs.map do |p|
151
205
  File.basename(p.to_s).sub(/\.ya?ml$/, '').sub(/\.rb$/, '')
152
- }.sort.map(&:to_sym)
206
+ end.sort.map(&:to_sym)
153
207
  end
154
208
  end
155
209
 
@@ -173,11 +227,33 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
173
227
  [lang, path, basename]
174
228
  end
175
229
 
230
+ LocalizedPageDescriptor = Struct.new(:path, :source_path, :lang) do
231
+ def to_resource(app)
232
+ p = ::Middleman::Sitemap::Resource.new(app.sitemap, path)
233
+ p.proxy_to(source_path)
234
+
235
+ templates_dir = app.extensions[:i18n].options[:templates_dir]
236
+
237
+ p.locale_root_path = source_path.gsub(templates_dir, '')
238
+
239
+ p
240
+ end
241
+ end
242
+
176
243
  def build_resource(path, source_path, page_id, lang)
177
244
  old_locale = ::I18n.locale
178
245
  ::I18n.locale = lang
179
246
  localized_page_id = ::I18n.t("paths.#{page_id}", default: page_id, fallback: [])
180
247
 
248
+ partially_localized_path = ''
249
+
250
+ File.dirname(path).split('/').each do |path_sub|
251
+ next if path_sub == ''
252
+ partially_localized_path = "#{partially_localized_path}/#{(::I18n.t("paths.#{path_sub}", default: path_sub).to_s)}"
253
+ end
254
+
255
+ path = "#{partially_localized_path}/#{File.basename(path)}"
256
+
181
257
  prefix = if (options[:mount_at_root] == lang) || (options[:mount_at_root].nil? && langs[0] == lang)
182
258
  '/'
183
259
  else
@@ -194,11 +270,9 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
194
270
 
195
271
  @_localization_data[path] = [lang, path, localized_page_id]
196
272
 
197
- p = ::Middleman::Sitemap::Resource.new(app.sitemap, path)
198
- p.proxy_to(source_path)
199
-
200
273
  ::I18n.locale = old_locale
201
- p
274
+
275
+ LocalizedPageDescriptor.new(path, source_path, lang)
202
276
  end
203
277
 
204
278
  module LocaleHelpers
@@ -209,10 +283,10 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
209
283
  end
210
284
 
211
285
  def locate_partial(partial_name, try_static=false)
212
- locals_dir = extensions[:i18n].options[:templates_dir]
286
+ locales_dir = extensions[:i18n].options[:templates_dir]
213
287
 
214
288
  # Try /localizable
215
- partials_path = File.join(locals_dir, partial_name)
289
+ partials_path = File.join(locales_dir, partial_name)
216
290
 
217
291
  lang_suffix = current_resource.metadata[:locals] && current_resource.metadata[:locals][:lang]
218
292
 
@@ -226,7 +300,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
226
300
 
227
301
  if lang_suffix
228
302
  super(suffixed_partial_name, maybe_static) ||
229
- super(File.join(locals_dir, suffixed_partial_name), maybe_static) ||
303
+ super(File.join(locales_dir, suffixed_partial_name), maybe_static) ||
230
304
  super(partials_path, try_static) ||
231
305
  super
232
306
  else
@@ -63,7 +63,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension
63
63
  @rack_app = app
64
64
  @exts = options[:exts]
65
65
  @ignore = options[:ignore]
66
- @exts_regex_text = @exts.map { |e| Regexp.escape(e) }.join('|')
66
+ @exts_regex_text = @exts.map { |e| Regexp.escape(e) }.sort.reverse.join('|')
67
67
  @middleman_app = options[:middleman_app]
68
68
  end
69
69
 
@@ -32,7 +32,7 @@ class Middleman::Extensions::AssetHost < ::Middleman::Extension
32
32
  # @param [String] path
33
33
  # @param [String] prefix
34
34
  # @return [String]
35
- def asset_url(path, prefix='')
35
+ def asset_url(path, prefix='', options={})
36
36
  controller = extensions[:asset_host]
37
37
 
38
38
  original_output = super
@@ -23,6 +23,13 @@ class Middleman::Extensions::AutomaticImageSizes < ::Middleman::Extension
23
23
  if File.exist?(full_path)
24
24
  begin
25
25
  width, height = ::FastImage.size(full_path, raise_on_failure: true)
26
+ # Check for @2x and @3x image
27
+ retina = full_path.match(/@(\d)x\.[a-zA-Z]{3,4}$/)
28
+ if retina
29
+ factor = retina[1].to_i
30
+ width /= factor
31
+ height /= factor
32
+ end
26
33
  params[:width] = width
27
34
  params[:height] = height
28
35
  rescue FastImage::UnknownImageType
@@ -21,7 +21,7 @@ class Middleman::Extensions::CacheBuster < ::Middleman::Extension
21
21
  # asset_url override if we're using cache busting
22
22
  # @param [String] path
23
23
  # @param [String] prefix
24
- def asset_url(path, prefix='')
24
+ def asset_url(path, prefix='', options={})
25
25
  http_path = super
26
26
 
27
27
  if http_path.include?('://') || !%w(.css .png .jpg .jpeg .svg .svgz .webp .js .gif).include?(File.extname(http_path))
@@ -152,8 +152,8 @@ class Middleman::Extensions::Lorem < ::Middleman::Extension
152
152
  color = options[:color]
153
153
 
154
154
  if options[:random_color]
155
- background_color = hex.shuffle[0...6].join
156
- color = hex.shuffle[0...6].join
155
+ background_color = hex.sample(6).join
156
+ color = hex.sample(6).join
157
157
  end
158
158
 
159
159
  src << "/#{background_color.sub(/^#/, '')}" if background_color
@@ -49,11 +49,11 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
49
49
  status, headers, response = @app.call(env)
50
50
 
51
51
  type = headers['Content-Type'].try(:slice, /^[^;]*/)
52
- path = env['PATH_INFO']
52
+ @path = env['PATH_INFO']
53
53
 
54
54
  minified = if @inline && minifiable_inline?(type)
55
55
  minify_inline(::Middleman::Util.extract_response_text(response))
56
- elsif minifiable?(type) && !ignore?(path)
56
+ elsif minifiable?(type) && !ignore?(@path)
57
57
  minify(::Middleman::Util.extract_response_text(response))
58
58
  end
59
59
 
@@ -94,7 +94,7 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
94
94
  def minify(content)
95
95
  @compressor.compress(content)
96
96
  rescue ExecJS::ProgramError => e
97
- warn "WARNING: Couldn't compress JavaScript in #{path}: #{e.message}"
97
+ warn "WARNING: Couldn't compress JavaScript in #{@path}: #{e.message}"
98
98
  content
99
99
  end
100
100
 
@@ -103,7 +103,9 @@ class Middleman::Extensions::MinifyJavascript < ::Middleman::Extension
103
103
  # @return [String]
104
104
  def minify_inline(content)
105
105
  content.gsub(INLINE_JS_REGEX) do |match|
106
- first, inline_content, last = $1, $2, $3
106
+ first = $1
107
+ inline_content = $2
108
+ last = $3
107
109
 
108
110
  # Only compress script tags that contain JavaScript (as opposed to
109
111
  # something like jQuery templates, identified with a "text/html" type).