Class: Plate::Draft
Overview
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.
Instance Attribute Summary
Attributes inherited from Page
#body, #content, #file, #layout, #meta, #partials, #raw, #site
Instance Method Summary collapse
-
#file_path ⇒ Object
Draft posts are placed in the /_drafts/ directory.
-
#publish! ⇒ Object
If this post is ready to be published, move it to its proper place in posts/.
-
#publish? ⇒ Boolean
Is this post ready to be published? (assumes meta data value of publish: true).
Methods inherited from Post
#<=>, #category, #category_for_url, #date, #day, #inspect, #month, #permalink, #permalink_template, #slug, #tags, #year
Methods inherited from Page
#<=>, #==, #base_path, #basename, #directory, #downgrade?, #engines, #extension, #extensions, #file?, #file_name, #format_extension, #id, #initialize, #inspect, #keywords, #load!, #loaded?, #path, #relative_file, #reload!, #rendered_body, #rendered_content, #slug, #title_for_url, #to_s, #url, #write!
Methods included from Callbacks
Constructor Details
This class inherits a constructor from Plate::Page
Instance Method Details
#file_path ⇒ Object
Draft posts are placed in the /_drafts/ directory
8 9 10 |
# File 'lib/plate/draft.rb', line 8 def file_path "/_drafts#{permalink}/index.html" end |
#publish! ⇒ Object
If this post is ready to be published, move it to its proper place in posts/
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/plate/draft.rb', line 18 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 |
#publish? ⇒ Boolean
Is this post ready to be published? (assumes meta data value of publish: true)
13 14 15 |
# File 'lib/plate/draft.rb', line 13 def publish? !!self.[:publish] end |