Added publish flag to posts, not preventing it from being in the destination directory yet.
This commit is contained in:
parent
1211f23b53
commit
ad617da4e0
|
@ -18,7 +18,7 @@ module Jekyll
|
||||||
name =~ MATCHER
|
name =~ MATCHER
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_accessor :date, :slug, :ext, :categories, :topics
|
attr_accessor :date, :slug, :ext, :categories, :topics, :published
|
||||||
attr_accessor :data, :content, :output
|
attr_accessor :data, :content, :output
|
||||||
|
|
||||||
# Initialize this Post instance.
|
# Initialize this Post instance.
|
||||||
|
@ -38,6 +38,12 @@ module Jekyll
|
||||||
|
|
||||||
self.process(name)
|
self.process(name)
|
||||||
self.read_yaml(@base, name)
|
self.read_yaml(@base, name)
|
||||||
|
|
||||||
|
if self.data.has_key?('published') && self.data['published'] == false
|
||||||
|
self.published = false
|
||||||
|
else
|
||||||
|
self.published = true
|
||||||
|
end
|
||||||
|
|
||||||
if self.categories.empty?
|
if self.categories.empty?
|
||||||
if self.data.has_key?('category')
|
if self.data.has_key?('category')
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
layout: default
|
||||||
|
title: Not published!
|
||||||
|
published: false
|
||||||
|
---
|
||||||
|
|
||||||
|
This should *not* be published!
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
layout: default
|
||||||
|
title: Publish
|
||||||
|
---
|
||||||
|
|
||||||
|
This should be published.
|
||||||
|
|
|
@ -71,6 +71,16 @@ class TestPost < Test::Unit::TestCase
|
||||||
assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", p.content
|
assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", p.content
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_published
|
||||||
|
p = Post.new(File.join(File.dirname(__FILE__), *%w[source publish_test]), '', "2008-02-02-publish.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")
|
||||||
|
assert_equal false, p.published
|
||||||
|
end
|
||||||
|
|
||||||
def test_yaml_category
|
def test_yaml_category
|
||||||
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2009-01-27-category.textile")
|
p = Post.new(File.join(File.dirname(__FILE__), *%w[source]), '', "2009-01-27-category.textile")
|
||||||
assert p.categories.include?('foo')
|
assert p.categories.include?('foo')
|
||||||
|
|
|
@ -27,7 +27,7 @@ class TestSite < Test::Unit::TestCase
|
||||||
@s.process
|
@s.process
|
||||||
|
|
||||||
posts = Dir[File.join(@source, "**", "_posts/*")]
|
posts = Dir[File.join(@source, "**", "_posts/*")]
|
||||||
categories = %w(bar baz category foo z_category).sort
|
categories = %w(bar baz category foo z_category publish_test).sort
|
||||||
|
|
||||||
assert_equal posts.size, @s.posts.size
|
assert_equal posts.size, @s.posts.size
|
||||||
assert_equal categories, @s.categories.keys.sort
|
assert_equal categories, @s.categories.keys.sort
|
||||||
|
|
Loading…
Reference in New Issue