jekyll 2.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jekyll might be problematic. Click here for more details.

Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +2 -2
  3. data/CONTRIBUTING.markdown +2 -2
  4. data/History.markdown +86 -0
  5. data/README.markdown +5 -30
  6. data/Rakefile +4 -9
  7. data/docs/jp/CONTRIBUTING.jp.markdown +2 -2
  8. data/docs/jp/README.jp.markdown +1 -2
  9. data/features/collections.feature +40 -3
  10. data/features/data.feature +41 -1
  11. data/features/frontmatter_defaults.feature +57 -0
  12. data/features/post_data.feature +12 -0
  13. data/features/rendering.feature +34 -0
  14. data/features/step_definitions/jekyll_steps.rb +5 -1
  15. data/features/support/env.rb +0 -3
  16. data/jekyll.gemspec +6 -5
  17. data/lib/jekyll.rb +18 -1
  18. data/lib/jekyll/cleaner.rb +22 -2
  19. data/lib/jekyll/collection.rb +9 -2
  20. data/lib/jekyll/command.rb +20 -10
  21. data/lib/jekyll/commands/build.rb +10 -47
  22. data/lib/jekyll/commands/serve.rb +1 -0
  23. data/lib/jekyll/configuration.rb +13 -1
  24. data/lib/jekyll/converters/markdown/redcarpet_parser.rb +9 -2
  25. data/lib/jekyll/convertible.rb +31 -2
  26. data/lib/jekyll/deprecator.rb +1 -1
  27. data/lib/jekyll/document.rb +21 -3
  28. data/lib/jekyll/excerpt.rb +1 -1
  29. data/lib/jekyll/filters.rb +16 -12
  30. data/lib/jekyll/frontmatter_defaults.rb +3 -3
  31. data/lib/jekyll/log_adapter.rb +102 -0
  32. data/lib/jekyll/post.rb +5 -5
  33. data/lib/jekyll/renderer.rb +9 -5
  34. data/lib/jekyll/site.rb +38 -18
  35. data/lib/jekyll/static_file.rb +1 -0
  36. data/lib/jekyll/stevenson.rb +54 -98
  37. data/lib/jekyll/tags/highlight.rb +13 -5
  38. data/lib/jekyll/url.rb +2 -2
  39. data/lib/jekyll/utils.rb +15 -7
  40. data/lib/jekyll/version.rb +1 -1
  41. data/lib/site_template/_config.yml +2 -0
  42. data/lib/site_template/_includes/footer.html +8 -8
  43. data/lib/site_template/_includes/header.html +1 -1
  44. data/lib/site_template/css/main.css +7 -2
  45. data/lib/site_template/feed.xml +10 -1
  46. data/site/_config.yml +1 -0
  47. data/site/_data/docs.yml +1 -0
  48. data/site/_includes/anchor_links.html +28 -23
  49. data/site/_includes/css/font-awesome.css +3 -3
  50. data/site/_includes/css/style.css +4 -0
  51. data/site/_includes/news_contents.html +11 -1
  52. data/site/_includes/top.html +0 -1
  53. data/site/_layouts/default.html +1 -0
  54. data/site/_posts/2013-07-25-jekyll-1-0-4-released.markdown +1 -1
  55. data/site/_posts/2013-07-25-jekyll-1-1-2-released.markdown +1 -1
  56. data/site/_posts/2014-06-04-jekyll-stickers-1-dollar-stickermule.markdown +19 -0
  57. data/site/_posts/2014-06-28-jekyll-turns-21-i-mean-2-1-0.markdown +27 -0
  58. data/site/docs/collections.md +59 -1
  59. data/site/docs/configuration.md +91 -21
  60. data/site/docs/continuous-integration.md +177 -0
  61. data/site/docs/contributing.md +2 -2
  62. data/site/docs/datafiles.md +47 -3
  63. data/site/docs/deployment-methods.md +3 -3
  64. data/site/docs/extras.md +3 -5
  65. data/site/docs/history.md +86 -0
  66. data/site/docs/installation.md +3 -1
  67. data/site/docs/pagination.md +2 -1
  68. data/site/docs/permalinks.md +4 -4
  69. data/site/docs/plugins.md +6 -0
  70. data/site/docs/quickstart.md +0 -6
  71. data/site/docs/resources.md +1 -1
  72. data/site/docs/templates.md +1 -1
  73. data/site/docs/troubleshooting.md +1 -1
  74. data/site/docs/windows.md +2 -2
  75. data/site/fonts/FontAwesome.otf +0 -0
  76. data/site/fonts/fontawesome-webfont.eot +0 -0
  77. data/site/fonts/fontawesome-webfont.svg +469 -379
  78. data/site/fonts/fontawesome-webfont.ttf +0 -0
  79. data/site/fonts/fontawesome-webfont.woff +0 -0
  80. data/site/img/jekyll-sticker.jpg +0 -0
  81. data/test/helper.rb +0 -3
  82. data/test/source/_data/categories/dairy.yaml +6 -0
  83. data/test/source/_data/members.json +12 -0
  84. data/test/source/_methods/site/initialize.md +1 -2
  85. data/test/source/_posts/2009-01-27-no-category.textile +6 -0
  86. data/test/source/_slides/example-slide-1.html +4 -0
  87. data/test/source/_slides/example-slide-2.html +7 -0
  88. data/test/source/_with.dots/all.dots/2.4.0.md +5 -0
  89. data/test/source/_with.dots/file.with.dots.md +0 -0
  90. data/test/source/environment.html +5 -0
  91. data/test/test_cleaner.rb +77 -0
  92. data/test/test_collections.rb +52 -3
  93. data/test/test_command.rb +25 -28
  94. data/test/test_configuration.rb +10 -1
  95. data/test/test_document.rb +123 -0
  96. data/test/test_excerpt.rb +11 -0
  97. data/test/test_filters.rb +28 -2
  98. data/test/test_generated_site.rb +1 -1
  99. data/test/test_log_adapter.rb +59 -0
  100. data/test/test_post.rb +77 -0
  101. data/test/test_site.rb +51 -0
  102. data/test/test_tags.rb +11 -114
  103. data/test/test_utils.rb +2 -2
  104. metadata +76 -39
  105. data/lib/jekyll/generators/pagination.rb +0 -217
  106. data/lib/jekyll/tags/gist.rb +0 -47
  107. data/test/test_pager.rb +0 -118
@@ -2,9 +2,6 @@ require 'simplecov'
2
2
  require 'simplecov-gem-adapter'
3
3
  SimpleCov.start('gem')
4
4
 
5
- require 'coveralls'
6
- Coveralls.wear_merged!
7
-
8
5
  require 'rubygems'
9
6
  require 'test/unit'
10
7
  require 'ostruct'
@@ -0,0 +1,6 @@
1
+ name: Dairy
2
+ products:
3
+ - name: cheese
4
+ price: 5.3
5
+ - name: milk
6
+ price: 2.5
@@ -0,0 +1,12 @@
1
+ [
2
+ {
3
+ "name": "Jack",
4
+ "age": 27,
5
+ "blog": "http://example.com/jack"
6
+ },
7
+ {
8
+ "name": "John",
9
+ "age": 32,
10
+ "blog": "http://example.com/john"
11
+ }
12
+ ]
@@ -1,5 +1,4 @@
1
1
  ---
2
- title: "Site#initialize"
3
2
  ---
4
3
 
5
- Create dat site.
4
+ Page without title.
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: default
3
+ title: Category in YAML
4
+ ---
5
+
6
+ Best *post* ever
@@ -0,0 +1,4 @@
1
+ ---
2
+ title: Example slide
3
+ layout: slide
4
+ ---
@@ -0,0 +1,7 @@
1
+ ---
2
+ title: Override title
3
+ layout: slide
4
+ nested:
5
+ test1: override1
6
+ test2: override2
7
+ ---
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: v2.4.0
3
+ ---
4
+
5
+ v2.4.0
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: I'm a Jekyll environment exchequer
3
+ ---
4
+
5
+ {{ jekyll.environment }}
@@ -0,0 +1,77 @@
1
+ require 'helper'
2
+
3
+ class TestCleaner < Test::Unit::TestCase
4
+ context "directory in keep_files" do
5
+ setup do
6
+ clear_dest
7
+ stub(Jekyll).configuration do
8
+ Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir})
9
+ end
10
+
11
+ FileUtils.mkdir_p(dest_dir('to_keep/child_dir'))
12
+ FileUtils.touch(File.join(dest_dir('to_keep'), 'index.html'))
13
+ FileUtils.touch(File.join(dest_dir('to_keep/child_dir'), 'index.html'))
14
+
15
+ @site = Site.new(Jekyll.configuration)
16
+ @site.keep_files = ['to_keep/child_dir']
17
+
18
+ @cleaner = Site::Cleaner.new(@site)
19
+ @cleaner.cleanup!
20
+ end
21
+
22
+ teardown do
23
+ FileUtils.rm_rf(dest_dir('to_keep'))
24
+ end
25
+
26
+ should "keep the parent directory" do
27
+ assert File.exist?(dest_dir('to_keep'))
28
+ end
29
+
30
+ should "keep the child directory" do
31
+ assert File.exist?(dest_dir('to_keep/child_dir'))
32
+ end
33
+
34
+ should "keep the file in the directory in keep_files" do
35
+ assert File.exist?(File.join(dest_dir('to_keep/child_dir'), 'index.html'))
36
+ end
37
+
38
+ should "delete the file in the directory not in keep_files" do
39
+ assert !File.exist?(File.join(dest_dir('to_keep'), 'index.html'))
40
+ end
41
+ end
42
+
43
+ context "directory containing no files and non-empty directories" do
44
+ setup do
45
+ clear_dest
46
+ stub(Jekyll).configuration do
47
+ Jekyll::Configuration::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir})
48
+ end
49
+
50
+ FileUtils.mkdir_p(source_dir('no_files_inside/child_dir'))
51
+ FileUtils.touch(File.join(source_dir('no_files_inside/child_dir'), 'index.html'))
52
+
53
+ @site = Site.new(Jekyll.configuration)
54
+ @site.process
55
+
56
+ @cleaner = Site::Cleaner.new(@site)
57
+ @cleaner.cleanup!
58
+ end
59
+
60
+ teardown do
61
+ FileUtils.rm_rf(source_dir('no_files_inside'))
62
+ FileUtils.rm_rf(dest_dir('no_files_inside'))
63
+ end
64
+
65
+ should "keep the parent directory" do
66
+ assert File.exist?(dest_dir('no_files_inside'))
67
+ end
68
+
69
+ should "keep the child directory" do
70
+ assert File.exist?(dest_dir('no_files_inside/child_dir'))
71
+ end
72
+
73
+ should "keep the file" do
74
+ assert File.exist?(File.join(dest_dir('no_files_inside/child_dir'), 'index.html'))
75
+ end
76
+ end
77
+ end
@@ -17,15 +17,15 @@ class TestCollections < Test::Unit::TestCase
17
17
  end
18
18
 
19
19
  should "sanitize the label name" do
20
- assert_equal @collection.label, "etcpassword"
20
+ assert_equal @collection.label, "....etcpassword"
21
21
  end
22
22
 
23
23
  should "have a sanitized relative path name" do
24
- assert_equal @collection.relative_directory, "_etcpassword"
24
+ assert_equal @collection.relative_directory, "_....etcpassword"
25
25
  end
26
26
 
27
27
  should "have a sanitized full path" do
28
- assert_equal @collection.directory, source_dir("_etcpassword")
28
+ assert_equal @collection.directory, source_dir("_....etcpassword")
29
29
  end
30
30
  end
31
31
 
@@ -38,6 +38,10 @@ class TestCollections < Test::Unit::TestCase
38
38
  assert_equal @collection.label, "methods"
39
39
  end
40
40
 
41
+ should "have default url template" do
42
+ assert_equal @collection.url_template, "/:collection/:path:output_ext"
43
+ end
44
+
41
45
  should "contain no docs when initialized" do
42
46
  assert_empty @collection.docs
43
47
  end
@@ -91,6 +95,24 @@ class TestCollections < Test::Unit::TestCase
91
95
  end
92
96
  end
93
97
 
98
+ context "a collection with permalink" do
99
+ setup do
100
+ @site = fixture_site({
101
+ "collections" => {
102
+ "methods" => {
103
+ "permalink" => "/awesome/:path/"
104
+ }
105
+ }
106
+ })
107
+ @site.process
108
+ @collection = @site.collections["methods"]
109
+ end
110
+
111
+ should "have custom url template" do
112
+ assert_equal @collection.url_template, "/awesome/:path/"
113
+ end
114
+ end
115
+
94
116
  context "with a collection" do
95
117
  setup do
96
118
  @site = fixture_site({
@@ -172,4 +194,31 @@ class TestCollections < Test::Unit::TestCase
172
194
  end
173
195
  end
174
196
 
197
+ context "with dots in the filenames" do
198
+ setup do
199
+ @site = fixture_site({
200
+ "collections" => ["with.dots"],
201
+ "safe" => true
202
+ })
203
+ @site.process
204
+ @collection = @site.collections["with.dots"]
205
+ end
206
+
207
+ should "exist" do
208
+ assert_not_nil @collection
209
+ end
210
+
211
+ should "contain one document" do
212
+ assert_equal 2, @collection.docs.size
213
+ end
214
+
215
+ should "allow dots in the filename" do
216
+ assert_equal "_with.dots", @collection.relative_directory
217
+ end
218
+
219
+ should "read document in subfolders with dots" do
220
+ assert @collection.docs.any? { |d| d.path.include?("all.dots") }
221
+ end
222
+ end
223
+
175
224
  end
@@ -1,38 +1,35 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestCommand < Test::Unit::TestCase
4
- context "when calling .globs" do
5
- context "when non-default dest & source dirs" do
6
- setup do
7
- @source = source_dir
8
- @dest = dest_dir
9
- directory_with_contents(@dest)
10
- @globs = Command.globs(@source, @dest)
11
- end
12
- should "return an array without the destination dir" do
13
- assert @globs.is_a?(Array)
14
- assert !@globs.include?(@dest)
15
- end
16
- teardown do
17
- clear_dest
4
+ context "when calling .ignore_paths" do
5
+ context "when source is absolute" do
6
+ setup { @source = source_dir }
7
+ should "return an array with regex for destination" do
8
+ absolute = source_dir('dest')
9
+ relative = Pathname.new(source_dir('dest')).relative_path_from(Pathname.new('.').expand_path).to_s
10
+ [absolute, relative].each do |dest|
11
+ config = build_configs("source" => @source, "destination" => dest)
12
+ assert Command.ignore_paths(config).include?(/dest/), "failed with destination: #{dest}"
13
+ end
18
14
  end
19
15
  end
20
- context "when using default dest dir" do
21
- setup do
22
- @source = test_dir
23
- @dest = test_dir('_site')
24
- directory_with_contents(@dest)
25
- @globs = Command.globs(@source, @dest)
26
- end
27
- should "return an array without the destination dir" do
28
- assert @globs.is_a?(Array)
29
- assert !@globs.include?(@dest)
30
- @globs.each do |glob|
31
- assert !glob.include?(File.basename(@dest))
16
+ context "when source is relative" do
17
+ setup { @source = Pathname.new(source_dir).relative_path_from(Pathname.new('.').expand_path).to_s }
18
+ should "return an array with regex for destination" do
19
+ absolute = source_dir('dest')
20
+ relative = Pathname.new(source_dir('dest')).relative_path_from(Pathname.new('.').expand_path).to_s
21
+ [absolute, relative].each do |dest|
22
+ config = build_configs("source" => @source, "destination" => dest)
23
+ assert Command.ignore_paths(config).include?(/dest/), "failed with destination: #{dest}"
32
24
  end
33
25
  end
34
- teardown do
35
- FileUtils.rm_r(@dest)
26
+ end
27
+ context "multiple config files" do
28
+ should "return an array with regex for config files" do
29
+ config = build_configs("config"=> ["_config.yaml", "_config2.yml"])
30
+ ignore_paths = Command.ignore_paths(config)
31
+ assert ignore_paths.include?(/_config\.yaml/), 'did not include _config.yaml'
32
+ assert ignore_paths.include?(/_config2\.yml/), 'did not include _config2.yml'
36
33
  end
37
34
  end
38
35
  end
@@ -39,7 +39,16 @@ class TestConfiguration < Test::Unit::TestCase
39
39
  assert @config.config_files(@multiple_files).is_a?(Array)
40
40
  end
41
41
  should "return the default config path if no config files are specified" do
42
- assert_equal [File.join(source_dir, "_config.yml")], @config.config_files(@no_override)
42
+ assert_equal [source_dir("_config.yml")], @config.config_files(@no_override)
43
+ end
44
+ should "return .yaml if it exists but .yml does not" do
45
+ mock(File).exists?(source_dir("_config.yml")) { false }
46
+ mock(File).exists?(source_dir("_config.yaml")) { true }
47
+ assert_equal [source_dir("_config.yaml")], @config.config_files(@no_override)
48
+ end
49
+ should "return .yml if both .yml and .yaml exist" do
50
+ mock(File).exists?(source_dir("_config.yml")) { true }
51
+ assert_equal [source_dir("_config.yml")], @config.config_files(@no_override)
43
52
  end
44
53
  should "return the config if given one config file" do
45
54
  assert_equal %w[config.yml], @config.config_files(@one_config_file)
@@ -40,6 +40,129 @@ class TestDocument < Test::Unit::TestCase
40
40
  }, @document.data)
41
41
  end
42
42
 
43
+ should "output the collection name in the #to_liquid method" do
44
+ assert_equal @document.to_liquid['collection'], "methods"
45
+ end
46
+
47
+ end
48
+
49
+ context "a document as part of a collection with frontmatter defaults" do
50
+ setup do
51
+ @site = Site.new(Jekyll.configuration({
52
+ "collections" => ["slides"],
53
+ "source" => source_dir,
54
+ "destination" => dest_dir,
55
+ "defaults" => [{
56
+ "scope"=> {"path"=>"", "type"=>"slides"},
57
+ "values"=> {
58
+ "nested"=> {
59
+ "key"=>"myval",
60
+ }
61
+ }
62
+ }]
63
+ }))
64
+ @site.process
65
+ @document = @site.collections["slides"].docs.first
66
+ end
67
+
68
+ should "know the frontmatter defaults" do
69
+ assert_equal({
70
+ "title"=>"Example slide",
71
+ "layout"=>"slide",
72
+ "nested"=> {
73
+ "key"=>"myval"
74
+ }
75
+ }, @document.data)
76
+ end
77
+ end
78
+
79
+ context "a document as part of a collection with overriden default values" do
80
+ setup do
81
+ @site = Site.new(Jekyll.configuration({
82
+ "collections" => ["slides"],
83
+ "source" => source_dir,
84
+ "destination" => dest_dir,
85
+ "defaults" => [{
86
+ "scope"=> {"path"=>"", "type"=>"slides"},
87
+ "values"=> {
88
+ "nested"=> {
89
+ "test1"=>"default1",
90
+ "test2"=>"default1"
91
+ }
92
+ }
93
+ }]
94
+ }))
95
+ @site.process
96
+ @document = @site.collections["slides"].docs[1]
97
+ end
98
+
99
+ should "override default values in the document frontmatter" do
100
+ assert_equal({
101
+ "title"=>"Override title",
102
+ "layout"=>"slide",
103
+ "nested"=> {
104
+ "test1"=>"override1",
105
+ "test2"=>"override2"
106
+ }
107
+ }, @document.data)
108
+ end
109
+ end
110
+
111
+ context "a document as part of a collection with valid path" do
112
+ setup do
113
+ @site = Site.new(Jekyll.configuration({
114
+ "collections" => ["slides"],
115
+ "source" => source_dir,
116
+ "destination" => dest_dir,
117
+ "defaults" => [{
118
+ "scope"=> {"path"=>"slides", "type"=>"slides"},
119
+ "values"=> {
120
+ "nested"=> {
121
+ "key"=>"value123",
122
+ }
123
+ }
124
+ }]
125
+ }))
126
+ @site.process
127
+ @document = @site.collections["slides"].docs.first
128
+ end
129
+
130
+ should "know the frontmatter defaults" do
131
+ assert_equal({
132
+ "title"=>"Example slide",
133
+ "layout"=>"slide",
134
+ "nested"=> {
135
+ "key"=>"value123"
136
+ }
137
+ }, @document.data)
138
+ end
139
+ end
140
+
141
+ context "a document as part of a collection with invalid path" do
142
+ setup do
143
+ @site = Site.new(Jekyll.configuration({
144
+ "collections" => ["slides"],
145
+ "source" => source_dir,
146
+ "destination" => dest_dir,
147
+ "defaults" => [{
148
+ "scope"=> {"path"=>"somepath", "type"=>"slides"},
149
+ "values"=> {
150
+ "nested"=> {
151
+ "key"=>"myval",
152
+ }
153
+ }
154
+ }]
155
+ }))
156
+ @site.process
157
+ @document = @site.collections["slides"].docs.first
158
+ end
159
+
160
+ should "not know the specified frontmatter defaults" do
161
+ assert_equal({
162
+ "title"=>"Example slide",
163
+ "layout"=>"slide"
164
+ }, @document.data)
165
+ end
43
166
  end
44
167
 
45
168
  context " a document part of a rendered collection" do