diary 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -22
- data/Gemfile +4 -0
- data/Gemfile.lock +28 -0
- data/Rakefile +2 -20
- data/bin/diary +1 -40
- data/diary.gemspec +19 -60
- data/lib/diary.rb +23 -20
- data/lib/diary/cli.rb +5 -43
- data/lib/diary/cli/commands.rb +23 -0
- data/lib/diary/cli/commands/compile.rb +16 -0
- data/lib/diary/cli/commands/init.rb +40 -0
- data/lib/diary/cli/commands/new_item.rb +9 -0
- data/lib/diary/cli/commands/server.rb +13 -0
- data/lib/diary/cli/commands/sync.rb +20 -0
- data/lib/diary/cli/parser.rb +37 -0
- data/lib/diary/item/base.rb +26 -0
- data/lib/diary/item/creator.rb +80 -0
- data/lib/diary/item/data.rb +37 -0
- data/lib/diary/item/finder.rb +37 -0
- data/lib/diary/item/output.rb +58 -0
- data/lib/diary/item/snippet.rb +9 -0
- data/lib/diary/item/template.rb +38 -0
- data/lib/diary/item/url.rb +9 -0
- data/lib/diary/items/page.rb +7 -0
- data/lib/diary/items/post.rb +10 -0
- data/lib/diary/message.rb +40 -19
- data/lib/diary/server.rb +5 -0
- data/lib/diary/snippet.rb +19 -0
- data/lib/diary/version.rb +3 -0
- metadata +85 -38
- data/LICENSE +0 -20
- data/README.rdoc +0 -3
- data/VERSION +0 -1
- data/lib/diary/draft.rb +0 -14
- data/lib/diary/item.rb +0 -138
- data/lib/diary/output.rb +0 -57
- data/lib/diary/page.rb +0 -6
- data/lib/diary/post.rb +0 -22
- data/lib/diary/site.rb +0 -55
- data/lib/diary/template.rb +0 -27
- data/test/helper.rb +0 -10
- data/test/test_diary.rb +0 -7
data/lib/diary/site.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
module Diary
|
2
|
-
class Site
|
3
|
-
include Message
|
4
|
-
|
5
|
-
def initialize(options = {})
|
6
|
-
# Create directories
|
7
|
-
create_dir 'templates'
|
8
|
-
create_dir 'drafts'
|
9
|
-
create_dir 'posts'
|
10
|
-
create_dir 'pages'
|
11
|
-
create_dir 'assets'
|
12
|
-
|
13
|
-
# Create files
|
14
|
-
create_file 'templates/index.html', '{{ yield }}'
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.compile(force = false)
|
18
|
-
unless (Post.all.size == 0) and (Page.all.size == 0)
|
19
|
-
Post.all.each { |p| p.output(force) }
|
20
|
-
Page.all.each { |p| p.output(force) }
|
21
|
-
return self
|
22
|
-
else
|
23
|
-
puts "#{Error} Nothing to compile"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.sync
|
28
|
-
# TODO use rsync to sync over ftp
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def create_dir(path)
|
34
|
-
unless File.exists?(path)
|
35
|
-
FileUtils.mkdir_p(path)
|
36
|
-
|
37
|
-
say Create, path
|
38
|
-
else
|
39
|
-
say Exist, path
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def create_file(path, content)
|
44
|
-
unless File.exists?(path)
|
45
|
-
f = File.new(path, "w+")
|
46
|
-
f.puts(content)
|
47
|
-
f.close
|
48
|
-
|
49
|
-
say Create, path
|
50
|
-
else
|
51
|
-
say Exist, path
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/lib/diary/template.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
module Diary
|
2
|
-
module Template
|
3
|
-
include Message
|
4
|
-
|
5
|
-
def template
|
6
|
-
File.new(template_lookup).tap do |file|
|
7
|
-
say Invoke, file.path
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
def template_lookup
|
14
|
-
template_names.each do |name|
|
15
|
-
return template_path(name) if File.exists?(template_path(name))
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def template_path(name)
|
20
|
-
File.join("templates", "#{name}.html")
|
21
|
-
end
|
22
|
-
|
23
|
-
def template_names
|
24
|
-
[data.template, slug, self.class.name.downcase, 'index'].compact
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/test/helper.rb
DELETED