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
@@ -1,7 +1,7 @@
1
1
  helpers do
2
2
  def title
3
3
  content_tag :h1 do
4
- 'Title'
4
+ "Title"
5
5
  end
6
6
  end
7
7
  end
@@ -1,2 +1,2 @@
1
- page '/sub1/page-classes.html', layout: false
2
- page '/sub1/sub2/page-classes.html', layout: false
1
+ page "/sub1/page-classes.html", layout: false
2
+ page "/sub1/sub2/page-classes.html", layout: false
@@ -1,4 +1,4 @@
1
- page '/path/*', layout: 'alt'
1
+ page "/path/*", layout: "alt"
2
2
 
3
3
  # Doesn't work, and shouldn't
4
4
  # page "/path/*" do
@@ -1,7 +1,7 @@
1
- %w[1 2 3].each do |n|
2
- proxy "/#{n}.html", '/index.html', id: "page#{n}"
1
+ %w(1 2 3).each do |n|
2
+ proxy "/#{n}.html", "/index.html", id: "page#{n}"
3
3
  end
4
4
 
5
- page '/overwrites/*', id: :"something-else"
5
+ page "/overwrites/*", id: :"something-else"
6
6
 
7
- config[:page_id_generator] = ->(path) { path + '-foo' }
7
+ config[:page_id_generator] = ->(path){ path + "-foo" }
@@ -1,5 +1,5 @@
1
- %w[1 2 3].each do |n|
2
- proxy "/#{n}.html", '/index.html', id: "page#{n}"
1
+ %w(1 2 3).each do |n|
2
+ proxy "/#{n}.html", "/index.html", id: "page#{n}"
3
3
  end
4
4
 
5
- page '/overwrites/*', id: :"something-else"
5
+ page "/overwrites/*", id: :"something-else"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: "Test Article"
3
- date: "2011-01-01"
3
+ date: 2011-01-01
4
4
  tags: foo
5
5
  ---
6
6
  Test Article Content
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: "Test Article"
3
- date: "2011-01-02"
3
+ date: 2011-01-02
4
4
  tags: foo
5
5
  ---
6
6
  Test Article Content
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: "Test Article"
3
- date: "2011-01-03"
3
+ date: 2011-01-03
4
4
  tags: bar
5
5
  ---
6
6
  Test Article Content
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: "Test Article"
3
- date: "2011-01-04"
3
+ date: 2011-01-04
4
4
  tags: bar
5
5
  ---
6
6
  Test Article Content
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: "Test Article"
3
- date: "2011-01-05"
3
+ date: 2011-01-05
4
4
  tags: bar
5
5
  ---
6
6
  Test Article Content
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: "Test Article"
3
- date: "2011-02-01"
3
+ date: 2011-02-01
4
4
  tags: bar
5
5
  ---
6
6
  Test Article Content
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: "Test Article"
3
- date: "2011-02-02"
3
+ date: 2011-02-02
4
4
  tags: bar
5
5
  ---
6
6
  Test Article Content
@@ -1 +1 @@
1
- Local vars are '<%= locals['foo'] %>', '<%= locals[:bar] %>' and '<%= baz %>'
1
+ Local var is <%= foo %>
@@ -1 +1 @@
1
- <%= partial 'locals', locals: { foo: 'foo', 'bar' => 'bar', 'baz': 'baz' } %>
1
+ <%= partial 'locals', locals: { foo: 'bar' } %>
@@ -1,17 +1,18 @@
1
- proxy '/fake.html', '/real.html', layout: false
2
- proxy 'fake2.html', '/real.html', layout: false
3
- proxy 'fake3.html', 'real.html', layout: false
4
- proxy '/fake4.html', 'real.html', layout: false
1
+ # -*- coding: utf-8 -*-
2
+ proxy "/fake.html", "/real.html", layout: false
3
+ proxy "fake2.html", "/real.html", layout: false
4
+ proxy "fake3.html", "real.html", layout: false
5
+ proxy "/fake4.html", "real.html", layout: false
5
6
 
6
- proxy '/target_ignore.html', '/should_be_ignored3.html', ignore: true
7
- proxy 'target_ignore2.html', '/should_be_ignored6.html', ignore: true
8
- proxy 'target_ignore3.html', 'should_be_ignored7.html', ignore: true
9
- proxy '/target_ignore4.html', 'should_be_ignored8.html', ignore: true
7
+ proxy "/target_ignore.html", "/should_be_ignored3.html", ignore: true
8
+ proxy "target_ignore2.html", "/should_be_ignored6.html", ignore: true
9
+ proxy "target_ignore3.html", "should_be_ignored7.html", ignore: true
10
+ proxy "/target_ignore4.html", "should_be_ignored8.html", ignore: true
10
11
 
11
- %w[one two].each do |num|
12
- proxy "/fake/#{num}.html", '/real/index.html', ignore: true, locals: { num: num }
13
- proxy "fake2/#{num}.html", '/real/index.html', ignore: true, locals: { num: num }
14
- proxy "fake3/#{num}.html", 'real/index.html', ignore: true, locals: { num: num }
12
+ %w(one two).each do |num|
13
+ proxy "/fake/#{num}.html", "/real/index.html", ignore: true, locals: { num: num }
14
+ proxy "fake2/#{num}.html", "/real/index.html", ignore: true, locals: { num: num }
15
+ proxy "fake3/#{num}.html", "real/index.html", ignore: true, locals: { num: num }
15
16
  end
16
17
 
17
- proxy '明日がある.html', '/real.html', layout: false
18
+ proxy "明日がある.html", "/real.html", layout: false
@@ -1,4 +1,4 @@
1
1
  set :sass_assets_paths, [
2
- File.join(root, 'assets', 'stylesheets'),
3
- File.join(root, 'my-vendor', 'stylesheets')
2
+ File.join(root, "assets", "stylesheets"),
3
+ File.join(root, "my-vendor", "stylesheets")
4
4
  ]
@@ -0,0 +1 @@
1
+ @include invalid-mixin;
@@ -1,14 +1,14 @@
1
- require 'sinatra'
1
+ require "sinatra"
2
2
 
3
3
  class MySinatra < Sinatra::Base
4
- get '/' do
5
- 'Hello World (Sinatra)'
4
+ get "/" do
5
+ "Hello World (Sinatra)"
6
6
  end
7
- get '/derp.html' do
8
- 'De doo'
7
+ get "/derp.html" do
8
+ "De doo"
9
9
  end
10
10
  end
11
11
 
12
- map '/sinatra' do
12
+ map "/sinatra" do
13
13
  run MySinatra
14
14
  end
@@ -1,5 +1,5 @@
1
- proxy '/sub/fake.html', '/proxied.html', ignore: true
2
- proxy '/sub/fake2.html', '/proxied.html', ignore: true
1
+ proxy "/sub/fake.html", "/proxied.html", ignore: true
2
+ proxy "/sub/fake2.html", "/proxied.html", ignore: true
3
3
 
4
- proxy '/directory-indexed/fake.html', '/proxied.html', ignore: true
5
- proxy '/directory-indexed/fake2.html', '/proxied.html', ignore: true
4
+ proxy "/directory-indexed/fake.html", "/proxied.html", ignore: true
5
+ proxy "/directory-indexed/fake2.html", "/proxied.html", ignore: true
@@ -7,7 +7,7 @@ class ExtensionOne < ::Middleman::Extension
7
7
 
8
8
  attr_reader :extension_two_was_activated
9
9
 
10
- def initialize(app, options_hash = {})
10
+ def initialize(app, options_hash={})
11
11
  super
12
12
 
13
13
  after_extension_activated :extension_two do
@@ -27,7 +27,7 @@ class ExtensionTwo < ::Middleman::Extension
27
27
 
28
28
  attr_reader :extension_one_was_activated
29
29
 
30
- def initialize(app, options_hash = {})
30
+ def initialize(app, options_hash={})
31
31
  super
32
32
 
33
33
  after_extension_activated :extension_one do
@@ -1 +1 @@
1
- page '/admin/*', layout: :admin
1
+ page "/admin/*", layout: :admin
@@ -1,2 +1,2 @@
1
1
  activate :directory_indexes
2
- page '/admin/*', layout: :admin
2
+ page "/admin/*", layout: :admin
@@ -2,4 +2,11 @@ require 'middleman-core/load_paths'
2
2
  ::Middleman.setup_load_paths
3
3
 
4
4
  require 'middleman-core'
5
+ require 'middleman-core/rack'
5
6
  require 'middleman-core/application'
7
+
8
+ module Middleman
9
+ def self.server
10
+ ::Middleman::Rack.new(::Middleman::Application.new)
11
+ end
12
+ end
@@ -53,7 +53,7 @@ module Middleman
53
53
  # An anonymous subclass of ::Middleman::TemplateContext
54
54
  attr_reader :template_context_class
55
55
 
56
- # An instance of the above anonymous class.
56
+ # An instance of the above anonymouse class.
57
57
  attr_reader :generic_template_context
58
58
 
59
59
  Contract ::Middleman::Configuration::ConfigurationManager
@@ -158,11 +158,11 @@ module Middleman
158
158
 
159
159
  # Which file extensions have a layout by default.
160
160
  # @return [Array.<String>]
161
- define_setting :extensions_with_layout, %w[.htm .html .xhtml .php], 'Which file extensions have a layout by default.'
161
+ define_setting :extensions_with_layout, %w(.htm .html .xhtml .php), 'Which file extensions have a layout by default.'
162
162
 
163
163
  # Which file extensions are "assets."
164
164
  # @return [Array.<String>]
165
- define_setting :asset_extensions, %w[.css .png .jpg .jpeg .webp .svg .svgz .js .gif .ttf .otf .woff .woff2 .eot .ico .map], 'Which file extensions are treated as assets.'
165
+ define_setting :asset_extensions, %w(.css .png .jpg .jpeg .webp .svg .svgz .js .gif .ttf .otf .woff .woff2 .eot .ico .map), 'Which file extensions are treated as assets.'
166
166
 
167
167
  # Default string encoding for templates and output.
168
168
  # @return [String]
@@ -182,7 +182,7 @@ module Middleman
182
182
  ignored = false
183
183
 
184
184
  file[:relative_path].ascend do |f|
185
- if /^_[^_]/.match?(f.basename.to_s)
185
+ if f.basename.to_s =~ %r{^_[^_]}
186
186
  ignored = true
187
187
  break
188
188
  end
@@ -345,14 +345,13 @@ module Middleman
345
345
 
346
346
  # Clean up missing Tilt exts
347
347
  def prune_tilt_templates!
348
- mapping = ::Tilt.default_mapping
349
- mapping.lazy_map.each_key do |key|
348
+ ::Tilt.default_mapping.lazy_map.each_key do |key|
350
349
  begin
351
- mapping[key]
350
+ ::Tilt[".#{key}"]
352
351
  rescue LoadError, NameError
352
+ ::Tilt.default_mapping.lazy_map.delete(key)
353
353
  end
354
354
  end
355
- mapping.lazy_map.clear
356
355
  end
357
356
 
358
357
  # Whether we're in a specific mode
@@ -439,10 +438,10 @@ module Middleman
439
438
  #
440
439
  # @deprecated Prefer accessing settings through "config".
441
440
  #
442
- # @param [Symbol] key Name of the attribute
441
+ # @param [Symbol] key Name of the attribue
443
442
  # @param value Attribute value
444
443
  # @return [void]
445
- def set(key, value = nil, &block)
444
+ def set(key, value=nil, &block)
446
445
  logger.warn "Warning: `set :#{key}` is deprecated. Use `config[:#{key}] =` instead."
447
446
 
448
447
  value = block if block_given?
@@ -21,17 +21,17 @@ module Middleman
21
21
  def_delegator :@app, :logger
22
22
 
23
23
  # Sort order, images, fonts, js/css and finally everything else.
24
- SORT_ORDER = %w[.png .jpeg .jpg .gif .bmp .svg .svgz .webp .ico .woff .woff2 .otf .ttf .eot .js .css].freeze
24
+ SORT_ORDER = %w(.png .jpeg .jpg .gif .bmp .svg .svgz .webp .ico .woff .woff2 .otf .ttf .eot .js .css).freeze
25
25
 
26
26
  # Create a new Builder instance.
27
27
  # @param [Middleman::Application] app The app to build.
28
28
  # @param [Hash] opts The builder options
29
- def initialize(app, opts = {})
29
+ def initialize(app, opts={})
30
30
  @app = app
31
31
  @source_dir = Pathname(File.join(@app.root, @app.config[:source]))
32
32
  @build_dir = Pathname(@app.config[:build_dir])
33
33
 
34
- if /\A[.\/]+\Z/.match?(@build_dir.expand_path.relative_path_from(@source_dir).to_s)
34
+ if @build_dir.expand_path.relative_path_from(@source_dir).to_s =~ /\A[.\/]+\Z/
35
35
  raise ":build_dir (#{@build_dir}) cannot be a parent of :source_dir (#{@source_dir})"
36
36
  end
37
37
 
@@ -133,40 +133,11 @@ module Middleman
133
133
 
134
134
  Contract ResourceList => ResourceList
135
135
  def output_resources(resources)
136
- res_count = resources.count
137
-
138
- return resources if res_count.zero?
139
-
140
136
  results = if @parallel
141
- processes = ::Parallel.processor_count
142
- processes = processes < res_count ? processes : res_count
143
- min_parts = res_count / processes
144
- remainder = res_count % processes
145
- offset = 0
146
- ranges = []
147
-
148
- while offset < res_count
149
- end_r = offset + min_parts
150
-
151
- if remainder.positive?
152
- end_r += 1
153
- remainder -= 1
154
- end
155
-
156
- range = offset...end_r
157
- offset = end_r
158
- ranges << range
159
- end
160
-
161
- outputs = Parallel.map(ranges, in_processes: processes) do |r|
162
- resources[r].map!(&method(:output_resource))
163
- end
164
-
165
- outputs.flatten!
166
- outputs
167
- else
168
- resources.map(&method(:output_resource))
169
- end
137
+ ::Parallel.map(resources, &method(:output_resource))
138
+ else
139
+ resources.map(&method(:output_resource))
140
+ end
170
141
 
171
142
  @has_error = true if results.any? { |r| r == false }
172
143
 
@@ -175,11 +146,11 @@ module Middleman
175
146
  next unless p.exist?
176
147
 
177
148
  # handle UTF-8-MAC filename on MacOS
178
- cleaned_name = if RUBY_PLATFORM.match?(/darwin/)
179
- p.to_s.encode('UTF-8', 'UTF-8-MAC')
180
- else
181
- p
182
- end
149
+ cleaned_name = if RUBY_PLATFORM =~ /darwin/
150
+ p.to_s.encode('UTF-8', 'UTF-8-MAC')
151
+ else
152
+ p
153
+ end
183
154
 
184
155
  @to_clean.delete(Pathname(cleaned_name))
185
156
  end
@@ -213,8 +184,8 @@ module Middleman
213
184
  ])
214
185
  file.binmode
215
186
  file.write(contents)
216
- File.chmod(0o644, file)
217
187
  file.close
188
+ File.chmod(0o644, file)
218
189
  file
219
190
  end
220
191
 
@@ -228,14 +199,14 @@ module Middleman
228
199
  source = write_tempfile(output_file, source.to_s) if source.is_a? String
229
200
 
230
201
  method, source_path = if source.is_a? Tempfile
231
- [::FileUtils.method(:mv), source.path]
232
- else
233
- [::FileUtils.method(:cp), source.to_s]
234
- end
202
+ [::FileUtils.method(:mv), source.path]
203
+ else
204
+ [::FileUtils.method(:cp), source.to_s]
205
+ end
235
206
 
236
207
  mode = which_mode(output_file, source_path)
237
208
 
238
- if %i[created updated].include? mode
209
+ if mode == :created || mode == :updated
239
210
  ::FileUtils.mkdir_p(output_file.dirname)
240
211
  method.call(source_path, output_file.to_s)
241
212
  end
@@ -268,7 +239,7 @@ module Middleman
268
239
  return false
269
240
  end
270
241
  end
271
- rescue StandardError => e
242
+ rescue => e
272
243
  trigger(:error, output_file, "#{e}\n#{e.backtrace.join("\n")}")
273
244
  return false
274
245
  end
@@ -296,7 +267,7 @@ module Middleman
296
267
 
297
268
  # handle UTF-8-MAC filename on MacOS
298
269
  @to_clean = @to_clean.map do |path|
299
- if RUBY_PLATFORM.match?(/darwin/)
270
+ if RUBY_PLATFORM =~ /darwin/
300
271
  Pathname(path.to_s.encode('UTF-8', 'UTF-8-MAC'))
301
272
  else
302
273
  Pathname(path)
@@ -324,7 +295,7 @@ module Middleman
324
295
  end
325
296
 
326
297
  Contract Symbol, Or[String, Pathname], Maybe[String] => Any
327
- def trigger(event_type, target, extra = nil)
298
+ def trigger(event_type, target, extra=nil)
328
299
  @events[event_type] ||= []
329
300
  @events[event_type] << target
330
301
 
@@ -47,7 +47,7 @@ module Middleman
47
47
  end
48
48
 
49
49
  Contract Or[Symbol, ArrayOf[Symbol]], Maybe[ArrayOf[Any]], Maybe[RespondTo[:instance_exec]] => Any
50
- def execute(keys, args = [], scope = self)
50
+ def execute(keys, args=[], scope=self)
51
51
  callbacks = callbacks_for(keys)
52
52
  callbacks_count = callbacks.length + @subscribers.length
53
53
 
@@ -16,7 +16,7 @@ module Middleman
16
16
  @template_context_class = template_context_class
17
17
 
18
18
  @callbacks = ::Middleman::CallbackManager.new
19
- @callbacks.install_methods!(self, %i[before_build after_build configure after_configuration ready])
19
+ @callbacks.install_methods!(self, [:before_build, :after_build, :configure, :after_configuration, :ready])
20
20
 
21
21
  # Trigger internal callbacks when app level are executed.
22
22
  app.subscribe_to_callbacks(&method(:execute_callbacks))
@@ -49,7 +49,7 @@ module Middleman
49
49
  instance_eval File.read(other_config), other_config, 1
50
50
  end
51
51
 
52
- def set(key, default = nil, &block)
52
+ def set(key, default=nil, &block)
53
53
  config.define_setting(key, default) unless config.defines_setting?(key)
54
54
  @app.config[key] = block_given? ? block : default
55
55
  end
@@ -43,15 +43,15 @@ module Middleman
43
43
  if defines_setting?(method) && args.empty?
44
44
  self[method]
45
45
  elsif method.to_s =~ /^(\w+)=$/ && args.size == 1
46
- self[Regexp.last_match(1).to_sym] = args[0]
46
+ self[$1.to_sym] = args[0]
47
47
  else
48
48
  super
49
49
  end
50
50
  end
51
51
 
52
52
  # Needed so that method_missing makes sense
53
- def respond_to?(method, include_private = false)
54
- super || defines_setting?(method) || (method =~ /^(\w+)=$/ && defines_setting?(Regexp.last_match(1)))
53
+ def respond_to?(method, include_private=false)
54
+ super || defines_setting?(method) || (method =~ /^(\w+)=$/ && defines_setting?($1))
55
55
  end
56
56
 
57
57
  # Does this configuration manager know about the setting identified by key?
@@ -71,7 +71,7 @@ module Middleman
71
71
  # @param [String] description A human-readable description of what the option does
72
72
  # @param [Hash] options Additional options.
73
73
  # @return [ConfigSetting]
74
- def define_setting(key, default = nil, description = nil, options = {})
74
+ def define_setting(key, default=nil, description=nil, options={})
75
75
  raise "Setting #{key} doesn't exist" if @finalized
76
76
  raise "Setting #{key} already defined" if @settings.key?(key)
77
77
  raise 'Setting key must be a Symbol' unless key.is_a? Symbol
@@ -127,7 +127,7 @@ module Middleman
127
127
  # Additional config.
128
128
  attr_accessor :options
129
129
 
130
- def initialize(key, default, description, options = {})
130
+ def initialize(key, default, description, options={})
131
131
  @value_set = false
132
132
  self.key = key
133
133
  self.default = default
@@ -29,10 +29,10 @@ else
29
29
 
30
30
  # rubocop:disable MethodName
31
31
  def Contract(*); end
32
- # rubocop:enable MethodName
33
32
 
34
33
  class Callable
35
- def self.[](*); end
34
+ def self.[](*)
35
+ end
36
36
  end
37
37
 
38
38
  class Bool
@@ -13,7 +13,7 @@ module Middleman
13
13
  @data = data
14
14
  end
15
15
 
16
- def value(_ctx = nil)
16
+ def value(_ctx=nil)
17
17
  @data
18
18
  end
19
19
 
@@ -2,9 +2,9 @@ module Middleman
2
2
  module CoreExtensions
3
3
  module Collections
4
4
  class LazyCollectorStep < BasicObject
5
- DELEGATE = %i[hash eql?].freeze
5
+ DELEGATE = [:hash, :eql?].freeze
6
6
 
7
- def initialize(name, args, block, parent = nil)
7
+ def initialize(name, args, block, parent=nil)
8
8
  @name = name
9
9
  @args = args
10
10
  @block = block
@@ -19,19 +19,19 @@ module Middleman
19
19
  @parent.leaves
20
20
  end
21
21
 
22
- def value(ctx = nil)
22
+ def value(ctx=nil)
23
23
  data = @parent.value(ctx)
24
24
 
25
25
  original_block = @block
26
26
 
27
27
  if original_block
28
28
  b = if ctx
29
- ::Proc.new do |*args|
30
- ctx.instance_exec(*args, &original_block)
31
- end
32
- else
33
- original_block
34
- end
29
+ ::Proc.new do |*args|
30
+ ctx.instance_exec(*args, &original_block)
31
+ end
32
+ else
33
+ original_block
34
+ end
35
35
  end
36
36
 
37
37
  data.send(@name, *@args.deep_dup, &b)
@@ -8,12 +8,12 @@ module Middleman
8
8
  return to_enum(__method__, per_page) unless block_given?
9
9
 
10
10
  parts = if per_page.respond_to? :call
11
- per_page.call(dup)
12
- else
13
- each_slice(per_page).reduce([]) do |sum, items|
14
- sum << items
15
- end
16
- end
11
+ per_page.call(dup)
12
+ else
13
+ each_slice(per_page).reduce([]) do |sum, items|
14
+ sum << items
15
+ end
16
+ end
17
17
 
18
18
  num_pages = parts.length
19
19
  collection = self
@@ -34,7 +34,7 @@ module Middleman
34
34
  end
35
35
  end
36
36
 
37
- def initialize(app, options_hash = {}, &block)
37
+ def initialize(app, options_hash={}, &block)
38
38
  super
39
39
 
40
40
  @leaves = Set.new