retter 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/.travis.yml +1 -1
  2. data/ChangeLog.md +10 -0
  3. data/README.md +1 -3
  4. data/bin/retter +8 -4
  5. data/lib/retter/binder.rb +50 -0
  6. data/lib/retter/command.rb +42 -39
  7. data/lib/retter/config.rb +24 -23
  8. data/lib/retter/entries.rb +14 -18
  9. data/lib/retter/entry.rb +52 -29
  10. data/lib/retter/generator/base.rb +6 -7
  11. data/lib/retter/generator/skel/Gemfile +1 -2
  12. data/lib/retter/generator/skel/Retterfile +2 -2
  13. data/lib/retter/generator/skel/layouts/article.html.haml +3 -2
  14. data/lib/retter/generator/skel/layouts/entry.html.haml +3 -2
  15. data/lib/retter/generator/skel/layouts/index.html.haml +4 -2
  16. data/lib/retter/generator.rb +0 -1
  17. data/lib/retter/{renderers.rb → markdown.rb} +22 -1
  18. data/lib/retter/page/article.rb +54 -0
  19. data/lib/retter/page/base.rb +97 -0
  20. data/lib/retter/page/entries.rb +17 -0
  21. data/lib/retter/page/entry.rb +46 -0
  22. data/lib/retter/page/feed.rb +63 -0
  23. data/lib/retter/page/index.rb +17 -0
  24. data/lib/retter/page/profile.rb +17 -0
  25. data/lib/retter/page/view_helper.rb +9 -1
  26. data/lib/retter/page.rb +22 -74
  27. data/lib/retter/preprint.rb +19 -10
  28. data/lib/retter/version.rb +1 -1
  29. data/lib/retter.rb +41 -29
  30. data/retter.gemspec +44 -53
  31. data/spec/command/callback_spec.rb +16 -6
  32. data/spec/command/clean_spec.rb +20 -0
  33. data/spec/command/commit_spec.rb +11 -12
  34. data/spec/command/edit_spec.rb +28 -38
  35. data/spec/command/list_spec.rb +4 -4
  36. data/spec/command/open_spec.rb +2 -2
  37. data/spec/command/preview_spec.rb +7 -12
  38. data/spec/command/rebind_spec.rb +143 -66
  39. data/spec/spec_helper.rb +10 -3
  40. data/spec/support/example_group_helper.rb +55 -15
  41. data/spec/support/matchers.rb +0 -1
  42. metadata +195 -78
  43. data/lib/retter/generator/updator.rb +0 -7
  44. data/lib/retter/pages/article.rb +0 -41
  45. data/lib/retter/pages/entries.rb +0 -15
  46. data/lib/retter/pages/entry.rb +0 -35
  47. data/lib/retter/pages/feed.rb +0 -51
  48. data/lib/retter/pages/index.rb +0 -15
  49. data/lib/retter/pages/profile.rb +0 -15
  50. data/lib/retter/pages.rb +0 -77
  51. data/spec/command/invoke_after_spec.rb +0 -29
  52. data/spec/fixtures/sample.md +0 -295
@@ -1,15 +0,0 @@
1
- # coding: utf-8
2
-
3
- module Retter
4
- class Pages::Profile
5
- include Page
6
-
7
- def pathname
8
- config.retter_home.join('profile.html')
9
- end
10
-
11
- def part_layout_pathname
12
- Pages.find_layout_path('profile')
13
- end
14
- end
15
- end
data/lib/retter/pages.rb DELETED
@@ -1,77 +0,0 @@
1
- # coding: utf-8
2
-
3
- module Retter
4
- class Pages # XXX 名前が気に食わない
5
- autoload :Index, 'retter/pages/index'
6
- autoload :Profile, 'retter/pages/profile'
7
- autoload :Entries, 'retter/pages/entries'
8
- autoload :Feed, 'retter/pages/feed'
9
- autoload :Entry, 'retter/pages/entry'
10
- autoload :Article, 'retter/pages/article'
11
-
12
- include Stationery
13
- extend Configurable
14
-
15
- configurable :layouts_dir, :entries_dir, :allow_binding
16
-
17
- class << self
18
- def find_layout_path(name)
19
- detected = Dir.glob(layouts_dir.join("#{name}.*.*")).first
20
-
21
- Pathname.new(detected)
22
- end
23
-
24
- def layout_file
25
- @layout_file ||= find_layout_path('retter')
26
- end
27
-
28
- def entry_file(date)
29
- entries_dir.join date.strftime('%Y%m%d.html')
30
- end
31
-
32
- def entry_dir(date)
33
- entries_dir.join date.strftime('%Y%m%d')
34
- end
35
- end
36
-
37
- def initialize
38
- load_singleton_pages
39
- end
40
-
41
- def bind!
42
- print_entries
43
-
44
- @singleton_pages.each(&:print)
45
- end
46
-
47
- def print_entries
48
- entries.each do |entry|
49
- entry_page = Entry.new(entry)
50
- entry_page.print
51
-
52
- entry.articles.each do |article|
53
- article_page = Article.new(article)
54
- article_page.print
55
- end
56
- end
57
- end
58
-
59
- private
60
-
61
- def load_singleton_pages
62
- @singleton_pages = available_singleton_page_names.map {|name|
63
- Pages.const_get(name.capitalize).new
64
- }
65
- end
66
-
67
- def available_singleton_page_names
68
- availables = [:index]
69
-
70
- unless allow_binding == :none
71
- availables += allow_binding || [:profile, :entries, :feed]
72
- end
73
-
74
- availables.map(&:downcase).uniq
75
- end
76
- end
77
- end
@@ -1,29 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'spec_helper'
4
-
5
- describe 'Retter::Command#invoke_after', clean: :all do
6
- context 'invoke with proc' do
7
- before do
8
- Retter.config.after(:edit) { commit }
9
- end
10
-
11
- specify 'callback should called' do
12
- command.should_receive(:commit)
13
-
14
- command.edit
15
- end
16
- end
17
-
18
- context 'invoke with symbol' do
19
- before do
20
- Retter.config.after(:edit, :commit)
21
- end
22
-
23
- specify 'callback should called' do
24
- command.should_receive(:invoke).with(:commit)
25
-
26
- command.edit
27
- end
28
- end
29
- end
@@ -1,295 +0,0 @@
1
- # RETTER (レッター) Flyweight diary workflow. [![Build Status](https://secure.travis-ci.org/hibariya/retter.png?branch=master)](http://travis-ci.org/hibariya/retter)
2
-
3
- 手軽さを追求した記事作成ツール。以下のような特徴があります。
4
-
5
- * CLIでの操作を前提としています
6
- * どこ(cwd)にいてもすぐに記事を編集できます(Markdown)
7
- * オフラインで簡単にプレビューできます
8
- * だいたいどんなサーバ上でも動作します(Heroku, GitHub Pages, Dropbox などで、静的HTMLまたはRackアプリとして)
9
- * RSSフィードを吐きます
10
- * トラックバック、**コメント**などの機能は外部のサービスを使用できます
11
- * コールバックを設定することでさらに手数を減らすことができます
12
-
13
- # Quick Start
14
-
15
- *ruby-1.9.2* or later is required.
16
-
17
- **Install:**
18
-
19
- ~~~~
20
- gem install retter
21
- ~~~~
22
-
23
- **Generate a new site:**
24
-
25
- ~~~~
26
- $ retter new my_sweet_diary
27
- ~~~~
28
-
29
- **Initial settings:**
30
-
31
- ~~~~
32
- $ export EDITOR=vim
33
- $ export RETTER_HOME=`pwd`/my_sweet_diary
34
- ~~~~
35
-
36
- **Writing today's article:**
37
-
38
- ~~~~
39
- $ retter
40
- ~~~~
41
-
42
- `retter` opens `$EDITOR`. Write an article with Markdown.
43
-
44
- **Preview:**
45
-
46
- ~~~~
47
- $ retter preview
48
- ~~~~
49
-
50
- `preview` opens the draft article by your default browser.
51
-
52
- **Bind:**
53
-
54
- ~~~~
55
- $ retter rebind
56
- ~~~~
57
-
58
- `bind` and `rebind` binds the draft article. And re-generates actual html web pages. All html pages will be overwritten.
59
-
60
- **Browse offline:**
61
-
62
- ~~~~
63
- $ retter open
64
- ~~~~
65
-
66
- `open` sub-command opens your (static) website by your default browser.
67
-
68
- **Show Articles list:**
69
-
70
- ~~~~
71
- $ retter list
72
- [e0] 2011-11-09
73
- my sweet article title
74
- ~~~~
75
-
76
- **Re-writing an article:**
77
-
78
- ~~~~
79
- $ retter edit e0
80
- ... abbr ...
81
- $ retter preview e0
82
- ~~~~
83
-
84
- **Deploy example:**
85
-
86
- ~~~~
87
- $ cd $RETTER_HOME
88
- $ git add .
89
- $ git commit -m 'Entry written'
90
- $ git push [your_git_remote] master
91
- ~~~~
92
-
93
- To publish, use the git command. Or, upload the file to your server.
94
-
95
- # Environment variables
96
-
97
- **retter requires `$EDITOR` variable.**
98
-
99
- Retterで記事を編集する際には任意のエディタが起動します。そのためには`$EDITOR`環境変数が設定されている必要があります。
100
- 大抵の場合は設定されていると思いますが、もし設定されていなければ`~/.bash_profile`や`~/.zshenv`などに追記する必要があります。
101
-
102
- ~~~~
103
- $ echo "export EDITOR=vim" >> ~/.bash_profile
104
- $ . ~/.bash_profile
105
- ~~~~
106
-
107
- ## $RETTER_HOME
108
-
109
- ファイルシステム上のどこに居ても`retter`コマンドを使って編集から公開まで行えるよう、 事前に`$RETTER_HOME`環境変数を設定することをおすすめします。
110
-
111
- You can use `retter` command anywhere, If you set `$RETTER_HOME` variable.
112
-
113
- ~~~~
114
- $ echo "export RETTER_HOME=/path/to/my_sweet_diary" >> ~/.bash_profile
115
- $ . ~/.bash_profile
116
- ~~~~
117
-
118
- 作業ディレクトリにRetterfileがある場合は、そのディレクトリが`$RETTER_HOME`に指定されているものとして動作します。
119
-
120
- # Using shortcuts
121
-
122
- いくつかのショートカットを使い、コミットメッセージを書くことを省略したりすることができます。
123
-
124
- ~~~~
125
- $ retter commit # Shortcut of `git add . ; git commit -m 'Retter commit'`
126
- $ retter home # Open a new shell at $RETTER_HOME
127
- (retter) git push [remote] [branch] # heroku, github pages, etc..
128
- ~~~~
129
-
130
- # Specify a date
131
-
132
- Date is specify-able in `edit` `preview` sub-command.
133
-
134
- ~~~~
135
- $ retter edit 20110101 # edit
136
- $ retter preview 20110101 # preview
137
- ~~~~
138
-
139
- Relative date is available too.
140
-
141
- ~~~~
142
- $ retter edit yesterday # 昨日
143
- $ retter edit today # 今日
144
- $ retter edit tommorow # 明日
145
-
146
- $ retter edit '3 days ago' # 3日前
147
- $ retter edit 3.days.ago # 3日前
148
- $ retter edit 3.days.since # 3日後
149
- $ retter edit 1.week.ago # 1週間前
150
- $ retter edit 3.weeks.ago # 3週間前
151
- $ retter edit 3.months.ago # 3カ月前
152
- $ retter edit 3.years.ago # 3年前
153
- ~~~~
154
-
155
- And file name.
156
-
157
- ~~~~
158
- $ retter edit today.md
159
- $ retter edit 20110101.md
160
- $ retter preview 20110101.md
161
- ~~~~
162
-
163
- # Callbacks
164
-
165
- コールバックはいくつかのサブコマンド(edit bind rebind commit)の実行直後に自動的に実行されます。
166
- コールバックを定義しておくことで、手数の多い割に代わり映えのしない作業を自動化することができます。
167
-
168
- Callback is enabled in `edit`, `bind`, `rebind` and `commit` sub-command.
169
-
170
- ### Syntax
171
-
172
- In Retterfile:
173
-
174
- ~~~~ruby
175
- after [command], [invoke command or proc]
176
- ~~~~
177
-
178
- ## Auto preview
179
-
180
- 記事を編集しエディタを終了したあとブラウザでプレビューしたい場合は、`edit`へのコールバックを設定できます。
181
-
182
- In Retterfile:
183
-
184
- ~~~~ruby
185
- after :edit do
186
- preview ARGV.pop if yes?("Preview now? [yes/no]")
187
- end
188
- ~~~~
189
-
190
- ## Auto deploying
191
-
192
- 以下のような内容を Retterfile に記述しておくことで、rebind または bind が実行されると即座に公開までの処理も実行されます。
193
-
194
- In Retterfile:
195
-
196
- ~~~~ruby
197
- after :rebind, :commit # git commit
198
-
199
- after :commit do # deploy
200
- system "cd #{config.retter_home}"
201
- system 'git push origin master'
202
- end
203
- ~~~~
204
-
205
- もし毎回デプロイするのが煩わしい場合は、`--silent`オプションを付けることでコールバックを回避できます。
206
-
207
- `--silent` option skip those callback.
208
-
209
- ## Run callback
210
-
211
- `callback` sub-command runs only callback proccess.
212
-
213
- ~~~~
214
- $ retter callback --after edit
215
- ~~~~
216
-
217
- ## コメントシステム(DISQUS)の導入 - Install DISQUS
218
-
219
- ### Prepare
220
-
221
- 1. Create DISQUS Account
222
- 2. Add new site for retter
223
-
224
- ### Install
225
-
226
- First, Add your `disqus_shortname` to Retterfile.
227
-
228
- in Retterfile
229
-
230
- ~~~~ruby
231
- disqus_shortname 'your_disqus_shortname'
232
- ~~~~
233
-
234
- Second, Edit templete and paste `render_disqus_comment_form`.
235
-
236
- in layouts/article.html.haml
237
-
238
- ~~~~haml
239
- -# abbrev
240
- #comments= render_disqus_comment_form
241
- -# abbrev
242
- ~~~~
243
-
244
- ## 組込みテーマ - Pre-installed themes
245
-
246
- スタイルシートを変更することでテーマを変更できます。HTMLのヘッダを変更するには `layouts/retter.html.haml` を編集します。
247
- スタイルシートの指定を変更し、`retter rebind`コマンドを実行するとすべてのページが更新されます。
248
-
249
- ### Default
250
-
251
- ~~~~haml
252
- %link{href: '/stylesheets/default.css', media: 'screen', rel: 'stylesheet', type: 'text/css'}
253
- ~~~~
254
-
255
- ![Default](http://hibariya.github.com/images/theme_samples/retter_default.jpg)
256
-
257
- ### Orange
258
-
259
- ~~~~haml
260
- %link{href: '/stylesheets/orange.css', media: 'screen', rel: 'stylesheet', type: 'text/css'}
261
- ~~~~
262
-
263
- ![Orange](http://hibariya.github.com/images/theme_samples/retter_orange.jpg)
264
-
265
- ## HTMLの修正 - HTML Layout
266
-
267
- HTMLのレイアウト自体を変更するには`layouts/`ディレクトリ以下のHAMLファイルを修正します。
268
- これらのファイルを変更したとしても、`retter rebind`コマンドを実行するまでは反映されません。
269
-
270
- ~~~~
271
- layouts
272
- |-- article.html.haml
273
- |-- entries.html.haml
274
- |-- entry.html.haml
275
- |-- index.html.haml
276
- |-- profile.html.haml
277
- `-- retter.html.haml
278
- ~~~~
279
-
280
- `retter.html.haml`はHTML宣言を含めた全体のHTMLが含まれています。
281
- `entry.html.haml`を変更することで日別のページのレイアウトを変更することができます。
282
- `article.html.haml`を変更することで個々の記事のレイアウトを変更することができます。
283
- その他のファイルは実際のURLと名前が対応しています。
284
-
285
- # LICENSE
286
-
287
- The MIT License
288
-
289
- Copyright (c) 2011 hibariya, uzura29
290
-
291
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
292
-
293
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
294
-
295
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.