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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/brief/briefcase/initializer.rb', line 7
def run
options = @options
root = options.root
FileUtils.mkdir_p(root.join("docs","posts"))
config = "use(#{options.app})\n" if options.app
config = <<-EOF
root = Pathname(Dir.pwd)
config do
# You can put any special brief configuration here
# set(models_path: root.join('models')) if root.join('models').exist?
# set(templates_path: root.join('templates')) if root.join('templates').exist?
# set(docs_path: root.join('documents')) if root.join('documents').exist?
end
\n
define "Post" do
meta do
title
status :in => %w(draft published)
tags Array
end
\n
content do
title "h1:first-of-type"
subheading "h2:first-of-type"
end
end
EOF
example = <<-EOF
---
type: post
title: This is my first post
status: published
tags:
- default
- intro
---
# This is my first post
I should write something clever.
EOF
config.gsub!(/^\ {1,6}/m, '')
example.gsub!(/^\ {1,6}/m, '')
root.join("docs","posts","this-is-my-first-post.md").open("w+") {|fh| fh.write(example) }
root.join("brief.rb").open("w+") do |fh|
fh.write(config)
end
end
|