Refactored setting of Post.published flag
This commit is contained in:
parent
266a52b161
commit
482986e346
|
@ -41,18 +41,11 @@ module Jekyll
|
||||||
self.process(name)
|
self.process(name)
|
||||||
self.read_yaml(@base, name)
|
self.read_yaml(@base, name)
|
||||||
|
|
||||||
# If we've added a date and time to the YAML, use that instead of the
|
|
||||||
# filename date. Means we'll sort correctly.
|
|
||||||
if self.data.has_key?('date')
|
if self.data.has_key?('date')
|
||||||
# ensure Time via to_s and reparse
|
|
||||||
self.date = Time.parse(self.data["date"].to_s)
|
self.date = Time.parse(self.data["date"].to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.data.has_key?('published') && self.data['published'] == false
|
self.published = self.is_published
|
||||||
self.published = false
|
|
||||||
else
|
|
||||||
self.published = true
|
|
||||||
end
|
|
||||||
|
|
||||||
self.tags = self.data.pluralized_array("tag", "tags")
|
self.tags = self.data.pluralized_array("tag", "tags")
|
||||||
|
|
||||||
|
@ -64,6 +57,14 @@ module Jekyll
|
||||||
self.categories.flatten!
|
self.categories.flatten!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_published
|
||||||
|
if self.data.has_key?('published') && self.data['published'] == false
|
||||||
|
false
|
||||||
|
else
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Get the full path to the directory containing the post files
|
# Get the full path to the directory containing the post files
|
||||||
def containing_dir(source, dir)
|
def containing_dir(source, dir)
|
||||||
return File.join(source, dir, '_posts')
|
return File.join(source, dir, '_posts')
|
||||||
|
|
Loading…
Reference in New Issue