Merge pull request #3172 from alfredxing/docs-output-overrides

This commit is contained in:
Parker Moore 2015-01-05 23:19:12 -08:00
commit 502fd94f2c
4 changed files with 40 additions and 6 deletions

View File

@ -40,7 +40,7 @@ module Jekyll
if Utils.has_yaml_header? full_path if Utils.has_yaml_header? full_path
doc = Jekyll::Document.new(full_path, { site: site, collection: self }) doc = Jekyll::Document.new(full_path, { site: site, collection: self })
doc.read doc.read
docs << doc docs << doc if site.publisher.publish?(doc)
else else
relative_dir = Jekyll.sanitized_path(relative_directory, File.dirname(file_path)).chomp("/.") relative_dir = Jekyll.sanitized_path(relative_directory, File.dirname(file_path)).chomp("/.")
files << StaticFile.new(site, site.source, relative_dir, File.basename(full_path), self) files << StaticFile.new(site, site.source, relative_dir, File.basename(full_path), self)
@ -183,6 +183,5 @@ module Jekyll
{} {}
end end
end end
end end
end end

View File

@ -494,6 +494,10 @@ module Jekyll
override['full_rebuild'] || config['full_rebuild'] override['full_rebuild'] || config['full_rebuild']
end end
def publisher
@publisher ||= Publisher.new(self)
end
private private
def has_relative_page? def has_relative_page?
@ -514,9 +518,5 @@ module Jekyll
name.gsub!(/(^|\b\s)\s+($|\s?\b)/, '\\1\\2') name.gsub!(/(^|\b\s)\s+($|\s?\b)/, '\\1\\2')
name.gsub(/\s+/, '_') name.gsub(/\s+/, '_')
end end
def publisher
@publisher ||= Publisher.new(self)
end
end end
end end

View File

@ -0,0 +1,7 @@
---
title: Non outputted slide
layout: slide
published: false
---
This should not be output

View File

@ -241,6 +241,34 @@ class TestDocument < Test::Unit::TestCase
end end
end end
context "documents in a collection" do
setup do
@site = Site.new(Jekyll.configuration({
"collections" => {
"slides" => {
"output" => true
}
},
"source" => source_dir,
"destination" => dest_dir
}))
@site.process
@files = @site.collections["slides"].docs
end
context "without output overrides" do
should "be output according to collection defaults" do
assert_not_nil @files.find { |doc| doc.relative_path == "_slides/example-slide-4.html" }
end
end
context "with output overrides" do
should "be output according its front matter" do
assert_nil @files.find { |doc| doc.relative_path == "_slides/non-outputted-slide.html" }
end
end
end
context "a static file in a collection" do context "a static file in a collection" do
setup do setup do
@site = Site.new(Jekyll.configuration({ @site = Site.new(Jekyll.configuration({