jekyll-reloaded 0.12
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/Gemfile +2 -0
- data/History.txt +321 -0
- data/LICENSE +21 -0
- data/README.textile +41 -0
- data/Rakefile +161 -0
- data/bin/jekyll +289 -0
- data/cucumber.yml +1 -0
- data/features/create_sites.feature +112 -0
- data/features/embed_filters.feature +60 -0
- data/features/markdown.feature +30 -0
- data/features/pagination.feature +27 -0
- data/features/permalinks.feature +65 -0
- data/features/post_data.feature +153 -0
- data/features/site_configuration.feature +145 -0
- data/features/site_data.feature +82 -0
- data/features/step_definitions/jekyll_steps.rb +145 -0
- data/features/support/env.rb +19 -0
- data/jekyll.gemspec +146 -0
- data/lib/guard/jekyll.rb +57 -0
- data/lib/jekyll/converter.rb +50 -0
- data/lib/jekyll/converters/identity.rb +22 -0
- data/lib/jekyll/converters/markdown.rb +125 -0
- data/lib/jekyll/converters/textile.rb +50 -0
- data/lib/jekyll/convertible.rb +116 -0
- data/lib/jekyll/core_ext.rb +52 -0
- data/lib/jekyll/errors.rb +6 -0
- data/lib/jekyll/filters.rb +118 -0
- data/lib/jekyll/generator.rb +7 -0
- data/lib/jekyll/generators/pagination.rb +113 -0
- data/lib/jekyll/layout.rb +51 -0
- data/lib/jekyll/live_site.rb +216 -0
- data/lib/jekyll/migrators/csv.rb +26 -0
- data/lib/jekyll/migrators/drupal.rb +103 -0
- data/lib/jekyll/migrators/enki.rb +49 -0
- data/lib/jekyll/migrators/joomla.rb +53 -0
- data/lib/jekyll/migrators/marley.rb +52 -0
- data/lib/jekyll/migrators/mephisto.rb +84 -0
- data/lib/jekyll/migrators/mt.rb +86 -0
- data/lib/jekyll/migrators/posterous.rb +67 -0
- data/lib/jekyll/migrators/rss.rb +47 -0
- data/lib/jekyll/migrators/textpattern.rb +58 -0
- data/lib/jekyll/migrators/tumblr.rb +195 -0
- data/lib/jekyll/migrators/typo.rb +51 -0
- data/lib/jekyll/migrators/wordpress.rb +294 -0
- data/lib/jekyll/migrators/wordpressdotcom.rb +70 -0
- data/lib/jekyll/page.rb +160 -0
- data/lib/jekyll/plugin.rb +77 -0
- data/lib/jekyll/post.rb +262 -0
- data/lib/jekyll/site.rb +339 -0
- data/lib/jekyll/static_file.rb +77 -0
- data/lib/jekyll/tags/highlight.rb +118 -0
- data/lib/jekyll/tags/include.rb +37 -0
- data/lib/jekyll/tags/post_url.rb +38 -0
- data/lib/jekyll.rb +134 -0
- data/test/helper.rb +34 -0
- data/test/source/.htaccess +8 -0
- data/test/source/_includes/sig.markdown +3 -0
- data/test/source/_layouts/default.html +27 -0
- data/test/source/_layouts/simple.html +1 -0
- 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/2008-10-18-foo-bar.textile +8 -0
- data/test/source/_posts/2008-11-21-complex.textile +8 -0
- data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
- data/test/source/_posts/2008-12-13-include.markdown +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/source/_posts/2009-01-27-empty-categories.textile +7 -0
- data/test/source/_posts/2009-01-27-empty-category.textile +7 -0
- data/test/source/_posts/2009-03-12-hash-#1.markdown +6 -0
- data/test/source/_posts/2009-05-18-empty-tag.textile +6 -0
- data/test/source/_posts/2009-05-18-empty-tags.textile +6 -0
- data/test/source/_posts/2009-05-18-tag.textile +6 -0
- data/test/source/_posts/2009-05-18-tags.textile +9 -0
- data/test/source/_posts/2009-06-22-empty-yaml.textile +3 -0
- data/test/source/_posts/2009-06-22-no-yaml.textile +1 -0
- data/test/source/_posts/2010-01-08-triple-dash.markdown +5 -0
- data/test/source/_posts/2010-01-09-date-override.textile +7 -0
- data/test/source/_posts/2010-01-09-time-override.textile +7 -0
- data/test/source/_posts/2010-01-09-timezone-override.textile +7 -0
- data/test/source/_posts/2010-01-16-override-data.textile +4 -0
- data/test/source/_posts/2011-04-12-md-extension.md +7 -0
- data/test/source/_posts/2011-04-12-text-extension.text +0 -0
- data/test/source/about.html +6 -0
- data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
- data/test/source/contacts.html +5 -0
- data/test/source/css/screen.css +76 -0
- data/test/source/deal.with.dots.html +7 -0
- data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
- data/test/source/index.html +22 -0
- data/test/source/sitemap.xml +32 -0
- data/test/source/win/_posts/2009-05-24-yaml-linebreak.markdown +7 -0
- data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
- data/test/suite.rb +11 -0
- data/test/test_configuration.rb +29 -0
- data/test/test_core_ext.rb +66 -0
- data/test/test_filters.rb +62 -0
- data/test/test_generated_site.rb +72 -0
- data/test/test_kramdown.rb +23 -0
- data/test/test_page.rb +117 -0
- data/test/test_pager.rb +113 -0
- data/test/test_post.rb +450 -0
- data/test/test_rdiscount.rb +18 -0
- data/test/test_redcarpet.rb +21 -0
- data/test/test_redcloth.rb +86 -0
- data/test/test_site.rb +220 -0
- data/test/test_tags.rb +201 -0
- metadata +332 -0
|
@@ -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,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,32 @@
|
|
|
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: "%Y-%m-%d" }}</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>{{ post.date | date: "%Y-%m-%d" }}</lastmod>
|
|
19
|
+
<changefreq>monthly</changefreq>
|
|
20
|
+
<priority>0.2</priority>
|
|
21
|
+
</url>
|
|
22
|
+
{% endfor %}
|
|
23
|
+
|
|
24
|
+
{% for page in site.html_pages %}
|
|
25
|
+
<url>
|
|
26
|
+
<loc>http://example.com{{ page.url }}</loc>
|
|
27
|
+
<lastmod>{{ site.time | date: "%Y-%m-%d" }}</lastmod>
|
|
28
|
+
{% if page.changefreq %}<changefreq>{{ page.changefreq }}</changefreq>{% endif %}
|
|
29
|
+
{% if page.priority %}<priority>{{ page.priority }}</priority>{% endif %}
|
|
30
|
+
</url>
|
|
31
|
+
{% endfor %}
|
|
32
|
+
</urlset>
|
data/test/suite.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
gem 'test-unit'
|
|
3
|
+
require 'test/unit'
|
|
4
|
+
|
|
5
|
+
# for some reason these tests fail when run via TextMate
|
|
6
|
+
# but succeed when run on the command line.
|
|
7
|
+
|
|
8
|
+
tests = Dir[File.expand_path("#{File.dirname(__FILE__)}/test_*.rb")]
|
|
9
|
+
tests.each do |file|
|
|
10
|
+
require file
|
|
11
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class TestConfiguration < Test::Unit::TestCase
|
|
4
|
+
context "loading configuration" do
|
|
5
|
+
setup do
|
|
6
|
+
@path = File.join(Dir.pwd, '_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,66 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class TestCoreExt < Test::Unit::TestCase
|
|
4
|
+
context "hash" do
|
|
5
|
+
|
|
6
|
+
context "pluralized_array" do
|
|
7
|
+
|
|
8
|
+
should "return empty array with no values" do
|
|
9
|
+
data = {}
|
|
10
|
+
assert_equal [], data.pluralized_array('tag', 'tags')
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
should "return empty array with no matching values" do
|
|
14
|
+
data = { 'foo' => 'bar' }
|
|
15
|
+
assert_equal [], data.pluralized_array('tag', 'tags')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
should "return empty array with matching nil singular" do
|
|
19
|
+
data = { 'foo' => 'bar', 'tag' => nil, 'tags' => ['dog', 'cat'] }
|
|
20
|
+
assert_equal [], data.pluralized_array('tag', 'tags')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
should "return single value array with matching singular" do
|
|
24
|
+
data = { 'foo' => 'bar', 'tag' => 'dog', 'tags' => ['dog', 'cat'] }
|
|
25
|
+
assert_equal ['dog'], data.pluralized_array('tag', 'tags')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
should "return single value array with matching singular with spaces" do
|
|
29
|
+
data = { 'foo' => 'bar', 'tag' => 'dog cat', 'tags' => ['dog', 'cat'] }
|
|
30
|
+
assert_equal ['dog cat'], data.pluralized_array('tag', 'tags')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
should "return empty array with matching nil plural" do
|
|
34
|
+
data = { 'foo' => 'bar', 'tags' => nil }
|
|
35
|
+
assert_equal [], data.pluralized_array('tag', 'tags')
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
should "return empty array with matching empty array" do
|
|
39
|
+
data = { 'foo' => 'bar', 'tags' => [] }
|
|
40
|
+
assert_equal [], data.pluralized_array('tag', 'tags')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
should "return single value array with matching plural with single string value" do
|
|
44
|
+
data = { 'foo' => 'bar', 'tags' => 'dog' }
|
|
45
|
+
assert_equal ['dog'], data.pluralized_array('tag', 'tags')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
should "return multiple value array with matching plural with single string value with spaces" do
|
|
49
|
+
data = { 'foo' => 'bar', 'tags' => 'dog cat' }
|
|
50
|
+
assert_equal ['dog', 'cat'], data.pluralized_array('tag', 'tags')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
should "return single value array with matching plural with single value array" do
|
|
54
|
+
data = { 'foo' => 'bar', 'tags' => ['dog'] }
|
|
55
|
+
assert_equal ['dog'], data.pluralized_array('tag', 'tags')
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
should "return multiple value array with matching plural with multiple value array" do
|
|
59
|
+
data = { 'foo' => 'bar', 'tags' => ['dog', 'cat'] }
|
|
60
|
+
assert_equal ['dog', 'cat'], data.pluralized_array('tag', 'tags')
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class TestFilters < Test::Unit::TestCase
|
|
4
|
+
class JekyllFilter
|
|
5
|
+
include Jekyll::Filters
|
|
6
|
+
|
|
7
|
+
def initialize
|
|
8
|
+
site = Jekyll::Site.new(Jekyll.configuration({}))
|
|
9
|
+
@context = Liquid::Context.new({}, {}, { :site => site })
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
context "filters" do
|
|
14
|
+
setup do
|
|
15
|
+
@filter = JekyllFilter.new
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
should "textilize with simple string" do
|
|
19
|
+
assert_equal "<p>something <strong>really</strong> simple</p>", @filter.textilize("something *really* simple")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
should "markdownify with simple string" do
|
|
23
|
+
assert_equal "<p>something <strong>really</strong> simple</p>", @filter.markdownify("something **really** simple")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
should "convert array to sentence string with no args" do
|
|
27
|
+
assert_equal "", @filter.array_to_sentence_string([])
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
should "convert array to sentence string with one arg" do
|
|
31
|
+
assert_equal "1", @filter.array_to_sentence_string([1])
|
|
32
|
+
assert_equal "chunky", @filter.array_to_sentence_string(["chunky"])
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
should "convert array to sentence string with two args" do
|
|
36
|
+
assert_equal "1 and 2", @filter.array_to_sentence_string([1, 2])
|
|
37
|
+
assert_equal "chunky and bacon", @filter.array_to_sentence_string(["chunky", "bacon"])
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
should "convert array to sentence string with multiple args" do
|
|
41
|
+
assert_equal "1, 2, 3, and 4", @filter.array_to_sentence_string([1, 2, 3, 4])
|
|
42
|
+
assert_equal "chunky, bacon, bits, and pieces", @filter.array_to_sentence_string(["chunky", "bacon", "bits", "pieces"])
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
should "escape xml with ampersands" do
|
|
46
|
+
assert_equal "AT&T", @filter.xml_escape("AT&T")
|
|
47
|
+
assert_equal "<code>command &lt;filename&gt;</code>", @filter.xml_escape("<code>command <filename></code>")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
should "escape space as plus" do
|
|
51
|
+
assert_equal "my+things", @filter.cgi_escape("my things")
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
should "escape special characters" do
|
|
55
|
+
assert_equal "hey%21", @filter.cgi_escape("hey!")
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
should "escape space as %20" do
|
|
59
|
+
assert_equal "my%20things", @filter.uri_escape("my things")
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require '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 "ensure post count is as expected" do
|
|
17
|
+
assert_equal 28, @site.posts.size
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
should "insert site.posts into the index" do
|
|
21
|
+
assert @index.include?("#{@site.posts.size} Posts")
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
should "render latest post's content" do
|
|
25
|
+
assert @index.include?(@site.posts.last.content)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
should "hide unpublished posts" do
|
|
29
|
+
published = Dir[dest_dir('publish_test/2008/02/02/*.html')].map {|f| File.basename(f)}
|
|
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 "process other static files and generate correct permalinks" do
|
|
40
|
+
assert File.exists?(dest_dir('/about/index.html'))
|
|
41
|
+
assert File.exists?(dest_dir('/contacts.html'))
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
context "generating limited posts" do
|
|
46
|
+
setup do
|
|
47
|
+
clear_dest
|
|
48
|
+
stub(Jekyll).configuration do
|
|
49
|
+
Jekyll::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => 5})
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
@site = Site.new(Jekyll.configuration)
|
|
53
|
+
@site.process
|
|
54
|
+
@index = File.read(dest_dir('index.html'))
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
should "generate only the specified number of posts" do
|
|
58
|
+
assert_equal 5, @site.posts.size
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
should "ensure limit posts is 1 or more" do
|
|
62
|
+
assert_raise ArgumentError do
|
|
63
|
+
clear_dest
|
|
64
|
+
stub(Jekyll).configuration do
|
|
65
|
+
Jekyll::DEFAULTS.merge({'source' => source_dir, 'destination' => dest_dir, 'limit_posts' => 0})
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
@site = Site.new(Jekyll.configuration)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class TestKramdown < Test::Unit::TestCase
|
|
4
|
+
context "kramdown" do
|
|
5
|
+
setup do
|
|
6
|
+
config = {
|
|
7
|
+
'markdown' => 'kramdown',
|
|
8
|
+
'kramdown' => {
|
|
9
|
+
'auto_ids' => false,
|
|
10
|
+
'footnote_nr' => 1,
|
|
11
|
+
'entity_output' => 'as_char',
|
|
12
|
+
'toc_levels' => '1..6'
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
@markdown = MarkdownConverter.new config
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# http://kramdown.rubyforge.org/converter/html.html#options
|
|
19
|
+
should "pass kramdown options" do
|
|
20
|
+
assert_equal "<h1>Some Header</h1>", @markdown.convert('# Some Header #').strip
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/test/test_page.rb
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
require '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
|
+
should "deal properly with extensions" do
|
|
27
|
+
@page = setup_page('deal.with.dots.html')
|
|
28
|
+
assert_equal ".html", @page.ext
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
should "deal properly with dots" do
|
|
32
|
+
@page = setup_page('deal.with.dots.html')
|
|
33
|
+
assert_equal "deal.with.dots", @page.basename
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "with pretty url style" do
|
|
37
|
+
setup do
|
|
38
|
+
@site.permalink_style = :pretty
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
should "return dir correctly" do
|
|
42
|
+
@page = setup_page('contacts.html')
|
|
43
|
+
assert_equal '/contacts/', @page.dir
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
should "return dir correctly for index page" do
|
|
47
|
+
@page = setup_page('index.html')
|
|
48
|
+
assert_equal '/', @page.dir
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context "with any other url style" do
|
|
53
|
+
should "return dir correctly" do
|
|
54
|
+
@site.permalink_style = nil
|
|
55
|
+
@page = setup_page('contacts.html')
|
|
56
|
+
assert_equal '/', @page.dir
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
should "respect permalink in yaml front matter" do
|
|
61
|
+
file = "about.html"
|
|
62
|
+
@page = setup_page(file)
|
|
63
|
+
|
|
64
|
+
assert_equal "/about/", @page.permalink
|
|
65
|
+
assert_equal @page.permalink, @page.url
|
|
66
|
+
assert_equal "/about/", @page.dir
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
context "rendering" do
|
|
71
|
+
setup do
|
|
72
|
+
clear_dest
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
should "write properly" do
|
|
76
|
+
page = setup_page('contacts.html')
|
|
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.html'))
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
should "write properly without html extension" do
|
|
85
|
+
page = setup_page('contacts.html')
|
|
86
|
+
page.site.permalink_style = :pretty
|
|
87
|
+
do_render(page)
|
|
88
|
+
page.write(dest_dir)
|
|
89
|
+
|
|
90
|
+
assert File.directory?(dest_dir)
|
|
91
|
+
assert File.exists?(File.join(dest_dir, 'contacts', 'index.html'))
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
should "write properly with extension different from html" do
|
|
95
|
+
page = setup_page("sitemap.xml")
|
|
96
|
+
page.site.permalink_style = :pretty
|
|
97
|
+
do_render(page)
|
|
98
|
+
page.write(dest_dir)
|
|
99
|
+
|
|
100
|
+
assert_equal("/sitemap.xml", page.url)
|
|
101
|
+
assert_nil(page.url[/\.html$/])
|
|
102
|
+
assert File.directory?(dest_dir)
|
|
103
|
+
assert File.exists?(File.join(dest_dir,'sitemap.xml'))
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
should "write dotfiles properly" do
|
|
107
|
+
page = setup_page('.htaccess')
|
|
108
|
+
do_render(page)
|
|
109
|
+
page.write(dest_dir)
|
|
110
|
+
|
|
111
|
+
assert File.directory?(dest_dir)
|
|
112
|
+
assert File.exists?(File.join(dest_dir, '.htaccess'))
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
end
|
|
117
|
+
end
|
data/test/test_pager.rb
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
class TestPager < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
should "calculate number of pages" do
|
|
6
|
+
assert_equal(0, Pager.calculate_pages([], '2'))
|
|
7
|
+
assert_equal(1, Pager.calculate_pages([1], '2'))
|
|
8
|
+
assert_equal(1, Pager.calculate_pages([1,2], '2'))
|
|
9
|
+
assert_equal(2, Pager.calculate_pages([1,2,3], '2'))
|
|
10
|
+
assert_equal(2, Pager.calculate_pages([1,2,3,4], '2'))
|
|
11
|
+
assert_equal(3, Pager.calculate_pages([1,2,3,4,5], '2'))
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
context "pagination disabled" do
|
|
15
|
+
setup do
|
|
16
|
+
stub(Jekyll).configuration do
|
|
17
|
+
Jekyll::DEFAULTS.merge({
|
|
18
|
+
'source' => source_dir,
|
|
19
|
+
'destination' => dest_dir
|
|
20
|
+
})
|
|
21
|
+
end
|
|
22
|
+
@config = Jekyll.configuration
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
should "report that pagination is disabled" do
|
|
26
|
+
assert !Pager.pagination_enabled?(@config, 'index.html')
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context "pagination enabled for 2" do
|
|
32
|
+
setup do
|
|
33
|
+
stub(Jekyll).configuration do
|
|
34
|
+
Jekyll::DEFAULTS.merge({
|
|
35
|
+
'source' => source_dir,
|
|
36
|
+
'destination' => dest_dir,
|
|
37
|
+
'paginate' => 2
|
|
38
|
+
})
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
@config = Jekyll.configuration
|
|
42
|
+
@site = Site.new(@config)
|
|
43
|
+
@site.process
|
|
44
|
+
@posts = @site.posts
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
should "report that pagination is enabled" do
|
|
48
|
+
assert Pager.pagination_enabled?(@config, 'index.html')
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context "with 4 posts" do
|
|
52
|
+
setup do
|
|
53
|
+
@posts = @site.posts[1..4] # limit to 4
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
should "create first pager" do
|
|
57
|
+
pager = Pager.new(@config, 1, @posts)
|
|
58
|
+
assert_equal(2, pager.posts.size)
|
|
59
|
+
assert_equal(2, pager.total_pages)
|
|
60
|
+
assert_nil(pager.previous_page)
|
|
61
|
+
assert_equal(2, pager.next_page)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
should "create second pager" do
|
|
65
|
+
pager = Pager.new(@config, 2, @posts)
|
|
66
|
+
assert_equal(2, pager.posts.size)
|
|
67
|
+
assert_equal(2, pager.total_pages)
|
|
68
|
+
assert_equal(1, pager.previous_page)
|
|
69
|
+
assert_nil(pager.next_page)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
should "not create third pager" do
|
|
73
|
+
assert_raise(RuntimeError) { Pager.new(@config, 3, @posts) }
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
context "with 5 posts" do
|
|
79
|
+
setup do
|
|
80
|
+
@posts = @site.posts[1..5] # limit to 5
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
should "create first pager" do
|
|
84
|
+
pager = Pager.new(@config, 1, @posts)
|
|
85
|
+
assert_equal(2, pager.posts.size)
|
|
86
|
+
assert_equal(3, pager.total_pages)
|
|
87
|
+
assert_nil(pager.previous_page)
|
|
88
|
+
assert_equal(2, pager.next_page)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
should "create second pager" do
|
|
92
|
+
pager = Pager.new(@config, 2, @posts)
|
|
93
|
+
assert_equal(2, pager.posts.size)
|
|
94
|
+
assert_equal(3, pager.total_pages)
|
|
95
|
+
assert_equal(1, pager.previous_page)
|
|
96
|
+
assert_equal(3, pager.next_page)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
should "create third pager" do
|
|
100
|
+
pager = Pager.new(@config, 3, @posts)
|
|
101
|
+
assert_equal(1, pager.posts.size)
|
|
102
|
+
assert_equal(3, pager.total_pages)
|
|
103
|
+
assert_equal(2, pager.previous_page)
|
|
104
|
+
assert_nil(pager.next_page)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
should "not create fourth pager" do
|
|
108
|
+
assert_raise(RuntimeError) { Pager.new(@config, 4, @posts) }
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|