Making sure that posts flagged as published: false don't get rendered or copied.
This commit is contained in:
parent
ad617da4e0
commit
efdd5ef395
|
@ -63,10 +63,13 @@ module Jekyll
|
|||
entries.each do |f|
|
||||
if Post.valid?(f)
|
||||
post = Post.new(self.source, dir, f)
|
||||
|
||||
if post.published
|
||||
self.posts << post
|
||||
post.categories.each { |c| self.categories[c] << post }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# second pass renders each post now that full site payload is available
|
||||
self.posts.each do |post|
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
layout: default
|
||||
title: Not published!
|
||||
published: false
|
||||
category: publish_test
|
||||
---
|
||||
|
||||
This should *not* be published!
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
layout: default
|
||||
title: Publish
|
||||
category: publish_test
|
||||
---
|
||||
|
||||
This should be published.
|
|
@ -22,4 +22,11 @@ class TestGeneratedSite < Test::Unit::TestCase
|
|||
post.transform
|
||||
assert @index.include?(post.content)
|
||||
end
|
||||
|
||||
def test_unpublished_posts_are_hidden
|
||||
published = Dir[File.join(dest_dir, 'publish_test/2008/02/02/*.html')].map {|f| File.basename(f)}
|
||||
|
||||
assert_equal 1, published.size
|
||||
assert_equal "published.html", published.first
|
||||
end
|
||||
end
|
||||
|
|
|
@ -72,12 +72,12 @@ class TestPost < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_published
|
||||
p = Post.new(File.join(File.dirname(__FILE__), *%w[source publish_test]), '', "2008-02-02-publish.textile")
|
||||
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2008-02-02-published.textile")
|
||||
assert_equal true, p.published
|
||||
end
|
||||
|
||||
def test_not_published
|
||||
p = Post.new(File.join(File.dirname(__FILE__), *%w[source publish_test]), '', "2008-02-02-not-published.textile")
|
||||
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2008-02-02-not-published.textile")
|
||||
assert_equal false, p.published
|
||||
end
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class TestSite < Test::Unit::TestCase
|
|||
def test_read_posts
|
||||
@s.read_posts('')
|
||||
posts = Dir[File.join(@source, '_posts/*')]
|
||||
assert_equal posts.size, @s.posts.size
|
||||
assert_equal posts.size - 1, @s.posts.size
|
||||
end
|
||||
|
||||
def test_site_payload
|
||||
|
@ -29,7 +29,7 @@ class TestSite < Test::Unit::TestCase
|
|||
posts = Dir[File.join(@source, "**", "_posts/*")]
|
||||
categories = %w(bar baz category foo z_category publish_test).sort
|
||||
|
||||
assert_equal posts.size, @s.posts.size
|
||||
assert_equal posts.size - 1, @s.posts.size
|
||||
assert_equal categories, @s.categories.keys.sort
|
||||
assert_equal 3, @s.categories['foo'].size
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue