lonnon-jekyll 0.6.0

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 (75) hide show
  1. data/.gitignore +6 -0
  2. data/History.txt +151 -0
  3. data/README.textile +613 -0
  4. data/Rakefile +91 -0
  5. data/VERSION.yml +4 -0
  6. data/bin/jekyll +166 -0
  7. data/features/create_sites.feature +57 -0
  8. data/features/embed_filters.feature +74 -0
  9. data/features/pagination.feature +40 -0
  10. data/features/permalinks.feature +65 -0
  11. data/features/post_data.feature +153 -0
  12. data/features/site_configuration.feature +63 -0
  13. data/features/site_data.feature +82 -0
  14. data/features/step_definitions/jekyll_steps.rb +136 -0
  15. data/features/support/env.rb +16 -0
  16. data/lib/jekyll.rb +86 -0
  17. data/lib/jekyll/albino.rb +122 -0
  18. data/lib/jekyll/converters/csv.rb +26 -0
  19. data/lib/jekyll/converters/mephisto.rb +79 -0
  20. data/lib/jekyll/converters/mt.rb +59 -0
  21. data/lib/jekyll/converters/textpattern.rb +50 -0
  22. data/lib/jekyll/converters/typo.rb +49 -0
  23. data/lib/jekyll/converters/wordpress.rb +61 -0
  24. data/lib/jekyll/convertible.rb +139 -0
  25. data/lib/jekyll/core_ext.rb +37 -0
  26. data/lib/jekyll/filters.rb +56 -0
  27. data/lib/jekyll/haml_helpers.rb +15 -0
  28. data/lib/jekyll/layout.rb +37 -0
  29. data/lib/jekyll/page.rb +112 -0
  30. data/lib/jekyll/pager.rb +45 -0
  31. data/lib/jekyll/post.rb +316 -0
  32. data/lib/jekyll/site.rb +326 -0
  33. data/lib/jekyll/tags/highlight.rb +56 -0
  34. data/lib/jekyll/tags/include.rb +31 -0
  35. data/test/helper.rb +27 -0
  36. data/test/source/_includes/sig.markdown +3 -0
  37. data/test/source/_layouts/default.html +27 -0
  38. data/test/source/_layouts/simple.html +1 -0
  39. data/test/source/_posts/2008-02-02-not-published.textile +8 -0
  40. data/test/source/_posts/2008-02-02-published.textile +8 -0
  41. data/test/source/_posts/2008-10-18-foo-bar.textile +8 -0
  42. data/test/source/_posts/2008-11-21-complex.textile +8 -0
  43. data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
  44. data/test/source/_posts/2008-12-13-include.markdown +8 -0
  45. data/test/source/_posts/2009-01-27-array-categories.textile +10 -0
  46. data/test/source/_posts/2009-01-27-categories.textile +7 -0
  47. data/test/source/_posts/2009-01-27-category.textile +7 -0
  48. data/test/source/_posts/2009-03-12-hash-#1.markdown +6 -0
  49. data/test/source/_posts/2009-05-18-tag.textile +6 -0
  50. data/test/source/_posts/2009-05-18-tags.textile +9 -0
  51. data/test/source/_posts/2009-06-22-empty-yaml.textile +3 -0
  52. data/test/source/_posts/2009-06-22-no-yaml.textile +1 -0
  53. data/test/source/_posts/2009-11-27-more-divider.markdown +5 -0
  54. data/test/source/about.html +6 -0
  55. data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
  56. data/test/source/contacts.html +5 -0
  57. data/test/source/css/screen.css +76 -0
  58. data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
  59. data/test/source/index.html +22 -0
  60. data/test/source/paginated/_posts/2009-11-29-one-page.markdown +3 -0
  61. data/test/source/paginated/_posts/2009-11-29-red-page.markdown +4 -0
  62. data/test/source/paginated/_posts/2009-11-29-two-page.markdown +3 -0
  63. data/test/source/sitemap.xml +23 -0
  64. data/test/source/win/_posts/2009-05-24-yaml-linebreak.markdown +7 -0
  65. data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
  66. data/test/suite.rb +9 -0
  67. data/test/test_configuration.rb +29 -0
  68. data/test/test_filters.rb +54 -0
  69. data/test/test_generated_site.rb +40 -0
  70. data/test/test_page.rb +98 -0
  71. data/test/test_pager.rb +47 -0
  72. data/test/test_post.rb +317 -0
  73. data/test/test_site.rb +85 -0
  74. data/test/test_tags.rb +115 -0
  75. metadata +196 -0
@@ -0,0 +1,23 @@
1
+ ---
2
+ layout: nil
3
+ ---
4
+ <?xml version="1.0" encoding="UTF-8"?>
5
+ <urlset
6
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
7
+
8
+ <url>
9
+ <loc>http://example.com</loc>
10
+ <lastmod>{{ site.time | date_to_xmlschema }}</lastmod>
11
+ <changefreq>daily</changefreq>
12
+ <priority>1.0</priority>
13
+ </url>
14
+
15
+ {% for post in site.posts %}
16
+ <url>
17
+ <loc>http://example.com/{{ post.url }}/</loc>
18
+ <lastmod>{{ site.time }}</lastmod>
19
+ <changefreq>monthly</changefreq>
20
+ <priority>0.2</priority>
21
+ </url>
22
+ {% endfor %}
23
+ </urlset>
@@ -0,0 +1,7 @@
1
+ ---
2
+ layout: post
3
+ title: "Test title"
4
+ tag: "Ruby"
5
+ ---
6
+
7
+ This is the content
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: default
3
+ title: Categories
4
+ ---
5
+
6
+ Categories _should_ work. Even if ordered after index.
data/test/suite.rb ADDED
@@ -0,0 +1,9 @@
1
+ require 'test/unit'
2
+
3
+ # for some reason these tests fail when run via TextMate
4
+ # but succeed when run on the command line.
5
+
6
+ tests = Dir["#{File.dirname(__FILE__)}/test_*.rb"]
7
+ tests.each do |file|
8
+ require file
9
+ end
@@ -0,0 +1,29 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestConfiguration < Test::Unit::TestCase
4
+ context "loading configuration" do
5
+ setup do
6
+ @path = './_config.yml'
7
+ end
8
+
9
+ should "fire warning with no _config.yml" do
10
+ mock(YAML).load_file(@path) { raise "No such file or directory - #{@path}" }
11
+ mock(STDERR).puts("WARNING: Could not read configuration. Using defaults (and options).")
12
+ mock(STDERR).puts("\tNo such file or directory - #{@path}")
13
+ assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
14
+ end
15
+
16
+ should "load configuration as hash" do
17
+ mock(YAML).load_file(@path) { Hash.new }
18
+ mock(STDOUT).puts("Configuration from #{@path}")
19
+ assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
20
+ end
21
+
22
+ should "fire warning with bad config" do
23
+ mock(YAML).load_file(@path) { Array.new }
24
+ mock(STDERR).puts("WARNING: Could not read configuration. Using defaults (and options).")
25
+ mock(STDERR).puts("\tInvalid configuration - #{@path}")
26
+ assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,54 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestFilters < Test::Unit::TestCase
4
+ class JekyllFilter
5
+ include Jekyll::Filters
6
+ end
7
+
8
+ context "filters" do
9
+ setup do
10
+ @filter = JekyllFilter.new
11
+ end
12
+
13
+ should "textilize with simple string" do
14
+ assert_equal "<p>something <strong>really</strong> simple</p>", @filter.textilize("something *really* simple")
15
+ end
16
+
17
+ should "markdownize with simple string" do
18
+ assert_equal "<p>something <strong>really</strong> simple</p>\n",
19
+ @filter.markdownize("something **really** simple")
20
+ end
21
+
22
+ should "convert array to sentence string with no args" do
23
+ assert_equal "", @filter.array_to_sentence_string([])
24
+ end
25
+
26
+ should "convert array to sentence string with one arg" do
27
+ assert_equal "1", @filter.array_to_sentence_string([1])
28
+ assert_equal "chunky", @filter.array_to_sentence_string(["chunky"])
29
+ end
30
+
31
+ should "convert array to sentence string with two args" do
32
+ assert_equal "1 and 2", @filter.array_to_sentence_string([1, 2])
33
+ assert_equal "chunky and bacon", @filter.array_to_sentence_string(["chunky", "bacon"])
34
+ end
35
+
36
+ should "convert array to sentence string with multiple args" do
37
+ assert_equal "1, 2, 3, and 4", @filter.array_to_sentence_string([1, 2, 3, 4])
38
+ assert_equal "chunky, bacon, bits, and pieces", @filter.array_to_sentence_string(["chunky", "bacon", "bits", "pieces"])
39
+ end
40
+
41
+ should "escape xml with ampersands" do
42
+ assert_equal "AT&amp;T", @filter.xml_escape("AT&T")
43
+ assert_equal "&lt;code&gt;command &amp;lt;filename&amp;gt;&lt;/code&gt;", @filter.xml_escape("<code>command &lt;filename&gt;</code>")
44
+ end
45
+
46
+ should "escape space as plus" do
47
+ assert_equal "my+things", @filter.cgi_escape("my things")
48
+ end
49
+
50
+ should "escape special characters" do
51
+ assert_equal "hey%21", @filter.cgi_escape("hey!")
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,40 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestGeneratedSite < Test::Unit::TestCase
4
+ context "generated sites" do
5
+ setup do
6
+ clear_dest
7
+ stub(Jekyll).configuration do
8
+ Jekyll::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir})
9
+ end
10
+
11
+ @site = Site.new(Jekyll.configuration)
12
+ @site.process
13
+ @index = File.read(dest_dir('index.html'))
14
+ end
15
+
16
+ should "insert site.posts into the index" do
17
+ assert @index.include?("#{@site.posts.size} Posts")
18
+ end
19
+
20
+ should "render latest post's content" do
21
+ assert @index.include?(@site.posts.last.content)
22
+ end
23
+
24
+ should "hide unpublished posts" do
25
+ published = Dir[dest_dir('publish_test/2008/02/02/*.html')].map {|f| File.basename(f)}
26
+
27
+ assert_equal 1, published.size
28
+ assert_equal "published.html", published.first
29
+ end
30
+
31
+ should "not copy _posts directory" do
32
+ assert !File.exist?(dest_dir('_posts'))
33
+ end
34
+
35
+ should "process other static files and generate correct permalinks" do
36
+ assert File.exists?(dest_dir('/about/index.html'))
37
+ assert File.exists?(dest_dir('/contacts.html'))
38
+ end
39
+ end
40
+ end
data/test/test_page.rb ADDED
@@ -0,0 +1,98 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestPage < Test::Unit::TestCase
4
+ def setup_page(file)
5
+ @page = Page.new(@site, source_dir, '', file)
6
+ end
7
+
8
+ def do_render(page)
9
+ layouts = { "default" => Layout.new(@site, source_dir('_layouts'), "simple.html")}
10
+ page.render(layouts, {"site" => {"posts" => []}})
11
+ end
12
+
13
+ context "A Page" do
14
+ setup do
15
+ clear_dest
16
+ stub(Jekyll).configuration { Jekyll::DEFAULTS }
17
+ @site = Site.new(Jekyll.configuration)
18
+ end
19
+
20
+ context "processing pages" do
21
+ should "create url based on filename" do
22
+ @page = setup_page('contacts.html')
23
+ assert_equal "/contacts.html", @page.url
24
+ end
25
+
26
+ context "with pretty url style" do
27
+ setup do
28
+ @site.permalink_style = :pretty
29
+ end
30
+
31
+ should "return dir correctly" do
32
+ @page = setup_page('contacts.html')
33
+ assert_equal '/contacts/', @page.dir
34
+ end
35
+
36
+ should "return dir correctly for index page" do
37
+ @page = setup_page('index.html')
38
+ assert_equal '/', @page.dir
39
+ end
40
+ end
41
+
42
+ context "with any other url style" do
43
+ should "return dir correctly" do
44
+ @site.permalink_style = nil
45
+ @page = setup_page('contacts.html')
46
+ assert_equal '/', @page.dir
47
+ end
48
+ end
49
+
50
+ should "respect permalink in yaml front matter" do
51
+ file = "about.html"
52
+ @page = setup_page(file)
53
+
54
+ assert_equal "/about/", @page.permalink
55
+ assert_equal @page.permalink, @page.url
56
+ assert_equal "/about/", @page.dir
57
+ end
58
+ end
59
+
60
+ context "rendering" do
61
+ setup do
62
+ clear_dest
63
+ end
64
+
65
+ should "write properly" do
66
+ page = setup_page('contacts.html')
67
+ do_render(page)
68
+ page.write(dest_dir)
69
+
70
+ assert File.directory?(dest_dir)
71
+ assert File.exists?(File.join(dest_dir, 'contacts.html'))
72
+ end
73
+
74
+ should "write properly without html extension" do
75
+ page = setup_page('contacts.html')
76
+ page.site.permalink_style = :pretty
77
+ do_render(page)
78
+ page.write(dest_dir)
79
+
80
+ assert File.directory?(dest_dir)
81
+ assert File.exists?(File.join(dest_dir, 'contacts', 'index.html'))
82
+ end
83
+
84
+ should "write properly with extension different from html" do
85
+ page = setup_page("sitemap.xml")
86
+ page.site.permalink_style = :pretty
87
+ do_render(page)
88
+ page.write(dest_dir)
89
+
90
+ assert_equal("/sitemap.xml", page.url)
91
+ assert_nil(page.url[/\.html$/])
92
+ assert File.directory?(dest_dir)
93
+ assert File.exists?(File.join(dest_dir,'sitemap.xml'))
94
+ end
95
+ end
96
+
97
+ end
98
+ end
@@ -0,0 +1,47 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestPager < Test::Unit::TestCase
4
+ context "pagination enabled" do
5
+ setup do
6
+ stub(Jekyll).configuration do
7
+ Jekyll::DEFAULTS.merge({
8
+ 'source' => source_dir,
9
+ 'destination' => dest_dir,
10
+ 'paginate' => 2
11
+ })
12
+ end
13
+
14
+ @config = Jekyll.configuration
15
+ @site = Site.new(@config)
16
+ @site.read_posts('paginated')
17
+ end
18
+
19
+ should "calculate number of pages" do
20
+ assert_equal(2, Pager.calculate_pages(@site.posts, @config['paginate']))
21
+ end
22
+
23
+ should "create first pager" do
24
+ pager = Pager.new(@config, 1, @site.posts)
25
+ assert_equal(@config['paginate'].to_i, pager.posts.size)
26
+ assert_equal(2, pager.total_pages)
27
+ assert_nil(pager.previous_page)
28
+ assert_equal(2, pager.next_page)
29
+ end
30
+
31
+ should "create second pager" do
32
+ pager = Pager.new(@config, 2, @site.posts)
33
+ assert_equal(@site.posts.size - @config['paginate'].to_i, pager.posts.size)
34
+ assert_equal(2, pager.total_pages)
35
+ assert_equal(1, pager.previous_page)
36
+ assert_nil(pager.next_page)
37
+ end
38
+
39
+ should "not create third pager" do
40
+ assert_raise(RuntimeError) { Pager.new(@config, 3, @site.posts) }
41
+ end
42
+
43
+ should "report that pagination is enabled" do
44
+ assert Pager.pagination_enabled?(@config, 'index.html')
45
+ end
46
+ end
47
+ end
data/test/test_post.rb ADDED
@@ -0,0 +1,317 @@
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-10-19-foo-bar.textile")
22
+ assert Post.valid?("foo/bar/2008-10-19-foo-bar.textile")
23
+
24
+ assert !Post.valid?("lol2008-10-19-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-10-19-foo-bar.textile"
35
+ @source = source_dir('_posts')
36
+ end
37
+
38
+ should "keep date, title, and markup type" do
39
+ @post.process(@fake_file)
40
+
41
+ assert_equal Time.parse("2008-10-19"), @post.date
42
+ assert_equal "foo-bar", @post.slug
43
+ assert_equal ".textile", @post.ext
44
+ assert_equal "/2008/10/19", @post.dir
45
+ assert_equal "/2008/10/19/foo-bar", @post.id
46
+ end
47
+
48
+ should "create url based on date and title" do
49
+ @post.categories = []
50
+ @post.process(@fake_file)
51
+ assert_equal "/2008/10/19/foo-bar.html", @post.url
52
+ end
53
+
54
+ should "CGI escape urls" do
55
+ @post.categories = []
56
+ @post.process("2009-03-12-hash-#1.markdown")
57
+ assert_equal "/2009/03/12/hash-%231.html", @post.url
58
+ assert_equal "/2009/03/12/hash-#1", @post.id
59
+ end
60
+
61
+ should "respect permalink in yaml front matter" do
62
+ file = "2008-12-03-permalinked-post.textile"
63
+ @post.process(file)
64
+ @post.read_yaml(@source, file)
65
+
66
+ assert_equal "my_category/permalinked-post", @post.permalink
67
+ assert_equal "my_category", @post.dir
68
+ assert_equal "my_category/permalinked-post", @post.url
69
+ end
70
+
71
+ context "with CRLF linebreaks" do
72
+ setup do
73
+ @real_file = "2009-05-24-yaml-linebreak.markdown"
74
+ @source = source_dir('win/_posts')
75
+ end
76
+ should "read yaml front-matter" do
77
+ @post.read_yaml(@source, @real_file)
78
+
79
+ assert_equal({"title" => "Test title", "layout" => "post", "tag" => "Ruby"}, @post.data)
80
+ assert_equal "\r\nThis is the content", @post.content
81
+ end
82
+ end
83
+
84
+ context "with a more divider" do
85
+ setup do
86
+ @real_file = "2009-11-27-more-divider.markdown"
87
+ end
88
+ should "separate post into excerpt and remainder" do
89
+ @post.process(@real_file)
90
+ @post.read_yaml(@source, @real_file)
91
+ @post.transform
92
+
93
+ assert_equal "<p>Excerpt part</p>", @post.data['excerpt']
94
+ assert_equal "<p>Everything else</p>", @post.data['remainder']
95
+ assert_equal "<p>Excerpt part</p>\n<div id='more' />\n<p>Everything else</p>", @post.content
96
+ end
97
+ end
98
+
99
+ context "with site wide permalink" do
100
+ setup do
101
+ @post.categories = []
102
+ end
103
+
104
+ context "with unspecified (date) style" do
105
+ setup do
106
+ @post.process(@fake_file)
107
+ end
108
+
109
+ should "process the url correctly" do
110
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
111
+ assert_equal "/2008/10/19/foo-bar.html", @post.url
112
+ end
113
+ end
114
+
115
+ context "with unspecified (date) style and a category" do
116
+ setup do
117
+ @post.categories << "beer"
118
+ @post.process(@fake_file)
119
+ end
120
+
121
+ should "process the url correctly" do
122
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
123
+ assert_equal "/beer/2008/10/19/foo-bar.html", @post.url
124
+ end
125
+ end
126
+
127
+ context "with unspecified (date) style and categories" do
128
+ setup do
129
+ @post.categories << "food"
130
+ @post.categories << "beer"
131
+ @post.process(@fake_file)
132
+ end
133
+
134
+ should "process the url correctly" do
135
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
136
+ assert_equal "/beer/food/2008/10/19/foo-bar.html", @post.url
137
+ end
138
+ end
139
+
140
+ context "with none style" do
141
+ setup do
142
+ @post.site.permalink_style = :none
143
+ @post.process(@fake_file)
144
+ end
145
+
146
+ should "process the url correctly" do
147
+ assert_equal "/:categories/:title.html", @post.template
148
+ assert_equal "/foo-bar.html", @post.url
149
+ end
150
+ end
151
+
152
+ context "with pretty style" do
153
+ setup do
154
+ @post.site.permalink_style = :pretty
155
+ @post.process(@fake_file)
156
+ end
157
+
158
+ should "process the url correctly" do
159
+ assert_equal "/:categories/:year/:month/:day/:title/", @post.template
160
+ assert_equal "/2008/10/19/foo-bar/", @post.url
161
+ end
162
+ end
163
+
164
+ context "with prefix style and no extension" do
165
+ setup do
166
+ @post.site.permalink_style = "/prefix/:title"
167
+ @post.process(@fake_file)
168
+ end
169
+
170
+ should "process the url correctly" do
171
+ assert_equal "/prefix/:title", @post.template
172
+ assert_equal "/prefix/foo-bar", @post.url
173
+ end
174
+ end
175
+ end
176
+
177
+ should "read yaml front-matter" do
178
+ @post.read_yaml(@source, @real_file)
179
+
180
+ assert_equal({"title" => "Foo Bar", "layout" => "default"}, @post.data)
181
+ assert_equal "\nh1. {{ page.title }}\n\nBest *post* ever", @post.content
182
+ end
183
+
184
+ should "transform textile" do
185
+ @post.process(@real_file)
186
+ @post.read_yaml(@source, @real_file)
187
+ @post.transform
188
+
189
+ assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", @post.content
190
+ end
191
+ end
192
+
193
+ context "when in a site" do
194
+ setup do
195
+ clear_dest
196
+ stub(Jekyll).configuration { Jekyll::DEFAULTS }
197
+ @site = Site.new(Jekyll.configuration)
198
+ @site.posts = [setup_post('2008-02-02-published.textile'),
199
+ setup_post('2009-01-27-categories.textile')]
200
+ end
201
+
202
+ should "have next post" do
203
+ assert_equal(@site.posts.last, @site.posts.first.next)
204
+ end
205
+
206
+ should "have previous post" do
207
+ assert_equal(@site.posts.first, @site.posts.last.previous)
208
+ end
209
+
210
+ should "not have previous post if first" do
211
+ assert_equal(nil, @site.posts.first.previous)
212
+ end
213
+
214
+ should "not have next post if last" do
215
+ assert_equal(nil, @site.posts.last.next)
216
+ end
217
+ end
218
+
219
+ context "initializing posts" do
220
+ should "publish when published yaml is no specified" do
221
+ post = setup_post("2008-02-02-published.textile")
222
+ assert_equal true, post.published
223
+ end
224
+
225
+ should "not published when published yaml is false" do
226
+ post = setup_post("2008-02-02-not-published.textile")
227
+ assert_equal false, post.published
228
+ end
229
+
230
+ should "recognize category in yaml" do
231
+ post = setup_post("2009-01-27-category.textile")
232
+ assert post.categories.include?('foo')
233
+ end
234
+
235
+ should "recognize several categories in yaml" do
236
+ post = setup_post("2009-01-27-categories.textile")
237
+ assert post.categories.include?('foo')
238
+ assert post.categories.include?('bar')
239
+ assert post.categories.include?('baz')
240
+ end
241
+
242
+ should "recognize tag in yaml" do
243
+ post = setup_post("2009-05-18-tag.textile")
244
+ assert post.tags.include?('code')
245
+ end
246
+
247
+ should "recognize tags in yaml" do
248
+ post = setup_post("2009-05-18-tags.textile")
249
+ assert post.tags.include?('food')
250
+ assert post.tags.include?('cooking')
251
+ assert post.tags.include?('pizza')
252
+ end
253
+
254
+ should "allow no yaml" do
255
+ post = setup_post("2009-06-22-no-yaml.textile")
256
+ assert_equal "No YAML.", post.content
257
+ end
258
+
259
+ should "allow empty yaml" do
260
+ post = setup_post("2009-06-22-empty-yaml.textile")
261
+ assert_equal "Empty YAML.", post.content
262
+ end
263
+
264
+ context "rendering" do
265
+ setup do
266
+ clear_dest
267
+ end
268
+
269
+ should "render properly" do
270
+ post = setup_post("2008-10-18-foo-bar.textile")
271
+ do_render(post)
272
+ assert_equal "<<< <h1>Foo Bar</h1>\n<p>Best <strong>post</strong> ever</p> >>>", post.output
273
+ end
274
+
275
+ should "write properly" do
276
+ post = setup_post("2008-10-18-foo-bar.textile")
277
+ do_render(post)
278
+ post.write(dest_dir)
279
+
280
+ assert File.directory?(dest_dir)
281
+ assert File.exists?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html'))
282
+ end
283
+
284
+ should "write properly without html extension" do
285
+ post = setup_post("2008-10-18-foo-bar.textile")
286
+ post.site.permalink_style = ":title"
287
+ do_render(post)
288
+ post.write(dest_dir)
289
+
290
+ assert File.directory?(dest_dir)
291
+ assert File.exists?(File.join(dest_dir, 'foo-bar', 'index.html'))
292
+ end
293
+
294
+ should "insert data" do
295
+ post = setup_post("2008-11-21-complex.textile")
296
+ do_render(post)
297
+
298
+ 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
299
+ end
300
+
301
+ should "include templates" do
302
+ post = setup_post("2008-12-13-include.markdown")
303
+ post.site.source = File.join(File.dirname(__FILE__), 'source')
304
+ do_render(post)
305
+
306
+ assert_equal "<<< <hr />\n<p>Tom Preston-Werner github.com/mojombo</p>\n\n<p>This <em>is</em> cool</p> >>>", post.output
307
+ end
308
+ end
309
+ end
310
+
311
+ should "generate categories and topics" do
312
+ post = Post.new(@site, File.join(File.dirname(__FILE__), *%w[source]), 'foo', 'bar/2008-12-12-topical-post.textile')
313
+ assert_equal ['foo'], post.categories
314
+ end
315
+
316
+ end
317
+ end