middleman-core 4.3.0.rc.4 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/cucumber.yml +2 -2
  3. data/features/builder.feature +1 -1
  4. data/features/chained_templates.feature +0 -7
  5. data/features/coffee-script.feature +1 -1
  6. data/features/collections.feature +2 -2
  7. data/features/console.feature +1 -1
  8. data/features/data.feature +31 -0
  9. data/features/extension_api_deprecations.feature +3 -1
  10. data/features/extension_hooks.feature +3 -1
  11. data/features/helpers_external.feature +1 -17
  12. data/features/i18n_link_to.feature +0 -23
  13. data/features/i18n_mixed_sources.feature +0 -8
  14. data/features/i18n_preview.feature +1 -30
  15. data/features/ignore.feature +11 -67
  16. data/features/ignore_already_minified.feature +1 -1
  17. data/features/markdown.feature +1 -0
  18. data/features/minify_javascript.feature +35 -35
  19. data/features/mount_rack.feature +0 -1
  20. data/features/page-id.feature +2 -2
  21. data/features/partials.feature +1 -1
  22. data/features/relative_assets_helpers_only.feature +6 -4
  23. data/features/scss-support.feature +6 -1
  24. data/features/support/env.rb +5 -5
  25. data/features/tilde_directories.feature +2 -0
  26. data/features/unicode_filenames.feature +1 -1
  27. data/fixtures/asset-hash-app/config.rb +1 -0
  28. data/fixtures/asset-hash-app/lib/middleware.rb +2 -2
  29. data/fixtures/asset-hash-app/source/stylesheets/_partial.sass +1 -1
  30. data/fixtures/asset-hash-minified-app/config.rb +1 -1
  31. data/fixtures/asset-hash-prefix/config.rb +2 -1
  32. data/fixtures/asset-hash-prefix/lib/middleware.rb +2 -2
  33. data/fixtures/asset-hash-source-map/config.rb +1 -0
  34. data/fixtures/asset-hash-source-map/lib/middleware.rb +2 -2
  35. data/fixtures/asset-host-app/config.rb +1 -1
  36. data/fixtures/auto-css-app/config.rb +2 -2
  37. data/fixtures/auto-js-app/config.rb +2 -2
  38. data/fixtures/auto-js-directory-index-app/config.rb +1 -1
  39. data/fixtures/automatic-directory-matcher-app/config.rb +1 -1
  40. data/fixtures/basic-data-app/config.rb +2 -2
  41. data/fixtures/capture-html-app/config.rb +4 -4
  42. data/fixtures/clean-app/config-complications.rb +6 -6
  43. data/fixtures/clean-app/config-hidden-dir-after.rb +4 -4
  44. data/fixtures/clean-app/config-hidden-dir-before.rb +1 -1
  45. data/fixtures/clean-app/config.rb +6 -6
  46. data/fixtures/clean-dir-app/config.rb +1 -0
  47. data/fixtures/clean-nested-app/config.rb +1 -1
  48. data/fixtures/collections-app/source/blog1/2011-01-01-new-article.html.markdown +1 -1
  49. data/fixtures/collections-app/source/blog1/2011-01-02-another-article.html.markdown +1 -1
  50. data/fixtures/collections-app/source/blog2/2011-01-01-new-article.html.markdown +1 -1
  51. data/fixtures/collections-app/source/blog2/2011-01-02-another-article.html.markdown +1 -1
  52. data/fixtures/content-for-app/config.rb +4 -4
  53. data/fixtures/dynamic-pages-app/config.rb +26 -25
  54. data/fixtures/ember-cli-app/config.rb +4 -4
  55. data/fixtures/env-app/environments/development.rb +1 -1
  56. data/fixtures/env-app/environments/production.rb +1 -1
  57. data/fixtures/env-app/source/stylesheets/site.css.scss +1 -1
  58. data/fixtures/extension-hooks-app/config.rb +8 -8
  59. data/fixtures/external-helpers/config.rb +2 -2
  60. data/fixtures/external-helpers/helpers/derp.rb +1 -3
  61. data/fixtures/external-helpers/helpers/four_helpers.rb +1 -3
  62. data/fixtures/external-helpers/helpers/one_helper.rb +1 -3
  63. data/fixtures/external-helpers/helpers/yet_another_thingy.rb +1 -3
  64. data/fixtures/external-helpers/lib/hello_helper.rb +1 -1
  65. data/fixtures/external-pipeline-error/config.rb +4 -4
  66. data/fixtures/feature-params-app/config.rb +1 -1
  67. data/fixtures/frontmatter-app/config.rb +1 -1
  68. data/fixtures/generator-test/config.rb +15 -1
  69. data/fixtures/glob-app/config.rb +1 -1
  70. data/fixtures/i-8859-1-app/config.rb +1 -1
  71. data/fixtures/i18n-force-locale/config.rb +4 -4
  72. data/fixtures/i18n-mixed-sources/config.rb +1 -1
  73. data/fixtures/i18n-test-app/locales/en.yml +1 -7
  74. data/fixtures/i18n-test-app/locales/es.yml +1 -2
  75. data/fixtures/import-app/config.rb +3 -3
  76. data/fixtures/indexable-app/config.rb +3 -3
  77. data/fixtures/large-build-app/config.rb +1 -1
  78. data/fixtures/manual-layout-override/config.rb +1 -1
  79. data/fixtures/missing-tilt-library-app/config.rb +2 -2
  80. data/fixtures/more-traversal-app/config.rb +4 -4
  81. data/fixtures/multiple-data-sources-app/config.rb +1 -1
  82. data/fixtures/multiple-sources-app/config.rb +1 -1
  83. data/fixtures/multiple-sources-with-duplicate-file-names-app/config.rb +1 -1
  84. data/fixtures/nested-layout-app/source/another.html.markdown +1 -1
  85. data/fixtures/nested-layout-app/source/haml-test.html.markdown +1 -1
  86. data/fixtures/nested-layout-app/source/slim-test.html.markdown +1 -1
  87. data/fixtures/padrino-helpers-app/config.rb +1 -1
  88. data/fixtures/page-classes-app/config.rb +2 -2
  89. data/fixtures/page-helper-layout-block-app/config.rb +1 -1
  90. data/fixtures/page-id-app/config-proc.rb +4 -4
  91. data/fixtures/page-id-app/config.rb +3 -3
  92. data/fixtures/page-id-app/source/{forty-two.html.erb → fourty-two.html.erb} +0 -0
  93. data/fixtures/paginate-app/source/blog/2011-01-01-test-article.html.markdown +1 -1
  94. data/fixtures/paginate-app/source/blog/2011-01-02-test-article.html.markdown +1 -1
  95. data/fixtures/paginate-app/source/blog/2011-01-03-test-article.html.markdown +1 -1
  96. data/fixtures/paginate-app/source/blog/2011-01-04-test-article.html.markdown +1 -1
  97. data/fixtures/paginate-app/source/blog/2011-01-05-test-article.html.markdown +1 -1
  98. data/fixtures/paginate-app/source/blog/2011-02-01-test-article.html.markdown +1 -1
  99. data/fixtures/paginate-app/source/blog/2011-02-02-test-article.html.markdown +1 -1
  100. data/fixtures/partials-app/source/_locals.erb +1 -1
  101. data/fixtures/partials-app/source/locals.html.erb +1 -1
  102. data/fixtures/proxy-pages-app/config.rb +14 -13
  103. data/fixtures/sass-assets-path-app/config.rb +2 -2
  104. data/fixtures/scss-app/source/stylesheets/error.css.sass +1 -0
  105. data/fixtures/sinatra-app/config.rb +6 -6
  106. data/fixtures/traversal-app/config.rb +4 -4
  107. data/fixtures/v4-extension-callbacks/config.rb +2 -2
  108. data/fixtures/wildcard-app/config.rb +1 -1
  109. data/fixtures/wildcard-directory-index-app/config.rb +1 -1
  110. data/lib/middleman/rack.rb +7 -0
  111. data/lib/middleman-core/application.rb +9 -10
  112. data/lib/middleman-core/builder.rb +21 -50
  113. data/lib/middleman-core/callback_manager.rb +1 -1
  114. data/lib/middleman-core/config_context.rb +2 -2
  115. data/lib/middleman-core/configuration.rb +5 -5
  116. data/lib/middleman-core/contracts.rb +2 -2
  117. data/lib/middleman-core/core_extensions/collections/lazy_root.rb +1 -1
  118. data/lib/middleman-core/core_extensions/collections/lazy_step.rb +9 -9
  119. data/lib/middleman-core/core_extensions/collections/pagination.rb +6 -6
  120. data/lib/middleman-core/core_extensions/collections.rb +1 -1
  121. data/lib/middleman-core/core_extensions/data.rb +11 -11
  122. data/lib/middleman-core/core_extensions/default_helpers.rb +29 -26
  123. data/lib/middleman-core/core_extensions/external_helpers.rb +1 -1
  124. data/lib/middleman-core/core_extensions/file_watcher.rb +1 -1
  125. data/lib/middleman-core/core_extensions/front_matter.rb +3 -3
  126. data/lib/middleman-core/core_extensions/i18n.rb +23 -44
  127. data/lib/middleman-core/core_extensions/inline_url_rewriter.rb +7 -10
  128. data/lib/middleman-core/core_extensions/routing.rb +1 -1
  129. data/lib/middleman-core/core_extensions.rb +2 -2
  130. data/lib/middleman-core/dns_resolver/basic_network_resolver.rb +3 -3
  131. data/lib/middleman-core/dns_resolver/hosts_resolver.rb +1 -1
  132. data/lib/middleman-core/dns_resolver/local_link_resolver.rb +1 -1
  133. data/lib/middleman-core/dns_resolver/network_resolver.rb +1 -1
  134. data/lib/middleman-core/dns_resolver.rb +1 -1
  135. data/lib/middleman-core/extension.rb +32 -34
  136. data/lib/middleman-core/extension_manager.rb +2 -6
  137. data/lib/middleman-core/extensions/asset_hash.rb +22 -24
  138. data/lib/middleman-core/extensions/asset_host.rb +10 -10
  139. data/lib/middleman-core/extensions/automatic_alt_tags.rb +1 -1
  140. data/lib/middleman-core/extensions/automatic_image_sizes.rb +3 -3
  141. data/lib/middleman-core/extensions/cache_buster.rb +2 -2
  142. data/lib/middleman-core/extensions/directory_indexes.rb +1 -1
  143. data/lib/middleman-core/extensions/external_pipeline.rb +9 -14
  144. data/lib/middleman-core/extensions/gzip.rb +6 -8
  145. data/lib/middleman-core/extensions/lorem.rb +9 -9
  146. data/lib/middleman-core/extensions/minify_css.rb +16 -14
  147. data/lib/middleman-core/extensions/minify_javascript.rb +13 -13
  148. data/lib/middleman-core/extensions/relative_assets.rb +8 -8
  149. data/lib/middleman-core/extensions.rb +7 -8
  150. data/lib/middleman-core/file_renderer.rb +6 -7
  151. data/lib/middleman-core/load_paths.rb +10 -13
  152. data/lib/middleman-core/logger.rb +4 -3
  153. data/lib/middleman-core/meta_pages/sitemap_resource.rb +2 -0
  154. data/lib/middleman-core/meta_pages/sitemap_tree.rb +1 -1
  155. data/lib/middleman-core/meta_pages.rb +1 -1
  156. data/lib/middleman-core/preview_server/checks.rb +1 -1
  157. data/lib/middleman-core/preview_server/information.rb +13 -13
  158. data/lib/middleman-core/preview_server/network_interface_inventory.rb +3 -3
  159. data/lib/middleman-core/preview_server/server_information.rb +1 -1
  160. data/lib/middleman-core/preview_server/server_information_callback_proxy.rb +1 -1
  161. data/lib/middleman-core/preview_server/server_url.rb +1 -1
  162. data/lib/middleman-core/preview_server/tcp_port_prober.rb +1 -1
  163. data/lib/middleman-core/preview_server.rb +25 -25
  164. data/lib/middleman-core/rack.rb +1 -1
  165. data/lib/middleman-core/renderers/coffee_script.rb +2 -2
  166. data/lib/middleman-core/renderers/haml.rb +4 -8
  167. data/lib/middleman-core/renderers/less.rb +1 -1
  168. data/lib/middleman-core/renderers/liquid.rb +2 -3
  169. data/lib/middleman-core/renderers/markdown.rb +7 -7
  170. data/lib/middleman-core/renderers/redcarpet.rb +2 -2
  171. data/lib/middleman-core/renderers/sass.rb +23 -26
  172. data/lib/middleman-core/renderers/sass_functions.rb +14 -17
  173. data/lib/middleman-core/renderers/slim.rb +2 -2
  174. data/lib/middleman-core/sitemap/extensions/ignores.rb +4 -2
  175. data/lib/middleman-core/sitemap/extensions/import.rb +1 -1
  176. data/lib/middleman-core/sitemap/extensions/on_disk.rb +1 -1
  177. data/lib/middleman-core/sitemap/extensions/proxies.rb +1 -2
  178. data/lib/middleman-core/sitemap/extensions/redirects.rb +1 -1
  179. data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +1 -1
  180. data/lib/middleman-core/sitemap/extensions/traversal.rb +25 -80
  181. data/lib/middleman-core/sitemap/resource.rb +20 -21
  182. data/lib/middleman-core/sitemap/store.rb +6 -6
  183. data/lib/middleman-core/sources/source_watcher.rb +11 -17
  184. data/lib/middleman-core/sources.rb +12 -12
  185. data/lib/middleman-core/step_definitions/builder_steps.rb +12 -38
  186. data/lib/middleman-core/step_definitions/commandline_steps.rb +6 -6
  187. data/lib/middleman-core/step_definitions/middleman_steps.rb +14 -13
  188. data/lib/middleman-core/step_definitions/server_steps.rb +16 -18
  189. data/lib/middleman-core/template_context.rb +10 -17
  190. data/lib/middleman-core/template_renderer.rb +33 -35
  191. data/lib/middleman-core/util/binary.rb +1 -3
  192. data/lib/middleman-core/util/data.rb +22 -12
  193. data/lib/middleman-core/util/files.rb +3 -3
  194. data/lib/middleman-core/util/paths.rb +44 -47
  195. data/lib/middleman-core/util/rack.rb +3 -3
  196. data/lib/middleman-core/util/uri_templates.rb +0 -1
  197. data/lib/middleman-core/util.rb +2 -2
  198. data/lib/middleman-core/version.rb +1 -1
  199. data/lib/middleman-core.rb +3 -3
  200. data/middleman-core.gemspec +13 -12
  201. data/spec/middleman-core/callbacks_spec.rb +14 -15
  202. data/spec/middleman-core/core_extensions/data_spec.rb +74 -70
  203. data/spec/middleman-core/dns_resolver_spec.rb +6 -6
  204. data/spec/middleman-core/util_spec.rb +86 -81
  205. data/spec/spec_helper.rb +6 -1
  206. data/spec/support/given.rb +15 -11
  207. metadata +59 -76
  208. data/features/multiple-sources-reload.feature +0 -40
  209. data/fixtures/chained-app/source/stylesheets/main.css.scss.erb +0 -3
  210. data/fixtures/chained-app/source/stylesheets/sub.scss +0 -1
  211. data/fixtures/destination-dir-different-from-source-dir-name/external/page.html.erb +0 -1
  212. data/fixtures/destination-dir-different-from-source-dir-name/my-app/config.rb +0 -2
  213. data/fixtures/destination-dir-different-from-source-dir-name/my-app/source/index.html.erb +0 -1
  214. data/fixtures/i18n-default-app/source/name.html.erb +0 -1
  215. data/fixtures/i18n-mixed-sources/source/c/d/index.html.erb +0 -9
  216. data/fixtures/i18n-mixed-sources/source/localizable/c/d/index.html.erb +0 -9
  217. data/fixtures/i18n-test-app/source/localizable/tac.html.erb +0 -1
  218. data/fixtures/multiple-sources-with-destination-dir/config.rb +0 -2
  219. data/fixtures/multiple-sources-with-destination-dir/external/page.html.erb +0 -1
  220. data/fixtures/multiple-sources-with-destination-dir/source/index.html.erb +0 -1
  221. data/fixtures/multiple-sources-without-destination-dir/config.rb +0 -1
  222. data/fixtures/multiple-sources-without-destination-dir/external/page.html.erb +0 -1
  223. data/fixtures/multiple-sources-without-destination-dir/source/index.html.erb +0 -1
@@ -19,7 +19,7 @@ module Middleman
19
19
  # The regex which tells Middleman which files are for data
20
20
  DATA_FILE_MATCHER = /^(.*?)[\w-]+\.(yml|yaml|json)$/
21
21
 
22
- def initialize(app, config = {}, &block)
22
+ def initialize(app, config={}, &block)
23
23
  super
24
24
 
25
25
  @data_store = DataStore.new(app, DATA_FILE_MATCHER)
@@ -32,7 +32,7 @@ module Middleman
32
32
 
33
33
  # Tell the file watcher to observe the :data_dir
34
34
  @watcher = app.files.watch :data,
35
- path: File.expand_path(dir, app.root),
35
+ path: File.join(app.root, dir),
36
36
  only: DATA_FILE_MATCHER
37
37
 
38
38
  # Setup data files before anything else so they are available when
@@ -68,7 +68,7 @@ module Middleman
68
68
  # @param [Hash] content The content for this data
69
69
  # @return [Hash]
70
70
  Contract Symbol, Or[Hash, Array] => Hash
71
- def store(name = nil, content = nil)
71
+ def store(name=nil, content=nil)
72
72
  @local_sources[name.to_s] = content unless name.nil? || content.nil?
73
73
  @local_sources
74
74
  end
@@ -79,7 +79,7 @@ module Middleman
79
79
  # @param [Proc] proc The callback which will return data
80
80
  # @return [Hash]
81
81
  Contract Maybe[Symbol], Maybe[Proc] => Hash
82
- def callbacks(name = nil, proc = nil)
82
+ def callbacks(name=nil, proc=nil)
83
83
  @callback_sources[name.to_s] = proc unless name.nil? || proc.nil?
84
84
  @callback_sources
85
85
  end
@@ -102,9 +102,9 @@ module Middleman
102
102
  extension = File.extname(data_path)
103
103
  basename = File.basename(data_path, extension)
104
104
 
105
- return unless %w[.yaml .yml .json].include?(extension)
105
+ return unless %w(.yaml .yml .json).include?(extension)
106
106
 
107
- if %w[.yaml .yml].include?(extension)
107
+ if %w(.yaml .yml).include?(extension)
108
108
  data, postscript = ::Middleman::Util::Data.parse(file, @app.config[:frontmatter_delims], :yaml)
109
109
  data[:postscript] = postscript if !postscript.nil? && data.is_a?(Hash)
110
110
  elsif extension == '.json'
@@ -153,10 +153,10 @@ module Middleman
153
153
  Contract Or[String, Symbol] => Maybe[Or[Array, IsA['Middleman::Util::EnhancedHash']]]
154
154
  def data_for_path(path)
155
155
  response = if store.key?(path.to_s)
156
- store[path.to_s]
157
- elsif callbacks.key?(path.to_s)
158
- callbacks[path.to_s].call
159
- end
156
+ store[path.to_s]
157
+ elsif callbacks.key?(path.to_s)
158
+ callbacks[path.to_s].call
159
+ end
160
160
 
161
161
  ::Middleman::Util.recursively_enhance(response)
162
162
  end
@@ -179,7 +179,7 @@ module Middleman
179
179
  end
180
180
 
181
181
  # Needed so that method_missing makes sense
182
- def respond_to?(method, include_private = false)
182
+ def respond_to?(method, include_private=false)
183
183
  super || key?(method)
184
184
  end
185
185
 
@@ -1,4 +1,11 @@
1
1
  require 'padrino-helpers'
2
+ require 'padrino-helpers/output_helpers'
3
+ require 'padrino-helpers/asset_tag_helpers'
4
+ require 'padrino-helpers/form_helpers'
5
+ require 'padrino-helpers/format_helpers'
6
+ require 'padrino-helpers/number_helpers'
7
+ require 'padrino-helpers/output_helpers'
8
+ require 'padrino-helpers/render_helpers'
2
9
  require 'middleman-core/contracts'
3
10
 
4
11
  # Don't fail on invalid locale, that's not what our current
@@ -20,7 +27,7 @@ end
20
27
  class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
21
28
  define_setting :relative_links, false, 'Whether to generate relative links instead of absolute ones'
22
29
 
23
- def initialize(app, options_hash = {}, &block)
30
+ def initialize(app, options_hash={}, &block)
24
31
  super
25
32
 
26
33
  require 'active_support/core_ext/object/to_query'
@@ -38,7 +45,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
38
45
  # The helpers
39
46
  helpers do
40
47
  # Make all block content html_safe
41
- def content_tag(name, content = nil, options = nil, &block)
48
+ def content_tag(name, content=nil, options=nil, &block)
42
49
  # safe_content_tag(name, content, options, &block)
43
50
  if block_given?
44
51
  options = content if content.is_a?(Hash)
@@ -64,13 +71,11 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
64
71
  end
65
72
 
66
73
  def capture_html(*args, &block)
67
- handler = auto_find_proper_handler(&block)
68
-
69
- result = if handler
70
- handler.capture_from_template(*args, &block)
71
- else
72
- yield(*args)
73
- end
74
+ result = if handler = auto_find_proper_handler(&block)
75
+ handler.capture_from_template(*args, &block)
76
+ else
77
+ yield(*args)
78
+ end
74
79
 
75
80
  ::ActiveSupport::SafeBuffer.new.safe_concat(result)
76
81
  end
@@ -142,14 +147,14 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
142
147
  # @param [Symbol] asset_ext The type of asset
143
148
  # @param [String] asset_dir Where to look for assets
144
149
  # @return [void]
145
- def auto_tag(asset_ext, asset_dir = nil)
150
+ def auto_tag(asset_ext, asset_dir=nil)
146
151
  if asset_dir.nil?
147
152
  asset_dir = case asset_ext
148
- when :js
149
- config[:js_dir]
150
- when :css
151
- config[:css_dir]
152
- end
153
+ when :js
154
+ config[:js_dir]
155
+ when :css
156
+ config[:css_dir]
157
+ end
153
158
  end
154
159
 
155
160
  # If the basename of the request as no extension, assume we are serving a
@@ -163,7 +168,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
163
168
  # Generate body css classes based on the current path
164
169
  #
165
170
  # @return [String]
166
- def page_classes(path = current_path.dup, options = {})
171
+ def page_classes(path=current_path.dup, options={})
167
172
  if path.is_a? Hash
168
173
  options = path
169
174
  path = current_path.dup
@@ -193,7 +198,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
193
198
  # @param [String] source The path to the file
194
199
  # @param [Hash] options Data to pass through.
195
200
  # @return [String]
196
- def asset_path(kind, source, options = {})
201
+ def asset_path(kind, source, options={})
197
202
  options_with_resource = {}.merge!(options).merge!(current_resource: current_resource)
198
203
  ::Middleman::Util.asset_path(app, kind, source, options_with_resource)
199
204
  end
@@ -204,7 +209,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
204
209
  # @param [String] prefix The type prefix (such as "images")
205
210
  # @param [Hash] options Additional options.
206
211
  # @return [String] The fully qualified asset url
207
- def asset_url(path, prefix = '', options = {})
212
+ def asset_url(path, prefix='', options={})
208
213
  options_with_resource = {}.merge!(options).merge!(current_resource: current_resource)
209
214
  ::Middleman::Util.asset_url(app, path, prefix, options_with_resource)
210
215
  end
@@ -212,7 +217,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
212
217
  # Given a source path (referenced either absolutely or relatively)
213
218
  # or a Resource, this will produce the nice URL configured for that
214
219
  # path, respecting :relative_links, directory indexes, etc.
215
- def url_for(path_or_resource, options = {})
220
+ def url_for(path_or_resource, options={})
216
221
  options_with_resource = {}.merge!(options).merge!(current_resource: current_resource)
217
222
  ::Middleman::Util.url_for(app, path_or_resource, options_with_resource)
218
223
  end
@@ -238,9 +243,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
238
243
  raise ArgumentError, 'Too many arguments to link_to(url, options={}, &block)'
239
244
  end
240
245
 
241
- url = args[url_arg_index]
242
-
243
- if url
246
+ if url = args[url_arg_index]
244
247
  options = args[options_index] || {}
245
248
  raise ArgumentError, 'Options must be a hash' unless options.is_a?(Hash)
246
249
 
@@ -256,14 +259,14 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
256
259
 
257
260
  # Modified Padrino form_for that uses Middleman's url_for
258
261
  # to transform the URL.
259
- def form_tag(url, options = {}, &block)
262
+ def form_tag(url, options={}, &block)
260
263
  url = url_for(url, options)
261
264
  super
262
265
  end
263
266
 
264
267
  # Modified Padrino image_tag so that it finds the paths for srcset
265
268
  # using asset_path for the images listed in the srcset param
266
- def image_tag(path, params = {})
269
+ def image_tag(path, params={})
267
270
  params.symbolize_keys!
268
271
 
269
272
  if params.key?(:srcset)
@@ -282,8 +285,8 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
282
285
  super(path, params)
283
286
  end
284
287
 
285
- def partial(template, options = {}, &block)
286
- including_parent_locals = Middleman::Util::EnhancedHash.new
288
+ def partial(template, options={}, &block)
289
+ including_parent_locals = {}
287
290
  including_parent_locals.merge!(@locs || {})
288
291
  including_parent_locals.merge!(options[:locals] || {})
289
292
 
@@ -19,7 +19,7 @@ module Middleman
19
19
  module_name = app.config[:helpers_filename_to_module_name_proc].call(filename)
20
20
  next unless module_name
21
21
 
22
- load filename
22
+ require filename
23
23
  next unless Object.const_defined?(module_name.to_sym)
24
24
 
25
25
  app.template_context_class.send :include, Object.const_get(module_name.to_sym)
@@ -24,7 +24,7 @@ module Middleman
24
24
  }.freeze
25
25
 
26
26
  # Setup the extension.
27
- def initialize(app, config = {}, &block)
27
+ def initialize(app, config={}, &block)
28
28
  super
29
29
 
30
30
  # Setup source collection.
@@ -16,11 +16,11 @@ module Middleman::CoreExtensions
16
16
 
17
17
  # Set textual delimiters that denote the start and end of frontmatter
18
18
  define_setting :frontmatter_delims, {
19
- json: [%w[;;; ;;;]],
20
- yaml: [%w[--- ---], %w[--- ...]]
19
+ json: [%w(;;; ;;;)],
20
+ yaml: [%w(--- ---), %w(--- ...)]
21
21
  }, 'Allowed frontmatter delimiters'
22
22
 
23
- def initialize(app, options_hash = {}, &block)
23
+ def initialize(app, options_hash={}, &block)
24
24
  super
25
25
 
26
26
  @cache = {}
@@ -29,11 +29,11 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
29
29
  # don't completely reload middleman, I18n.load_path can get
30
30
  # polluted with paths from other test app directories that don't
31
31
  # exist anymore.
32
- return unless ENV['TEST']
33
-
34
- app.after_configuration_eval do
35
- ::I18n.load_path.delete_if { |path| path =~ %r{tmp/aruba} }
36
- ::I18n.reload!
32
+ if ENV['TEST']
33
+ app.after_configuration_eval do
34
+ ::I18n.load_path.delete_if { |path| path =~ %r{tmp/aruba} }
35
+ ::I18n.reload!
36
+ end
37
37
  end
38
38
  end
39
39
 
@@ -68,7 +68,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
68
68
  ::I18n.t(*args)
69
69
  end
70
70
 
71
- def url_for(path_or_resource, options = {})
71
+ def url_for(path_or_resource, options={})
72
72
  locale = options.delete(:locale) || ::I18n.locale
73
73
 
74
74
  opts = options.dup
@@ -79,9 +79,12 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
79
79
 
80
80
  href = super(path_or_resource, opts)
81
81
 
82
- result = extensions[:i18n].localized_path(href, locale)
83
-
84
- final_path = result || href
82
+ final_path = if result = extensions[:i18n].localized_path(href, locale)
83
+ result
84
+ else
85
+ # Should we log the missing file?
86
+ href
87
+ end
85
88
 
86
89
  opts[:relative] = should_relativize
87
90
 
@@ -92,7 +95,7 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
92
95
  end
93
96
  end
94
97
 
95
- def locate_partial(partial_name, try_static = false)
98
+ def locate_partial(partial_name, try_static=false)
96
99
  locals_dir = extensions[:i18n].options[:templates_dir]
97
100
 
98
101
  # Try /localizable
@@ -103,10 +106,10 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
103
106
  extname = File.extname(partial_name)
104
107
  maybe_static = !extname.empty?
105
108
  suffixed_partial_name = if maybe_static
106
- partial_name.sub(extname, ".#{locale_suffix}#{extname}")
107
- else
108
- "#{partial_name}.#{locale_suffix}"
109
- end
109
+ partial_name.sub(extname, ".#{locale_suffix}#{extname}")
110
+ else
111
+ "#{partial_name}.#{locale_suffix}"
112
+ end
110
113
 
111
114
  if locale_suffix
112
115
  super(suffixed_partial_name, maybe_static) ||
@@ -152,8 +155,6 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
152
155
 
153
156
  # If it's a "localizable template"
154
157
  localizable_folder_resources.each do |resource|
155
- next if resource.ignored?
156
-
157
158
  page_id = File.basename(resource.path, File.extname(resource.path))
158
159
  locales.each do |locale|
159
160
  # Remove folder name
@@ -173,30 +174,15 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
173
174
 
174
175
  # If it uses file extension localization
175
176
  file_extension_resources.each do |resource|
176
- next if resource.ignored?
177
-
178
177
  result = parse_locale_extension(resource.path)
179
178
  ext_locale, path, page_id = result
180
-
181
- new_resource = build_resource(path, resource.path, page_id, ext_locale)
182
-
183
- # extension resources replace original i18n attempt.
184
- exists = new_resources.find { |r| r.path == new_resource.path }
185
- new_resources.delete(exists) if exists
186
-
187
- new_resources << new_resource
179
+ new_resources << build_resource(path, resource.path, page_id, ext_locale)
188
180
 
189
181
  resource.ignore!
190
182
  end
191
183
 
192
184
  @lookup = new_resources.each_with_object({}) do |desc, sum|
193
185
  abs_path = desc.source_path.sub(options[:templates_dir], '')
194
-
195
- # Process templates with locale suffix
196
- locales.each do |locale|
197
- abs_path = abs_path.sub(".#{locale}.", '.')
198
- end
199
-
200
186
  sum[abs_path] ||= {}
201
187
  sum[abs_path][desc.locale] = '/' + desc.path
202
188
  end
@@ -208,15 +194,10 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
208
194
 
209
195
  Contract String, Symbol => Maybe[String]
210
196
  def localized_path(path, locale)
211
- lookup = ::Middleman::Util.parse_uri(path)
212
- lookup.path << app.config[:index_file] if lookup.path&.end_with?('/')
197
+ lookup_path = path.dup
198
+ lookup_path << app.config[:index_file] if lookup_path.end_with?('/')
213
199
 
214
- if @lookup[lookup.path] && @lookup[lookup.path][locale]
215
- lookup.path = @lookup[lookup.path][locale]
216
- lookup.to_s
217
- end
218
- rescue ::Addressable::URI::InvalidURIError
219
- nil
200
+ @lookup[lookup_path] && @lookup[lookup_path][locale]
220
201
  end
221
202
 
222
203
  Contract Symbol => String
@@ -291,14 +272,12 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
291
272
  def build_resource(path, source_path, page_id, locale)
292
273
  old_locale = ::I18n.locale
293
274
  ::I18n.locale = locale
294
- localized_page_id = ::I18n.t("paths.#{page_id}", default: page_id)
295
-
275
+ localized_page_id = ::I18n.t("paths.#{page_id}", default: page_id, fallback: false)
296
276
  partially_localized_path = ''
297
277
 
298
278
  File.dirname(path).split('/').each do |path_sub|
299
279
  next if path_sub == ''
300
-
301
- partially_localized_path = "#{partially_localized_path}/#{::I18n.t("paths.#{path_sub}", default: path_sub)}"
280
+ partially_localized_path = "#{partially_localized_path}/#{::I18n.t("paths.#{path_sub}", default: path_sub, fallback: false)}"
302
281
  end
303
282
 
304
283
  path = "#{partially_localized_path}/#{File.basename(path)}"
@@ -20,7 +20,7 @@ module Middleman
20
20
  after: Maybe[Symbol]
21
21
  }.freeze
22
22
 
23
- def initialize(app, options_hash = {}, &block)
23
+ def initialize(app, options_hash={}, &block)
24
24
  super
25
25
 
26
26
  @rewriters = {}
@@ -53,7 +53,7 @@ module Middleman
53
53
  middleman_app: IsA['Middleman::Application'],
54
54
  rewriters: ArrayOf[REWRITER_DESCRIPTOR]
55
55
  } => Any
56
- def initialize(app, options = {})
56
+ def initialize(app, options={})
57
57
  @rack_app = app
58
58
  @middleman_app = options.fetch(:middleman_app)
59
59
  @rewriters = options.fetch(:rewriters)
@@ -79,10 +79,7 @@ module Middleman
79
79
  path = ::Middleman::Util.full_path(env['PATH_INFO'], @middleman_app)
80
80
 
81
81
  return [status, headers, response] unless path =~ /(^\/$)|(#{@source_exts_regex_text}$)/
82
-
83
- body = ::Middleman::Util.extract_response_text(response)
84
-
85
- return [status, headers, response] unless body
82
+ return [status, headers, response] unless body = ::Middleman::Util.extract_response_text(response)
86
83
 
87
84
  dirpath = ::Pathname.new(File.dirname(path))
88
85
 
@@ -93,10 +90,10 @@ module Middleman
93
90
  relative_path = uri.host.nil?
94
91
 
95
92
  full_asset_path = if relative_path
96
- dirpath.join(asset_path).to_s
97
- else
98
- asset_path
99
- end
93
+ dirpath.join(asset_path).to_s
94
+ else
95
+ asset_path
96
+ end
100
97
 
101
98
  @rewriters.each do |rewriter|
102
99
  uid = rewriter.fetch(:id)
@@ -49,7 +49,7 @@ module Middleman
49
49
  # @option opts [Hash] data Extra metadata to add to the page. This is the same as frontmatter, though frontmatter will take precedence over metadata defined here. Available via {Resource#data}.
50
50
  # @return [void]
51
51
  Contract Or[String, Regexp], Hash => PageDescriptor
52
- def page(path, opts = {})
52
+ def page(path, opts={})
53
53
  options = opts.dup
54
54
 
55
55
  page_data = options.delete(:data) || {}
@@ -100,10 +100,10 @@ Middleman::Extensions.register :minify_css do
100
100
  Middleman::Extensions::MinifyCss
101
101
  end
102
102
 
103
- # MinifyJavaScript compresses JS
103
+ # MinifyJavascript compresses JS
104
104
  Middleman::Extensions.register :minify_javascript do
105
105
  require 'middleman-core/extensions/minify_javascript'
106
- Middleman::Extensions::MinifyJavaScript
106
+ Middleman::Extensions::MinifyJavascript
107
107
  end
108
108
 
109
109
  # GZIP assets and pages during build
@@ -8,7 +8,7 @@ module Middleman
8
8
 
9
9
  public
10
10
 
11
- def initialize(opts = {})
11
+ def initialize(opts={})
12
12
  @timeouts = opts.fetch(:timeouts, 2)
13
13
  end
14
14
 
@@ -21,7 +21,7 @@ module Middleman
21
21
  # Array of Names
22
22
  def getnames(ip)
23
23
  resolver.getnames(ip.to_s).map(&:to_s)
24
- rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL, Errno::ENETUNREACH
24
+ rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL
25
25
  []
26
26
  end
27
27
 
@@ -34,7 +34,7 @@ module Middleman
34
34
  # Array of ipaddresses
35
35
  def getaddresses(name)
36
36
  resolver.getaddresses(name.to_s).map(&:to_s)
37
- rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL, Errno::ENETUNREACH
37
+ rescue Resolv::ResolvError, Errno::EADDRNOTAVAIL
38
38
  []
39
39
  end
40
40
 
@@ -8,7 +8,7 @@ module Middleman
8
8
 
9
9
  public
10
10
 
11
- def initialize(opts = {})
11
+ def initialize(opts={})
12
12
  # using the splat operator works around a non-existing HOSTSRC variable
13
13
  # using nil as input does not work, but `*[]` does and then Resolv::Hosts
14
14
  # uses its defaults
@@ -4,7 +4,7 @@ module Middleman
4
4
  class DnsResolver
5
5
  # Use network name server to resolve ips and names
6
6
  class LocalLinkResolver < BasicNetworkResolver
7
- def initialize(opts = {})
7
+ def initialize(opts={})
8
8
  super
9
9
 
10
10
  @timeouts = opts.fetch(:timeouts, 1)
@@ -4,7 +4,7 @@ module Middleman
4
4
  class DnsResolver
5
5
  # Use network name server to resolve ips and names
6
6
  class NetworkResolver < BasicNetworkResolver
7
- def initialize(opts = {})
7
+ def initialize(opts={})
8
8
  super
9
9
 
10
10
  @resolver = opts.fetch(:resolver, Resolv::DNS.new(nameserver_config))
@@ -27,7 +27,7 @@ module Middleman
27
27
  #
28
28
  # First the local resolver is queried. If this raises an error or returns
29
29
  # nil or [] the network resolver is queried.
30
- def initialize(opts = {})
30
+ def initialize(opts={})
31
31
  @resolvers = []
32
32
  @resolvers << opts.fetch(:hosts_resolver, HostsResolver.new)
33
33