middleman-core 4.1.2 → 4.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56d4346f7e637375c81e78637eb685379d71afdc
4
- data.tar.gz: 49168cf55df8f81be1c53ccff538bd36916089a4
3
+ metadata.gz: 07f3019963e912c90ffd23f7781a1e2708916d99
4
+ data.tar.gz: 390ae3524c422182a88efcc01cf84b99406819b2
5
5
  SHA512:
6
- metadata.gz: 3b13b9ee36f2d9e64a56569d167d81d5b4fc8cfd3fb71d653640cd9ec59ef352ba80f01ed6bb353a413d96ea96b747b1a2fe7a258491ef81174228ef3a0d0f2b
7
- data.tar.gz: af98ca1aa0717fa1d25258324e42a3cafc38e8f4d813ae9286321b24fed8a18a0a884d6738de5db9b1a692a0753da725468f6d4490403d9e9a3c2136f5f2daf7
6
+ metadata.gz: 808225bf5afa002a4ce07c597bcc3bf9db8896214701b7d07ca279c3a5549101a147617b3c285c9d912d4edad6aa2d8315cc0e026e9f68cb7105b8e464520371
7
+ data.tar.gz: 6252c9056ac15fac4b34ad46a7853b0855a0d7d89ad1fffc605b2eaa23a78e240af0bba31dcb3d6f96a65951f728c4422f665a3d0771e5ff4b10c0ce42cbc81f
@@ -5,25 +5,30 @@ Feature: Provide Sane Defaults for Partial Behavior
5
5
  When I go to "/index.html"
6
6
  Then I should see "Header"
7
7
  And I should see "Footer"
8
-
8
+
9
9
  Scenario: Finds shared partials relative to the root (sub)
10
10
  Given the Server is running at "partials-app"
11
11
  When I go to "/sub/index.html"
12
12
  Then I should see "Header"
13
13
  And I should see "Footer"
14
-
14
+
15
+ Scenario: Flags error when partial is not found
16
+ Given the Server is running at "partials-app"
17
+ When I go to "/index_missing.html"
18
+ Then I should see "Error: Could not locate partial"
19
+
15
20
  Scenario: Prefers partials of the same engine type
16
21
  Given the Server is running at "partials-app"
17
22
  When I go to "/index.html"
18
23
  Then I should see "ERb Main"
19
-
24
+
20
25
  Scenario: Prefers partials of the same engine type
21
26
  Given the Server is running at "partials-app"
22
27
  When I go to "/second.html"
23
28
  Then I should see "Str Main"
24
29
  And I should see "Header"
25
30
  And I should see "Footer"
26
-
31
+
27
32
  Scenario: Finds partial relative to template
28
33
  Given the Server is running at "partials-app"
29
34
  When I go to "/sub/index.html"
@@ -33,7 +38,7 @@ Feature: Provide Sane Defaults for Partial Behavior
33
38
  Given the Server is running at "partials-app"
34
39
  When I go to "/locals.html"
35
40
  Then I should see "Local var is bar"
36
-
41
+
37
42
  Scenario: Partial and Layout use different engines
38
43
  Given the Server is running at "different-engine-partial"
39
44
  When I go to "/index.html"
@@ -0,0 +1,3 @@
1
+ <%= partial "shared/header" %>
2
+ <%= partial "i_do_not_exist" %>
3
+ <%= partial "shared/footer" %>
@@ -96,6 +96,10 @@ module Middleman
96
96
  # @return [String]
97
97
  define_setting :source, 'source', 'Name of the source directory'
98
98
 
99
+ # If we should not run the sitemap.
100
+ # @return [Boolean]
101
+ define_setting :disable_sitemap, false, 'If we should not run the sitemap.'
102
+
99
103
  # If we should exit before ready event.
100
104
  # @return [Boolean]
101
105
  define_setting :exit_before_ready, false, 'If we should exit before ready event.'
@@ -106,7 +110,7 @@ module Middleman
106
110
 
107
111
  # Middleman environment. Defaults to :development
108
112
  # @return [String]
109
- define_setting :environment, ((ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :development), 'Middleman environment. Defaults to :development'
113
+ define_setting :environment, ((ENV['MM_ENV'] && ENV['MM_ENV'].to_sym) || :development), 'Middleman environment. Defaults to :development', import: proc { |s| s.to_sym }
110
114
 
111
115
  # Which file should be used for directory indexes
112
116
  # @return [String]
@@ -117,7 +117,13 @@ module Middleman
117
117
  .sort_by { |resource| SORT_ORDER.index(resource.ext) || 100 }
118
118
 
119
119
  if @glob
120
- resources = resources.select { |resource| File.fnmatch(@glob, resource.destination_path) }
120
+ resources = resources.select do |resource|
121
+ if defined?(::File::FNM_EXTGLOB)
122
+ File.fnmatch(@glob, resource.destination_path, ::File::FNM_EXTGLOB)
123
+ else
124
+ File.fnmatch(@glob, resource.destination_path)
125
+ end
126
+ end
121
127
  end
122
128
 
123
129
  output_resources(resources)
@@ -52,7 +52,7 @@ module Middleman
52
52
  def register(name, extension_class=nil, options={}, &block)
53
53
  raise 'Extension name must be a symbol' unless name.is_a?(Symbol)
54
54
  # If we've already got an extension registered under this name, bail out
55
- raise "There is already an extension registered with the name '#{name}'" if registered.key?(name)
55
+ # raise "There is a already an extension registered with the name '#{name}'" if registered.key?(name)
56
56
 
57
57
  # If the extension is defined with a block, grab options out of the "extension_class" parameter.
58
58
  if extension_class && block_given? && options.empty? && extension_class.is_a?(Hash)
@@ -11,16 +11,22 @@ class Middleman::Extensions::DirectoryIndexes < ::Middleman::Extension
11
11
  index_file = app.config[:index_file]
12
12
  new_index_path = "/#{index_file}"
13
13
 
14
+ extensions = %w(.htm .html .php)
15
+
14
16
  resources.each do |resource|
15
17
  # Check if it would be pointless to reroute
16
18
  next if resource.destination_path == index_file ||
17
19
  resource.destination_path.end_with?(new_index_path) ||
18
- File.extname(index_file) != resource.ext
20
+ !extensions.include?(resource.ext)
19
21
 
20
22
  # Check if file metadata (options set by "page" in config.rb or frontmatter) turns directory_index off
21
23
  next if resource.options[:directory_index] == false
22
24
 
23
- resource.destination_path = resource.destination_path.chomp(File.extname(index_file)) + new_index_path
25
+ extensions.each do |ext|
26
+ resource.destination_path = resource.destination_path.chomp(ext)
27
+ end
28
+
29
+ resource.destination_path += new_index_path
24
30
  end
25
31
  end
26
32
  end
@@ -18,12 +18,13 @@ module Middleman
18
18
 
19
19
  # Start an instance of Middleman::Application
20
20
  # @return [void]
21
- def start(opts={})
21
+ def start(opts={}, cli_options={})
22
22
  # Do not buffer output, otherwise testing of output does not work
23
23
  $stdout.sync = true
24
24
  $stderr.sync = true
25
25
 
26
26
  @options = opts
27
+ @cli_options = cli_options
27
28
  @server_information = ServerInformation.new
28
29
  @server_information.https = (@options[:https] == true)
29
30
 
@@ -131,6 +132,7 @@ module Middleman
131
132
 
132
133
  def initialize_new_app
133
134
  opts = @options.dup
135
+ cli_options = @cli_options.dup
134
136
 
135
137
  ::Middleman::Logger.singleton(
136
138
  opts[:debug] ? 0 : 1,
@@ -138,17 +140,14 @@ module Middleman
138
140
  )
139
141
 
140
142
  app = ::Middleman::Application.new do
141
- config[:environment] = opts[:environment].to_sym if opts[:environment]
142
- config[:watcher_disable] = opts[:disable_watcher]
143
- config[:watcher_force_polling] = opts[:force_polling]
144
- config[:watcher_latency] = opts[:latency]
145
-
146
- config[:port] = opts[:port] if opts[:port]
147
- config[:bind_address] = opts[:bind_address]
148
- config[:server_name] = opts[:server_name]
149
- config[:https] = opts[:https] unless opts[:https].nil?
150
- config[:ssl_certificate] = opts[:ssl_certificate] if opts[:ssl_certificate]
151
- config[:ssl_private_key] = opts[:ssl_private_key] if opts[:ssl_private_key]
143
+ cli_options.each do |k, v|
144
+ setting = config.setting(k.to_sym)
145
+ next unless setting
146
+
147
+ v = setting.options[:import].call(v) if setting.options[:import]
148
+
149
+ config[k.to_sym] = v
150
+ end
152
151
 
153
152
  ready do
154
153
  unless config[:watcher_disable]
@@ -23,8 +23,8 @@ module Middleman
23
23
  ImportPathDescriptor = Struct.new(:from, :renameProc) do
24
24
  def execute_descriptor(app, resources)
25
25
  resources + ::Middleman::Util.glob_directory(File.join(from, '**/*'))
26
- .reject { |path| File.directory?(path) }
27
- .map do |path|
26
+ .reject { |path| File.directory?(path) }
27
+ .map do |path|
28
28
  target_path = Pathname(path).relative_path_from(Pathname(from).parent).to_s
29
29
 
30
30
  ::Middleman::Sitemap::Resource.new(
@@ -216,6 +216,8 @@ module Middleman
216
216
  # rebuild_resource_list! since the last time it was run. This is
217
217
  # very expensive!
218
218
  def ensure_resource_list_updated!
219
+ return if @app.config[:disable_sitemap]
220
+
219
221
  @lock.synchronize do
220
222
  return unless @needs_sitemap_rebuild
221
223
 
@@ -237,7 +239,16 @@ module Middleman
237
239
  # Rebuild cache
238
240
  @resources.each do |resource|
239
241
  @_lookup_by_path[resource.path] = resource
242
+ end
243
+
244
+ @resources.each do |resource|
240
245
  @_lookup_by_destination_path[resource.destination_path] = resource
246
+ end
247
+
248
+ # NB: This needs to be done after the previous two steps,
249
+ # since some proxy resources are looked up by path in order to
250
+ # get their metadata and subsequently their page_id.
251
+ @resources.each do |resource|
241
252
  @_lookup_by_page_id[resource.page_id.to_sym] = resource
242
253
  end
243
254
 
@@ -116,7 +116,8 @@ module Middleman
116
116
  Contract Or[Symbol, HANDLER], Maybe[Hash] => HANDLER
117
117
  def watch(type_or_handler, options={})
118
118
  handler = if type_or_handler.is_a? Symbol
119
- SourceWatcher.new(self, type_or_handler, options.delete(:path), options)
119
+ path = File.expand_path(options.delete(:path), app.root)
120
+ SourceWatcher.new(self, type_or_handler, path, options)
120
121
  else
121
122
  type_or_handler
122
123
  end
@@ -92,7 +92,7 @@ module Middleman
92
92
  # @return [void]
93
93
  Contract String => Any
94
94
  def update_path(directory)
95
- @directory = Pathname(directory)
95
+ @directory = Pathname(File.expand_path(directory, app.root))
96
96
 
97
97
  stop_listener! if @listener
98
98
 
@@ -133,6 +133,7 @@ module Middleman
133
133
  return nil if p.absolute? && !p.to_s.start_with?(@directory.to_s)
134
134
 
135
135
  p = @directory + p if p.relative?
136
+
136
137
  if glob
137
138
  @extensionless_files[p]
138
139
  else
@@ -104,7 +104,6 @@ module Middleman
104
104
 
105
105
  partial_file = locate_partial(name, false) || locate_partial(name, true)
106
106
 
107
- return '' unless partial_file
108
107
  raise ::Middleman::TemplateRenderer::TemplateNotFound, "Could not locate partial: #{name}" unless partial_file
109
108
 
110
109
  source_path = sitemap.file_to_path(partial_file)
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  # Current Version
3
3
  # @return [String]
4
- VERSION = '4.1.2'.freeze unless const_defined?(:VERSION)
4
+ VERSION = '4.1.3'.freeze unless const_defined?(:VERSION)
5
5
  end
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
29
29
  # Helpers
30
30
  s.add_dependency('activesupport', ['~> 4.2'])
31
31
  s.add_dependency('padrino-helpers', ['~> 0.13.0'])
32
- s.add_dependency("addressable", ["~> 2.4.0"])
32
+ s.add_dependency("addressable", ["~> 2.3"])
33
33
 
34
34
  # Watcher
35
35
  s.add_dependency('listen', ['~> 3.0'])
@@ -41,7 +41,7 @@ Gem::Specification.new do |s|
41
41
  s.add_dependency('i18n', ['~> 0.7.0'])
42
42
 
43
43
  # Automatic Image Sizes
44
- s.add_dependency('fastimage', ['~> 1.8'])
44
+ s.add_dependency('fastimage', ['~> 1.7'])
45
45
 
46
46
  # Minify CSS
47
47
  s.add_dependency('sass', ['>= 3.4'])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.2
4
+ version: 4.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Reynolds
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-02-29 00:00:00.000000000 Z
13
+ date: 2016-03-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -136,14 +136,14 @@ dependencies:
136
136
  requirements:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: 2.4.0
139
+ version: '2.3'
140
140
  type: :runtime
141
141
  prerelease: false
142
142
  version_requirements: !ruby/object:Gem::Requirement
143
143
  requirements:
144
144
  - - "~>"
145
145
  - !ruby/object:Gem::Version
146
- version: 2.4.0
146
+ version: '2.3'
147
147
  - !ruby/object:Gem::Dependency
148
148
  name: listen
149
149
  requirement: !ruby/object:Gem::Requirement
@@ -192,14 +192,14 @@ dependencies:
192
192
  requirements:
193
193
  - - "~>"
194
194
  - !ruby/object:Gem::Version
195
- version: '1.8'
195
+ version: '1.7'
196
196
  type: :runtime
197
197
  prerelease: false
198
198
  version_requirements: !ruby/object:Gem::Requirement
199
199
  requirements:
200
200
  - - "~>"
201
201
  - !ruby/object:Gem::Version
202
- version: '1.8'
202
+ version: '1.7'
203
203
  - !ruby/object:Gem::Dependency
204
204
  name: sass
205
205
  requirement: !ruby/object:Gem::Requirement
@@ -1202,6 +1202,7 @@ files:
1202
1202
  - fixtures/partials-app/source/block.html.erb
1203
1203
  - fixtures/partials-app/source/images/tiger.svg
1204
1204
  - fixtures/partials-app/source/index.html.erb
1205
+ - fixtures/partials-app/source/index_missing.html.erb
1205
1206
  - fixtures/partials-app/source/locals.html.erb
1206
1207
  - fixtures/partials-app/source/second.html.str
1207
1208
  - fixtures/partials-app/source/shared/_footer.erb
@@ -2356,6 +2357,7 @@ test_files:
2356
2357
  - fixtures/partials-app/source/block.html.erb
2357
2358
  - fixtures/partials-app/source/images/tiger.svg
2358
2359
  - fixtures/partials-app/source/index.html.erb
2360
+ - fixtures/partials-app/source/index_missing.html.erb
2359
2361
  - fixtures/partials-app/source/locals.html.erb
2360
2362
  - fixtures/partials-app/source/second.html.str
2361
2363
  - fixtures/partials-app/source/shared/_footer.erb