mirror of
https://github.com/jekyll/jekyll.git
synced 2026-02-04 19:55:00 -05:00
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>
41 lines
905 B
Ruby
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
|