middleman-core 3.3.2 → 3.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/features/helpers_select_tag.feature +6 -8
  3. data/lib/middleman-core.rb +1 -2
  4. data/lib/middleman-core/application.rb +10 -9
  5. data/lib/middleman-core/cli.rb +9 -13
  6. data/lib/middleman-core/cli/build.rb +26 -27
  7. data/lib/middleman-core/cli/bundler.rb +6 -7
  8. data/lib/middleman-core/cli/console.rb +10 -13
  9. data/lib/middleman-core/cli/extension.rb +2 -4
  10. data/lib/middleman-core/cli/init.rb +27 -28
  11. data/lib/middleman-core/cli/server.rb +43 -44
  12. data/lib/middleman-core/configuration.rb +13 -11
  13. data/lib/middleman-core/core_extensions/data.rb +21 -29
  14. data/lib/middleman-core/core_extensions/extensions.rb +8 -8
  15. data/lib/middleman-core/core_extensions/external_helpers.rb +3 -5
  16. data/lib/middleman-core/core_extensions/file_watcher.rb +7 -11
  17. data/lib/middleman-core/core_extensions/front_matter.rb +5 -6
  18. data/lib/middleman-core/core_extensions/rendering.rb +40 -30
  19. data/lib/middleman-core/core_extensions/request.rb +16 -19
  20. data/lib/middleman-core/core_extensions/routing.rb +37 -36
  21. data/lib/middleman-core/core_extensions/show_exceptions.rb +1 -5
  22. data/lib/middleman-core/extension.rb +14 -16
  23. data/lib/middleman-core/extensions.rb +4 -6
  24. data/lib/middleman-core/load_paths.rb +3 -6
  25. data/lib/middleman-core/logger.rb +1 -3
  26. data/lib/middleman-core/meta_pages.rb +11 -11
  27. data/lib/middleman-core/meta_pages/config_setting.rb +4 -4
  28. data/lib/middleman-core/meta_pages/sitemap_resource.rb +2 -2
  29. data/lib/middleman-core/meta_pages/sitemap_tree.rb +4 -4
  30. data/lib/middleman-core/preview_server.rb +12 -11
  31. data/lib/middleman-core/profiling.rb +6 -8
  32. data/lib/middleman-core/renderers/asciidoc.rb +12 -13
  33. data/lib/middleman-core/renderers/coffee_script.rb +2 -4
  34. data/lib/middleman-core/renderers/erb.rb +3 -4
  35. data/lib/middleman-core/renderers/haml.rb +2 -4
  36. data/lib/middleman-core/renderers/kramdown.rb +3 -4
  37. data/lib/middleman-core/renderers/less.rb +3 -9
  38. data/lib/middleman-core/renderers/liquid.rb +4 -8
  39. data/lib/middleman-core/renderers/markdown.rb +7 -11
  40. data/lib/middleman-core/renderers/redcarpet.rb +14 -16
  41. data/lib/middleman-core/renderers/sass.rb +36 -15
  42. data/lib/middleman-core/renderers/slim.rb +7 -10
  43. data/lib/middleman-core/renderers/stylus.rb +2 -6
  44. data/lib/middleman-core/sitemap.rb +6 -13
  45. data/lib/middleman-core/sitemap/extensions/ignores.rb +4 -10
  46. data/lib/middleman-core/sitemap/extensions/on_disk.rb +3 -7
  47. data/lib/middleman-core/sitemap/extensions/proxies.rb +7 -12
  48. data/lib/middleman-core/sitemap/extensions/redirects.rb +7 -15
  49. data/lib/middleman-core/sitemap/extensions/request_endpoints.rb +7 -15
  50. data/lib/middleman-core/sitemap/extensions/traversal.rb +4 -7
  51. data/lib/middleman-core/sitemap/queryable.rb +22 -27
  52. data/lib/middleman-core/sitemap/resource.rb +13 -25
  53. data/lib/middleman-core/sitemap/store.rb +11 -15
  54. data/lib/middleman-core/templates.rb +9 -12
  55. data/lib/middleman-core/templates/default.rb +6 -7
  56. data/lib/middleman-core/templates/empty.rb +0 -1
  57. data/lib/middleman-core/templates/extension/Gemfile +1 -1
  58. data/lib/middleman-core/templates/extension/Rakefile +2 -2
  59. data/lib/middleman-core/templates/extension/lib/lib.rb +0 -1
  60. data/lib/middleman-core/templates/html5.rb +6 -7
  61. data/lib/middleman-core/templates/local.rb +1 -2
  62. data/lib/middleman-core/templates/mobile.rb +3 -4
  63. data/lib/middleman-core/templates/shared/config.ru +1 -1
  64. data/lib/middleman-core/util.rb +5 -6
  65. data/lib/middleman-core/version.rb +1 -1
  66. data/lib/middleman-more/core_extensions/compass.rb +0 -1
  67. data/lib/middleman-more/core_extensions/default_helpers.rb +25 -16
  68. data/lib/middleman-more/core_extensions/i18n.rb +24 -23
  69. data/lib/middleman-more/extensions/asset_hash.rb +4 -6
  70. data/lib/middleman-more/extensions/asset_host.rb +1 -1
  71. data/lib/middleman-more/extensions/automatic_alt_tags.rb +2 -3
  72. data/lib/middleman-more/extensions/automatic_image_sizes.rb +4 -5
  73. data/lib/middleman-more/extensions/cache_buster.rb +0 -1
  74. data/lib/middleman-more/extensions/gzip.rb +1 -1
  75. data/lib/middleman-more/extensions/lorem.rb +8 -8
  76. data/lib/middleman-more/extensions/minify_css.rb +9 -8
  77. data/lib/middleman-more/extensions/minify_javascript.rb +5 -6
  78. data/lib/middleman-more/extensions/relative_assets.rb +0 -1
  79. data/lib/middleman-more/templates/smacss.rb +6 -7
  80. data/middleman-core.gemspec +1 -1
  81. metadata +5 -5
@@ -17,30 +17,27 @@ end
17
17
 
18
18
  module Middleman
19
19
  module Renderers
20
-
21
20
  # Slim renderer
22
21
  module Slim
23
-
24
22
  # Setup extension
25
23
  class << self
26
-
27
24
  # Once registered
28
25
  def registered(app)
29
26
  app.before_configuration do
30
- template_extensions :slim => :html
27
+ template_extensions slim: :html
31
28
  end
32
29
 
33
30
  # Setup Slim options to work with partials
34
31
  ::Slim::Engine.set_default_options(
35
- :buffer => '@_out_buf',
36
- :use_html_safe => true,
37
- :generator => ::Temple::Generators::RailsOutputBuffer,
38
- :disable_escape => true
32
+ buffer: '@_out_buf',
33
+ use_html_safe: true,
34
+ generator: ::Temple::Generators::RailsOutputBuffer,
35
+ disable_escape: true
39
36
  )
40
37
 
41
38
  app.after_configuration do
42
39
  context_hack = {
43
- :context => self
40
+ context: self
44
41
  }
45
42
 
46
43
  ::Slim::Embedded::SassEngine.disable_option_validator!
@@ -50,7 +47,7 @@ module Middleman
50
47
  end
51
48
  end
52
49
 
53
- alias :included :registered
50
+ alias_method :included, :registered
54
51
  end
55
52
  end
56
53
  end
@@ -3,26 +3,22 @@ require 'stylus/tilt'
3
3
 
4
4
  module Middleman
5
5
  module Renderers
6
-
7
6
  # Sass renderer
8
7
  module Stylus
9
-
10
8
  # Setup extension
11
9
  class << self
12
-
13
10
  # Once registered
14
11
  def registered(app)
15
12
  # Default less options
16
13
  app.set :styl, {}
17
14
 
18
15
  app.before_configuration do
19
- template_extensions :styl => :css
16
+ template_extensions styl: :css
20
17
  end
21
18
  end
22
19
 
23
- alias :included :registered
20
+ alias_method :included, :registered
24
21
  end
25
-
26
22
  end
27
23
  end
28
24
  end
@@ -9,15 +9,11 @@ require 'middleman-core/sitemap/extensions/ignores'
9
9
 
10
10
  # Core Sitemap Extensions
11
11
  module Middleman
12
-
13
12
  module Sitemap
14
-
15
13
  # Setup Extension
16
14
  class << self
17
-
18
15
  # Once registered
19
16
  def registered(app)
20
-
21
17
  app.register Middleman::Sitemap::Extensions::RequestEndpoints
22
18
  app.register Middleman::Sitemap::Extensions::Proxies
23
19
  app.register Middleman::Sitemap::Extensions::Ignores
@@ -29,18 +25,18 @@ module Middleman
29
25
  # Setup callbacks which can exclude paths from the sitemap
30
26
  app.config.define_setting :ignored_sitemap_matchers, {
31
27
  # dotfiles and folders in the root
32
- :root_dotfiles => proc { |file| file.start_with?('.') },
28
+ root_dotfiles: proc { |file| file.start_with?('.') },
33
29
 
34
30
  # Files starting with an dot, but not .htaccess
35
- :source_dotfiles => proc { |file|
31
+ source_dotfiles: proc { |file|
36
32
  file =~ %r{/\.} && file !~ %r{/\.(htaccess|htpasswd|nojekyll)}
37
33
  },
38
34
 
39
35
  # Files starting with an underscore, but not a double-underscore
40
- :partials => proc { |file| file =~ %r{/_[^_]} },
36
+ partials: proc { |file| file =~ %r{/_[^_]} },
41
37
 
42
- :layout => proc { |file, app|
43
- file.start_with?(File.join(app.config[:source], 'layout.')) || file.start_with?(File.join(app.config[:source], 'layouts/'))
38
+ layout: proc { |file, sitemap_app|
39
+ file.start_with?(File.join(sitemap_app.config[:source], 'layout.')) || file.start_with?(File.join(sitemap_app.config[:source], 'layouts/'))
44
40
  }
45
41
  }, 'Callbacks that can exclude paths from the sitemap'
46
42
 
@@ -52,13 +48,11 @@ module Middleman
52
48
  sitemap
53
49
  end
54
50
  end
55
- alias :included :registered
56
-
51
+ alias_method :included, :registered
57
52
  end
58
53
 
59
54
  # Sitemap instance methods
60
55
  module InstanceMethods
61
-
62
56
  # Get the sitemap class instance
63
57
  # @return [Middleman::Sitemap::Store]
64
58
  def sitemap
@@ -77,7 +71,6 @@ module Middleman
77
71
  return nil unless current_path
78
72
  sitemap.find_resource_by_destination_path(current_path)
79
73
  end
80
-
81
74
  end
82
75
  end
83
76
  end
@@ -1,14 +1,9 @@
1
1
  module Middleman
2
-
3
2
  module Sitemap
4
-
5
3
  module Extensions
6
-
7
4
  module Ignores
8
-
9
5
  # Setup extension
10
6
  class << self
11
-
12
7
  # Once registered
13
8
  def registered(app)
14
9
  # Include methods
@@ -17,12 +12,11 @@ module Middleman
17
12
  ::Middleman::Sitemap::Resource.send :include, ResourceInstanceMethods
18
13
  end
19
14
 
20
- alias :included :registered
15
+ alias_method :included, :registered
21
16
  end
22
17
 
23
18
  # Helpers methods for Resources
24
19
  module ResourceInstanceMethods
25
-
26
20
  # Whether the Resource is ignored
27
21
  # @return [Boolean]
28
22
  def ignored?
@@ -61,15 +55,15 @@ module Middleman
61
55
  # @return [void]
62
56
  def ignore(path=nil, &block)
63
57
  if path.is_a? Regexp
64
- @ignored_callbacks << Proc.new {|p| p =~ path }
58
+ @ignored_callbacks << proc { |p| p =~ path }
65
59
  elsif path.is_a? String
66
60
  path_clean = ::Middleman::Util.normalize_path(path)
67
61
  if path_clean.include?('*') # It's a glob
68
- @ignored_callbacks << Proc.new {|p| File.fnmatch(path_clean, p) }
62
+ @ignored_callbacks << proc { |p| File.fnmatch(path_clean, p) }
69
63
  else
70
64
  # Add a specific-path ignore unless that path is already covered
71
65
  return if ignored?(path_clean)
72
- @ignored_callbacks << Proc.new {|p| p == path_clean }
66
+ @ignored_callbacks << proc { |p| p == path_clean }
73
67
  end
74
68
  elsif block_given?
75
69
  @ignored_callbacks << block
@@ -1,13 +1,9 @@
1
1
  require 'set'
2
2
 
3
3
  module Middleman
4
-
5
4
  module Sitemap
6
-
7
5
  module Extensions
8
-
9
6
  class OnDisk
10
-
11
7
  attr_accessor :sitemap
12
8
  attr_accessor :waiting_for_ready
13
9
 
@@ -39,13 +35,13 @@ module Middleman
39
35
  # Update or add an on-disk file path
40
36
  # @param [String] file
41
37
  # @return [Boolean]
42
- def touch_file(file, rebuild=true)
38
+ def touch_file(file)
43
39
  return false if File.directory?(file)
44
40
 
45
41
  path = @sitemap.file_to_path(file)
46
42
  return false unless path
47
43
 
48
- ignored = @app.config[:ignored_sitemap_matchers].any? do |name, callback|
44
+ ignored = @app.config[:ignored_sitemap_matchers].any? do |_, callback|
49
45
  if callback.arity == 1
50
46
  callback.call(file)
51
47
  else
@@ -71,7 +67,7 @@ module Middleman
71
67
  # Remove a file from the store
72
68
  # @param [String] file
73
69
  # @return [void]
74
- def remove_file(file, rebuild=true)
70
+ def remove_file(file)
75
71
  if @file_paths_on_disk.delete?(file)
76
72
  @sitemap.rebuild_resource_list!(:removed_file)
77
73
  unless waiting_for_ready || @app.build?
@@ -1,14 +1,9 @@
1
1
  module Middleman
2
-
3
2
  module Sitemap
4
-
5
3
  module Extensions
6
-
7
4
  module Proxies
8
-
9
5
  # Setup extension
10
6
  class << self
11
-
12
7
  # Once registered
13
8
  def registered(app)
14
9
  ::Middleman::Sitemap::Resource.send :include, ResourceInstanceMethods
@@ -17,14 +12,15 @@ module Middleman
17
12
  app.send :include, InstanceMethods
18
13
  end
19
14
 
20
- alias :included :registered
15
+ alias_method :included, :registered
21
16
  end
22
17
 
23
18
  module ResourceInstanceMethods
24
19
  # Whether this page is a proxy
20
+ # rubocop:disable TrivialAccessors
25
21
  # @return [Boolean]
26
22
  def proxy?
27
- !!@proxied_to
23
+ @proxied_to
28
24
  end
29
25
 
30
26
  # Set this page to proxy to a target path
@@ -38,9 +34,7 @@ module Middleman
38
34
 
39
35
  # The path of the page this page is proxied to, or nil if it's not proxied.
40
36
  # @return [String]
41
- def proxied_to
42
- @proxied_to
43
- end
37
+ attr_reader :proxied_to
44
38
 
45
39
  # The resource for the page this page is proxied to. Throws an exception
46
40
  # if there is no resource.
@@ -59,6 +53,7 @@ module Middleman
59
53
  proxy_resource
60
54
  end
61
55
 
56
+ # rubocop:disable AccessorMethodName
62
57
  def get_source_file
63
58
  if proxy?
64
59
  proxied_to_resource.source_file
@@ -104,14 +99,14 @@ module Middleman
104
99
  # :locals, :ignore to hide the proxy target, :layout, and :directory_indexes.
105
100
  # @return [void]
106
101
  def proxy(path, target, opts={}, &block)
107
- metadata = { :options => {}, :locals => {}, :blocks => [] }
102
+ metadata = { options: {}, locals: {}, blocks: [] }
108
103
  metadata[:blocks] << block if block_given?
109
104
  metadata[:locals] = opts.delete(:locals) || {}
110
105
 
111
106
  @app.ignore(target) if opts.delete(:ignore)
112
107
  metadata[:options] = opts
113
108
 
114
- @proxy_configs << ProxyConfiguration.new(:path => path, :target => target, :metadata => metadata)
109
+ @proxy_configs << ProxyConfiguration.new(path: path, target: target, metadata: metadata)
115
110
 
116
111
  @app.sitemap.rebuild_resource_list!(:added_proxy)
117
112
  end
@@ -1,21 +1,16 @@
1
1
  module Middleman
2
-
3
2
  module Sitemap
4
-
5
3
  module Extensions
6
-
7
4
  module Redirects
8
-
9
5
  # Setup extension
10
6
  class << self
11
-
12
7
  # Once registered
13
8
  def registered(app)
14
9
  # Include methods
15
10
  app.send :include, InstanceMethods
16
11
  end
17
12
 
18
- alias :included :registered
13
+ alias_method :included, :registered
19
14
  end
20
15
 
21
16
  module InstanceMethods
@@ -40,9 +35,7 @@ module Middleman
40
35
  # @param [String] path
41
36
  # @param [Hash] opts The :to value gives a target path
42
37
  def create_redirect(path, opts={}, &block)
43
- if block_given?
44
- opts[:template] = block
45
- end
38
+ opts[:template] = block if block_given?
46
39
 
47
40
  @redirects[path] = opts
48
41
 
@@ -77,11 +70,11 @@ module Middleman
77
70
  true
78
71
  end
79
72
 
80
- def render(*args, &block)
81
- url = ::Middleman::Util.url_for(store.app, @request_path, {
82
- :relative => false,
83
- :find_resource => true
84
- })
73
+ def render(*)
74
+ url = ::Middleman::Util.url_for(store.app, @request_path,
75
+ relative: false,
76
+ find_resource: true
77
+ )
85
78
 
86
79
  if output
87
80
  output.call(path, url)
@@ -119,7 +112,6 @@ module Middleman
119
112
  def metadata
120
113
  @local_metadata.dup
121
114
  end
122
-
123
115
  end
124
116
  end
125
117
  end
@@ -1,21 +1,16 @@
1
1
  module Middleman
2
-
3
2
  module Sitemap
4
-
5
3
  module Extensions
6
-
7
4
  module RequestEndpoints
8
-
9
5
  # Setup extension
10
6
  class << self
11
-
12
7
  # Once registered
13
8
  def registered(app)
14
9
  # Include methods
15
10
  app.send :include, InstanceMethods
16
11
  end
17
12
 
18
- alias :included :registered
13
+ alias_method :included, :registered
19
14
  end
20
15
 
21
16
  module InstanceMethods
@@ -42,13 +37,13 @@ module Middleman
42
37
  # differs from the output path
43
38
  def create_endpoint(path, opts={}, &block)
44
39
  endpoint = {
45
- :request_path => path
40
+ request_path: path
46
41
  }
47
42
 
48
43
  if block_given?
49
44
  endpoint[:output] = block
50
45
  else
51
- endpoint[:request_path] = opts[:path] if opts.has_key?(:path)
46
+ endpoint[:request_path] = opts[:path] if opts.key?(:path)
52
47
  end
53
48
 
54
49
  @endpoints[path] = endpoint
@@ -65,7 +60,7 @@ module Middleman
65
60
  path,
66
61
  config[:request_path]
67
62
  )
68
- r.output = config[:output] if config.has_key?(:output)
63
+ r.output = config[:output] if config.key?(:output)
69
64
  r
70
65
  end
71
66
  end
@@ -84,13 +79,11 @@ module Middleman
84
79
  true
85
80
  end
86
81
 
87
- def render(*args, &block)
88
- return self.output.call if self.output
82
+ def render(*)
83
+ return output.call if output
89
84
  end
90
85
 
91
- def request_path
92
- @request_path
93
- end
86
+ attr_reader :request_path
94
87
 
95
88
  def binary?
96
89
  false
@@ -107,7 +100,6 @@ module Middleman
107
100
  def metadata
108
101
  @local_metadata.dup
109
102
  end
110
-
111
103
  end
112
104
  end
113
105
  end
@@ -1,9 +1,6 @@
1
1
  module Middleman
2
-
3
2
  module Sitemap
4
-
5
3
  module Extensions
6
-
7
4
  module Traversal
8
5
  # This resource's parent resource
9
6
  # @return [Middleman::Sitemap::Resource, nil]
@@ -28,14 +25,14 @@ module Middleman
28
25
 
29
26
  if eponymous_directory?
30
27
  base_path = eponymous_directory_path
31
- prefix = %r|^#{base_path.sub("/", "\\/")}|
28
+ prefix = %r{^#{base_path.sub("/", "\\/")}}
32
29
  else
33
30
  base_path = path.sub("#{app.index_file}", '')
34
- prefix = %r|^#{base_path.sub("/", "\\/")}|
31
+ prefix = %r{^#{base_path.sub("/", "\\/")}}
35
32
  end
36
33
 
37
34
  store.resources.select do |sub_resource|
38
- if sub_resource.path == self.path || sub_resource.path !~ prefix
35
+ if sub_resource.path == path || sub_resource.path !~ prefix
39
36
  false
40
37
  else
41
38
  inner_path = sub_resource.path.sub(prefix, '')
@@ -72,7 +69,7 @@ module Middleman
72
69
  return true
73
70
  end
74
71
  full_path = File.join(app.source_dir, eponymous_directory_path)
75
- !!(File.exists?(full_path) && File.directory?(full_path))
72
+ File.exist?(full_path) && File.directory?(full_path)
76
73
  end
77
74
 
78
75
  # The path for this resource if it were a directory, and not a file