matflores-jekyll 0.4.3 → 0.5.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.
- data/History.txt +3 -1
- data/README.textile +37 -0
- data/Rakefile +91 -0
- data/VERSION.yml +2 -2
- data/bin/jekyll +60 -56
- data/lib/jekyll.rb +48 -32
- data/lib/jekyll/albino.rb +1 -1
- data/lib/jekyll/converters/mephisto.rb +8 -8
- data/lib/jekyll/converters/mt.rb +8 -8
- data/lib/jekyll/converters/textpattern.rb +4 -4
- data/lib/jekyll/converters/typo.rb +8 -8
- data/lib/jekyll/converters/wordpress.rb +0 -1
- data/lib/jekyll/convertible.rb +33 -22
- data/lib/jekyll/core_ext.rb +5 -5
- data/lib/jekyll/filters.rb +6 -6
- data/lib/jekyll/layout.rb +9 -6
- data/lib/jekyll/page.rb +13 -10
- data/lib/jekyll/post.rb +37 -33
- data/lib/jekyll/site.rb +92 -27
- data/lib/jekyll/tags/highlight.rb +12 -9
- data/lib/jekyll/tags/include.rb +5 -5
- data/test/helper.rb +15 -5
- data/test/source/_posts/2008-02-02-not-published.textile +8 -0
- data/test/source/_posts/2008-02-02-published.textile +8 -0
- data/test/source/_posts/2009-01-27-array-categories.textile +10 -0
- data/test/source/_posts/2009-01-27-categories.textile +7 -0
- data/test/source/_posts/2009-01-27-category.textile +7 -0
- data/test/test_filters.rb +30 -30
- data/test/test_generated_site.rb +58 -55
- data/test/test_post.rb +128 -124
- data/test/test_site.rb +49 -37
- data/test/test_tags.rb +17 -13
- metadata +19 -25
- data/test/test_jekyll.rb +0 -0
data/test/helper.rb
CHANGED
@@ -2,13 +2,23 @@ require File.join(File.dirname(__FILE__), *%w[.. lib jekyll])
|
|
2
2
|
|
3
3
|
require 'test/unit'
|
4
4
|
require 'redgreen'
|
5
|
+
require 'shoulda'
|
6
|
+
require 'rr'
|
5
7
|
|
6
8
|
include Jekyll
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
class Test::Unit::TestCase
|
11
|
+
include RR::Adapters::TestUnit
|
12
|
+
|
13
|
+
def dest_dir(*subdirs)
|
14
|
+
File.join(File.dirname(__FILE__), 'dest', *subdirs)
|
15
|
+
end
|
16
|
+
|
17
|
+
def source_dir(*subdirs)
|
18
|
+
File.join(File.dirname(__FILE__), 'source', *subdirs)
|
19
|
+
end
|
11
20
|
|
12
|
-
def clear_dest
|
13
|
-
|
21
|
+
def clear_dest
|
22
|
+
FileUtils.rm_rf(dest_dir)
|
23
|
+
end
|
14
24
|
end
|
data/test/test_filters.rb
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/helper'
|
2
2
|
|
3
3
|
class TestFilters < Test::Unit::TestCase
|
4
|
-
|
5
4
|
class JekyllFilter
|
6
5
|
include Jekyll::Filters
|
7
6
|
end
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@filter = JekyllFilter.new
|
11
|
-
end
|
12
7
|
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
context "filters" do
|
9
|
+
setup do
|
10
|
+
@filter = JekyllFilter.new
|
11
|
+
end
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
|
13
|
+
should "textilize with simple string" do
|
14
|
+
assert_equal "<p>something <strong>really</strong> simple</p>", @filter.textilize("something *really* simple")
|
15
|
+
end
|
20
16
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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&T", @filter.xml_escape("AT&T")
|
38
|
+
assert_equal "<code>command &lt;filename&gt;</code>", @filter.xml_escape("<code>command <filename></code>")
|
39
|
+
end
|
39
40
|
end
|
40
|
-
|
41
41
|
end
|
data/test/test_generated_site.rb
CHANGED
@@ -1,60 +1,63 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/helper'
|
2
2
|
|
3
3
|
class TestGeneratedSite < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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', '*')].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('2008/02/02/*.html')].map {|f| File.basename(f)}
|
29
|
+
published.delete('index.html')
|
30
|
+
|
31
|
+
assert_equal 1, published.size
|
32
|
+
assert_equal "published.html", published.first
|
33
|
+
end
|
34
|
+
|
35
|
+
should "not copy _posts directory" do
|
36
|
+
assert !File.exist?(dest_dir('_posts'))
|
37
|
+
end
|
38
|
+
|
39
|
+
should "have an yearly archive" do
|
40
|
+
filename = File.join(dest_dir, '2008', 'index.html')
|
41
|
+
assert File.exists?(filename)
|
42
|
+
assert File.read(filename).include?("<h1>2008</h1>")
|
43
|
+
end
|
44
|
+
|
45
|
+
should "have a monthly archive" do
|
46
|
+
filename = File.join(dest_dir, '2008', '02', 'index.html')
|
47
|
+
assert File.exists?(filename)
|
48
|
+
assert File.read(filename).include?("<h1>February 2008</h1>")
|
49
|
+
end
|
50
|
+
|
51
|
+
should "have a daily archive" do
|
52
|
+
filename = File.join(dest_dir, '2008', '02', '02', 'index.html')
|
53
|
+
assert File.exists?(filename)
|
54
|
+
assert File.read(filename).include?("<h1>February 2, 2008</h1>")
|
55
|
+
end
|
56
|
+
|
57
|
+
should "have a category index" do
|
58
|
+
filename = File.join(dest_dir, 'category', 'foo', 'index.html')
|
59
|
+
assert File.exists?(filename)
|
60
|
+
assert File.read(filename).include?("<h1>Category: foo (#{@site.categories['foo'].size} posts)</h1>")
|
61
|
+
end
|
59
62
|
end
|
60
63
|
end
|
data/test/test_post.rb
CHANGED
@@ -1,141 +1,145 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/helper'
|
2
2
|
|
3
3
|
class TestPost < Test::Unit::TestCase
|
4
|
-
def
|
5
|
-
|
4
|
+
def setup_post(file)
|
5
|
+
Post.new(@site, source_dir, '', file)
|
6
6
|
end
|
7
|
-
|
8
|
-
def test_valid
|
9
|
-
assert Post.valid?("2008-10-19-foo-bar.textile")
|
10
|
-
assert Post.valid?("foo/bar/2008-10-19-foo-bar.textile")
|
11
|
-
|
12
|
-
assert !Post.valid?("lol2008-10-19-foo-bar.textile")
|
13
|
-
assert !Post.valid?("blah")
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_process
|
17
|
-
p = Post.allocate
|
18
|
-
p.process("2008-10-19-foo-bar.textile")
|
19
|
-
|
20
|
-
assert_equal Time.parse("2008-10-19"), p.date
|
21
|
-
assert_equal "foo-bar", p.slug
|
22
|
-
assert_equal ".textile", p.ext
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_url
|
26
|
-
p = Post.allocate
|
27
|
-
p.categories = []
|
28
|
-
p.process("2008-10-19-foo-bar.textile")
|
29
|
-
|
30
|
-
assert_equal "/2008/10/19/foo-bar.html", p.url
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_permalink
|
34
|
-
p = Post.allocate
|
35
|
-
p.process("2008-12-03-permalinked-post.textile")
|
36
|
-
p.read_yaml(File.join(File.dirname(__FILE__), *%w[source _posts]), "2008-12-03-permalinked-post.textile")
|
37
7
|
|
38
|
-
|
8
|
+
def do_render(post)
|
9
|
+
layouts = { "default" => Layout.new(@site, source_dir('_layouts'), "simple.html")}
|
10
|
+
post.render(layouts, {"site" => {"posts" => []}})
|
39
11
|
end
|
40
12
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
45
19
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
def test_url_respects_permalink
|
50
|
-
p = Post.allocate
|
51
|
-
p.process("2008-12-03-permalinked-post.textile")
|
52
|
-
p.read_yaml(File.join(File.dirname(__FILE__), *%w[source _posts]), "2008-12-03-permalinked-post.textile")
|
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")
|
53
23
|
|
54
|
-
|
55
|
-
|
24
|
+
assert !Post.valid?("lol2008-10-19-foo-bar.textile")
|
25
|
+
assert !Post.valid?("blah")
|
26
|
+
end
|
56
27
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
assert_equal({"title" => "Foo Bar", "layout" => "default"}, p.data)
|
62
|
-
assert_equal "\nh1. {{ page.title }}\n\nBest *post* ever", p.content
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_transform
|
66
|
-
p = Post.allocate
|
67
|
-
p.process("2008-10-18-foo-bar.textile")
|
68
|
-
p.read_yaml(File.join(File.dirname(__FILE__), *%w[source _posts]), "2008-10-18-foo-bar.textile")
|
69
|
-
p.transform
|
70
|
-
|
71
|
-
assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", p.content
|
72
|
-
end
|
28
|
+
context "processing posts" do
|
29
|
+
setup do
|
30
|
+
@post = Post.allocate
|
31
|
+
@post.site = @site
|
73
32
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
78
37
|
|
79
|
-
|
80
|
-
|
81
|
-
assert_equal false, p.published
|
82
|
-
end
|
38
|
+
should "keep date, title, and markup type" do
|
39
|
+
@post.process(@fake_file)
|
83
40
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
41
|
+
assert_equal Time.parse("2008-10-19"), @post.date
|
42
|
+
assert_equal "foo-bar", @post.slug
|
43
|
+
assert_equal ".textile", @post.ext
|
44
|
+
end
|
45
|
+
|
46
|
+
should "create url based on date and title" do
|
47
|
+
@post.categories = []
|
48
|
+
@post.process(@fake_file)
|
49
|
+
assert_equal "/2008/10/19/foo-bar.html", @post.url
|
50
|
+
end
|
51
|
+
|
52
|
+
should "respect permalink" do
|
53
|
+
file = "2008-12-03-permalinked-post.textile"
|
54
|
+
@post.process(file)
|
55
|
+
@post.read_yaml(@source, file)
|
56
|
+
|
57
|
+
assert_equal "my_category/permalinked-post", @post.permalink
|
58
|
+
assert_equal "my_category/", @post.dir
|
59
|
+
assert_equal "my_category/permalinked-post", @post.url
|
60
|
+
end
|
88
61
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
62
|
+
should "read yaml front-matter" do
|
63
|
+
@post.read_yaml(@source, @real_file)
|
64
|
+
|
65
|
+
assert_equal({"title" => "Foo Bar", "layout" => "default"}, @post.data)
|
66
|
+
assert_equal "\nh1. {{ page.title }}\n\nBest *post* ever", @post.content
|
67
|
+
end
|
68
|
+
|
69
|
+
should "transform textile" do
|
70
|
+
@post.process(@real_file)
|
71
|
+
@post.read_yaml(@source, @real_file)
|
72
|
+
@post.transform
|
73
|
+
|
74
|
+
assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", @post.content
|
75
|
+
end
|
99
76
|
end
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
77
|
+
|
78
|
+
context "initializing posts" do
|
79
|
+
should "publish when published yaml is no specified" do
|
80
|
+
post = setup_post("2008-02-02-published.textile")
|
81
|
+
assert_equal true, post.published
|
82
|
+
end
|
83
|
+
|
84
|
+
should "not published when published yaml is false" do
|
85
|
+
post = setup_post("2008-02-02-not-published.textile")
|
86
|
+
assert_equal false, post.published
|
87
|
+
end
|
88
|
+
|
89
|
+
should "recognize category in yaml" do
|
90
|
+
post = setup_post("2009-01-27-category.textile")
|
91
|
+
assert post.categories.include?('foo')
|
92
|
+
end
|
93
|
+
|
94
|
+
should "recognize several categories in yaml" do
|
95
|
+
post = setup_post("2009-01-27-categories.textile")
|
96
|
+
assert post.categories.include?('foo')
|
97
|
+
assert post.categories.include?('bar')
|
98
|
+
assert post.categories.include?('baz')
|
99
|
+
end
|
100
|
+
|
101
|
+
context "rendering" do
|
102
|
+
setup do
|
103
|
+
clear_dest
|
104
|
+
end
|
105
|
+
|
106
|
+
should "render properly" do
|
107
|
+
post = setup_post("2008-10-18-foo-bar.textile")
|
108
|
+
do_render(post)
|
109
|
+
assert_equal "<<< <h1>Foo Bar</h1>\n<p>Best <strong>post</strong> ever</p> >>>", post.output
|
110
|
+
end
|
111
|
+
|
112
|
+
should "write properly" do
|
113
|
+
post = setup_post("2008-10-18-foo-bar.textile")
|
114
|
+
do_render(post)
|
115
|
+
post.write(dest_dir)
|
116
|
+
|
117
|
+
assert File.directory?(dest_dir)
|
118
|
+
assert File.exists?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html'))
|
119
|
+
end
|
120
|
+
|
121
|
+
should "insert data" do
|
122
|
+
post = setup_post("2008-11-21-complex.textile")
|
123
|
+
do_render(post)
|
124
|
+
|
125
|
+
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
|
126
|
+
end
|
127
|
+
|
128
|
+
should "include templates" do
|
129
|
+
post = setup_post("2008-12-13-include.markdown")
|
130
|
+
post.site.source = File.join(File.dirname(__FILE__), 'source')
|
131
|
+
do_render(post)
|
132
|
+
|
133
|
+
assert_equal "<<< <hr />\n<p>Tom Preston-Werner github.com/mojombo</p>\n\n<p>This <em>is</em> cool</p> >>>", post.output
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
should "generate categories and topics" do
|
139
|
+
post = Post.new(@site, File.join(File.dirname(__FILE__), *%w[source]), 'foo', 'bar/2008-12-12-topical-post.textile')
|
140
|
+
assert_equal ['foo'], post.categories
|
141
|
+
assert_equal ['bar'], post.topics
|
142
|
+
end
|
143
|
+
|
140
144
|
end
|
141
145
|
end
|