cduruk-jekyll 0.5.2

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 (48) hide show
  1. data/History.txt +115 -0
  2. data/README.textile +649 -0
  3. data/Rakefile +91 -0
  4. data/VERSION.yml +4 -0
  5. data/bin/jekyll +156 -0
  6. data/lib/jekyll.rb +84 -0
  7. data/lib/jekyll/albino.rb +122 -0
  8. data/lib/jekyll/converters/csv.rb +26 -0
  9. data/lib/jekyll/converters/mephisto.rb +79 -0
  10. data/lib/jekyll/converters/mt.rb +59 -0
  11. data/lib/jekyll/converters/textpattern.rb +50 -0
  12. data/lib/jekyll/converters/typo.rb +49 -0
  13. data/lib/jekyll/converters/wordpress.rb +54 -0
  14. data/lib/jekyll/convertible.rb +117 -0
  15. data/lib/jekyll/core_ext.rb +29 -0
  16. data/lib/jekyll/filters.rb +47 -0
  17. data/lib/jekyll/haml_helpers.rb +15 -0
  18. data/lib/jekyll/layout.rb +37 -0
  19. data/lib/jekyll/page.rb +67 -0
  20. data/lib/jekyll/post.rb +305 -0
  21. data/lib/jekyll/site.rb +300 -0
  22. data/lib/jekyll/tags/highlight.rb +68 -0
  23. data/lib/jekyll/tags/include.rb +31 -0
  24. data/test/helper.rb +24 -0
  25. data/test/source/_includes/sig.markdown +3 -0
  26. data/test/source/_layouts/default.html +27 -0
  27. data/test/source/_layouts/simple.html +1 -0
  28. data/test/source/_posts/2008-02-02-not-published.textile +8 -0
  29. data/test/source/_posts/2008-02-02-published.textile +8 -0
  30. data/test/source/_posts/2008-10-18-foo-bar.textile +8 -0
  31. data/test/source/_posts/2008-11-21-complex.textile +8 -0
  32. data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
  33. data/test/source/_posts/2008-12-13-include.markdown +8 -0
  34. data/test/source/_posts/2009-01-27-array-categories.textile +10 -0
  35. data/test/source/_posts/2009-01-27-categories.textile +7 -0
  36. data/test/source/_posts/2009-01-27-category.textile +7 -0
  37. data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
  38. data/test/source/css/screen.css +76 -0
  39. data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
  40. data/test/source/index.html +22 -0
  41. data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
  42. data/test/suite.rb +9 -0
  43. data/test/test_filters.rb +41 -0
  44. data/test/test_generated_site.rb +38 -0
  45. data/test/test_post.rb +262 -0
  46. data/test/test_site.rb +57 -0
  47. data/test/test_tags.rb +51 -0
  48. metadata +165 -0
@@ -0,0 +1 @@
1
+ <<< {{ content }} >>>
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: default
3
+ title: Not published!
4
+ published: false
5
+ category: publish_test
6
+ ---
7
+
8
+ This should *not* be published!
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: default
3
+ title: Publish
4
+ category: publish_test
5
+ ---
6
+
7
+ This should be published.
8
+
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: default
3
+ title: Foo Bar
4
+ ---
5
+
6
+ h1. {{ page.title }}
7
+
8
+ Best *post* ever
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: default
3
+ title: Complex
4
+ ---
5
+
6
+ url: {{ page.url }}
7
+ date: {{ page.date }}
8
+ id: {{ page.id }}
@@ -0,0 +1,9 @@
1
+ ---
2
+ title: Post with Permalink
3
+ permalink: my_category/permalinked-post
4
+ ---
5
+
6
+ h1. {{ page.title }}
7
+
8
+
9
+ <p>Best <strong>post</strong> ever</p>
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: default
3
+ title: Include
4
+ ---
5
+
6
+ {% include sig.markdown %}
7
+
8
+ This _is_ cool
@@ -0,0 +1,10 @@
1
+ ---
2
+ layout: default
3
+ title: Array categories in YAML
4
+ categories:
5
+ - foo
6
+ - bar
7
+ - baz
8
+ ---
9
+
10
+ Best *post* ever
@@ -0,0 +1,7 @@
1
+ ---
2
+ layout: default
3
+ title: Categories in YAML
4
+ categories: foo bar baz
5
+ ---
6
+
7
+ Best *post* ever
@@ -0,0 +1,7 @@
1
+ ---
2
+ layout: default
3
+ title: Category in YAML
4
+ category: foo
5
+ ---
6
+
7
+ Best *post* ever
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: default
3
+ title: Categories
4
+ ---
5
+
6
+ Categories _should_ work
@@ -0,0 +1,76 @@
1
+ /*****************************************************************************/
2
+ /*
3
+ /* Common
4
+ /*
5
+ /*****************************************************************************/
6
+
7
+ /* Global Reset */
8
+
9
+ * {
10
+ margin: 0;
11
+ padding: 0;
12
+ }
13
+
14
+ html, body {
15
+ height: 100%;
16
+ }
17
+
18
+ body {
19
+ background-color: white;
20
+ font: 13.34px helvetica, arial, clean, sans-serif;
21
+ *font-size: small;
22
+ text-align: center;
23
+ }
24
+
25
+ h1, h2, h3, h4, h5, h6 {
26
+ font-size: 100%;
27
+ }
28
+
29
+ h1 {
30
+ margin-bottom: 1em;
31
+ }
32
+
33
+ p {
34
+ margin: 1em 0;
35
+ }
36
+
37
+ a {
38
+ color: #00a;
39
+ }
40
+
41
+ a:hover {
42
+ color: black;
43
+ }
44
+
45
+ a:visited {
46
+ color: #a0a;
47
+ }
48
+
49
+ table {
50
+ font-size: inherit;
51
+ font: 100%;
52
+ }
53
+
54
+ /*****************************************************************************/
55
+ /*
56
+ /* Site
57
+ /*
58
+ /*****************************************************************************/
59
+
60
+ .site {
61
+ font-size: 110%;
62
+ text-align: justify;
63
+ width: 40em;
64
+ margin: 3em auto 2em auto;
65
+ line-height: 1.5em;
66
+ }
67
+
68
+ .title {
69
+ color: #a00;
70
+ font-weight: bold;
71
+ margin-bottom: 2em;
72
+ }
73
+
74
+ .site .meta {
75
+ color: #aaa;
76
+ }
@@ -0,0 +1,8 @@
1
+ ---
2
+ layout: default
3
+ title: Topical Post
4
+ ---
5
+
6
+ h1. {{ page.title }}
7
+
8
+ This post has a topic.
@@ -0,0 +1,22 @@
1
+ ---
2
+ layout: default
3
+ title: Tom Preston-Werner
4
+ ---
5
+
6
+ h1. Welcome to my site
7
+
8
+ h2. Please read our {{ site.posts | size }} Posts
9
+
10
+ <ul>
11
+ {% for post in site.posts %}
12
+ <li>{{ post.date }} <a href="{{ post.url }}">{{ post.title }}</a></li>
13
+ {% endfor %}
14
+ </ul>
15
+
16
+ {% assign first_post = site.posts.first %}
17
+ <div id="first_post">
18
+ <h1>{{ first_post.title }}</h1>
19
+ <div>
20
+ {{ first_post.content }}
21
+ </div>
22
+ </div>
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: default
3
+ title: Categories
4
+ ---
5
+
6
+ Categories _should_ work. Even if ordered after index.
@@ -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,41 @@
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 "convert array to sentence string with no args" do
18
+ assert_equal "", @filter.array_to_sentence_string([])
19
+ end
20
+
21
+ should "convert array to sentence string with one arg" do
22
+ assert_equal "1", @filter.array_to_sentence_string([1])
23
+ assert_equal "chunky", @filter.array_to_sentence_string(["chunky"])
24
+ end
25
+
26
+ should "convert array to sentence string with two args" do
27
+ assert_equal "1 and 2", @filter.array_to_sentence_string([1, 2])
28
+ assert_equal "chunky and bacon", @filter.array_to_sentence_string(["chunky", "bacon"])
29
+ end
30
+
31
+ should "convert array to sentence string with multiple args" do
32
+ assert_equal "1, 2, 3, and 4", @filter.array_to_sentence_string([1, 2, 3, 4])
33
+ assert_equal "chunky, bacon, bits, and pieces", @filter.array_to_sentence_string(["chunky", "bacon", "bits", "pieces"])
34
+ end
35
+
36
+ should "escape xml with ampersands" do
37
+ assert_equal "AT&amp;T", @filter.xml_escape("AT&T")
38
+ assert_equal "&lt;code&gt;command &amp;lt;filename&amp;gt;&lt;/code&gt;", @filter.xml_escape("<code>command &lt;filename&gt;</code>")
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,38 @@
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 post.content" do
21
+ latest_post = Dir[source_dir('_posts', '*')].sort.last
22
+ post = Post.new(@site, source_dir, '', File.basename(latest_post))
23
+ post.transform
24
+ assert @index.include?(post.content)
25
+ end
26
+
27
+ should "hide unpublished posts" do
28
+ published = Dir[dest_dir('publish_test/2008/02/02/*.html')].map {|f| File.basename(f)}
29
+
30
+ assert_equal 1, published.size
31
+ assert_equal "published.html", published.first
32
+ end
33
+
34
+ should "not copy _posts directory" do
35
+ assert !File.exist?(dest_dir('_posts'))
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,262 @@
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
+
29
+ context "processing posts" do
30
+ setup do
31
+ @post = Post.allocate
32
+ @post.site = @site
33
+
34
+ @real_file = "2008-10-18-foo-bar.textile"
35
+ @fake_file = "2008-10-19-foo-bar.textile"
36
+ @source = source_dir('_posts')
37
+ end
38
+
39
+ should "keep date, title, and markup type" do
40
+ @post.process(@fake_file)
41
+
42
+ assert_equal Time.parse("2008-10-19"), @post.date
43
+ assert_equal "foo-bar", @post.slug
44
+ assert_equal ".textile", @post.ext
45
+ assert_equal "/2008/10/19", @post.dir
46
+ assert_equal "/2008/10/19/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/10/19/foo-bar.html", @post.url
53
+ end
54
+
55
+ should "respect permalink in yaml front matter" do
56
+ file = "2008-12-03-permalinked-post.textile"
57
+ @post.process(file)
58
+ @post.read_yaml(@source, file)
59
+
60
+ assert_equal "my_category/permalinked-post", @post.permalink
61
+ assert_equal "my_category", @post.dir
62
+ assert_equal "my_category/permalinked-post", @post.url
63
+ end
64
+
65
+ context "with site wide permalink" do
66
+ setup do
67
+ @post.categories = []
68
+ end
69
+
70
+ context "with unspecified (date) style" do
71
+ setup do
72
+ @post.process(@fake_file)
73
+ end
74
+
75
+ should "process the url correctly" do
76
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
77
+ assert_equal "/2008/10/19/foo-bar.html", @post.url
78
+ end
79
+ end
80
+
81
+ context "with unspecified (date) style and a category" do
82
+ setup do
83
+ @post.categories << "beer"
84
+ @post.process(@fake_file)
85
+ end
86
+
87
+ should "process the url correctly" do
88
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
89
+ assert_equal "/beer/2008/10/19/foo-bar.html", @post.url
90
+ end
91
+ end
92
+
93
+ context "with unspecified (date) style and categories" do
94
+ setup do
95
+ @post.categories << "food"
96
+ @post.categories << "beer"
97
+ @post.process(@fake_file)
98
+ end
99
+
100
+ should "process the url correctly" do
101
+ assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
102
+ assert_equal "/beer/food/2008/10/19/foo-bar.html", @post.url
103
+ end
104
+ end
105
+
106
+ context "with none style" do
107
+ setup do
108
+ @post.site.permalink_style = :none
109
+ @post.process(@fake_file)
110
+ end
111
+
112
+ should "process the url correctly" do
113
+ assert_equal "/:categories/:title.html", @post.template
114
+ assert_equal "/foo-bar.html", @post.url
115
+ end
116
+ end
117
+
118
+ context "with pretty style" do
119
+ setup do
120
+ @post.site.permalink_style = :pretty
121
+ @post.process(@fake_file)
122
+ end
123
+
124
+ should "process the url correctly" do
125
+ assert_equal "/:categories/:year/:month/:day/:title", @post.template
126
+ assert_equal "/2008/10/19/foo-bar", @post.url
127
+ end
128
+ end
129
+
130
+ context "with prefix style and no extension" do
131
+ setup do
132
+ @post.site.permalink_style = "/prefix/:title"
133
+ @post.process(@fake_file)
134
+ end
135
+
136
+ should "process the url correctly" do
137
+ assert_equal "/prefix/:title", @post.template
138
+ assert_equal "/prefix/foo-bar", @post.url
139
+ end
140
+ end
141
+ end
142
+
143
+ should "read yaml front-matter" do
144
+ @post.read_yaml(@source, @real_file)
145
+
146
+ assert_equal({"title" => "Foo Bar", "layout" => "default"}, @post.data)
147
+ assert_equal "\nh1. {{ page.title }}\n\nBest *post* ever", @post.content
148
+ end
149
+
150
+ should "transform textile" do
151
+ @post.process(@real_file)
152
+ @post.read_yaml(@source, @real_file)
153
+ @post.transform
154
+
155
+ assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", @post.content
156
+ end
157
+ end
158
+
159
+ context "when in a site" do
160
+ setup do
161
+ clear_dest
162
+ stub(Jekyll).configuration { Jekyll::DEFAULTS }
163
+ @site = Site.new(Jekyll.configuration)
164
+ @site.posts = [setup_post('2008-02-02-published.textile'),
165
+ setup_post('2009-01-27-categories.textile')]
166
+ end
167
+
168
+ should "have next post" do
169
+ assert_equal(@site.posts.last, @site.posts.first.next)
170
+ end
171
+
172
+ should "have previous post" do
173
+ assert_equal(@site.posts.first, @site.posts.last.previous)
174
+ end
175
+
176
+ should "not have previous post if first" do
177
+ assert_equal(nil, @site.posts.first.previous)
178
+ end
179
+
180
+ should "not have next post if last" do
181
+ assert_equal(nil, @site.posts.last.next)
182
+ end
183
+ end
184
+
185
+ context "initializing posts" do
186
+ should "publish when published yaml is no specified" do
187
+ post = setup_post("2008-02-02-published.textile")
188
+ assert_equal true, post.published
189
+ end
190
+
191
+ should "not published when published yaml is false" do
192
+ post = setup_post("2008-02-02-not-published.textile")
193
+ assert_equal false, post.published
194
+ end
195
+
196
+ should "recognize category in yaml" do
197
+ post = setup_post("2009-01-27-category.textile")
198
+ assert post.categories.include?('foo')
199
+ end
200
+
201
+ should "recognize several categories in yaml" do
202
+ post = setup_post("2009-01-27-categories.textile")
203
+ assert post.categories.include?('foo')
204
+ assert post.categories.include?('bar')
205
+ assert post.categories.include?('baz')
206
+ end
207
+
208
+ context "rendering" do
209
+ setup do
210
+ clear_dest
211
+ end
212
+
213
+ should "render properly" do
214
+ post = setup_post("2008-10-18-foo-bar.textile")
215
+ do_render(post)
216
+ assert_equal "<<< <h1>Foo Bar</h1>\n<p>Best <strong>post</strong> ever</p> >>>", post.output
217
+ end
218
+
219
+ should "write properly" do
220
+ post = setup_post("2008-10-18-foo-bar.textile")
221
+ do_render(post)
222
+ post.write(dest_dir)
223
+
224
+ assert File.directory?(dest_dir)
225
+ assert File.exists?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html'))
226
+ end
227
+
228
+ should "write properly without html extension" do
229
+ post = setup_post("2008-10-18-foo-bar.textile")
230
+ post.site.permalink_style = ":title"
231
+ do_render(post)
232
+ post.write(dest_dir)
233
+
234
+ assert File.directory?(dest_dir)
235
+ assert File.exists?(File.join(dest_dir, 'foo-bar', 'index.html'))
236
+ end
237
+
238
+ should "insert data" do
239
+ post = setup_post("2008-11-21-complex.textile")
240
+ do_render(post)
241
+
242
+ 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
243
+ end
244
+
245
+ should "include templates" do
246
+ post = setup_post("2008-12-13-include.markdown")
247
+ post.site.source = File.join(File.dirname(__FILE__), 'source')
248
+ do_render(post)
249
+
250
+ assert_equal "<<< <hr />\n<p>Tom Preston-Werner github.com/mojombo</p>\n\n<p>This <em>is</em> cool</p> >>>", post.output
251
+ end
252
+ end
253
+ end
254
+
255
+ should "generate categories and topics" do
256
+ post = Post.new(@site, File.join(File.dirname(__FILE__), *%w[source]), 'foo', 'bar/2008-12-12-topical-post.textile')
257
+ assert_equal ['foo'], post.categories
258
+ assert_equal ['bar'], post.topics
259
+ end
260
+
261
+ end
262
+ end