Sha256: 481b80504da4b0364e420387750756d1a3794d06902dfbe73d8f1bf9f55cf26e
Contents?: true
Size: 959 Bytes
Versions: 13
Compression:
Stored size: 959 Bytes
Contents
module Plate # Draft posts are located in the drafts/ folder and are not yet published. # # Add a publish: true meta flag to any draft post to publish it automatically # on the next build. class Draft < Post # Draft posts are placed in the /_drafts/ directory def file_path "/_drafts#{permalink}/index.html" end # Is this post ready to be published? (assumes meta data value of publish: true) def publish? !!self.meta[:publish] end # If this post is ready to be published, move it to its proper place in posts/ def publish! return unless publish? new_file = File.join(self.site.source, 'posts', self.date.strftime('%Y/%m'), self.basename) self.site.log("Publishing draft #{self.name}") if File.exists?(self.file) and !File.exists?(new_file) FileUtils.mkdir_p(File.dirname(new_file)) FileUtils.mv(self.file, new_file) end new_file end end end
Version data entries
13 entries across 13 versions & 1 rubygems