Files
jekyll/lib/jekyll/draft.rb
Martin Jorn Rogalla 4b8e3cfdbd Moved the in_(source/dest)_dir back to site.rb.
After carefully looking at these two methods, as of right now they do not
belong in the reader, as they should also be used by the writer. Thus the
decision was made to move them back into the class containing the source
and dest fields, site.rb.

Signed-off-by: Martin Jorn Rogalla <martin@martinrogalla.com>
2015-03-05 13:34:46 +01:00

41 lines
905 B
Ruby

module Jekyll
class Draft < Post
# Valid post name regex (no date)
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
# Get the full path to the directory containing the draft files
def containing_dir(dir)
site.in_source_dir(dir, '_drafts')
end
# The path to the draft source file, relative to the site source
def relative_path
File.join(@dir, '_drafts', @name)
end
# Extract information from the post filename.
#
# name - The String filename of the post file.
#
# Returns nothing.
def process(name)
m, slug, ext = *name.match(MATCHER)
self.date = File.mtime(File.join(@base, name))
self.slug = slug
self.ext = ext
end
end
end