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.
Files changed (141) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -11
  3. data/.travis.yml +4 -2
  4. data/ChangeLog.md +11 -5
  5. data/Gemfile +4 -1
  6. data/LICENSE.txt +22 -0
  7. data/README.md +163 -246
  8. data/Rakefile +25 -5
  9. data/bin/retter +2 -22
  10. data/lib/retter.rb +57 -43
  11. data/lib/retter/cli.rb +46 -0
  12. data/lib/retter/cli/edit.rb +33 -0
  13. data/lib/retter/cli/hooks.rb +46 -0
  14. data/lib/retter/cli/list.rb +15 -0
  15. data/lib/retter/cli/new.rb +20 -0
  16. data/lib/retter/cli/preview.rb +9 -0
  17. data/lib/retter/cli/publish.rb +22 -0
  18. data/lib/retter/deprecated.rb +160 -0
  19. data/lib/retter/entry.rb +31 -106
  20. data/lib/retter/entry/article.rb +36 -0
  21. data/lib/retter/entry/find_methods.rb +38 -0
  22. data/lib/retter/entry/model_base.rb +10 -0
  23. data/lib/retter/entry/pagination.rb +23 -0
  24. data/lib/retter/entry/sort_methods.rb +7 -0
  25. data/lib/retter/entry/utils.rb +12 -0
  26. data/lib/retter/initializing.rb +45 -0
  27. data/lib/retter/repository.rb +99 -12
  28. data/lib/retter/retterfile.rb +67 -0
  29. data/lib/retter/retterfile/context.rb +57 -0
  30. data/lib/retter/static_site.rb +34 -0
  31. data/lib/retter/static_site/app.rb +13 -0
  32. data/lib/retter/static_site/app/application.rb +94 -0
  33. data/lib/retter/{generator/skel/entries → static_site/app/assets/images}/.gitkeep +0 -0
  34. data/lib/retter/{generator/skel → static_site/app/assets}/images/orange/bg_body.jpg +0 -0
  35. data/lib/retter/{generator/skel → static_site/app/assets}/images/orange/bg_entry.jpg +0 -0
  36. data/lib/retter/{generator/skel → static_site/app/assets}/images/orange/bg_header.png +0 -0
  37. data/lib/retter/{generator/skel → static_site/app/assets}/images/orange/ic_li01.gif +0 -0
  38. data/lib/retter/{generator/skel/images → static_site/app/assets/javascripts}/.gitkeep +0 -0
  39. data/lib/retter/static_site/app/assets/stylesheets/application.css.scss +3 -0
  40. data/lib/retter/{generator/skel/stylesheets/base.css → static_site/app/assets/stylesheets/base.css.scss} +0 -0
  41. data/lib/retter/{generator/skel/stylesheets/pygments.css → static_site/app/assets/stylesheets/highlight.css.scss} +0 -0
  42. data/lib/retter/static_site/app/assets/stylesheets/orange.css.scss +262 -0
  43. data/lib/retter/static_site/app/assets/stylesheets/retter.css.scss +198 -0
  44. data/lib/retter/static_site/app/config.ru +7 -0
  45. data/lib/retter/static_site/app/controllers.rb +113 -0
  46. data/lib/retter/static_site/app/helpers.rb +36 -0
  47. data/lib/retter/{generator/skel/layouts/profile.html.haml → static_site/app/templates/about/show.html.haml} +0 -0
  48. data/lib/retter/static_site/app/templates/entries/articles/show.html.haml +7 -0
  49. data/lib/retter/static_site/app/templates/entries/index.html.haml +13 -0
  50. data/lib/retter/static_site/app/templates/entries/index.rss.haml +24 -0
  51. data/lib/retter/static_site/app/templates/entries/show.html.haml +11 -0
  52. data/lib/retter/static_site/app/templates/index/show.html.haml +14 -0
  53. data/lib/retter/static_site/app/templates/layouts/application.html.haml +34 -0
  54. data/lib/retter/static_site/builder.rb +106 -0
  55. data/lib/retter/static_site/cli.rb +25 -0
  56. data/lib/retter/static_site/cli/build.rb +85 -0
  57. data/lib/retter/static_site/cli/edit.rb +17 -0
  58. data/lib/retter/static_site/cli/migrate.rb +93 -0
  59. data/lib/retter/static_site/cli/new.rb +50 -0
  60. data/lib/retter/static_site/cli/preview.rb +66 -0
  61. data/lib/retter/static_site/markdown.rb +25 -0
  62. data/lib/retter/static_site/markdown/code_ray_renderer.rb +13 -0
  63. data/lib/retter/static_site/markdown/pygments_renderer.rb +18 -0
  64. data/lib/retter/static_site/markdown_entry.rb +111 -0
  65. data/lib/retter/static_site/monkey/sprockets_task.rb +10 -0
  66. data/lib/retter/version.rb +1 -1
  67. data/retter.gemspec +59 -43
  68. data/skel/.gitignore +2 -0
  69. data/skel/Retterfile +16 -0
  70. data/skel/config.ru +22 -0
  71. data/{lib/retter/generator/skel/javascripts → skel/retters}/.gitkeep +0 -0
  72. data/skel/retters/today.md +3 -0
  73. data/spec/cli/build_spec.rb +87 -0
  74. data/spec/cli/edit_spec.rb +76 -0
  75. data/spec/cli/invocation_spec.rb +19 -0
  76. data/spec/cli/list_spec.rb +64 -0
  77. data/spec/cli/migrate_spec.rb +65 -0
  78. data/spec/cli/new_spec.rb +30 -0
  79. data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/.gitignore +0 -0
  80. data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/Retterfile +6 -3
  81. data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/config.ru +0 -0
  82. data/{lib/retter/generator/skel/retters/.gitkeep → spec/fixtures/sites/site-0.2.5/entries.html} +0 -0
  83. data/spec/fixtures/sites/site-0.2.5/entries.rss +0 -0
  84. data/spec/fixtures/sites/site-0.2.5/entries/.gitkeep +0 -0
  85. data/spec/fixtures/sites/site-0.2.5/images/.gitkeep +0 -0
  86. data/spec/fixtures/sites/site-0.2.5/images/orange/bg_body.jpg +0 -0
  87. data/spec/fixtures/sites/site-0.2.5/images/orange/bg_entry.jpg +0 -0
  88. data/spec/fixtures/sites/site-0.2.5/images/orange/bg_header.png +0 -0
  89. data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/index.html +0 -0
  90. data/spec/fixtures/sites/site-0.2.5/javascripts/.gitkeep +0 -0
  91. data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/layouts/article.html.haml +0 -0
  92. data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/layouts/entries.html.haml +0 -0
  93. data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/layouts/entry.html.haml +0 -0
  94. data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/layouts/index.html.haml +0 -0
  95. data/spec/fixtures/sites/site-0.2.5/layouts/profile.html.haml +7 -0
  96. data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/layouts/retter.html.haml +0 -0
  97. data/spec/fixtures/sites/site-0.2.5/profile.html +0 -0
  98. data/spec/fixtures/sites/site-0.2.5/retters/.gitkeep +0 -0
  99. data/spec/fixtures/sites/site-0.2.5/stylesheets/base.css +22 -0
  100. data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/stylesheets/orange.css +0 -0
  101. data/spec/fixtures/sites/site-0.2.5/stylesheets/pygments.css +288 -0
  102. data/{lib/retter/generator/skel → spec/fixtures/sites/site-0.2.5}/stylesheets/retter.css +0 -0
  103. data/spec/retter/deprecated_spec.rb +106 -0
  104. data/spec/retter/initializing_spec.rb +86 -0
  105. data/spec/retter/retterfile_spec.rb +32 -0
  106. data/spec/spec_helper.rb +38 -27
  107. data/spec/support/example_helper.rb +46 -0
  108. data/spec/support/matchers.rb +14 -0
  109. data/spec/support/test_site.rb +59 -0
  110. metadata +329 -236
  111. data/lib/retter/binder.rb +0 -50
  112. data/lib/retter/command.rb +0 -192
  113. data/lib/retter/config.rb +0 -96
  114. data/lib/retter/configurable.rb +0 -26
  115. data/lib/retter/entries.rb +0 -115
  116. data/lib/retter/generator.rb +0 -7
  117. data/lib/retter/generator/base.rb +0 -65
  118. data/lib/retter/generator/creator.rb +0 -34
  119. data/lib/retter/generator/skel/Gemfile +0 -5
  120. data/lib/retter/markdown.rb +0 -31
  121. data/lib/retter/markdown/code_ray_renderer.rb +0 -11
  122. data/lib/retter/markdown/pygments_renderer.rb +0 -16
  123. data/lib/retter/page.rb +0 -43
  124. data/lib/retter/page/article.rb +0 -54
  125. data/lib/retter/page/base.rb +0 -97
  126. data/lib/retter/page/entries.rb +0 -17
  127. data/lib/retter/page/entry.rb +0 -46
  128. data/lib/retter/page/feed.rb +0 -63
  129. data/lib/retter/page/index.rb +0 -17
  130. data/lib/retter/page/profile.rb +0 -17
  131. data/lib/retter/page/view_helper.rb +0 -66
  132. data/lib/retter/preprint.rb +0 -34
  133. data/spec/command/callback_spec.rb +0 -27
  134. data/spec/command/clean_spec.rb +0 -20
  135. data/spec/command/commit_spec.rb +0 -40
  136. data/spec/command/edit_spec.rb +0 -119
  137. data/spec/command/list_spec.rb +0 -42
  138. data/spec/command/open_spec.rb +0 -12
  139. data/spec/command/preview_spec.rb +0 -40
  140. data/spec/command/rebind_spec.rb +0 -276
  141. data/spec/support/example_group_helper.rb +0 -98
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'invocation' do
4
+ context 'RETTER_ROOT is not set' do
5
+ specify do
6
+ Dir.chdir Retter::TestSite.tmpdir do
7
+ invoke_retter('version', retter_root: nil).should be_exit_successfully
8
+ end
9
+ end
10
+ end
11
+
12
+ context 'RETTER_ROOT is empty' do
13
+ specify do
14
+ Dir.chdir Retter::TestSite.tmpdir do
15
+ invoke_retter('version', retter_root: '').should be_exit_successfully
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'retter list' do
4
+ context 'default site', :with_default_site do
5
+ before do
6
+ File.write 'source/retters/20140101.md', <<-DIARY.strip_heredoc
7
+ # First
8
+
9
+ Hi, Alice.
10
+
11
+ # Second
12
+
13
+ Hi, Bob.
14
+ DIARY
15
+
16
+ File.write 'source/retters/20140103.md', <<-DIARY.strip_heredoc
17
+ # Third
18
+
19
+ Hi, Charlie
20
+ DIARY
21
+
22
+ File.write 'source/retters/today.md', <<-DIARY.strip_heredoc
23
+ # Today
24
+
25
+ Hi, Present.
26
+ DIARY
27
+ end
28
+
29
+ subject { invoke_retter('list') }
30
+
31
+ its(:stdout) { should == <<-LISTING.strip_heredoc }
32
+ [e0] 2014-01-01
33
+ First
34
+ Second
35
+ [e1] 2014-01-03
36
+ Third
37
+ [e2] #{Date.today.strftime('%Y-%m-%d')}
38
+ Today
39
+ LISTING
40
+ end
41
+
42
+ context 'multi branch', :with_multi_branch_site do
43
+ before do
44
+ Retter::Repository.new '.' do |repo|
45
+ repo.checkout 'source' do
46
+ File.write 'source/retters/20140101.md', <<-DIARY.strip_heredoc
47
+ # First
48
+
49
+ Hi, Alice.
50
+ DIARY
51
+ end
52
+
53
+ invoke_retter('build').should be_exit_successfully
54
+ end
55
+ end
56
+
57
+ subject { invoke_retter('list') }
58
+
59
+ its(:stdout) { should == <<-LISTING.strip_heredoc }
60
+ [e0] 2014-01-01
61
+ First
62
+ LISTING
63
+ end
64
+ end
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'retter migrate' do
4
+ before :all do
5
+ site_dir = Retter::TestSite.sites_dir
6
+
7
+ FileUtils.mkdir_p site_dir
8
+
9
+ Dir.chdir site_dir do
10
+ FileUtils.cp_r RETTER_GEM_DIR.join('spec/fixtures/sites/site-0.2.5'), site_dir.join('old-site')
11
+
12
+ Dir.chdir 'old-site' do
13
+ result = invoke_retter('migrate')
14
+
15
+ raise result.inspect unless result.status.success?
16
+ end
17
+ end
18
+ end
19
+
20
+ around :each do |example|
21
+ Dir.chdir Retter::TestSite.sites_dir.join('old-site') do
22
+ example.run
23
+ end
24
+ end
25
+
26
+ describe 'migrated files' do
27
+ specify 'source files are migrated' do
28
+ Pathname('layouts').should_not be_directory
29
+ Pathname('retters').should_not be_directory
30
+
31
+ Pathname('source/retters').should be_directory
32
+ Pathname('source/assets').should be_directory
33
+ Pathname('source/templates').should be_directory
34
+ end
35
+
36
+ specify 'symlinks for old html are created' do
37
+ Pathname('about.html').should be_symlink
38
+ end
39
+ end
40
+
41
+ describe 're-generate html' do
42
+ let(:html_files) { %w(index.html entries.html entries.rss) }
43
+
44
+ before do
45
+ Retter::Repository.new '.' do |repo|
46
+ repo.init
47
+ repo.add '-A'
48
+ repo.add '-u'
49
+ repo.commit '-m', 'Migrated'
50
+ end
51
+
52
+ FileUtils.rm html_files
53
+ end
54
+
55
+ specify 'edit, list and build commands should be success' do
56
+ invoke_retter('edit').should be_exit_successfully
57
+ invoke_retter('list').should be_exit_successfully
58
+ invoke_retter('build').should be_exit_successfully
59
+
60
+ html_files.each do |file|
61
+ Pathname(file).should written
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'retter new' do
4
+ before :all do
5
+ site_dir = Retter::TestSite.sites_dir
6
+
7
+ FileUtils.mkdir_p site_dir
8
+
9
+ Dir.chdir site_dir do |dir|
10
+ result = invoke_retter('new', site_dir.join('new-site'), retter_root: '')
11
+
12
+ raise result.inspect unless result.status.success?
13
+ end
14
+ end
15
+
16
+ around :each do |example|
17
+ Dir.chdir Retter::TestSite.sites_dir.join('new-site') do
18
+ example.run
19
+ end
20
+ end
21
+
22
+ specify 'files are installed' do
23
+ Pathname('Retterfile').should be_exist
24
+ Pathname('source').should be_exist
25
+ end
26
+
27
+ specify 'current branch is master' do
28
+ capture_command('git', 'branch').should match(/\*\smaster/)
29
+ end
30
+ end
@@ -2,11 +2,14 @@
2
2
  # coding: utf-8
3
3
 
4
4
  url 'http://retter.example.com/'
5
- title '<%= name %>'
6
- description '<%= name %>'
7
- author '<%= ENV["USER"] %>'
5
+ title 'site-0.2.5'
6
+ description 'site-0.2.5'
7
+ author 'hibariya'
8
8
  renderer Retter::Markdown::PygmentsRenderer
9
9
 
10
+ after :edit do
11
+ # do nothing: just testing `after' method.
12
+ end
10
13
  # Callbacks for retter sub-command: edit, rebind, commit
11
14
  #
12
15
  # Syntax:
File without changes
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ %article
2
+ %h1 Profile
3
+ %dl
4
+ %dt Author
5
+ %dd= config.author
6
+ %dt= config.title
7
+ %dd= config.description
File without changes
File without changes
@@ -0,0 +1,22 @@
1
+ dl dd {
2
+ margin-bottom: 1em;
3
+ }
4
+
5
+ pre {
6
+ overflow: hidden;
7
+ line-height: 1.3em;
8
+ }
9
+
10
+ code {
11
+ padding: 0 5px;
12
+ }
13
+
14
+ .clearfix {
15
+ width: 100%;
16
+ }
17
+
18
+ .clearfix:after {
19
+ content: "";
20
+ display: block;
21
+ clear: both;
22
+ }
@@ -0,0 +1,288 @@
1
+ .highlight {
2
+ background: #fff;
3
+ }
4
+
5
+ .highlight .c {
6
+ color: #998;
7
+ font-style: italic;
8
+ }
9
+
10
+ .highlight .err {
11
+ color: #a61717;
12
+ background-color: #e3d2d2;
13
+ }
14
+
15
+ .highlight .k {
16
+ font-weight: bold;
17
+ }
18
+
19
+ .highlight .o {
20
+ font-weight: bold;
21
+ }
22
+
23
+ .highlight .cm {
24
+ color: #998;
25
+ font-style: italic;
26
+ }
27
+
28
+ .highlight .cp {
29
+ color: #999;
30
+ font-weight: bold;
31
+ }
32
+
33
+ .highlight .c1 {
34
+ color: #998;
35
+ font-style: italic;
36
+ }
37
+
38
+ .highlight .cs {
39
+ color: #999;
40
+ font-weight: bold;
41
+ font-style: italic;
42
+ }
43
+
44
+ .highlight .gd {
45
+ color: #000;
46
+ background-color: #fdd;
47
+ }
48
+
49
+ .highlight .gd .x {
50
+ color: #000;
51
+ background-color: #faa;
52
+ }
53
+
54
+ .highlight .ge {
55
+ font-style: italic;
56
+ }
57
+
58
+ .highlight .gr {
59
+ color: #a00;
60
+ }
61
+
62
+ .highlight .gh {
63
+ color: #999;
64
+ }
65
+
66
+ .highlight .gi {
67
+ color: #000;
68
+ background-color: #dfd;
69
+ }
70
+
71
+ .highlight .gi .x {
72
+ color: #000;
73
+ background-color: #afa;
74
+ }
75
+
76
+ .highlight .go {
77
+ color: #888;
78
+ }
79
+
80
+ .highlight .gp {
81
+ color: #555;
82
+ }
83
+
84
+ .highlight .gs {
85
+ font-weight: bold;
86
+ }
87
+
88
+ .highlight .gu {
89
+ color: #800080;
90
+ font-weight: bold;
91
+ }
92
+
93
+ .highlight .gt {
94
+ color: #a00;
95
+ }
96
+
97
+ .highlight .kc {
98
+ font-weight: bold;
99
+ }
100
+
101
+ .highlight .kd {
102
+ font-weight: bold;
103
+ }
104
+
105
+ .highlight .kn {
106
+ font-weight: bold;
107
+ }
108
+
109
+ .highlight .kp {
110
+ font-weight: bold;
111
+ }
112
+
113
+ .highlight .kr {
114
+ font-weight: bold;
115
+ }
116
+
117
+ .highlight .kt {
118
+ color: #458;
119
+ font-weight: bold;
120
+ }
121
+
122
+ .highlight .m {
123
+ color: #099;
124
+ }
125
+
126
+ .highlight .s {
127
+ color: #d14;
128
+ }
129
+
130
+ .highlight .na {
131
+ color: #008080;
132
+ }
133
+
134
+ .highlight .nb {
135
+ color: #0086B3;
136
+ }
137
+
138
+ .highlight .nc {
139
+ color: #458;
140
+ font-weight: bold;
141
+ }
142
+
143
+ .highlight .no {
144
+ color: #008080;
145
+ }
146
+
147
+ .highlight .ni {
148
+ color: #800080;
149
+ }
150
+
151
+ .highlight .ne {
152
+ color: #900;
153
+ font-weight: bold;
154
+ }
155
+
156
+ .highlight .nf {
157
+ color: #900;
158
+ font-weight: bold;
159
+ }
160
+
161
+ .highlight .nn {
162
+ color: #555;
163
+ }
164
+
165
+ .highlight .nt {
166
+ color: #000080;
167
+ }
168
+
169
+ .highlight .nv {
170
+ color: #008080;
171
+ }
172
+
173
+ .highlight .ow {
174
+ font-weight: bold;
175
+ }
176
+
177
+ .highlight .w {
178
+ color: #bbb;
179
+ }
180
+
181
+ .highlight .mf {
182
+ color: #099;
183
+ }
184
+
185
+ .highlight .mh {
186
+ color: #099;
187
+ }
188
+
189
+ .highlight .mi {
190
+ color: #099;
191
+ }
192
+
193
+ .highlight .mo {
194
+ color: #099;
195
+ }
196
+
197
+ .highlight .sb {
198
+ color: #d14;
199
+ }
200
+
201
+ .highlight .sc {
202
+ color: #d14;
203
+ }
204
+
205
+ .highlight .sd {
206
+ color: #d14;
207
+ }
208
+
209
+ .highlight .s2 {
210
+ color: #d14;
211
+ }
212
+
213
+ .highlight .se {
214
+ color: #d14;
215
+ }
216
+
217
+ .highlight .sh {
218
+ color: #d14;
219
+ }
220
+
221
+ .highlight .si {
222
+ color: #d14;
223
+ }
224
+
225
+ .highlight .sx {
226
+ color: #d14;
227
+ }
228
+
229
+ .highlight .sr {
230
+ color: #009926;
231
+ }
232
+
233
+ .highlight .s1 {
234
+ color: #d14;
235
+ }
236
+
237
+ .highlight .ss {
238
+ color: #990073;
239
+ }
240
+
241
+ .highlight .bp {
242
+ color: #999;
243
+ }
244
+
245
+ .highlight .vc {
246
+ color: #008080;
247
+ }
248
+
249
+ .highlight .vg {
250
+ color: #008080;
251
+ }
252
+
253
+ .highlight .vi {
254
+ color: #008080;
255
+ }
256
+
257
+ .highlight .il {
258
+ color: #099;
259
+ }
260
+
261
+ .type-csharp .highlight .k {
262
+ color: #00F;
263
+ }
264
+
265
+ .type-csharp .highlight .kt {
266
+ color: #00F;
267
+ }
268
+
269
+ .type-csharp .highlight .nf {
270
+ color: #000;
271
+ font-weight: normal;
272
+ }
273
+
274
+ .type-csharp .highlight .nc {
275
+ color: #2B91AF;
276
+ }
277
+
278
+ .type-csharp .highlight .nn {
279
+ color: #000;
280
+ }
281
+
282
+ .type-csharp .highlight .s {
283
+ color: #A31515;
284
+ }
285
+
286
+ .type-csharp .highlight .sc {
287
+ color: #A31515;
288
+ }