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
@@ -30,10 +30,6 @@ module Middleman
30
30
 
31
31
  def evaluate(scope, locals, &block)
32
32
  options = {}.merge!(@options).merge!(filename: eval_file, line: line, context: @context || scope)
33
- if options.include?(:outvar)
34
- options[:buffer] = options.delete(:outvar)
35
- options[:save_buffer] = true
36
- end
37
33
  @engine = ::Haml::Engine.new(data, options)
38
34
  output = @engine.render(scope, locals, &block)
39
35
 
@@ -43,14 +39,13 @@ module Middleman
43
39
 
44
40
  # Haml Renderer
45
41
  class Haml < ::Middleman::Extension
46
- def initialize(app, options = {}, &block)
42
+ def initialize(app, options={}, &block)
47
43
  super
48
44
 
49
45
  ::Haml::Options.defaults[:context] = nil
50
46
  ::Haml::Options.send :attr_accessor, :context
51
- if defined?(::Haml::TempleEngine)
52
- ::Haml::TempleEngine.define_options context: nil
53
- end
47
+
48
+ # rubocop:disable NestedMethodDefinition
54
49
  [::Haml::Filters::Sass, ::Haml::Filters::Scss, ::Haml::Filters::Markdown].each do |f|
55
50
  f.class_exec do
56
51
  def self.render_with_options(text, compiler_options)
@@ -62,6 +57,7 @@ module Middleman
62
57
  end
63
58
  end
64
59
  end
60
+ # rubocop:enable NestedMethodDefinition
65
61
 
66
62
  ::Tilt.prefer(::Middleman::Renderers::HamlTemplate, :haml)
67
63
 
@@ -6,7 +6,7 @@ module Middleman
6
6
  class Less < ::Middleman::Extension
7
7
  define_setting :less, {}, 'LESS compiler options'
8
8
 
9
- def initialize(app, options = {}, &block)
9
+ def initialize(app, options={}, &block)
10
10
  super
11
11
 
12
12
  # Tell Tilt to use it as well (for inline sass blocks)
@@ -11,10 +11,9 @@ module Middleman
11
11
  end
12
12
 
13
13
  # Called by Liquid to retrieve a template file
14
- def read_template_file(template_path)
14
+ def read_template_file(template_path, _)
15
15
  file = app.files.find(:source, "_#{template_path}.liquid")
16
16
  raise ::Liquid::FileSystemError, "No such template '#{template_path}'" unless file
17
-
18
17
  file.read
19
18
  end
20
19
 
@@ -25,7 +24,7 @@ module Middleman
25
24
 
26
25
  resources.each do |resource|
27
26
  next if resource.file_descriptor.nil?
28
- next unless resource.file_descriptor[:full_path].to_s =~ /\.liquid$/
27
+ next unless resource.file_descriptor[:full_path].to_s =~ %r{\.liquid$}
29
28
 
30
29
  # Convert data object into a hash for liquid
31
30
  resource.add_metadata locals: {
@@ -7,7 +7,7 @@ module Middleman
7
7
 
8
8
  # Once configuration is parsed
9
9
  def after_configuration
10
- markdown_exts = %w[markdown mdown md mkd mkdn]
10
+ markdown_exts = %w(markdown mdown md mkd mkdn)
11
11
 
12
12
  begin
13
13
  # Look for the user's preferred engine
@@ -20,12 +20,12 @@ module Middleman
20
20
  elsif app.config[:markdown_engine]
21
21
  # Map symbols to classes
22
22
  markdown_engine_klass = if app.config[:markdown_engine].is_a? Symbol
23
- engine = app.config[:markdown_engine].to_s
24
- engine = engine == 'rdiscount' ? 'RDiscount' : engine.camelize
25
- app.config[:markdown_engine_prefix].const_get("#{engine}Template")
26
- else
27
- app.config[:markdown_engine_prefix]
28
- end
23
+ engine = app.config[:markdown_engine].to_s
24
+ engine = engine == 'rdiscount' ? 'RDiscount' : engine.camelize
25
+ app.config[:markdown_engine_prefix].const_get("#{engine}Template")
26
+ else
27
+ app.config[:markdown_engine_prefix]
28
+ end
29
29
 
30
30
  # Tell tilt to use that engine
31
31
  ::Tilt.prefer(markdown_engine_klass, *markdown_exts)
@@ -35,7 +35,7 @@ module Middleman
35
35
  end
36
36
 
37
37
  # Renderer Options
38
- possible_render_opts = %i[filter_html no_images no_links no_styles safe_links_only with_toc_data hard_wrap xhtml prettify link_attributes]
38
+ possible_render_opts = [:filter_html, :no_images, :no_links, :no_styles, :safe_links_only, :with_toc_data, :hard_wrap, :xhtml, :prettify, :link_attributes]
39
39
 
40
40
  render_options = possible_render_opts.each_with_object({}) do |opt, sum|
41
41
  sum[opt] = options.delete(opt) if options.key?(opt)
@@ -65,7 +65,7 @@ module Middleman
65
65
  class MiddlemanRedcarpetHTML < ::Redcarpet::Render::HTML
66
66
  cattr_accessor :scope
67
67
 
68
- def initialize(options = {})
68
+ def initialize(options={})
69
69
  @local_options = options.dup
70
70
 
71
71
  super
@@ -1,32 +1,20 @@
1
- require 'sass'
2
-
3
- begin
4
- require 'sassc'
5
- rescue LoadError
6
- end
1
+ require 'sassc'
7
2
 
8
3
  module Middleman
9
4
  module Renderers
10
5
  # Sass renderer
11
6
  class Sass < ::Middleman::Extension
12
- DEFAULT_SASS_CACHE_LOCATION = './.sass-cache'.freeze
13
-
14
7
  opts = { output_style: :nested }
15
8
  opts[:line_comments] = false if ENV['TEST']
16
9
  define_setting :sass, opts, 'Sass engine options'
17
10
  define_setting :sass_assets_paths, [], 'Paths to extra SASS/SCSS files'
18
11
  define_setting :sass_source_maps, nil, 'Whether to inline sourcemap into Sass'
19
- define_setting :sass_cache_location, ENV['SASS_CACHE_LOCATION'] || DEFAULT_SASS_CACHE_LOCATION, 'Where to store sass cache files'
20
12
 
21
13
  # Setup extension
22
- def initialize(app, options = {}, &block)
14
+ def initialize(app, options={}, &block)
23
15
  super
24
16
 
25
- logger.info '== Preferring use of LibSass' if defined?(::SassC)
26
-
27
- if app.config[:sass_cache_location] == DEFAULT_SASS_CACHE_LOCATION
28
- app.files.ignore :sass_cache, :source, /(^|\/)\.sass-cache\//
29
- end
17
+ app.files.ignore :sass_cache, :source, /(^|\/)\.sass-cache\//
30
18
 
31
19
  # Tell Tilt to use it as well (for inline sass blocks)
32
20
  ::Tilt.register 'sass', SassPlusCSSFilenameTemplate
@@ -61,32 +49,41 @@ module Middleman
61
49
  def evaluate(context, _)
62
50
  @context ||= context
63
51
 
64
- sass_module = if defined?(::SassC)
65
- ::SassC
66
- else
67
- ::Sass
68
- end
69
-
70
- @engine = sass_module::Engine.new(data, sass_options)
52
+ @engine = ::SassC::Engine.new(data, sass_options)
71
53
 
72
54
  begin
73
55
  @engine.render
74
- rescue sass_module::SyntaxError => e
75
- ::Sass::SyntaxError.exception_to_css(e)
56
+ rescue ::SassC::SyntaxError => e
57
+ exception_to_css(e)
76
58
  end
77
59
  end
78
60
 
61
+ def exception_to_css(e)
62
+ header = "#{e.class}: #{e.message}"
63
+
64
+ <<~END
65
+ /*
66
+ #{header.gsub('*/', '*\\/')}
67
+
68
+ Backtrace:\n#{e.backtrace.join("\n").gsub('*/', '*\\/')}
69
+ */
70
+ body:before {
71
+ white-space: pre;
72
+ font-family: monospace;
73
+ content: "#{header.gsub('"', '\"').gsub("\n", '\\A ')}"; }
74
+ END
75
+ end
76
+
79
77
  # Change Sass path, for url functions, to the build folder if we're building
80
78
  # @return [Hash]
81
79
  def sass_options
82
80
  ctx = @context
83
81
 
84
82
  more_opts = {
85
- load_paths: ::Sass.load_paths | ctx.app.config[:sass_assets_paths],
83
+ load_paths: ctx.app.config[:sass_assets_paths],
86
84
  filename: eval_file,
87
85
  line: line,
88
86
  syntax: syntax,
89
- cache_location: ctx.app.config[:sass_cache_location],
90
87
  custom: {}.merge!(options[:custom] || {}).merge!(
91
88
  middleman_context: ctx.app,
92
89
  current_resource: ctx.current_resource
@@ -14,9 +14,9 @@ module Middleman
14
14
  # background: url(image-path("image.jpg")); // background: url("/assets/image.jpg");
15
15
  # background: url(image-path("image.jpg", $digest: true)); // background: url("/assets/image-27a8f1f96afd8d4c67a59eb9447f45bd.jpg");
16
16
  #
17
- def image_path(source, options = {})
17
+ def image_path(source, options={})
18
18
  p = ::Middleman::Util.asset_path(middleman_context, :images, source.value, map_options(options))
19
- ::Sass::Script::String.new p.to_s, :string
19
+ ::SassC::Script::Value::String.new p.to_s, :string
20
20
  end
21
21
 
22
22
  # Using Middleman::Util#asset_path, return the url CSS
@@ -28,7 +28,7 @@ module Middleman
28
28
  # background: image-url("image.jpg"); // background: url("/assets/image.jpg");
29
29
  # background: image-url("image.jpg", $digest: true); // background: url("/assets/image-27a8f1f96afd8d4c67a59eb9447f45bd.jpg");
30
30
  #
31
- def image_url(source, options = {}, _cache_buster = nil)
31
+ def image_url(source, options={}, _cache_buster=nil)
32
32
  # Work with the Compass #image_url API
33
33
  if options.respond_to? :value
34
34
  case options.value
@@ -38,7 +38,8 @@ module Middleman
38
38
  options = {}
39
39
  end
40
40
  end
41
- ::Sass::Script::String.new "url(#{image_path(source, options)})"
41
+
42
+ ::SassC::Script::Value::String.new "url(#{image_path(source, options)})"
42
43
  end
43
44
 
44
45
  # Using Middleman::Util#asset_path, return the full path
@@ -50,9 +51,9 @@ module Middleman
50
51
  # src: url(font-path("font.ttf")); // src: url("/assets/font.ttf");
51
52
  # src: url(font-path("font.ttf", $digest: true)); // src: url("/assets/font-27a8f1f96afd8d4c67a59eb9447f45bd.ttf");
52
53
  #
53
- def font_path(source, options = {})
54
+ def font_path(source, options={})
54
55
  p = ::Middleman::Util.asset_path(middleman_context, :fonts, source.value, map_options(options))
55
- ::Sass::Script::String.new p.to_s, :string
56
+ ::SassC::Script::Value::String.new p.to_s, :string
56
57
  end
57
58
 
58
59
  # Using Middleman::Util#asset_path, return the url CSS
@@ -64,7 +65,7 @@ module Middleman
64
65
  # src: font-url("font.ttf"); // src: url("/assets/font.ttf");
65
66
  # src: font-url("image.jpg", $digest: true); // src: url("/assets/font-27a8f1f96afd8d4c67a59eb9447f45bd.ttf");
66
67
  #
67
- def font_url(source, options = {})
68
+ def font_url(source, options={})
68
69
  # Work with the Compass #font_url API
69
70
  if options.respond_to? :value
70
71
  case options.value
@@ -74,7 +75,7 @@ module Middleman
74
75
  options = {}
75
76
  end
76
77
  end
77
- ::Sass::Script::String.new "url(#{font_path(source, options)})"
78
+ ::SassC::Script::Value::String.new "url(#{font_path(source, options)})"
78
79
  end
79
80
 
80
81
  protected
@@ -92,10 +93,10 @@ module Middleman
92
93
 
93
94
  # Returns an options hash where the keys are symbolized
94
95
  # and the values are unwrapped Sass literals.
95
- def map_options(options = {}) # :nodoc:
96
- ::Sass::Util.map_hash(options) do |key, value|
97
- [key.to_sym, value.respond_to?(:value) ? value.value : value]
98
- end
96
+ def map_options(options={}) # :nodoc:
97
+ # ::Sass::Util.map_hash(options) do |key, value|
98
+ # [key.to_sym, value.respond_to?(:value) ? value.value : value]
99
+ # end
99
100
 
100
101
  options[:current_resource] = current_resource
101
102
 
@@ -105,8 +106,4 @@ module Middleman
105
106
  end
106
107
  end
107
108
 
108
- if defined?(::SassC)
109
- ::SassC::Script::Functions.send :include, ::Middleman::Sass::Functions
110
- elsif defined?(::Sass)
111
- ::Sass::Script::Functions.send :include, ::Middleman::Sass::Functions
112
- end
109
+ ::SassC::Script::Functions.send :include, ::Middleman::Sass::Functions
@@ -13,7 +13,7 @@ class ::Slim::Template
13
13
  def initialize(file, line, opts, &block)
14
14
  if opts.key?(:context)
15
15
  ::Slim::Embedded::SassEngine.disable_option_validator!
16
- %w[sass scss markdown].each do |engine|
16
+ %w(sass scss markdown).each do |engine|
17
17
  (::Slim::Embedded.options[engine.to_sym] ||= {})[:context] = opts[:context]
18
18
  end
19
19
  end
@@ -31,7 +31,7 @@ module Middleman
31
31
  # Slim renderer
32
32
  class Slim < ::Middleman::Extension
33
33
  # Setup extension
34
- def initialize(_app, _options = {}, &_block)
34
+ def initialize(_app, _options={}, &_block)
35
35
  super
36
36
 
37
37
  # Setup Slim options to work with partials
@@ -12,7 +12,7 @@ module Middleman
12
12
  # @param [String, Regexp] path Path glob expression, or path regex
13
13
  # @return [IgnoreDescriptor]
14
14
  Contract Or[String, Regexp, Proc] => RespondTo[:execute_descriptor]
15
- def ignore(path = nil, &block)
15
+ def ignore(path=nil, &block)
16
16
  @app.sitemap.invalidate_resources_not_ignored_cache!
17
17
 
18
18
  if path.is_a? Regexp
@@ -34,7 +34,7 @@ module Middleman
34
34
 
35
35
  IgnoreDescriptor = Struct.new(:path, :block) do
36
36
  def execute_descriptor(_app, resources)
37
- resources.each do |r|
37
+ resources.map do |r|
38
38
  # Ignore based on the source path (without template extensions)
39
39
  if ignored?(r.normalized_path)
40
40
  r.ignore!
@@ -42,6 +42,8 @@ module Middleman
42
42
  # This allows files to be ignored by their source file name (with template extensions)
43
43
  r.ignore!
44
44
  end
45
+
46
+ r
45
47
  end
46
48
  end
47
49
 
@@ -12,7 +12,7 @@ module Middleman
12
12
 
13
13
  ImportFileDescriptor = Struct.new(:from, :to) do
14
14
  def execute_descriptor(app, resources)
15
- source = ::Middleman::SourceFile.new(Pathname(from).relative_path_from(app.source_dir), Pathname(from), app.source_dir, Set.new(%i[source binary]), 0)
15
+ source = ::Middleman::SourceFile.new(Pathname(from).relative_path_from(app.source_dir), Pathname(from), app.source_dir, Set.new([:source, :binary]), 0)
16
16
 
17
17
  resources + [
18
18
  ::Middleman::Sitemap::Resource.new(app.sitemap, to, source)
@@ -7,7 +7,7 @@ module Middleman
7
7
  class OnDisk < Extension
8
8
  self.resource_list_manipulator_priority = 0
9
9
 
10
- def initialize(app, config = {}, &block)
10
+ def initialize(app, config={}, &block)
11
11
  super
12
12
 
13
13
  @file_paths_on_disk = Set.new
@@ -22,7 +22,7 @@ module Middleman
22
22
  # @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}.
23
23
  # @return [ProxyDescriptor]
24
24
  Contract String, String, Maybe[Hash] => RespondTo[:execute_descriptor]
25
- def proxy(path, target, opts = {})
25
+ def proxy(path, target, opts={})
26
26
  ProxyDescriptor.new(
27
27
  ::Middleman::Util.normalize_path(path),
28
28
  ::Middleman::Util.normalize_path(target),
@@ -75,7 +75,6 @@ module Middleman
75
75
 
76
76
  target = ::Middleman::Util.normalize_path(target)
77
77
  raise "You can't proxy #{path} to itself!" if target == path
78
-
79
78
  @target = target
80
79
  end
81
80
 
@@ -29,7 +29,7 @@ module Middleman
29
29
  # @param [String] path
30
30
  # @param [Hash] opts The :to value gives a target path
31
31
  Contract String, { to: Or[String, ::Middleman::Sitemap::Resource] }, Maybe[Proc] => RedirectDescriptor
32
- def redirect(path, opts = {}, &block)
32
+ def redirect(path, opts={}, &block)
33
33
  RedirectDescriptor.new(path, opts[:to], block_given? ? block : nil)
34
34
  end
35
35
  end
@@ -27,7 +27,7 @@ module Middleman
27
27
  # @param [Hash] opts The :path value gives a request path if it
28
28
  # differs from the output path
29
29
  Contract String, Or[{ path: String }, Proc] => EndpointDescriptor
30
- def endpoint(path, opts = {}, &block)
30
+ def endpoint(path, opts={}, &block)
31
31
  if block_given?
32
32
  EndpointDescriptor.new(path, path, block)
33
33
  else
@@ -4,93 +4,39 @@ module Middleman
4
4
  module Traversal
5
5
  def traversal_root
6
6
  root = if !@app.extensions[:i18n]
7
- '/'
8
- else
9
- @app.extensions[:i18n].path_root(::I18n.locale)
10
- end
7
+ '/'
8
+ else
9
+ @app.extensions[:i18n].path_root(::I18n.locale)
10
+ end
11
11
 
12
12
  root.sub(/^\//, '')
13
13
  end
14
14
 
15
15
  # This resource's parent resource
16
16
  # @return [Middleman::Sitemap::Resource, nil]
17
- def parent(_recurse = false)
18
- max_recursion = @app.config[:max_traversal_recursion] || 99
19
- parent_helper(path, max_recursion)
20
- end
21
-
22
- def parent_helper(child_path, max_recursion)
23
- # What is the configured format for index pages.
24
- index_file = @app.config[:index_file]
25
- parts = child_path.split('/')
26
- # Reduce the path by the current page to get the parent level path.
27
- current_page = parts.pop
28
- # Does the current page has the name of an index file?
29
- is_index = current_page == index_file
30
- # Is the `current_page` in the traversal root?
31
- # Note: `traversal_root` is `/` for non localized pages and `/[lang]/` for
32
- # localized pages.
33
- at_traversal_root = !(child_path =~ /^#{traversal_root}#{current_page}$/).nil?
34
-
35
- # Check that we have any path parts left after the pop because if we
36
- # don't, `current_page` is either root or another file under root.
37
- # Also, if we are `at_traversal_root`, we consider this root.
38
- if parts.empty? || at_traversal_root
39
- # If this `is_index`, the `current_page` is root and there is no parent.
40
- return nil if is_index
17
+ def parent
18
+ root = path.sub(/^#{::Regexp.escape(traversal_root)}/, '')
19
+ parts = root.split('/')
41
20
 
42
- # `current_page` must be a page under root, let's return the root
43
- # index page of the `traversal_root` (`/` or `/[lang]/`).
44
- return @store.find_resource_by_path("#{traversal_root}#{index_file}")
45
- end
46
-
47
- # Get the index file for the parent path parts, e.g.: `/blog/index.html`
48
- # for `/blog/`.
49
- index_by_parts = proc do |subparts|
50
- found = @store.find_resource_by_destination_path("#{subparts.join('/')}/#{index_file}")
51
- return found unless found.nil?
52
- end
21
+ tail = parts.pop
22
+ is_index = (tail == @app.config[:index_file])
53
23
 
54
- # Get a file that has the name of the parent path parts e.g.:
55
- # `/blog.html` for `/blog/`.
56
- file_by_parts = proc do |subparts|
57
- test_expr = Regexp.escape(subparts.join('/'))
58
- # eponymous reverse-lookup
59
- found = @store.resources.find do |candidate|
60
- candidate.path =~ %r{^#{test_expr}(?:\.[a-zA-Z0-9]+|\/)$}
61
- end
62
- return found unless found.nil?
24
+ if parts.empty?
25
+ return is_index ? nil : @store.find_resource_by_path(@app.config[:index_file])
63
26
  end
64
27
 
65
- # Try to find a file matching the parent path name and return it.
66
- # E.g. `parts == ['en', 'blog']`, we try to find: `/en/blog.html`
67
- file_by_parts.call(parts)
68
-
69
- # Try to find an non-localized parent instead if `traversal_root`
70
- # indicates the path is localized and there are still more parts
71
- # remaining, and return it.
72
- # E.g. `parts == ['en', 'blog']`, we try to find: `/blog.html`
73
- if traversal_root != '/' && parts.length > 1
74
- file_by_parts.call(parts[1..-1])
28
+ test_expr = parts.join('\\/')
29
+ # eponymous reverse-lookup
30
+ found = @store.resources.find do |candidate|
31
+ candidate.path =~ %r{^#{test_expr}(?:\.[a-zA-Z0-9]+|\/)$}
75
32
  end
76
33
 
77
- # Now let's drop the last part of the path to try to find an index
78
- # file in the path above `current_page`'s path and return it.
79
- # E.g. `parts == ['en', 'blog']`, we try to find: `/en/index.html`
80
- parts.pop if is_index
81
- index_by_parts.call(parts)
82
-
83
- # Lastly, check for an non-localized index index file in the path
84
- # above `current_page`'s path and return it.
85
- # E.g. `parts == ['en', 'blog']`, we try to find: `/index.html`
86
- if traversal_root == "#{parts.first}/"
87
- index_by_parts.call(parts[1..-1] || '')
88
- end
89
- if !parts.empty? && max_recursion.positive?
90
- return parent_helper(parts.join('/'), max_recursion - 1)
34
+ if found
35
+ found
36
+ else
37
+ parts.pop if is_index
38
+ @store.find_resource_by_destination_path("#{parts.join('/')}/#{@app.config[:index_file]}")
91
39
  end
92
-
93
- nil
94
40
  end
95
41
 
96
42
  # This resource's child resources
@@ -99,12 +45,12 @@ module Middleman
99
45
  return [] unless directory_index?
100
46
 
101
47
  base_path = if eponymous_directory?
102
- eponymous_directory_path
103
- else
104
- path.sub(@app.config[:index_file].to_s, '')
105
- end
48
+ eponymous_directory_path
49
+ else
50
+ path.sub(@app.config[:index_file].to_s, '')
51
+ end
106
52
 
107
- prefix = /^#{base_path.sub("/", "\\/")}/
53
+ prefix = %r{^#{base_path.sub("/", "\\/")}}
108
54
 
109
55
  @store.resources.select do |sub_resource|
110
56
  if sub_resource.path == path || sub_resource.path !~ prefix
@@ -127,7 +73,6 @@ module Middleman
127
73
  # @return [Array<Middleman::Sitemap::Resource>]
128
74
  def siblings
129
75
  return [] unless parent
130
-
131
76
  parent.children.reject { |p| p == self }
132
77
  end
133
78
 
@@ -45,19 +45,19 @@ module Middleman
45
45
  # @param [String] path
46
46
  # @param [String] source
47
47
  Contract IsA['Middleman::Sitemap::Store'], String, Maybe[Or[IsA['Middleman::SourceFile'], String]] => Any
48
- def initialize(store, path, source = nil)
48
+ def initialize(store, path, source=nil)
49
49
  @store = store
50
50
  @app = @store.app
51
51
  @path = path
52
52
  @ignored = false
53
53
 
54
- source = Pathname(source) if source&.is_a?(String)
54
+ source = Pathname(source) if source && source.is_a?(String)
55
55
 
56
- @file_descriptor = if source&.is_a?(Pathname)
57
- ::Middleman::SourceFile.new(source.relative_path_from(@app.source_dir), source, @app.source_dir, Set.new([:source]), 0)
58
- else
59
- source
60
- end
56
+ @file_descriptor = if source && source.is_a?(Pathname)
57
+ ::Middleman::SourceFile.new(source.relative_path_from(@app.source_dir), source, @app.source_dir, Set.new([:source]), 0)
58
+ else
59
+ source
60
+ end
61
61
 
62
62
  @destination_path = @path
63
63
 
@@ -75,7 +75,6 @@ module Middleman
75
75
  Contract Bool
76
76
  def template?
77
77
  return false if file_descriptor.nil?
78
-
79
78
  !::Middleman::Util.tilt_class(file_descriptor[:full_path].to_s).nil?
80
79
  end
81
80
 
@@ -98,14 +97,14 @@ module Middleman
98
97
  # Page are data that is exposed through this resource's data member.
99
98
  # Note: It is named 'page' for backwards compatibility with older MM.
100
99
  Contract METADATA_HASH, Maybe[Bool] => METADATA_HASH
101
- def add_metadata(meta = {}, reverse = false)
100
+ def add_metadata(meta={}, reverse=false)
102
101
  @page_data = nil
103
102
 
104
103
  @metadata = if reverse
105
- meta.deep_merge(@metadata)
106
- else
107
- @metadata.deep_merge(meta)
108
- end
104
+ meta.deep_merge(@metadata)
105
+ else
106
+ @metadata.deep_merge(meta)
107
+ end
109
108
  end
110
109
 
111
110
  # Data about this resource, populated from frontmatter or extensions.
@@ -140,7 +139,7 @@ module Middleman
140
139
  # Render this resource
141
140
  # @return [String]
142
141
  Contract Hash, Hash => String
143
- def render(opts = {}, locs = {})
142
+ def render(opts={}, locs={})
144
143
  return ::Middleman::FileRenderer.new(@app, file_descriptor[:full_path].to_s).template_data_for_file unless template?
145
144
 
146
145
  md = metadata
@@ -219,14 +218,14 @@ module Middleman
219
218
  Contract String => String
220
219
  def make_implicit_page_id(path)
221
220
  @id ||= begin
222
- prok = @app.config[:page_id_generator]
223
-
224
- return prok.call(path) if prok
221
+ if prok = @app.config[:page_id_generator]
222
+ return prok.call(path)
223
+ end
225
224
 
226
225
  basename = if ext == '.html'
227
- File.basename(path, ext)
228
- else
229
- File.basename(path)
226
+ File.basename(path, ext)
227
+ else
228
+ File.basename(path)
230
229
  end
231
230
 
232
231
  # Remove leading dot or slash if present
@@ -236,7 +235,7 @@ module Middleman
236
235
  end
237
236
 
238
237
  class StringResource < Resource
239
- def initialize(store, path, contents = nil, &block)
238
+ def initialize(store, path, contents=nil, &block)
240
239
  @request_path = path
241
240
  @contents = block_given? ? block : contents
242
241
  super(store, path)