Class: Middleman::Cli::Entry
- Inherits:
-
Thor::Group
- Object
- Thor::Group
- Middleman::Cli::Entry
- Includes:
- Thor::Actions
- Defined in:
- lib/middleman-journal/commands/entry.rb
Overview
This class provides an “entry” command for the middleman CLI.
Class Method Summary collapse
-
.source_root ⇒ String
Template files are relative to this file.
Instance Method Summary collapse
Class Method Details
.source_root ⇒ String
Template files are relative to this file
23 24 25 |
# File 'lib/middleman-journal/commands/entry.rb', line 23 def self.source_root File.dirname( __FILE__ ) end |
Instance Method Details
#entry ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/middleman-journal/commands/entry.rb', line 27 def entry @date = Time.now @title = @date.strftime('%F') @slug = @date.strftime('%F') app = ::Middleman::Application.new do config[ :mode ] = :config config[ :disable_sitemap ] = true config[ :watcher_disable ] = true config[ :exit_before_ready ] = true end absolute_entry_path = File.join(app.source_dir, 'journal', "#{@title}.html.markdown") if File.exists?(absolute_entry_path) throw "An entry for #{@title} already exists: #{absolute_entry_path}" end entry_template = File.('entry.tt', File.dirname(__FILE__)) template entry_template, absolute_entry_path end |