realityforge-jekyll 0.7.1-java

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.
Files changed (91) hide show
  1. data/History.txt +255 -0
  2. data/LICENSE +21 -0
  3. data/README.textile +41 -0
  4. data/Rakefile +159 -0
  5. data/bin/jekyll +178 -0
  6. data/cucumber.yml +1 -0
  7. data/features/create_sites.feature +94 -0
  8. data/features/embed_filters.feature +60 -0
  9. data/features/markdown.feature +30 -0
  10. data/features/pagination.feature +27 -0
  11. data/features/permalinks.feature +65 -0
  12. data/features/post_data.feature +153 -0
  13. data/features/site_configuration.feature +103 -0
  14. data/features/site_data.feature +82 -0
  15. data/features/step_definitions/jekyll_steps.rb +145 -0
  16. data/features/support/env.rb +16 -0
  17. data/jekyll.gemspec +135 -0
  18. data/lib/jekyll.rb +109 -0
  19. data/lib/jekyll/albino.rb +120 -0
  20. data/lib/jekyll/converter.rb +50 -0
  21. data/lib/jekyll/converters/identity.rb +22 -0
  22. data/lib/jekyll/converters/markdown.rb +80 -0
  23. data/lib/jekyll/converters/textile.rb +33 -0
  24. data/lib/jekyll/convertible.rb +82 -0
  25. data/lib/jekyll/core_ext.rb +52 -0
  26. data/lib/jekyll/errors.rb +6 -0
  27. data/lib/jekyll/filters.rb +47 -0
  28. data/lib/jekyll/generator.rb +7 -0
  29. data/lib/jekyll/generators/pagination.rb +87 -0
  30. data/lib/jekyll/layout.rb +36 -0
  31. data/lib/jekyll/migrators/csv.rb +26 -0
  32. data/lib/jekyll/migrators/mephisto.rb +79 -0
  33. data/lib/jekyll/migrators/mt.rb +59 -0
  34. data/lib/jekyll/migrators/textpattern.rb +50 -0
  35. data/lib/jekyll/migrators/typo.rb +49 -0
  36. data/lib/jekyll/migrators/wordpress.rb +55 -0
  37. data/lib/jekyll/page.rb +133 -0
  38. data/lib/jekyll/plugin.rb +76 -0
  39. data/lib/jekyll/post.rb +242 -0
  40. data/lib/jekyll/site.rb +235 -0
  41. data/lib/jekyll/static_file.rb +76 -0
  42. data/lib/jekyll/tags/highlight.rb +73 -0
  43. data/lib/jekyll/tags/include.rb +31 -0
  44. data/test/helper.rb +33 -0
  45. data/test/source/_includes/sig.markdown +3 -0
  46. data/test/source/_layouts/default.html +27 -0
  47. data/test/source/_layouts/simple.html +1 -0
  48. data/test/source/_posts/2008-02-02-not-published.textile +8 -0
  49. data/test/source/_posts/2008-02-02-published.textile +8 -0
  50. data/test/source/_posts/2008-10-18-foo-bar.textile +8 -0
  51. data/test/source/_posts/2008-11-21-complex.textile +8 -0
  52. data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
  53. data/test/source/_posts/2008-12-13-include.markdown +8 -0
  54. data/test/source/_posts/2009-01-27-array-categories.textile +10 -0
  55. data/test/source/_posts/2009-01-27-categories.textile +7 -0
  56. data/test/source/_posts/2009-01-27-category.textile +7 -0
  57. data/test/source/_posts/2009-01-27-empty-categories.textile +7 -0
  58. data/test/source/_posts/2009-01-27-empty-category.textile +7 -0
  59. data/test/source/_posts/2009-03-12-hash-#1.markdown +6 -0
  60. data/test/source/_posts/2009-05-18-empty-tag.textile +6 -0
  61. data/test/source/_posts/2009-05-18-empty-tags.textile +6 -0
  62. data/test/source/_posts/2009-05-18-tag.textile +6 -0
  63. data/test/source/_posts/2009-05-18-tags.textile +9 -0
  64. data/test/source/_posts/2009-06-22-empty-yaml.textile +3 -0
  65. data/test/source/_posts/2009-06-22-no-yaml.textile +1 -0
  66. data/test/source/_posts/2010-01-08-triple-dash.markdown +5 -0
  67. data/test/source/_posts/2010-01-09-date-override.textile +7 -0
  68. data/test/source/_posts/2010-01-09-time-override.textile +7 -0
  69. data/test/source/_posts/2010-01-09-timezone-override.textile +7 -0
  70. data/test/source/_posts/2010-01-16-override-data.textile +4 -0
  71. data/test/source/about.html +6 -0
  72. data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
  73. data/test/source/contacts.html +5 -0
  74. data/test/source/css/screen.css +76 -0
  75. data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
  76. data/test/source/index.html +22 -0
  77. data/test/source/sitemap.xml +32 -0
  78. data/test/source/win/_posts/2009-05-24-yaml-linebreak.markdown +7 -0
  79. data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
  80. data/test/suite.rb +9 -0
  81. data/test/test_configuration.rb +29 -0
  82. data/test/test_core_ext.rb +66 -0
  83. data/test/test_filters.rb +49 -0
  84. data/test/test_generated_site.rb +44 -0
  85. data/test/test_page.rb +98 -0
  86. data/test/test_pager.rb +113 -0
  87. data/test/test_post.rb +396 -0
  88. data/test/test_rdiscount.rb +18 -0
  89. data/test/test_site.rb +153 -0
  90. data/test/test_tags.rb +116 -0
  91. metadata +282 -0
@@ -0,0 +1,113 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestPager < Test::Unit::TestCase
4
+
5
+ should "calculate number of pages" do
6
+ assert_equal(0, Pager.calculate_pages([], '2'))
7
+ assert_equal(1, Pager.calculate_pages([1], '2'))
8
+ assert_equal(1, Pager.calculate_pages([1,2], '2'))
9
+ assert_equal(2, Pager.calculate_pages([1,2,3], '2'))
10
+ assert_equal(2, Pager.calculate_pages([1,2,3,4], '2'))
11
+ assert_equal(3, Pager.calculate_pages([1,2,3,4,5], '2'))
12
+ end
13
+
14
+ context "pagination disabled" do
15
+ setup do
16
+ stub(Jekyll).configuration do
17
+ Jekyll::DEFAULTS.merge({
18
+ 'source' => source_dir,
19
+ 'destination' => dest_dir
20
+ })
21
+ end
22
+ @config = Jekyll.configuration
23
+ end
24
+
25
+ should "report that pagination is disabled" do
26
+ assert !Pager.pagination_enabled?(@config, 'index.html')
27
+ end
28
+
29
+ end
30
+
31
+ context "pagination enabled for 2" do
32
+ setup do
33
+ stub(Jekyll).configuration do
34
+ Jekyll::DEFAULTS.merge({
35
+ 'source' => source_dir,
36
+ 'destination' => dest_dir,
37
+ 'paginate' => 2
38
+ })
39
+ end
40
+
41
+ @config = Jekyll.configuration
42
+ @site = Site.new(@config)
43
+ @site.process
44
+ @posts = @site.posts
45
+ end
46
+
47
+ should "report that pagination is enabled" do
48
+ assert Pager.pagination_enabled?(@config, 'index.html')
49
+ end
50
+
51
+ context "with 4 posts" do
52
+ setup do
53
+ @posts = @site.posts[1..4] # limit to 4
54
+ end
55
+
56
+ should "create first pager" do
57
+ pager = Pager.new(@config, 1, @posts)
58
+ assert_equal(2, pager.posts.size)
59
+ assert_equal(2, pager.total_pages)
60
+ assert_nil(pager.previous_page)
61
+ assert_equal(2, pager.next_page)
62
+ end
63
+
64
+ should "create second pager" do
65
+ pager = Pager.new(@config, 2, @posts)
66
+ assert_equal(2, pager.posts.size)
67
+ assert_equal(2, pager.total_pages)
68
+ assert_equal(1, pager.previous_page)
69
+ assert_nil(pager.next_page)
70
+ end
71
+
72
+ should "not create third pager" do
73
+ assert_raise(RuntimeError) { Pager.new(@config, 3, @posts) }
74
+ end
75
+
76
+ end
77
+
78
+ context "with 5 posts" do
79
+ setup do
80
+ @posts = @site.posts[1..5] # limit to 5
81
+ end
82
+
83
+ should "create first pager" do
84
+ pager = Pager.new(@config, 1, @posts)
85
+ assert_equal(2, pager.posts.size)
86
+ assert_equal(3, pager.total_pages)
87
+ assert_nil(pager.previous_page)
88
+ assert_equal(2, pager.next_page)
89
+ end
90
+
91
+ should "create second pager" do
92
+ pager = Pager.new(@config, 2, @posts)
93
+ assert_equal(2, pager.posts.size)
94
+ assert_equal(3, pager.total_pages)
95
+ assert_equal(1, pager.previous_page)
96
+ assert_equal(3, pager.next_page)
97
+ end
98
+
99
+ should "create third pager" do
100
+ pager = Pager.new(@config, 3, @posts)
101
+ assert_equal(1, pager.posts.size)
102
+ assert_equal(3, pager.total_pages)
103
+ assert_equal(2, pager.previous_page)
104
+ assert_nil(pager.next_page)
105
+ end
106
+
107
+ should "not create fourth pager" do
108
+ assert_raise(RuntimeError) { Pager.new(@config, 4, @posts) }
109
+ end
110
+
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,396 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestPost < Test::Unit::TestCase
4
+ def setup_post(file)
5
+ Post.new(@site, source_dir, '', file)
6
+ end
7
+
8
+ def do_render(post)
9
+ layouts = { "default" => Layout.new(@site, source_dir('_layouts'), "simple.html")}
10
+ post.render(layouts, {"site" => {"posts" => []}})
11
+ end
12
+
13
+ context "A Post" do
14
+ setup do
15
+ clear_dest
16
+ stub(Jekyll).configuration { Jekyll::DEFAULTS }
17
+ @site = Site.new(Jekyll.configuration)
18
+ end
19
+
20
+ should "ensure valid posts are valid" do
21
+ assert Post.valid?("2008-09-09-foo-bar.textile")
22
+ assert Post.valid?("foo/bar/2008-09-09-foo-bar.textile")
23
+
24
+ assert !Post.valid?("lol2008-09-09-foo-bar.textile")
25
+ assert !Post.valid?("blah")
26
+ end
27
+
28
+ context "processing posts" do
29
+ setup do
30
+ @post = Post.allocate
31
+ @post.site = @site
32
+
33
+ @real_file = "2008-10-18-foo-bar.textile"
34
+ @fake_file = "2008-09-09-foo-bar.textile"
35
+ @source = source_dir('_posts')
36
+ end
37
+
38
+ should "keep date, title, and markup type" do
39
+ @post.categories = []
40
+ @post.process(@fake_file)
41
+
42
+ assert_equal Time.parse("2008-09-09"), @post.date
43
+ assert_equal "foo-bar", @post.slug
44
+ assert_equal ".textile", @post.ext
45
+ assert_equal "/2008/09/09", @post.dir
46
+ assert_equal "/2008/09/09/foo-bar", @post.id
47
+ end
48
+
49
+ should "create url based on date and title" do
50
+ @post.categories = []
51
+ @post.process(@fake_file)
52
+ assert_equal "/2008/09/09/foo-bar.html", @post.url
53
+ end
54
+
55
+ should "CGI escape urls" do
56
+ @post.categories = []
57
+ @post.process("2009-03-12-hash-#1.markdown")
58
+ assert_equal "/2009/03/12/hash-%231.html", @post.url
59
+ assert_equal "/2009/03/12/hash-#1", @post.id
60
+ end
61
+
62
+ should "respect permalink in yaml front matter" do
63
+ file = "2008-12-03-permalinked-post.textile"
64
+ @post.process(file)
65
+ @post.read_yaml(@source, file)
66
+
67
+ assert_equal "my_category/permalinked-post", @post.permalink
68
+ assert_equal "my_category", @post.dir
69
+ assert_equal "my_category/permalinked-post", @post.url
70
+ end
71
+
72
+ context "with CRLF linebreaks" do
73
+ setup do
74
+ @real_file = "2009-05-24-yaml-linebreak.markdown"
75
+ @source = source_dir('win/_posts')
76
+ end
77
+ should "read yaml front-matter" do
78
+ @post.read_yaml(@source, @real_file)
79
+
80
+ assert_equal({"title" => "Test title", "layout" => "post", "tag" => "Ruby"}, @post.data)
81
+ assert_equal "This is the content", @post.content
82
+ end
83
+ end
84
+
85
+ context "with embedded triple dash" do
86
+ setup do
87
+ @real_file = "2010-01-08-triple-dash.markdown"
88
+ end
89
+ should "consume the embedded dashes" do
90
+ @post.read_yaml(@source, @real_file)
91
+
92
+ assert_equal({"title" => "Foo --- Bar"}, @post.data)
93
+ assert_equal "Triple the fun!", @post.content
94
+ end
95
+ end
96
+
97
+ context "with site wide permalink" do
98
+ setup do
99
+ @post.categories = []
100
+ end
101
+
102
+ context "with unspecified (date) style" do
103
+ setup do
104
+ @post.process(@fake_file)
105
+ end
106
+
107
+ should "process the url correctly" do
108
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
109
+ assert_equal "/2008/09/09/foo-bar.html", @post.url
110
+ end
111
+ end
112
+
113
+ context "with unspecified (date) style and a category" do
114
+ setup do
115
+ @post.categories << "beer"
116
+ @post.process(@fake_file)
117
+ end
118
+
119
+ should "process the url correctly" do
120
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
121
+ assert_equal "/beer/2008/09/09/foo-bar.html", @post.url
122
+ end
123
+ end
124
+
125
+ context "with unspecified (date) style and categories" do
126
+ setup do
127
+ @post.categories << "food"
128
+ @post.categories << "beer"
129
+ @post.process(@fake_file)
130
+ end
131
+
132
+ should "process the url correctly" do
133
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
134
+ assert_equal "/food/beer/2008/09/09/foo-bar.html", @post.url
135
+ end
136
+ end
137
+
138
+ context "with none style" do
139
+ setup do
140
+ @post.site.permalink_style = :none
141
+ @post.process(@fake_file)
142
+ end
143
+
144
+ should "process the url correctly" do
145
+ assert_equal "/:categories/:title.html", @post.template
146
+ assert_equal "/foo-bar.html", @post.url
147
+ end
148
+ end
149
+
150
+ context "with pretty style" do
151
+ setup do
152
+ @post.site.permalink_style = :pretty
153
+ @post.process(@fake_file)
154
+ end
155
+
156
+ should "process the url correctly" do
157
+ assert_equal "/:categories/:year/:month/:day/:title/", @post.template
158
+ assert_equal "/2008/09/09/foo-bar/", @post.url
159
+ end
160
+ end
161
+
162
+ context "with custom date permalink" do
163
+ setup do
164
+ @post.site.permalink_style = '/:categories/:year/:i_month/:i_day/:title/'
165
+ @post.process(@fake_file)
166
+ end
167
+
168
+ should "process the url correctly" do
169
+ assert_equal "/2008/9/9/foo-bar/", @post.url
170
+ end
171
+ end
172
+
173
+ context "with prefix style and no extension" do
174
+ setup do
175
+ @post.site.permalink_style = "/prefix/:title"
176
+ @post.process(@fake_file)
177
+ end
178
+
179
+ should "process the url correctly" do
180
+ assert_equal "/prefix/:title", @post.template
181
+ assert_equal "/prefix/foo-bar", @post.url
182
+ end
183
+ end
184
+ end
185
+
186
+ should "read yaml front-matter" do
187
+ @post.read_yaml(@source, @real_file)
188
+
189
+ assert_equal({"title" => "Foo Bar", "layout" => "default"}, @post.data)
190
+ assert_equal "h1. {{ page.title }}\n\nBest *post* ever", @post.content
191
+ end
192
+
193
+ should "transform textile" do
194
+ @post.process(@real_file)
195
+ @post.read_yaml(@source, @real_file)
196
+ @post.transform
197
+
198
+ assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", @post.content
199
+ end
200
+ end
201
+
202
+ context "when in a site" do
203
+ setup do
204
+ clear_dest
205
+ stub(Jekyll).configuration { Jekyll::DEFAULTS }
206
+ @site = Site.new(Jekyll.configuration)
207
+ @site.posts = [setup_post('2008-02-02-published.textile'),
208
+ setup_post('2009-01-27-categories.textile')]
209
+ end
210
+
211
+ should "have next post" do
212
+ assert_equal(@site.posts.last, @site.posts.first.next)
213
+ end
214
+
215
+ should "have previous post" do
216
+ assert_equal(@site.posts.first, @site.posts.last.previous)
217
+ end
218
+
219
+ should "not have previous post if first" do
220
+ assert_equal(nil, @site.posts.first.previous)
221
+ end
222
+
223
+ should "not have next post if last" do
224
+ assert_equal(nil, @site.posts.last.next)
225
+ end
226
+ end
227
+
228
+ context "initializing posts" do
229
+ should "publish when published yaml is no specified" do
230
+ post = setup_post("2008-02-02-published.textile")
231
+ assert_equal true, post.published
232
+ end
233
+
234
+ should "not published when published yaml is false" do
235
+ post = setup_post("2008-02-02-not-published.textile")
236
+ assert_equal false, post.published
237
+ end
238
+
239
+ should "recognize date in yaml" do
240
+ post = setup_post("2010-01-09-date-override.textile")
241
+ do_render(post)
242
+ assert_equal Time, post.date.class
243
+ assert_equal Time, post.to_liquid["date"].class
244
+ assert_equal "/2010/01/10/date-override.html", post.url
245
+ assert_equal "<p>Post with a front matter date</p>\n<p>10 Jan 2010</p>", post.output
246
+ end
247
+
248
+ should "recognize time in yaml" do
249
+ post = setup_post("2010-01-09-time-override.textile")
250
+ do_render(post)
251
+ assert_equal Time, post.date.class
252
+ assert_equal Time, post.to_liquid["date"].class
253
+ assert_equal "/2010/01/10/time-override.html", post.url
254
+ assert_equal "<p>Post with a front matter time</p>\n<p>10 Jan 2010</p>", post.output
255
+ end
256
+
257
+ should "recognize time with timezone in yaml" do
258
+ post = setup_post("2010-01-09-timezone-override.textile")
259
+ do_render(post)
260
+ assert_equal Time, post.date.class
261
+ assert_equal Time, post.to_liquid["date"].class
262
+ assert_equal "/2010/01/10/timezone-override.html", post.url
263
+ assert_equal "<p>Post with a front matter time with timezone</p>\n<p>10 Jan 2010</p>", post.output
264
+ end
265
+
266
+ should "to_liquid prioritizes post attributes over data" do
267
+ post = setup_post("2010-01-16-override-data.textile")
268
+ assert_equal Array, post.tags.class
269
+ assert_equal Array, post.to_liquid["tags"].class
270
+ assert_equal Time, post.date.class
271
+ assert_equal Time, post.to_liquid["date"].class
272
+ end
273
+
274
+ should "recognize category in yaml" do
275
+ post = setup_post("2009-01-27-category.textile")
276
+ assert post.categories.include?('foo')
277
+ end
278
+
279
+ should "recognize several categories in yaml" do
280
+ post = setup_post("2009-01-27-categories.textile")
281
+ assert post.categories.include?('foo')
282
+ assert post.categories.include?('bar')
283
+ assert post.categories.include?('baz')
284
+ end
285
+
286
+ should "recognize empty category in yaml" do
287
+ post = setup_post("2009-01-27-empty-category.textile")
288
+ assert_equal [], post.categories
289
+ end
290
+
291
+ should "recognize empty categories in yaml" do
292
+ post = setup_post("2009-01-27-empty-categories.textile")
293
+ assert_equal [], post.categories
294
+ end
295
+
296
+ should "recognize tag in yaml" do
297
+ post = setup_post("2009-05-18-tag.textile")
298
+ assert post.tags.include?('code')
299
+ end
300
+
301
+ should "recognize tags in yaml" do
302
+ post = setup_post("2009-05-18-tags.textile")
303
+ assert post.tags.include?('food')
304
+ assert post.tags.include?('cooking')
305
+ assert post.tags.include?('pizza')
306
+ end
307
+
308
+ should "recognize empty tag in yaml" do
309
+ post = setup_post("2009-05-18-empty-tag.textile")
310
+ assert_equal [], post.tags
311
+ end
312
+
313
+ should "recognize empty tags in yaml" do
314
+ post = setup_post("2009-05-18-empty-tags.textile")
315
+ assert_equal [], post.tags
316
+ end
317
+
318
+ should "allow no yaml" do
319
+ post = setup_post("2009-06-22-no-yaml.textile")
320
+ assert_equal "No YAML.", post.content
321
+ end
322
+
323
+ should "allow empty yaml" do
324
+ post = setup_post("2009-06-22-empty-yaml.textile")
325
+ assert_equal "Empty YAML.", post.content
326
+ end
327
+
328
+ context "rendering" do
329
+ setup do
330
+ clear_dest
331
+ end
332
+
333
+ should "render properly" do
334
+ post = setup_post("2008-10-18-foo-bar.textile")
335
+ do_render(post)
336
+ assert_equal "<<< <h1>Foo Bar</h1>\n<p>Best <strong>post</strong> ever</p> >>>", post.output
337
+ end
338
+
339
+ should "write properly" do
340
+ post = setup_post("2008-10-18-foo-bar.textile")
341
+ do_render(post)
342
+ post.write(dest_dir)
343
+
344
+ assert File.directory?(dest_dir)
345
+ assert File.exists?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html'))
346
+ end
347
+
348
+ should "write properly without html extension" do
349
+ post = setup_post("2008-10-18-foo-bar.textile")
350
+ post.site.permalink_style = ":title"
351
+ do_render(post)
352
+ post.write(dest_dir)
353
+
354
+ assert File.directory?(dest_dir)
355
+ assert File.exists?(File.join(dest_dir, 'foo-bar', 'index.html'))
356
+ end
357
+
358
+ should "insert data" do
359
+ post = setup_post("2008-11-21-complex.textile")
360
+ do_render(post)
361
+
362
+ assert_equal "<<< <p>url: /2008/11/21/complex.html<br />\ndate: #{Time.parse("2008-11-21")}<br />\nid: /2008/11/21/complex</p> >>>", post.output
363
+ end
364
+
365
+ should "include templates" do
366
+ post = setup_post("2008-12-13-include.markdown")
367
+ post.site.source = File.join(File.dirname(__FILE__), 'source')
368
+ do_render(post)
369
+
370
+ assert_equal "<<< <hr />\n<p>Tom Preston-Werner github.com/mojombo</p>\n\n<p>This <em>is</em> cool</p> >>>", post.output
371
+ end
372
+
373
+ should "render date specified in front matter properly" do
374
+ post = setup_post("2010-01-09-date-override.textile")
375
+ do_render(post)
376
+
377
+ assert_equal "<p>Post with a front matter date</p>\n<p>10 Jan 2010</p>", post.output
378
+ end
379
+
380
+ should "render time specified in front matter properly" do
381
+ post = setup_post("2010-01-09-time-override.textile")
382
+ do_render(post)
383
+
384
+ assert_equal "<p>Post with a front matter time</p>\n<p>10 Jan 2010</p>", post.output
385
+ end
386
+
387
+ end
388
+ end
389
+
390
+ should "generate categories and topics" do
391
+ post = Post.new(@site, File.join(File.dirname(__FILE__), *%w[source]), 'foo', 'bar/2008-12-12-topical-post.textile')
392
+ assert_equal ['foo'], post.categories
393
+ end
394
+
395
+ end
396
+ end