implement and use Draft.valid?

This commit is contained in:
scribu 2013-02-09 22:41:47 +02:00
parent 1ac46b17c4
commit 642349f797
2 changed files with 9 additions and 1 deletions

View File

@ -5,6 +5,14 @@ module Jekyll
# Valid post name regex (no date) # Valid post name regex (no date)
MATCHER = /^(.*)(\.[^.]+)$/ MATCHER = /^(.*)(\.[^.]+)$/
# Draft name validator. Draft filenames must be like:
# my-awesome-post.textile
#
# Returns true if valid, false if not.
def self.valid?(name)
name =~ MATCHER
end
# Extract information from the post filename. # Extract information from the post filename.
# #
# name - The String filename of the post file. # name - The String filename of the post file.

View File

@ -212,7 +212,7 @@ module Jekyll
# first pass processes, but does not yet render post content # first pass processes, but does not yet render post content
entries.each do |f| entries.each do |f|
if Post.valid?(f) if Draft.valid?(f)
post = Draft.new(self, self.source, dir, f) post = Draft.new(self, self.source, dir, f)
if post.published && (self.future || post.date <= self.time) if post.published && (self.future || post.date <= self.time)