retter 0.2.5 → 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -11
- data/.travis.yml +4 -2
- data/ChangeLog.md +11 -5
- data/Gemfile +4 -1
- data/LICENSE.txt +22 -0
- data/README.md +163 -246
- data/Rakefile +25 -5
- data/bin/retter +2 -22
- data/lib/retter.rb +57 -43
- data/lib/retter/cli.rb +46 -0
- data/lib/retter/cli/edit.rb +33 -0
- data/lib/retter/cli/hooks.rb +46 -0
- data/lib/retter/cli/list.rb +15 -0
- data/lib/retter/cli/new.rb +20 -0
- data/lib/retter/cli/preview.rb +9 -0
- data/lib/retter/cli/publish.rb +22 -0
- data/lib/retter/deprecated.rb +160 -0
- data/lib/retter/entry.rb +31 -106
- data/lib/retter/entry/article.rb +36 -0
- data/lib/retter/entry/find_methods.rb +38 -0
- data/lib/retter/entry/model_base.rb +10 -0
- data/lib/retter/entry/pagination.rb +23 -0
- data/lib/retter/entry/sort_methods.rb +7 -0
- data/lib/retter/entry/utils.rb +12 -0
- data/lib/retter/initializing.rb +45 -0
- data/lib/retter/repository.rb +99 -12
- data/lib/retter/retterfile.rb +67 -0
- data/lib/retter/retterfile/context.rb +57 -0
- data/lib/retter/static_site.rb +34 -0
- data/lib/retter/static_site/app.rb +13 -0
- data/lib/retter/static_site/app/application.rb +94 -0
- data/lib/retter/{generator/skel/entries → static_site/app/assets/images}/.gitkeep +0 -0
- data/lib/retter/{generator/skel → static_site/app/assets}/images/orange/bg_body.jpg +0 -0
- data/lib/retter/{generator/skel → static_site/app/assets}/images/orange/bg_entry.jpg +0 -0
- data/lib/retter/{generator/skel → static_site/app/assets}/images/orange/bg_header.png +0 -0
- data/lib/retter/{generator/skel → static_site/app/assets}/images/orange/ic_li01.gif +0 -0
- data/lib/retter/{generator/skel/images → static_site/app/assets/javascripts}/.gitkeep +0 -0
- data/lib/retter/static_site/app/assets/stylesheets/application.css.scss +3 -0
- data/lib/retter/{generator/skel/stylesheets/base.css → static_site/app/assets/stylesheets/base.css.scss} +0 -0
- data/lib/retter/{generator/skel/stylesheets/pygments.css → static_site/app/assets/stylesheets/highlight.css.scss} +0 -0
- data/lib/retter/static_site/app/assets/stylesheets/orange.css.scss +262 -0
- data/lib/retter/static_site/app/assets/stylesheets/retter.css.scss +198 -0
- data/lib/retter/static_site/app/config.ru +7 -0
- data/lib/retter/static_site/app/controllers.rb +113 -0
- data/lib/retter/static_site/app/helpers.rb +36 -0
- data/lib/retter/{generator/skel/layouts/profile.html.haml → static_site/app/templates/about/show.html.haml} +0 -0
- data/lib/retter/static_site/app/templates/entries/articles/show.html.haml +7 -0
- data/lib/retter/static_site/app/templates/entries/index.html.haml +13 -0
- data/lib/retter/static_site/app/templates/entries/index.rss.haml +24 -0
- data/lib/retter/static_site/app/templates/entries/show.html.haml +11 -0
- data/lib/retter/static_site/app/templates/index/show.html.haml +14 -0
- data/lib/retter/static_site/app/templates/layouts/application.html.haml +34 -0
- data/lib/retter/static_site/builder.rb +106 -0
- data/lib/retter/static_site/cli.rb +25 -0
- data/lib/retter/static_site/cli/build.rb +85 -0
- data/lib/retter/static_site/cli/edit.rb +17 -0
- data/lib/retter/static_site/cli/migrate.rb +93 -0
- data/lib/retter/static_site/cli/new.rb +50 -0
- data/lib/retter/static_site/cli/preview.rb +66 -0
- data/lib/retter/static_site/markdown.rb +25 -0
- data/lib/retter/static_site/markdown/code_ray_renderer.rb +13 -0
- data/lib/retter/static_site/markdown/pygments_renderer.rb +18 -0
- data/lib/retter/static_site/markdown_entry.rb +111 -0
- data/lib/retter/static_site/monkey/sprockets_task.rb +10 -0
- data/lib/retter/version.rb +1 -1
- data/retter.gemspec +59 -43
- data/skel/.gitignore +2 -0
- data/skel/Retterfile +16 -0
- data/skel/config.ru +22 -0
- data/{lib/retter/generator/skel/javascripts → skel/retters}/.gitkeep +0 -0
- data/skel/retters/today.md +3 -0
- data/spec/cli/build_spec.rb +87 -0
- data/spec/cli/edit_spec.rb +76 -0
- data/spec/cli/invocation_spec.rb +19 -0
- data/spec/cli/list_spec.rb +64 -0
- data/spec/cli/migrate_spec.rb +65 -0
- data/spec/cli/new_spec.rb +30 -0
- data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/.gitignore +0 -0
- data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/Retterfile +6 -3
- data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/config.ru +0 -0
- data/{lib/retter/generator/skel/retters/.gitkeep → spec/fixtures/sites/site-0.2.5/entries.html} +0 -0
- data/spec/fixtures/sites/site-0.2.5/entries.rss +0 -0
- data/spec/fixtures/sites/site-0.2.5/entries/.gitkeep +0 -0
- data/spec/fixtures/sites/site-0.2.5/images/.gitkeep +0 -0
- data/spec/fixtures/sites/site-0.2.5/images/orange/bg_body.jpg +0 -0
- data/spec/fixtures/sites/site-0.2.5/images/orange/bg_entry.jpg +0 -0
- data/spec/fixtures/sites/site-0.2.5/images/orange/bg_header.png +0 -0
- data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/index.html +0 -0
- data/spec/fixtures/sites/site-0.2.5/javascripts/.gitkeep +0 -0
- data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/layouts/article.html.haml +0 -0
- data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/layouts/entries.html.haml +0 -0
- data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/layouts/entry.html.haml +0 -0
- data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/layouts/index.html.haml +0 -0
- data/spec/fixtures/sites/site-0.2.5/layouts/profile.html.haml +7 -0
- data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/layouts/retter.html.haml +0 -0
- data/spec/fixtures/sites/site-0.2.5/profile.html +0 -0
- data/spec/fixtures/sites/site-0.2.5/retters/.gitkeep +0 -0
- data/spec/fixtures/sites/site-0.2.5/stylesheets/base.css +22 -0
- data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/stylesheets/orange.css +0 -0
- data/spec/fixtures/sites/site-0.2.5/stylesheets/pygments.css +288 -0
- data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/stylesheets/retter.css +0 -0
- data/spec/retter/deprecated_spec.rb +106 -0
- data/spec/retter/initializing_spec.rb +86 -0
- data/spec/retter/retterfile_spec.rb +32 -0
- data/spec/spec_helper.rb +38 -27
- data/spec/support/example_helper.rb +46 -0
- data/spec/support/matchers.rb +14 -0
- data/spec/support/test_site.rb +59 -0
- metadata +329 -236
- data/lib/retter/binder.rb +0 -50
- data/lib/retter/command.rb +0 -192
- data/lib/retter/config.rb +0 -96
- data/lib/retter/configurable.rb +0 -26
- data/lib/retter/entries.rb +0 -115
- data/lib/retter/generator.rb +0 -7
- data/lib/retter/generator/base.rb +0 -65
- data/lib/retter/generator/creator.rb +0 -34
- data/lib/retter/generator/skel/Gemfile +0 -5
- data/lib/retter/markdown.rb +0 -31
- data/lib/retter/markdown/code_ray_renderer.rb +0 -11
- data/lib/retter/markdown/pygments_renderer.rb +0 -16
- data/lib/retter/page.rb +0 -43
- data/lib/retter/page/article.rb +0 -54
- data/lib/retter/page/base.rb +0 -97
- data/lib/retter/page/entries.rb +0 -17
- data/lib/retter/page/entry.rb +0 -46
- data/lib/retter/page/feed.rb +0 -63
- data/lib/retter/page/index.rb +0 -17
- data/lib/retter/page/profile.rb +0 -17
- data/lib/retter/page/view_helper.rb +0 -66
- data/lib/retter/preprint.rb +0 -34
- data/spec/command/callback_spec.rb +0 -27
- data/spec/command/clean_spec.rb +0 -20
- data/spec/command/commit_spec.rb +0 -40
- data/spec/command/edit_spec.rb +0 -119
- data/spec/command/list_spec.rb +0 -42
- data/spec/command/open_spec.rb +0 -12
- data/spec/command/preview_spec.rb +0 -40
- data/spec/command/rebind_spec.rb +0 -276
- data/spec/support/example_group_helper.rb +0 -98
data/spec/command/open_spec.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'launchy'
|
5
|
-
|
6
|
-
describe 'Retter::Command#open', clean: :all do
|
7
|
-
specify 'should be open application' do
|
8
|
-
Launchy.should_receive(:open).with(generated_file('index.html').to_path)
|
9
|
-
|
10
|
-
invoke_command :open
|
11
|
-
end
|
12
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'launchy'
|
5
|
-
|
6
|
-
describe 'Retter::Command#preview', clean: :all do
|
7
|
-
let(:preview_html) { generated_file('.preview.html').read }
|
8
|
-
|
9
|
-
before do
|
10
|
-
Launchy.should_receive(:open).with(anything)
|
11
|
-
end
|
12
|
-
|
13
|
-
context 'no options' do
|
14
|
-
before do
|
15
|
-
write_to_wip_file 'w00t!'
|
16
|
-
|
17
|
-
invoke_command :preview
|
18
|
-
end
|
19
|
-
|
20
|
-
subject { texts_of(preview_html, 'article p') }
|
21
|
-
|
22
|
-
it { should include 'w00t!' }
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'with date option' do
|
26
|
-
let(:date_file) { markdown_file('20110101') }
|
27
|
-
|
28
|
-
before do
|
29
|
-
write_to_wip_file 'w00t!'
|
30
|
-
date_file.open('w') {|f| f.puts 'preview me' }
|
31
|
-
|
32
|
-
invoke_command :preview, date: '20110101'
|
33
|
-
end
|
34
|
-
|
35
|
-
subject { texts_of(preview_html, 'article p') }
|
36
|
-
|
37
|
-
it { should_not include 'w00t!' }
|
38
|
-
it { should include 'preview me' }
|
39
|
-
end
|
40
|
-
end
|
data/spec/command/rebind_spec.rb
DELETED
@@ -1,276 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe 'Retter::Command#rebind', clean: :all do
|
6
|
-
context 'first post' do
|
7
|
-
let(:date_str) { '2011/01/01' }
|
8
|
-
let(:article) { <<-EOM }
|
9
|
-
# 朝11時
|
10
|
-
|
11
|
-
おはようございます
|
12
|
-
|
13
|
-
# 夜1時
|
14
|
-
|
15
|
-
おやすみなさい
|
16
|
-
EOM
|
17
|
-
|
18
|
-
before do
|
19
|
-
time_travel_to date_str
|
20
|
-
|
21
|
-
write_to_wip_file article
|
22
|
-
|
23
|
-
command.should_receive(:after_callback).with(:bind)
|
24
|
-
command.should_receive(:after_callback).with(:rebind)
|
25
|
-
|
26
|
-
invoke_command :rebind
|
27
|
-
end
|
28
|
-
|
29
|
-
describe 'wip file' do
|
30
|
-
specify 'wip file should be removed' do
|
31
|
-
wip_file.should_not be_exist
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe 'index.html' do
|
36
|
-
let(:index_html) { generated_file('index.html').read }
|
37
|
-
|
38
|
-
it { texts_of(index_html, 'article p').should include 'おはようございます' }
|
39
|
-
it { texts_of(index_html, 'article h1.date').should == %w(2011-01-01) }
|
40
|
-
it { texts_of(index_html, 'article h1').should == %w(2011-01-01 朝11時 夜1時) }
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'entries.html' do
|
44
|
-
let(:entries_html) { generated_file('entries.html').read }
|
45
|
-
|
46
|
-
it { texts_of(entries_html, 'a.entry').first.should == '01/01' }
|
47
|
-
it { texts_of(entries_html, 'a.article').should == %w(朝11時 夜1時) }
|
48
|
-
end
|
49
|
-
|
50
|
-
describe 'entry.html' do
|
51
|
-
let(:entry_html) { entry_html_file(date_str).read }
|
52
|
-
|
53
|
-
it { texts_of(entry_html, 'article p').should == %w(おはようございます おやすみなさい) }
|
54
|
-
it { texts_of(entry_html, 'article h1.date').should == %w(2011-01-01) }
|
55
|
-
it { texts_of(entry_html, 'article h1').should == %w(2011-01-01 朝11時 夜1時) }
|
56
|
-
end
|
57
|
-
|
58
|
-
describe 'article (first)' do
|
59
|
-
let(:article_html) { article_html_file(date_str, 'a0').read }
|
60
|
-
|
61
|
-
describe 'body' do
|
62
|
-
subject { texts_of(article_html, 'article p') }
|
63
|
-
|
64
|
-
it { should include 'おはようございます' }
|
65
|
-
it { should_not include 'おやすみなさい' }
|
66
|
-
end
|
67
|
-
|
68
|
-
describe 'date' do
|
69
|
-
subject { texts_of(article_html, 'article h1.date') }
|
70
|
-
|
71
|
-
it { should == %w(2011-01-01) }
|
72
|
-
end
|
73
|
-
|
74
|
-
describe 'headings' do
|
75
|
-
subject { texts_of(article_html, 'article h1') }
|
76
|
-
|
77
|
-
it { should include '朝11時' }
|
78
|
-
it { should_not include '夜1時' }
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
describe 'article (last)' do
|
83
|
-
let(:article_html) { article_html_file(date_str, 'a1').read }
|
84
|
-
|
85
|
-
describe 'body' do
|
86
|
-
subject { texts_of(article_html, 'article p') }
|
87
|
-
|
88
|
-
it { should include 'おやすみなさい' }
|
89
|
-
it { should_not include 'おはようございます' }
|
90
|
-
end
|
91
|
-
|
92
|
-
describe 'date' do
|
93
|
-
subject { texts_of(article_html, 'article h1.date') }
|
94
|
-
|
95
|
-
it { should == %w(2011-01-01) }
|
96
|
-
end
|
97
|
-
|
98
|
-
describe 'headings' do
|
99
|
-
subject { texts_of(article_html, 'article h1') }
|
100
|
-
|
101
|
-
it { should include '夜1時' }
|
102
|
-
it { should_not include '朝11時' }
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context 'article includes code block' do
|
108
|
-
let(:index_html) { generated_file('index.html').read }
|
109
|
-
let(:article) { <<-EOM }
|
110
|
-
# コードを書きました
|
111
|
-
|
112
|
-
```ruby
|
113
|
-
sleep 1000
|
114
|
-
```
|
115
|
-
EOM
|
116
|
-
|
117
|
-
before do
|
118
|
-
write_to_wip_file article
|
119
|
-
end
|
120
|
-
|
121
|
-
context 'use Pygments' do
|
122
|
-
before do
|
123
|
-
Retter::Site.config.renderer Retter::Markdown::PygmentsRenderer
|
124
|
-
|
125
|
-
invoke_command :rebind
|
126
|
-
end
|
127
|
-
|
128
|
-
specify 'code should be highlighted' do
|
129
|
-
nokogiri(index_html).search('.highlight').should_not be_empty
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
context 'use CodeRay' do
|
134
|
-
before do
|
135
|
-
Retter::Site.config.renderer Retter::Markdown::CodeRayRenderer
|
136
|
-
|
137
|
-
invoke_command :rebind
|
138
|
-
end
|
139
|
-
|
140
|
-
specify 'code should be highlighted' do
|
141
|
-
nokogiri(index_html).search('.code').should_not be_empty
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
context 'use custom markup' do
|
147
|
-
let(:index_html) { generated_file('index.html').read }
|
148
|
-
let(:custom_markup) { Object.new.tap {|o| o.define_singleton_method(:render, &:upcase) } }
|
149
|
-
|
150
|
-
before do
|
151
|
-
Retter::Site.config.markup custom_markup
|
152
|
-
|
153
|
-
write_to_wip_file 'hi'
|
154
|
-
|
155
|
-
invoke_command :rebind
|
156
|
-
end
|
157
|
-
|
158
|
-
after do
|
159
|
-
Retter::Entries.instance_variable_set :@markup, nil
|
160
|
-
end
|
161
|
-
|
162
|
-
subject { texts_of(index_html, 'article p') }
|
163
|
-
|
164
|
-
it { should include 'HI' }
|
165
|
-
end
|
166
|
-
|
167
|
-
context 'with silent option' do
|
168
|
-
before do
|
169
|
-
write_to_wip_file 'article'
|
170
|
-
end
|
171
|
-
|
172
|
-
specify 'rebind callback should not invoked' do
|
173
|
-
command.should_not_receive(:after_callback)
|
174
|
-
|
175
|
-
invoke_command :rebind, silent: true
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
context 'skipping some singleton pages binding' do
|
180
|
-
let(:index_html) { generated_file('index.html') }
|
181
|
-
let(:profile_html) { generated_file('profile.html') }
|
182
|
-
let(:entries_html) { generated_file('entries.html') }
|
183
|
-
let(:feed_file) { generated_file('feed.rss') }
|
184
|
-
|
185
|
-
before do
|
186
|
-
index_html.unlink
|
187
|
-
|
188
|
-
invoke_command :edit
|
189
|
-
end
|
190
|
-
|
191
|
-
context 'skipping all' do
|
192
|
-
before do
|
193
|
-
invoke_command :rebind do |config|
|
194
|
-
config.allow_binding :none
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
it { profile_html.should_not be_exist }
|
199
|
-
it { entries_html.should_not be_exist }
|
200
|
-
it { feed_file.should_not be_exist }
|
201
|
-
it { index_html.should be_exist }
|
202
|
-
end
|
203
|
-
|
204
|
-
context 'skipping only :feed' do
|
205
|
-
before do
|
206
|
-
invoke_command :rebind do |config|
|
207
|
-
config.allow_binding [:profile, :entries]
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
it { profile_html.should be_exist }
|
212
|
-
it { entries_html.should be_exist }
|
213
|
-
it { feed_file.should_not be_exist }
|
214
|
-
it { index_html.should be_exist }
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
context 'with link or image' do
|
219
|
-
let(:index_html) { generated_file('index.html').read }
|
220
|
-
let(:elements) { nokogiri(index_html) }
|
221
|
-
|
222
|
-
before do
|
223
|
-
write_to_wip_file article
|
224
|
-
|
225
|
-
invoke_command :rebind
|
226
|
-
end
|
227
|
-
|
228
|
-
describe 'a href="//example.com/foo/bar"' do
|
229
|
-
let(:article) { '[title](//example.com/foo/bar)' }
|
230
|
-
|
231
|
-
it { elements.search("a[href='//example.com/foo/bar']").should_not be_empty }
|
232
|
-
end
|
233
|
-
|
234
|
-
describe 'img src="//example.com/foo/bar.png"' do
|
235
|
-
let(:article) { '![title](//example.com/foo/bar.png)' }
|
236
|
-
|
237
|
-
it { elements.search("img[src='//example.com/foo/bar.png']").should_not be_empty }
|
238
|
-
end
|
239
|
-
|
240
|
-
describe 'a href="/foo/bar"' do
|
241
|
-
let(:article) { '[title](/foo/bar)' }
|
242
|
-
|
243
|
-
it { elements.search("a[href='./foo/bar']").should_not be_empty }
|
244
|
-
end
|
245
|
-
|
246
|
-
describe 'img src="/foo/bar.png"' do
|
247
|
-
let(:article) { '![title](/foo/bar.png)' }
|
248
|
-
|
249
|
-
it { elements.search("img[src='./foo/bar.png']").should_not be_empty }
|
250
|
-
end
|
251
|
-
|
252
|
-
describe 'a href="./foo/bar"' do
|
253
|
-
let(:article) { '[title](./foo/bar)' }
|
254
|
-
|
255
|
-
it { elements.search("a[href='./foo/bar']").should_not be_empty }
|
256
|
-
end
|
257
|
-
|
258
|
-
describe 'img src="./foo/bar.png"' do
|
259
|
-
let(:article) { '![title](./foo/bar.png)' }
|
260
|
-
|
261
|
-
it { elements.search("img[src='./foo/bar.png']").should_not be_empty }
|
262
|
-
end
|
263
|
-
|
264
|
-
describe 'a href="../foo/bar"' do
|
265
|
-
let(:article) { '[title](../foo/bar)' }
|
266
|
-
|
267
|
-
it { elements.search("a[href='../foo/bar']").should_not be_empty }
|
268
|
-
end
|
269
|
-
|
270
|
-
describe 'img src="../foo/bar.png"' do
|
271
|
-
let(:article) { '![title](../foo/bar.png)' }
|
272
|
-
|
273
|
-
it { elements.search("img[src='../foo/bar.png']").should_not be_empty }
|
274
|
-
end
|
275
|
-
end
|
276
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
require 'nokogiri'
|
4
|
-
require 'stringio'
|
5
|
-
|
6
|
-
module ExampleGroupHelper
|
7
|
-
module RetterShortcuts
|
8
|
-
def command
|
9
|
-
@command ||= Retter::Command.new
|
10
|
-
end
|
11
|
-
|
12
|
-
def invoke_command(command_name, *args)
|
13
|
-
@command ||= Retter::Command.new
|
14
|
-
|
15
|
-
yield Retter::Site.config if block_given?
|
16
|
-
|
17
|
-
if args.last.is_a?(Hash)
|
18
|
-
options = args.pop
|
19
|
-
|
20
|
-
@command.stub!(:options) { options }
|
21
|
-
end
|
22
|
-
|
23
|
-
@command.__send__ command_name, *args
|
24
|
-
end
|
25
|
-
|
26
|
-
def wip_file
|
27
|
-
Retter::Site.entries.wip_file
|
28
|
-
end
|
29
|
-
|
30
|
-
def write_to_wip_file(body)
|
31
|
-
wip_file.open('w') {|f| f.write body }
|
32
|
-
end
|
33
|
-
|
34
|
-
def generated_file(path)
|
35
|
-
Retter::Site.config.retter_home.join(path)
|
36
|
-
end
|
37
|
-
|
38
|
-
def markdown_file(date)
|
39
|
-
date = date_wrap(date)
|
40
|
-
|
41
|
-
Retter::Site.entries.retter_file(date)
|
42
|
-
end
|
43
|
-
|
44
|
-
def find_entry_by_string(str)
|
45
|
-
Retter::Site.entries.detect_by_string(str)
|
46
|
-
end
|
47
|
-
|
48
|
-
def entry_html_file(date)
|
49
|
-
date = date_wrap(date)
|
50
|
-
|
51
|
-
Retter::Page.entry_file(date)
|
52
|
-
end
|
53
|
-
|
54
|
-
def article_html_file(date, id)
|
55
|
-
date = date_wrap(date)
|
56
|
-
|
57
|
-
Retter::Page.entry_dir(date).join("#{id}.html")
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
def date_wrap(str)
|
63
|
-
Date.parse(str.to_s)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
module HTML
|
68
|
-
def nokogiri(html)
|
69
|
-
Nokogiri::HTML(html)
|
70
|
-
end
|
71
|
-
|
72
|
-
def texts_of(html, selector)
|
73
|
-
nokogiri(html).search(selector).map {|el|
|
74
|
-
el.text.strip
|
75
|
-
}
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
module Stream
|
80
|
-
def capture(stream)
|
81
|
-
begin
|
82
|
-
eval "$#{stream} = StringIO.new"
|
83
|
-
|
84
|
-
yield
|
85
|
-
|
86
|
-
result = eval("$#{stream}").string
|
87
|
-
ensure
|
88
|
-
eval %($#{stream} = #{stream.upcase})
|
89
|
-
end
|
90
|
-
|
91
|
-
result
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
include RetterShortcuts
|
96
|
-
include HTML
|
97
|
-
include Stream
|
98
|
-
end
|