add the Publisher class to handle publishing logic

This commit is contained in:
maul.esel 2014-04-07 15:36:26 +02:00
parent 91e9ecfa63
commit 26663a6cf9
2 changed files with 22 additions and 0 deletions

View File

@ -50,6 +50,7 @@ require 'jekyll/related_posts'
require 'jekyll/cleaner'
require 'jekyll/entry_filter'
require 'jekyll/layout_reader'
require 'jekyll/publisher'
# extensions
require 'jekyll/plugin'

21
lib/jekyll/publisher.rb Normal file
View File

@ -0,0 +1,21 @@
module Jekyll
class Publisher
def initialize(site)
@site = site
end
def publish?(thing)
can_be_published?(thing) && !hidden_in_the_future?(thing)
end
private
def can_be_published?(thing)
thing.data.fetch('published', true) || @site.unpublished
end
def hidden_in_the_future?(thing)
thing.is_a?(Post) && !@site.future && thing.date > @site.time
end
end
end