diff --git a/lib/jekyll/reader.rb b/lib/jekyll/reader.rb index 7c34ac33..96da74fa 100644 --- a/lib/jekyll/reader.rb +++ b/lib/jekyll/reader.rb @@ -74,6 +74,22 @@ module Jekyll end end + # Read all the files in //_drafts and create a new Post + # object with each one. + # + # dir - The String relative path of the directory to read. + # + # Returns nothing. + def read_drafts(dir) + drafts = read_content(dir, '_drafts', Draft) + + drafts.each do |draft| + if draft.published? + aggregate_post_info(draft) + end + end + end + def read_content(dir, magic_dir, klass) get_entries(dir, magic_dir).map do |entry| klass.new(site, site.source, dir, entry) if klass.valid?(entry) diff --git a/lib/jekyll/site.rb b/lib/jekyll/site.rb index 6dae33f7..5b2854d7 100644 --- a/lib/jekyll/site.rb +++ b/lib/jekyll/site.rb @@ -147,7 +147,7 @@ module Jekyll entries = Dir.chdir(base) { reader.filter_entries(Dir.entries('.'), base) } read_posts(dir) - read_drafts(dir) if show_drafts + reader.read_drafts(dir) if show_drafts posts.sort! limit_posts! if limit_posts > 0 # limit the posts if :limit_posts option is set @@ -182,22 +182,6 @@ module Jekyll end end - # Read all the files in //_drafts and create a new Post - # object with each one. - # - # dir - The String relative path of the directory to read. - # - # Returns nothing. - def read_drafts(dir) - drafts = reader.read_content(dir, '_drafts', Draft) - - drafts.each do |draft| - if draft.published? - reader.aggregate_post_info(draft) - end - end - end - # Read in all collections specified in the configuration # # Returns nothing.