class Jekyll::PostReader
def initialize(site)
def initialize(site) @site = site end
def processable?(doc)
def processable?(doc) if doc.content.nil? Jekyll.logger.debug "Skipping:", "Content in #{doc.relative_path} is nil" false elsif !doc.content.valid_encoding? Jekyll.logger.debug "Skipping:", "#{doc.relative_path} is not valid UTF-8" false else publishable?(doc) end end
def publishable?(doc)
def publishable?(doc) site.publisher.publish?(doc).tap do |will_publish| if !will_publish && site.publisher.hidden_in_the_future?(doc) Jekyll.logger.warn "Skipping:", "#{doc.relative_path} has a future date" end end end
def read_content(dir, magic_dir, matcher)
klass - The return type of the content.
looks for content here.
magic_dir - The String relative directory to
dir - The String relative path of the directory to read.
and return them with the type klass.
Read all the content files from
def read_content(dir, magic_dir, matcher) @site.reader.get_entries(dir, magic_dir).map do |entry| next unless matcher.match?(entry) path = @site.in_source_dir(File.join(dir, magic_dir, entry)) Document.new(path, :site => @site, :collection => @site.posts) end.tap(&:compact!) end
def read_drafts(dir)
dir - The String relative path of the directory to read.
Document object with each one.
Read all the files in
def read_drafts(dir) read_publishable(dir, "_drafts", Document::DATELESS_FILENAME_MATCHER) end
def read_posts(dir)
dir - The String relative path of the directory to read.
object with each one.
Read all the files in
def read_posts(dir) read_publishable(dir, "_posts", Document::DATE_FILENAME_MATCHER) end
def read_publishable(dir, magic_dir, matcher)
dir - The String relative path of the directory to read.
Document object with each one insofar as it matches the regexp matcher.
Read all the files in
def read_publishable(dir, magic_dir, matcher) read_content(dir, magic_dir, matcher) .tap { |docs| docs.each(&:read) } .select { |doc| processable?(doc) } end