diary 0.1.5 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ module Diary
2
+ VERSION = "0.2.0"
3
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 5
9
- version: 0.1.5
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Robin Clart
@@ -14,76 +14,121 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-07-02 00:00:00 +02:00
18
- default_executable: diary
17
+ date: 2011-03-04 00:00:00 +01:00
18
+ default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: liquid
21
+ name: activesupport
22
22
  prerelease: false
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
27
28
  segments:
28
- - 2
29
+ - 3
29
30
  - 0
30
31
  - 0
31
- version: 2.0.0
32
+ version: 3.0.0
32
33
  type: :runtime
33
34
  version_requirements: *id001
34
35
  - !ruby/object:Gem::Dependency
35
36
  name: bluecloth
36
37
  prerelease: false
37
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
38
40
  requirements:
39
41
  - - ">="
40
42
  - !ruby/object:Gem::Version
41
43
  segments:
42
44
  - 2
43
45
  - 0
44
- - 7
45
- version: 2.0.7
46
+ - 11
47
+ version: 2.0.11
46
48
  type: :runtime
47
49
  version_requirements: *id002
48
- description:
49
- email: robin@clart.me
50
+ - !ruby/object:Gem::Dependency
51
+ name: sinatra
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 1
60
+ - 1
61
+ - 0
62
+ version: 1.1.0
63
+ type: :runtime
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: bundler
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ segments:
74
+ - 1
75
+ - 0
76
+ - 0
77
+ - rc
78
+ - 6
79
+ version: 1.0.0.rc.6
80
+ type: :development
81
+ version_requirements: *id004
82
+ description: Diary makes it easy to maintain a file based website with template blog posts and pages.
83
+ email:
84
+ - robin@charlin.be
50
85
  executables:
51
86
  - diary
52
87
  extensions: []
53
88
 
54
- extra_rdoc_files:
55
- - LICENSE
56
- - README.rdoc
89
+ extra_rdoc_files: []
90
+
57
91
  files:
58
92
  - .gitignore
59
- - LICENSE
60
- - README.rdoc
93
+ - Gemfile
94
+ - Gemfile.lock
61
95
  - Rakefile
62
- - VERSION
63
96
  - bin/diary
64
97
  - diary.gemspec
65
98
  - lib/diary.rb
66
99
  - lib/diary/cli.rb
67
- - lib/diary/draft.rb
68
- - lib/diary/item.rb
100
+ - lib/diary/cli/commands.rb
101
+ - lib/diary/cli/commands/compile.rb
102
+ - lib/diary/cli/commands/init.rb
103
+ - lib/diary/cli/commands/new_item.rb
104
+ - lib/diary/cli/commands/server.rb
105
+ - lib/diary/cli/commands/sync.rb
106
+ - lib/diary/cli/parser.rb
107
+ - lib/diary/item/base.rb
108
+ - lib/diary/item/creator.rb
109
+ - lib/diary/item/data.rb
110
+ - lib/diary/item/finder.rb
111
+ - lib/diary/item/output.rb
112
+ - lib/diary/item/snippet.rb
113
+ - lib/diary/item/template.rb
114
+ - lib/diary/item/url.rb
115
+ - lib/diary/items/page.rb
116
+ - lib/diary/items/post.rb
69
117
  - lib/diary/message.rb
70
- - lib/diary/output.rb
71
- - lib/diary/page.rb
72
- - lib/diary/post.rb
73
- - lib/diary/site.rb
74
- - lib/diary/template.rb
75
- - test/helper.rb
76
- - test/test_diary.rb
118
+ - lib/diary/server.rb
119
+ - lib/diary/snippet.rb
120
+ - lib/diary/version.rb
77
121
  has_rdoc: true
78
- homepage: http://github.com/robinclart/diary
122
+ homepage: http://rubygems.org/gems/diary
79
123
  licenses: []
80
124
 
81
125
  post_install_message:
82
- rdoc_options:
83
- - --charset=UTF-8
126
+ rdoc_options: []
127
+
84
128
  require_paths:
85
129
  - lib
86
130
  required_ruby_version: !ruby/object:Gem::Requirement
131
+ none: false
87
132
  requirements:
88
133
  - - ">="
89
134
  - !ruby/object:Gem::Version
@@ -91,19 +136,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
91
136
  - 0
92
137
  version: "0"
93
138
  required_rubygems_version: !ruby/object:Gem::Requirement
139
+ none: false
94
140
  requirements:
95
141
  - - ">="
96
142
  - !ruby/object:Gem::Version
97
143
  segments:
98
- - 0
99
- version: "0"
144
+ - 1
145
+ - 3
146
+ - 6
147
+ version: 1.3.6
100
148
  requirements: []
101
149
 
102
- rubyforge_project:
103
- rubygems_version: 1.3.6
150
+ rubyforge_project: diary
151
+ rubygems_version: 1.3.7
104
152
  signing_key:
105
153
  specification_version: 3
106
- summary: Dead Simple, Static Blog Generator
107
- test_files:
108
- - test/helper.rb
109
- - test/test_diary.rb
154
+ summary: Another static blog generator
155
+ test_files: []
156
+
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 Robin Clart
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,3 +0,0 @@
1
- = Diary
2
-
3
- Dead Simple, Static Blog Generator.
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.1.5
@@ -1,14 +0,0 @@
1
- class Draft < Diary::Item
2
- @@base_directory = 'drafts'
3
-
4
- def publish(date = Date.today)
5
- to = File.join(Post.class_variable_get(:@@base_directory), *date.to_s.split('-'))
6
-
7
- FileUtils.mkpath to
8
- FileUtils.mv path, to
9
-
10
- say Publish, File.join(to, "#{slug}.md")
11
- rescue Errno::ENOENT
12
- say Error, "No draft found"
13
- end
14
- end
@@ -1,138 +0,0 @@
1
- # coding: utf-8
2
-
3
- module Diary
4
- class Item
5
- include Message
6
-
7
- ACCENTS = {
8
- ['á','à','â','ä','ã'] => 'a',
9
- ['Ã','Ä','Â','À','�?'] => 'A',
10
- ['é','è','ê','ë'] => 'e',
11
- ['Ë','É','È','Ê'] => 'E',
12
- ['í','ì','î','ï'] => 'i',
13
- ['�?','Î','Ì','�?'] => 'I',
14
- ['ó','ò','ô','ö','õ'] => 'o',
15
- ['Õ','Ö','Ô','Ò','Ó'] => 'O',
16
- ['ú','ù','û','ü'] => 'u',
17
- ['Ú','Û','Ù','Ü'] => 'U',
18
- ['ç'] => 'c', ['Ç'] => 'C',
19
- ['ñ'] => 'n', ['Ñ'] => 'N'
20
- }
21
-
22
- attr_reader :file
23
-
24
- def initialize(title_or_file, attributes = {})
25
- case title_or_file
26
- when File
27
- @new_file = false
28
- @file = title_or_file
29
- else
30
- @new_file = true
31
- @attributes = attributes
32
- @directory = extract_directory!
33
- @title = title_or_file
34
- @slug = nice_slug
35
-
36
- create!
37
- end
38
- end
39
-
40
- def slug
41
- @slug || basename
42
- end
43
-
44
- def title
45
- @title || data.title
46
- end
47
-
48
- def path
49
- file ? file.path : File.join(base_directory, directory, "#{slug}.md")
50
- end
51
-
52
- def directory
53
- @directory || File.dirname(path).gsub("#{base_directory}/", "")
54
- end
55
-
56
- def data
57
- OpenStruct.new(YAML.load_file(path))
58
- end
59
-
60
- def self.all
61
- Dir[File.join(self.class_variable_get(:@@base_directory), "**", "*.md")].map do |p|
62
- self.new File.new(p, 'r')
63
- end
64
- end
65
-
66
- def self.first
67
- all.first
68
- end
69
-
70
- def self.last
71
- all.last
72
- end
73
-
74
- private
75
-
76
- def base_directory
77
- self.class.class_variable_get(:@@base_directory)
78
- end
79
-
80
- def basename
81
- File.basename(file, '.md')
82
- end
83
-
84
- def nice_slug
85
- str = ""
86
- ACCENTS.each do |ac,rep|
87
- ac.each do |s|
88
- str = @title.gsub(s, rep)
89
- end
90
- end
91
- str.gsub(/[^a-zA-Z0-9 ]/, "")
92
- .gsub(/[ ]+/, " ")
93
- .gsub(/ /, "-")
94
- .downcase
95
- end
96
-
97
- def extract_directory!
98
- @attributes.delete(:directory) { |el| "" }
99
- end
100
-
101
- def create!
102
- if new_file?
103
- ensure_directories_exists
104
- @file = File.new(path, "w+")
105
- write!
106
-
107
- say Create, path
108
- else
109
- @file = File.new(path)
110
- @new_file = false
111
-
112
- say Exist, path
113
- end
114
-
115
- remove_instance_variable(:@attributes)
116
- remove_instance_variable(:@title)
117
- remove_instance_variable(:@slug)
118
- end
119
-
120
- def new_file?
121
- @new_file and not File.exists?(path)
122
- end
123
-
124
- def write!
125
- file.puts "---\n"
126
- file.puts "title: #{@title}"
127
- @attributes.each do |key, value|
128
- file.puts "#{key}: #{value}\n"
129
- end
130
- file.puts "\n---\n"
131
- file.close
132
- end
133
-
134
- def ensure_directories_exists
135
- FileUtils.mkpath(File.dirname(path))
136
- end
137
- end
138
- end
@@ -1,57 +0,0 @@
1
- module Diary
2
- module Output
3
- include Message
4
-
5
- @@output_base_directory = 'output'
6
-
7
- def output(force = false)
8
- if changed? or force
9
- FileUtils.mkpath output_directory
10
- f = File.new(output_path, 'w+')
11
- f.puts render
12
- f.close
13
-
14
- say Update, output_path
15
- else
16
- say Identical, output_path
17
- end
18
- end
19
-
20
- def content
21
- file.rewind
22
- file.read.split(/---\n/).slice(-1).strip
23
- end
24
-
25
- def render
26
- Liquid::Template.parse(template.read).render('yield' => html)
27
- end
28
-
29
- private
30
-
31
- def changed?
32
- file.mtime > output_file.ctime
33
- rescue Errno::ENOENT
34
- true
35
- end
36
-
37
- def html
38
- BlueCloth.new(content).to_html
39
- end
40
-
41
- def output_path
42
- path.gsub(base_directory, output_base_directory).gsub('.md', '.html')
43
- end
44
-
45
- def output_directory
46
- File.dirname(output_path)
47
- end
48
-
49
- def output_file
50
- File.new(output_path)
51
- end
52
-
53
- def output_base_directory
54
- self.class.class_variable_get(:@@output_base_directory)
55
- end
56
- end
57
- end
@@ -1,6 +0,0 @@
1
- class Page < Diary::Item
2
- @@base_directory = 'pages'
3
-
4
- include Diary::Template
5
- include Diary::Output
6
- end
@@ -1,22 +0,0 @@
1
- class Post < Diary::Item
2
- @@base_directory = 'posts'
3
-
4
- include Diary::Template
5
- include Diary::Output
6
-
7
- def initialize(title_or_file)
8
- super(title_or_file)
9
- end
10
-
11
- def date
12
- Date.parse(directory)
13
- end
14
-
15
- def output(force = false)
16
- if date <= Date.today
17
- super(force)
18
- else
19
- say Skip, path
20
- end
21
- end
22
- end