jekyll 1.0.0.beta1 → 1.0.0.beta2

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.

@@ -0,0 +1,60 @@
1
+ .highlight { background: #ffffff; }
2
+ .highlight .c { color: #999988; font-style: italic } /* Comment */
3
+ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
4
+ .highlight .k { font-weight: bold } /* Keyword */
5
+ .highlight .o { font-weight: bold } /* Operator */
6
+ .highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
7
+ .highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
8
+ .highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
9
+ .highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
10
+ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
11
+ .highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */
12
+ .highlight .ge { font-style: italic } /* Generic.Emph */
13
+ .highlight .gr { color: #aa0000 } /* Generic.Error */
14
+ .highlight .gh { color: #999999 } /* Generic.Heading */
15
+ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
16
+ .highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */
17
+ .highlight .go { color: #888888 } /* Generic.Output */
18
+ .highlight .gp { color: #555555 } /* Generic.Prompt */
19
+ .highlight .gs { font-weight: bold } /* Generic.Strong */
20
+ .highlight .gu { color: #aaaaaa } /* Generic.Subheading */
21
+ .highlight .gt { color: #aa0000 } /* Generic.Traceback */
22
+ .highlight .kc { font-weight: bold } /* Keyword.Constant */
23
+ .highlight .kd { font-weight: bold } /* Keyword.Declaration */
24
+ .highlight .kp { font-weight: bold } /* Keyword.Pseudo */
25
+ .highlight .kr { font-weight: bold } /* Keyword.Reserved */
26
+ .highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */
27
+ .highlight .m { color: #009999 } /* Literal.Number */
28
+ .highlight .s { color: #d14 } /* Literal.String */
29
+ .highlight .na { color: #008080 } /* Name.Attribute */
30
+ .highlight .nb { color: #0086B3 } /* Name.Builtin */
31
+ .highlight .nc { color: #445588; font-weight: bold } /* Name.Class */
32
+ .highlight .no { color: #008080 } /* Name.Constant */
33
+ .highlight .ni { color: #800080 } /* Name.Entity */
34
+ .highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */
35
+ .highlight .nf { color: #990000; font-weight: bold } /* Name.Function */
36
+ .highlight .nn { color: #555555 } /* Name.Namespace */
37
+ .highlight .nt { color: #000080 } /* Name.Tag */
38
+ .highlight .nv { color: #008080 } /* Name.Variable */
39
+ .highlight .ow { font-weight: bold } /* Operator.Word */
40
+ .highlight .w { color: #bbbbbb } /* Text.Whitespace */
41
+ .highlight .mf { color: #009999 } /* Literal.Number.Float */
42
+ .highlight .mh { color: #009999 } /* Literal.Number.Hex */
43
+ .highlight .mi { color: #009999 } /* Literal.Number.Integer */
44
+ .highlight .mo { color: #009999 } /* Literal.Number.Oct */
45
+ .highlight .sb { color: #d14 } /* Literal.String.Backtick */
46
+ .highlight .sc { color: #d14 } /* Literal.String.Char */
47
+ .highlight .sd { color: #d14 } /* Literal.String.Doc */
48
+ .highlight .s2 { color: #d14 } /* Literal.String.Double */
49
+ .highlight .se { color: #d14 } /* Literal.String.Escape */
50
+ .highlight .sh { color: #d14 } /* Literal.String.Heredoc */
51
+ .highlight .si { color: #d14 } /* Literal.String.Interpol */
52
+ .highlight .sx { color: #d14 } /* Literal.String.Other */
53
+ .highlight .sr { color: #009926 } /* Literal.String.Regex */
54
+ .highlight .s1 { color: #d14 } /* Literal.String.Single */
55
+ .highlight .ss { color: #990073 } /* Literal.String.Symbol */
56
+ .highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */
57
+ .highlight .vc { color: #008080 } /* Name.Variable.Class */
58
+ .highlight .vg { color: #008080 } /* Name.Variable.Global */
59
+ .highlight .vi { color: #008080 } /* Name.Variable.Instance */
60
+ .highlight .il { color: #009999 } /* Literal.Number.Integer.Long */
File without changes
@@ -0,0 +1,13 @@
1
+ ---
2
+ layout: default
3
+ title: Your New Jekyll Site
4
+ ---
5
+
6
+ <div id="home">
7
+ <h1>Blog Posts</h1>
8
+ <ul class="posts">
9
+ {% for post in site.posts %}
10
+ <li><span>{{ post.date | date_to_string }}</span> &raquo; <a href="{{ post.url }}">{{ post.title }}</a></li>
11
+ {% endfor %}
12
+ </ul>
13
+ </div>
@@ -22,6 +22,11 @@ paginate: 5
22
22
 
23
23
  The number should be the maximum number of posts you’d like to be displayed per-page in the generated site.
24
24
 
25
+ <div class="note info">
26
+ <h5>Pagination does not support tags or categories</h5>
27
+ <p>Pagination pages through every post in the <code>posts</code> variable regardless of variables defined in the YAML Front Matter of each. It does not currently allow paging over groups of posts linked by a common tag or category.</p>
28
+ </div>
29
+
25
30
  ## Render the paginated posts
26
31
 
27
32
  The next thing you need to do is to actually display your posts in a list using the `paginator` variable that will now be available to you. You’ll probably want to do this in one of the main pages of your site. Here’s one example of a simple way of rendering paginated posts in a HTML file:
@@ -28,17 +28,27 @@ class Test::Unit::TestCase
28
28
  include RR::Adapters::TestUnit
29
29
 
30
30
  def dest_dir(*subdirs)
31
- File.join(File.dirname(__FILE__), 'dest', *subdirs)
31
+ test_dir('dest', *subdirs)
32
32
  end
33
33
 
34
34
  def source_dir(*subdirs)
35
- File.join(File.dirname(__FILE__), 'source', *subdirs)
35
+ test_dir('source', *subdirs)
36
36
  end
37
37
 
38
38
  def clear_dest
39
39
  FileUtils.rm_rf(dest_dir)
40
40
  end
41
41
 
42
+ def test_dir(*subdirs)
43
+ File.join(File.dirname(__FILE__), *subdirs)
44
+ end
45
+
46
+ def directory_with_contents(path)
47
+ FileUtils.rm_rf(path)
48
+ FileUtils.mkdir(path)
49
+ File.open("#{path}/index.html", "w"){ |f| f.write("I was previously generated.") }
50
+ end
51
+
42
52
  def capture_stdout
43
53
  $old_stdout = $stdout
44
54
  $stdout = StringIO.new
@@ -0,0 +1,8 @@
1
+ module Jekyll
2
+ class Dummy < Generator
3
+ priority :high
4
+
5
+ def generate(site)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ ---
2
+ layout: ~
3
+ title: Post Excerpt
4
+ ---
5
+
6
+ First paragraph with [link ref][link].
7
+
8
+ Second paragraph
9
+
10
+ ---
11
+
12
+ Third paragraph
13
+
14
+ [link]: http://www.jekyllrb.com/
@@ -8,4 +8,4 @@ require 'test/unit'
8
8
  tests = Dir[File.expand_path("#{File.dirname(__FILE__)}/test_*.rb")]
9
9
  tests.each do |file|
10
10
  require file
11
- end
11
+ end
@@ -0,0 +1,39 @@
1
+ require 'helper'
2
+
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
18
+ end
19
+ 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))
32
+ end
33
+ end
34
+ teardown do
35
+ FileUtils.rm_r(@dest)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -25,4 +25,31 @@ class TestConfiguration < Test::Unit::TestCase
25
25
  assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
26
26
  end
27
27
  end
28
+ context "loading config from external file" do
29
+ setup do
30
+ @paths = {
31
+ :default => File.join(Dir.pwd, '_config.yml'),
32
+ :other => File.join(Dir.pwd, '_config.live.yml'),
33
+ :empty => ""
34
+ }
35
+ end
36
+
37
+ should "load default config if no config_file is set" do
38
+ mock(YAML).safe_load_file(@paths[:default]) { Hash.new }
39
+ mock($stdout).puts("Configuration file: #{@paths[:default]}")
40
+ assert_equal Jekyll::DEFAULTS, Jekyll.configuration({})
41
+ end
42
+
43
+ should "load different config if specified" do
44
+ mock(YAML).safe_load_file(@paths[:other]) { {"baseurl" => "http://wahoo.dev"} }
45
+ mock($stdout).puts("Configuration file: #{@paths[:other]}")
46
+ assert_equal Jekyll::DEFAULTS.deep_merge({ "baseurl" => "http://wahoo.dev" }), Jekyll.configuration({ "config" => @paths[:other] })
47
+ end
48
+
49
+ should "load default config if path passed is empty" do
50
+ mock(YAML).safe_load_file(@paths[:default]) { Hash.new }
51
+ mock($stdout).puts("Configuration file: #{@paths[:default]}")
52
+ assert_equal Jekyll::DEFAULTS, Jekyll.configuration({ "config" => @paths[:empty] })
53
+ end
54
+ end
28
55
  end
@@ -14,7 +14,7 @@ class TestGeneratedSite < Test::Unit::TestCase
14
14
  end
15
15
 
16
16
  should "ensure post count is as expected" do
17
- assert_equal 30, @site.posts.size
17
+ assert_equal 31, @site.posts.size
18
18
  end
19
19
 
20
20
  should "insert site.posts into the index" do
@@ -0,0 +1,104 @@
1
+ require 'helper'
2
+ require 'jekyll/commands/new'
3
+
4
+ class TestNewCommand < Test::Unit::TestCase
5
+ def dir_contents(path)
6
+ Dir["#{path}/**/*"].each do |file|
7
+ file.gsub! path, ''
8
+ end
9
+ end
10
+
11
+ def site_template
12
+ File.expand_path("../lib/site_template", File.dirname(__FILE__))
13
+ end
14
+
15
+ context 'when args contains a path' do
16
+ setup do
17
+ @path = 'new-site'
18
+ @args = [@path]
19
+ @full_path = File.expand_path(@path, Dir.pwd)
20
+ end
21
+
22
+ teardown do
23
+ FileUtils.rm_r @full_path
24
+ end
25
+
26
+ should 'create a new directory' do
27
+ assert !File.exists?(@full_path)
28
+ capture_stdout { Jekyll::Commands::New.process(@args) }
29
+ assert File.exists?(@full_path)
30
+ end
31
+
32
+ should 'display a success message' do
33
+ output = capture_stdout { Jekyll::Commands::New.process(@args) }
34
+ success_message = "New jekyll site installed in #{@full_path}.\n"
35
+ assert_equal success_message, output
36
+ end
37
+
38
+ should 'copy the static files in site template to the new directory' do
39
+ static_template_files = dir_contents(site_template).reject do |f|
40
+ File.extname(f) == '.erb'
41
+ end
42
+
43
+ capture_stdout { Jekyll::Commands::New.process(@args) }
44
+
45
+ new_site_files = dir_contents(@full_path).reject do |f|
46
+ File.extname(f) == '.markdown'
47
+ end
48
+
49
+ assert_same_elements static_template_files, new_site_files
50
+ end
51
+
52
+ should 'process any ERB files' do
53
+ erb_template_files = dir_contents(site_template).select do |f|
54
+ File.extname(f) == '.erb'
55
+ end
56
+
57
+ stubbed_date = '2013-01-01'
58
+ stub.instance_of(Time).strftime { stubbed_date }
59
+
60
+ erb_template_files.each do |f|
61
+ f.chomp! '.erb'
62
+ f.gsub! '0000-00-00', stubbed_date
63
+ end
64
+
65
+ capture_stdout { Jekyll::Commands::New.process(@args) }
66
+
67
+ new_site_files = dir_contents(@full_path).select do |f|
68
+ erb_template_files.include? f
69
+ end
70
+
71
+ assert_same_elements erb_template_files, new_site_files
72
+ end
73
+ end
74
+
75
+ context 'when multiple args are given' do
76
+ setup do
77
+ @site_name_with_spaces = 'new site name'
78
+ @multiple_args = @site_name_with_spaces.split
79
+ end
80
+
81
+ teardown do
82
+ FileUtils.rm_r File.expand_path(@site_name_with_spaces, Dir.pwd)
83
+ end
84
+
85
+ should 'create a new directory' do
86
+ assert !File.exists?(@site_name_with_spaces)
87
+ capture_stdout { Jekyll::Commands::New.process(@multiple_args) }
88
+ assert File.exists?(@site_name_with_spaces)
89
+ end
90
+ end
91
+
92
+ context 'when no args are given' do
93
+ setup do
94
+ @empty_args = []
95
+ end
96
+
97
+ should 'raise an ArgumentError' do
98
+ exception = assert_raise ArgumentError do
99
+ Jekyll::Commands::New.process(@empty_args)
100
+ end
101
+ assert_equal 'You must specify a path.', exception.message
102
+ end
103
+ end
104
+ end
@@ -252,6 +252,52 @@ class TestPost < Test::Unit::TestCase
252
252
 
253
253
  assert_equal "<h1>{{ page.title }}</h1>\n<p>Best <strong>post</strong> ever</p>", @post.content
254
254
  end
255
+
256
+ context "#excerpt" do
257
+ setup do
258
+ file = "2013-01-02-post-excerpt.markdown"
259
+ @post.process(file)
260
+ @post.read_yaml(@source, file)
261
+ @post.transform
262
+ end
263
+
264
+ should "return first paragraph by default" do
265
+ assert @post.excerpt.include?("First paragraph"), "contains first paragraph"
266
+ assert !@post.excerpt.include?("Second paragraph"), "does not contains second paragraph"
267
+ assert !@post.excerpt.include?("Third paragraph"), "does not contains third paragraph"
268
+ end
269
+
270
+ should "correctly resolve link references" do
271
+ assert @post.excerpt.include?("www.jekyllrb.com"), "contains referenced link URL"
272
+ end
273
+
274
+ should "return rendered HTML" do
275
+ assert_equal "<p>First paragraph with <a href='http://www.jekyllrb.com/'>link ref</a>.</p>",
276
+ @post.excerpt
277
+ end
278
+
279
+ context "with excerpt_separator setting" do
280
+ setup do
281
+ file = "2013-01-02-post-excerpt.markdown"
282
+
283
+ @post.site.config['excerpt_separator'] = "\n---\n"
284
+
285
+ @post.process(file)
286
+ @post.read_yaml(@source, file)
287
+ @post.transform
288
+ end
289
+
290
+ should "respect given separator" do
291
+ assert @post.excerpt.include?("First paragraph"), "contains first paragraph"
292
+ assert @post.excerpt.include?("Second paragraph"), "contains second paragraph"
293
+ assert !@post.excerpt.include?("Third paragraph"), "does not contains third paragraph"
294
+ end
295
+
296
+ should "replace separator with new-lines" do
297
+ assert !@post.excerpt.include?("---"), "does not contains separator"
298
+ end
299
+ end
300
+ end
255
301
  end
256
302
 
257
303
  context "when in a site" do
@@ -32,6 +32,15 @@ class TestSite < Test::Unit::TestCase
32
32
  assert_equal [], site.plugins
33
33
  end
34
34
 
35
+ should "expose default baseurl" do
36
+ site = Site.new(Jekyll::DEFAULTS)
37
+ assert_equal Jekyll::DEFAULTS['baseurl'], site.baseurl
38
+ end
39
+
40
+ should "expose baseurl passed in from config" do
41
+ site = Site.new(Jekyll::DEFAULTS.merge({'baseurl' => '/blog'}))
42
+ assert_equal '/blog', site.baseurl
43
+ end
35
44
  end
36
45
  context "creating sites" do
37
46
  setup do
@@ -45,6 +54,21 @@ class TestSite < Test::Unit::TestCase
45
54
  assert_equal Hash.new, @site.tags
46
55
  end
47
56
 
57
+ should "give site with parsed pages and posts to generators" do
58
+ @site.reset
59
+ @site.read
60
+ class MyGenerator < Generator
61
+ def generate(site)
62
+ site.pages.dup.each do |page|
63
+ raise "#{page} isn't a page" unless page.is_a?(Page)
64
+ raise "#{page} doesn't respond to :name" unless page.respond_to?(:name)
65
+ end
66
+ end
67
+ end
68
+ @site.generate
69
+ assert_not_equal 0, @site.pages.size
70
+ end
71
+
48
72
  should "reset data before processing" do
49
73
  clear_dest
50
74
  @site.process
@@ -124,6 +148,11 @@ class TestSite < Test::Unit::TestCase
124
148
  assert_equal mtime3, mtime4 # no modifications, so must be the same
125
149
  end
126
150
 
151
+ should "setup plugins in priority order" do
152
+ assert_equal @site.converters.sort_by(&:class).map{|c|c.class.priority}, @site.converters.map{|c|c.class.priority}
153
+ assert_equal @site.generators.sort_by(&:class).map{|g|g.class.priority}, @site.generators.map{|g|g.class.priority}
154
+ end
155
+
127
156
  should "read layouts" do
128
157
  @site.read_layouts
129
158
  assert_equal ["default", "simple"].sort, @site.layouts.keys.sort
@@ -170,7 +170,7 @@ CONTENT
170
170
  assert_match %r{<em>FINISH HIM</em>}, @result
171
171
  end
172
172
  end
173
-
173
+
174
174
  context "using Redcarpet" do
175
175
  setup do
176
176
  create_post(@content, 'markdown' => 'redcarpet')
@@ -203,22 +203,78 @@ CONTENT
203
203
  assert_match %r{/2008/11/21/complex/}, @result
204
204
  end
205
205
  end
206
-
207
- context "simple gist inclusion" do
208
- setup do
209
- @gist = 358471
210
- content = <<CONTENT
206
+
207
+ context "gist tag" do
208
+ context "simple" do
209
+ setup do
210
+ @gist = 358471
211
+ content = <<CONTENT
211
212
  ---
212
213
  title: My Cool Gist
213
214
  ---
214
215
 
215
216
  {% gist #{@gist} %}
216
217
  CONTENT
217
- create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
218
+ create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
219
+ end
220
+
221
+ should "write script tag" do
222
+ assert_match "<script src='https://gist.github.com/#{@gist}.js'>\s</script>", @result
223
+ end
218
224
  end
219
-
220
- should "write script tag" do
221
- assert_match %r{<script src='https://gist.github.com/#{@gist}.js'>\s</script>}, @result
225
+
226
+ context "with specific file" do
227
+ setup do
228
+ @gist = 358471
229
+ @filename = 'somefile.rb'
230
+ content = <<CONTENT
231
+ ---
232
+ title: My Cool Gist
233
+ ---
234
+
235
+ {% gist #{@gist} #{@filename} %}
236
+ CONTENT
237
+ create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
238
+ end
239
+
240
+ should "write script tag with specific file in gist" do
241
+ assert_match "<script src='https://gist.github.com/#{@gist}.js?file=#{@filename}'>\s</script>", @result
242
+ end
243
+ end
244
+
245
+ context "with blank gist id" do
246
+ setup do
247
+ content = <<CONTENT
248
+ ---
249
+ title: My Cool Gist
250
+ ---
251
+
252
+ {% gist %}
253
+ CONTENT
254
+ create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
255
+ end
256
+
257
+ should "output error message" do
258
+ assert_match "Error parsing gist id", @result
259
+ end
260
+ end
261
+
262
+ context "with invalid gist id" do
263
+ setup do
264
+ invalid_gist = 'invalid'
265
+ content = <<CONTENT
266
+ ---
267
+ title: My Cool Gist
268
+ ---
269
+
270
+ {% gist #{invalid_gist} %}
271
+ CONTENT
272
+ create_post(content, {'permalink' => 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true})
273
+ end
274
+
275
+ should "output error message" do
276
+ assert_match "Error parsing gist id", @result
277
+ end
222
278
  end
223
279
  end
224
280
  end