test missing config error, fix nasty frontmatter caching bug. closes #209
This commit is contained in:
parent
3a5fc69a71
commit
4f78ecf367
7 changed files with 25 additions and 15 deletions
|
@ -14,7 +14,7 @@ module Middleman
|
||||||
|
|
||||||
if !in_middleman_project? && !in_middleman_project_subdirectory?
|
if !in_middleman_project? && !in_middleman_project_subdirectory?
|
||||||
$stderr.puts "== Error: Could not find a Middleman project config, perhaps you are in the wrong folder?"
|
$stderr.puts "== Error: Could not find a Middleman project config, perhaps you are in the wrong folder?"
|
||||||
return
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
if in_middleman_project?
|
if in_middleman_project?
|
||||||
|
@ -57,8 +57,7 @@ module Middleman
|
||||||
end
|
end
|
||||||
|
|
||||||
ARGV << "server" if ARGV.length < 1
|
ARGV << "server" if ARGV.length < 1
|
||||||
|
if %w(server s build b).include?(ARGV[0])
|
||||||
if %w(server build migrate).include?(ARGV)
|
|
||||||
Middleman::ProjectLocator.locate_middleman_root!
|
Middleman::ProjectLocator.locate_middleman_root!
|
||||||
else
|
else
|
||||||
Middleman::ProjectLocator.start_cli!
|
Middleman::ProjectLocator.start_cli!
|
||||||
|
|
|
@ -46,6 +46,10 @@ Feature: Builder
|
||||||
Given a built app at "build-with-errors-app"
|
Given a built app at "build-with-errors-app"
|
||||||
Then the exit status should be 1
|
Then the exit status should be 1
|
||||||
|
|
||||||
|
Scenario: Build empty errors
|
||||||
|
Given a built app at "empty-app"
|
||||||
|
Then the exit status should be 1
|
||||||
|
|
||||||
Scenario: Build alias (b)
|
Scenario: Build alias (b)
|
||||||
Given a fixture app "test-app"
|
Given a fixture app "test-app"
|
||||||
When I run `middleman b`
|
When I run `middleman b`
|
||||||
|
|
|
@ -12,8 +12,13 @@ Feature: Allow nesting of layouts
|
||||||
Given the Server is running at "nested-layout-app"
|
Given the Server is running at "nested-layout-app"
|
||||||
When I go to "/data-one.html"
|
When I go to "/data-one.html"
|
||||||
Then I should see "Page Number One"
|
Then I should see "Page Number One"
|
||||||
|
And I should see "Inner"
|
||||||
When I go to "/data-two.html"
|
When I go to "/data-two.html"
|
||||||
Then I should see "Page Number Two"
|
Then I should see "Page Number Two"
|
||||||
|
And I should not see "Inner"
|
||||||
When I go to "/data-one.html"
|
When I go to "/data-one.html"
|
||||||
Then I should see "Page Number One"
|
Then I should see "Page Number One"
|
||||||
|
And I should see "Inner"
|
||||||
When I go to "/data-two.html"
|
When I go to "/data-two.html"
|
||||||
|
Then I should see "Page Number Two"
|
||||||
|
And I should not see "Inner"
|
||||||
|
|
0
fixtures/empty-app/not-config.rb
Normal file
0
fixtures/empty-app/not-config.rb
Normal file
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
title: Page Number One
|
title: Page Number One
|
||||||
layout: outer
|
layout: inner
|
||||||
---
|
---
|
||||||
Page #1
|
Page #1
|
|
@ -38,22 +38,18 @@ module Middleman::CoreExtensions::FrontMatter
|
||||||
provides_metadata matcher do |path|
|
provides_metadata matcher do |path|
|
||||||
relative_path = path.sub(source_dir, "")
|
relative_path = path.sub(source_dir, "")
|
||||||
|
|
||||||
data = if frontmatter.has_data?(relative_path)
|
fmdata = if frontmatter.has_data?(relative_path)
|
||||||
frontmatter.data(relative_path)[0]
|
frontmatter.data(relative_path)[0]
|
||||||
else
|
else
|
||||||
{}
|
{}
|
||||||
end
|
end
|
||||||
|
|
||||||
# Forward remaining data to helpers
|
data = {}
|
||||||
data_content("page", data)
|
|
||||||
|
|
||||||
%w(layout layout_engine).each do |opt|
|
%w(layout layout_engine).each do |opt|
|
||||||
if data.has_key?(opt)
|
data[opt.to_sym] = fmdata[opt] if fmdata.has_key?(opt)
|
||||||
data[opt.to_sym] = data.delete(opt)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
{ :options => data }
|
{ :options => data, :page => fmdata }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ module Middleman::Sitemap
|
||||||
|
|
||||||
def metadata
|
def metadata
|
||||||
metadata = app.cache.fetch(:metadata, source_file) do
|
metadata = app.cache.fetch(:metadata, source_file) do
|
||||||
data = { :options => {}, :locals => {} }
|
data = { :options => {}, :locals => {}, :page => {} }
|
||||||
|
|
||||||
app.provides_metadata.each do |callback, matcher|
|
app.provides_metadata.each do |callback, matcher|
|
||||||
next if !matcher.nil? && !source_file.match(matcher)
|
next if !matcher.nil? && !source_file.match(matcher)
|
||||||
|
@ -57,8 +57,14 @@ module Middleman::Sitemap
|
||||||
end
|
end
|
||||||
|
|
||||||
def render(opts={}, locs={}, &block)
|
def render(opts={}, locs={}, &block)
|
||||||
opts = options.deep_merge(metadata[:options]).deep_merge(opts)
|
md = metadata.dup
|
||||||
locs = locals.deep_merge(metadata[:locals]).deep_merge(locs)
|
opts = options.deep_merge(md[:options]).deep_merge(opts)
|
||||||
|
locs = locals.deep_merge(md[:locals]).deep_merge(locs)
|
||||||
|
|
||||||
|
# Forward remaining data to helpers
|
||||||
|
if md.has_key?(:page)
|
||||||
|
app.data_content("page", md[:page])
|
||||||
|
end
|
||||||
|
|
||||||
blocks.compact.each do |block|
|
blocks.compact.each do |block|
|
||||||
app.instance_eval(&block)
|
app.instance_eval(&block)
|
||||||
|
|
Loading…
Reference in a new issue