public
Description: my blogging engine - sinatra + yaml
Homepage: http://yapok.org/
Clone URL: git://github.com/madx/honk.git
Click here to lend your support to: honk and make a donation at www.pledgie.com !
honk / honk.thor
100644 40 lines (34 sloc) 1.039 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# vim:ft=ruby
require 'rack/utils'
require 'fileutils'
 
this = File.dirname(__FILE__)
require File.join(this, 'lib', 'honk')
require File.join(this, 'config')
 
class Blog < Thor
 
  desc "bootstrap", "create the default files"
  method_options :root => :optional
  def bootstrap
    if options[:root]
      Honk.root options[:root]
    end
    puts "Creating directories..."
    if File.exist?(Honk.root) && Dir.entries(Honk.root) != %w[. ..]
      puts "root directory is not empty, aborting."
      exit 1
    end
    FileUtils.mkdir_p Honk.root unless File.exist? Honk.root
    FileUtils.mkdir Honk.root/'posts' unless File.exist? Honk.root/'posts'
 
    puts "Creating default files..."
    File.open(Honk.root/'index.yml', 'w+') do |f|
      f.puts "--- !honk.yapok.org,2009/Index"
    end
    File.open(Honk.root/'tags.yml', 'w+') do |f|
      f.puts "--- !honk.yapok.org,2009/Tags"
    end
    puts "Finished."
    puts <<EOT
Put your posts in #{Honk.root/'posts'}.
Edit the index.yml and tags.yml files accordingly.
EOT
  end
 
end