jekyll 0.7.0 → 0.8.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.
- data/History.txt +13 -0
- data/bin/jekyll +19 -1
- data/features/create_sites.feature +2 -2
- data/features/site_configuration.feature +23 -0
- data/jekyll.gemspec +7 -2
- data/lib/jekyll.rb +17 -1
- data/lib/jekyll/converters/markdown.rb +34 -1
- data/lib/jekyll/filters.rb +6 -0
- data/lib/jekyll/migrators/mephisto.rb +1 -1
- data/lib/jekyll/migrators/mt.rb +23 -5
- data/lib/jekyll/migrators/textpattern.rb +1 -1
- data/lib/jekyll/migrators/typo.rb +1 -1
- data/lib/jekyll/migrators/wordpress.com.rb +38 -0
- data/lib/jekyll/migrators/wordpress.rb +1 -1
- data/lib/jekyll/page.rb +1 -1
- data/lib/jekyll/site.rb +8 -1
- data/lib/jekyll/tags/include.rb +7 -1
- data/test/helper.rb +1 -0
- data/test/source/.htaccess +8 -0
- data/test/source/deal.with.dots.html +7 -0
- data/test/test_filters.rb +4 -0
- data/test/test_generated_site.rb +28 -0
- data/test/test_kramdown.rb +23 -0
- data/test/test_page.rb +24 -5
- data/test/test_tags.rb +11 -0
- metadata +25 -4
data/History.txt
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
== 0.8.0 / 2010-11-22
|
2
|
+
* Minor Enhancements
|
3
|
+
* Add wordpress.com importer (#207)
|
4
|
+
* Add --limit-posts cli option (#212)
|
5
|
+
* Add uri_escape filter (#234)
|
6
|
+
* Add --base-url cli option (#235)
|
7
|
+
* Improve MT migrator (#238)
|
8
|
+
* Add kramdown support (#239)
|
9
|
+
* Bug Fixes
|
10
|
+
* Fixed filename basename generation (#208)
|
11
|
+
* Set mode to UTF8 on Sequel connections (#237)
|
12
|
+
* Prevent _includes dir from being a symlink
|
13
|
+
|
1
14
|
== 0.7.0 / 2010-08-24
|
2
15
|
* Minor Enhancements
|
3
16
|
* Add support for rdiscount extensions (#173)
|
data/bin/jekyll
CHANGED
@@ -40,6 +40,10 @@ opts = OptionParser.new do |opts|
|
|
40
40
|
options['server_port'] = port unless port.nil?
|
41
41
|
end
|
42
42
|
|
43
|
+
opts.on("--base-url [BASE_URL]", "Serve website from a given base URL (default '/'") do |baseurl|
|
44
|
+
options['baseurl'] = baseurl
|
45
|
+
end
|
46
|
+
|
43
47
|
opts.on("--lsi", "Use LSI for better related posts") do
|
44
48
|
options['lsi'] = true
|
45
49
|
end
|
@@ -52,6 +56,10 @@ opts = OptionParser.new do |opts|
|
|
52
56
|
options['markdown'] = 'rdiscount'
|
53
57
|
end
|
54
58
|
|
59
|
+
opts.on("--kramdown", "Use kramdown gem for Markdown") do
|
60
|
+
options['markdown'] = 'kramdown'
|
61
|
+
end
|
62
|
+
|
55
63
|
opts.on("--time [TIME]", "Time to generate the site for") do |time|
|
56
64
|
options['time'] = Time.parse(time)
|
57
65
|
end
|
@@ -78,6 +86,16 @@ opts = OptionParser.new do |opts|
|
|
78
86
|
end
|
79
87
|
end
|
80
88
|
|
89
|
+
opts.on("--limit_posts [MAX_POSTS]", "Limit the number of posts to publish") do |limit_posts|
|
90
|
+
begin
|
91
|
+
options['limit_posts'] = limit_posts.to_i
|
92
|
+
raise ArgumentError if options['limit_posts'] < 1
|
93
|
+
rescue
|
94
|
+
puts 'you must specify a number of posts by page bigger than 0'
|
95
|
+
exit 0
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
81
99
|
opts.on("--url [URL]", "Set custom site.url") do |url|
|
82
100
|
options['url'] = url
|
83
101
|
end
|
@@ -166,9 +184,9 @@ if options['server']
|
|
166
184
|
|
167
185
|
s = HTTPServer.new(
|
168
186
|
:Port => options['server_port'],
|
169
|
-
:DocumentRoot => destination,
|
170
187
|
:MimeTypes => mime_types
|
171
188
|
)
|
189
|
+
s.mount(options['baseurl'], HTTPServlet::FileHandler, destination)
|
172
190
|
t = Thread.new {
|
173
191
|
s.start
|
174
192
|
}
|
@@ -89,6 +89,6 @@ Feature: Create sites
|
|
89
89
|
And I have an "_includes/about.textile" file that contains "Generated by {% include jekyll.textile %}"
|
90
90
|
And I have an "_includes/jekyll.textile" file that contains "Jekyll"
|
91
91
|
And I have an "index.html" page that contains "Basic Site with include tag: {% include about.textile %}"
|
92
|
-
When I
|
92
|
+
When I debug jekyll
|
93
93
|
Then the _site directory should exist
|
94
|
-
And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/index.html"
|
94
|
+
And I should see "Basic Site with include tag: Generated by Jekyll" in "_site/index.html"
|
@@ -48,6 +48,13 @@ Feature: Site configuration
|
|
48
48
|
Then the _site directory should exist
|
49
49
|
And I should see "<a href="http://google.com">Google</a>" in "_site/index.html"
|
50
50
|
|
51
|
+
Scenario: Use Kramdown for markup
|
52
|
+
Given I have an "index.markdown" page that contains "[Google](http://google.com)"
|
53
|
+
And I have a configuration file with "markdown" set to "kramdown"
|
54
|
+
When I run jekyll
|
55
|
+
Then the _site directory should exist
|
56
|
+
And I should see "<a href="http://google.com">Google</a>" in "_site/index.html"
|
57
|
+
|
51
58
|
Scenario: Use Maruku for markup
|
52
59
|
Given I have an "index.markdown" page that contains "[Google](http://google.com)"
|
53
60
|
And I have a configuration file with "markdown" set to "maruku"
|
@@ -101,3 +108,19 @@ Feature: Site configuration
|
|
101
108
|
And I should see "Page Layout: 2 on 2010-01-01" in "_site/index.html"
|
102
109
|
And I should see "Post Layout: <p>content for entry1.</p>" in "_site/2007/12/31/entry1.html"
|
103
110
|
And I should see "Post Layout: <p>content for entry2.</p>" in "_site/2020/01/31/entry2.html"
|
111
|
+
|
112
|
+
Scenario: Limit the number of posts generated by most recent date
|
113
|
+
Given I have a _posts directory
|
114
|
+
And I have a configuration file with:
|
115
|
+
| key | value |
|
116
|
+
| limit_posts | 2 |
|
117
|
+
And I have the following posts:
|
118
|
+
| title | date | content |
|
119
|
+
| Apples | 3/27/2009 | An article about apples |
|
120
|
+
| Oranges | 4/1/2009 | An article about oranges |
|
121
|
+
| Bananas | 4/5/2009 | An article about bananas |
|
122
|
+
When I run jekyll
|
123
|
+
Then the _site directory should exist
|
124
|
+
And the "_site/2009/04/05/bananas.html" file should exist
|
125
|
+
And the "_site/2009/04/01/oranges.html" file should exist
|
126
|
+
And the "_site/2009/03/27/apples.html" file should not exist
|
data/jekyll.gemspec
CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.rubygems_version = '1.3.5'
|
5
5
|
|
6
6
|
s.name = 'jekyll'
|
7
|
-
s.version = '0.
|
8
|
-
s.date = '2010-
|
7
|
+
s.version = '0.8.0'
|
8
|
+
s.date = '2010-11-22'
|
9
9
|
s.rubyforge_project = 'jekyll'
|
10
10
|
|
11
11
|
s.summary = "A simple, blog aware, static site generator."
|
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_development_dependency('rr', [">= 4.2.1"])
|
34
34
|
s.add_development_dependency('cucumber', [">= 4.2.1"])
|
35
35
|
s.add_development_dependency('RedCloth', [">= 4.2.1"])
|
36
|
+
s.add_development_dependency('kramdown', [">= 0.12.0"])
|
36
37
|
|
37
38
|
# = MANIFEST =
|
38
39
|
s.files = %w[
|
@@ -71,6 +72,7 @@ Gem::Specification.new do |s|
|
|
71
72
|
lib/jekyll/migrators/mt.rb
|
72
73
|
lib/jekyll/migrators/textpattern.rb
|
73
74
|
lib/jekyll/migrators/typo.rb
|
75
|
+
lib/jekyll/migrators/wordpress.com.rb
|
74
76
|
lib/jekyll/migrators/wordpress.rb
|
75
77
|
lib/jekyll/page.rb
|
76
78
|
lib/jekyll/plugin.rb
|
@@ -80,6 +82,7 @@ Gem::Specification.new do |s|
|
|
80
82
|
lib/jekyll/tags/highlight.rb
|
81
83
|
lib/jekyll/tags/include.rb
|
82
84
|
test/helper.rb
|
85
|
+
test/source/.htaccess
|
83
86
|
test/source/_includes/sig.markdown
|
84
87
|
test/source/_layouts/default.html
|
85
88
|
test/source/_layouts/simple.html
|
@@ -110,6 +113,7 @@ Gem::Specification.new do |s|
|
|
110
113
|
test/source/category/_posts/2008-9-23-categories.textile
|
111
114
|
test/source/contacts.html
|
112
115
|
test/source/css/screen.css
|
116
|
+
test/source/deal.with.dots.html
|
113
117
|
test/source/foo/_posts/bar/2008-12-12-topical-post.textile
|
114
118
|
test/source/index.html
|
115
119
|
test/source/sitemap.xml
|
@@ -120,6 +124,7 @@ Gem::Specification.new do |s|
|
|
120
124
|
test/test_core_ext.rb
|
121
125
|
test/test_filters.rb
|
122
126
|
test/test_generated_site.rb
|
127
|
+
test/test_kramdown.rb
|
123
128
|
test/test_page.rb
|
124
129
|
test/test_pager.rb
|
125
130
|
test/test_post.rb
|
data/lib/jekyll.rb
CHANGED
@@ -45,7 +45,7 @@ require_all 'jekyll/generators'
|
|
45
45
|
require_all 'jekyll/tags'
|
46
46
|
|
47
47
|
module Jekyll
|
48
|
-
VERSION = '0.
|
48
|
+
VERSION = '0.8.0'
|
49
49
|
|
50
50
|
# Default options. Overriden by values in _config.yml or command-line opts.
|
51
51
|
# (Strings rather symbols used for compatability with YAML).
|
@@ -74,6 +74,22 @@ module Jekyll
|
|
74
74
|
},
|
75
75
|
'rdiscount' => {
|
76
76
|
'extensions' => []
|
77
|
+
},
|
78
|
+
'kramdown' => {
|
79
|
+
'auto_ids' => true,
|
80
|
+
'footnote_nr' => 1,
|
81
|
+
'entity_output' => 'as_char',
|
82
|
+
'toc_levels' => '1..6',
|
83
|
+
'use_coderay' => false,
|
84
|
+
|
85
|
+
'coderay' => {
|
86
|
+
'coderay_wrap' => 'div',
|
87
|
+
'coderay_line_numbers' => 'inline',
|
88
|
+
'coderay_line_number_start' => 1,
|
89
|
+
'coderay_tab_width' => 4,
|
90
|
+
'coderay_bold_every' => 10,
|
91
|
+
'coderay_css' => 'style'
|
92
|
+
}
|
77
93
|
}
|
78
94
|
}
|
79
95
|
|
@@ -10,6 +10,14 @@ module Jekyll
|
|
10
10
|
return if @setup
|
11
11
|
# Set the Markdown interpreter (and Maruku self.config, if necessary)
|
12
12
|
case @config['markdown']
|
13
|
+
when 'kramdown'
|
14
|
+
begin
|
15
|
+
require 'kramdown'
|
16
|
+
rescue LoadError
|
17
|
+
STDERR.puts 'You are missing a library required for Markdown. Please run:'
|
18
|
+
STDERR.puts ' $ [sudo] gem install kramdown'
|
19
|
+
raise FatalException.new("Missing dependency: kramdown")
|
20
|
+
end
|
13
21
|
when 'rdiscount'
|
14
22
|
begin
|
15
23
|
require 'rdiscount'
|
@@ -52,7 +60,7 @@ module Jekyll
|
|
52
60
|
end
|
53
61
|
else
|
54
62
|
STDERR.puts "Invalid Markdown processor: #{@config['markdown']}"
|
55
|
-
STDERR.puts " Valid options are [ maruku | rdiscount ]"
|
63
|
+
STDERR.puts " Valid options are [ maruku | rdiscount | kramdown ]"
|
56
64
|
raise FatalException.new("Invalid Markdown process: #{@config['markdown']}")
|
57
65
|
end
|
58
66
|
@setup = true
|
@@ -69,6 +77,31 @@ module Jekyll
|
|
69
77
|
def convert(content)
|
70
78
|
setup
|
71
79
|
case @config['markdown']
|
80
|
+
when 'kramdown'
|
81
|
+
# Check for use of coderay
|
82
|
+
if @config['kramdown']['use_coderay']
|
83
|
+
Kramdown::Document.new(content, {
|
84
|
+
:auto_ids => @config['kramdown']['auto_ids'],
|
85
|
+
:footnote_nr => @config['kramdown']['footnote_nr'],
|
86
|
+
:entity_output => @config['kramdown']['entity_output'],
|
87
|
+
:toc_levels => @config['kramdown']['toc_levels'],
|
88
|
+
|
89
|
+
:coderay_wrap => @config['kramdown']['coderay']['coderay_wrap'],
|
90
|
+
:coderay_line_numbers => @config['kramdown']['coderay']['coderay_line_numbers'],
|
91
|
+
:coderay_line_number_start => @config['kramdown']['coderay']['coderay_line_number_start'],
|
92
|
+
:coderay_tab_width => @config['kramdown']['coderay']['coderay_tab_width'],
|
93
|
+
:coderay_bold_every => @config['kramdown']['coderay']['coderay_bold_every'],
|
94
|
+
:coderay_css => @config['kramdown']['coderay']['coderay_css']
|
95
|
+
}).to_html
|
96
|
+
else
|
97
|
+
# not using coderay
|
98
|
+
Kramdown::Document.new(content, {
|
99
|
+
:auto_ids => @config['kramdown']['auto_ids'],
|
100
|
+
:footnote_nr => @config['kramdown']['footnote_nr'],
|
101
|
+
:entity_output => @config['kramdown']['entity_output'],
|
102
|
+
:toc_levels => @config['kramdown']['toc_levels']
|
103
|
+
}).to_html
|
104
|
+
end
|
72
105
|
when 'rdiscount'
|
73
106
|
RDiscount.new(content, *@rdiscount_extensions).to_html
|
74
107
|
when 'maruku'
|
data/lib/jekyll/filters.rb
CHANGED
@@ -40,7 +40,7 @@ module Jekyll
|
|
40
40
|
QUERY = "SELECT id, permalink, body, published_at, title FROM contents WHERE user_id = 1 AND type = 'Article' AND published_at IS NOT NULL ORDER BY published_at"
|
41
41
|
|
42
42
|
def self.process(dbname, user, pass, host = 'localhost')
|
43
|
-
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
43
|
+
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
|
44
44
|
|
45
45
|
FileUtils.mkdir_p "_posts"
|
46
46
|
|
data/lib/jekyll/migrators/mt.rb
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
require 'rubygems'
|
6
6
|
require 'sequel'
|
7
7
|
require 'fileutils'
|
8
|
+
require 'yaml'
|
8
9
|
|
9
10
|
# NOTE: This converter requires Sequel and the MySQL gems.
|
10
11
|
# The MySQL gem can be difficult to install on OS X. Once you have MySQL
|
@@ -17,19 +18,20 @@ module Jekyll
|
|
17
18
|
# This query will pull blog posts from all entries across all blogs. If
|
18
19
|
# you've got unpublished, deleted or otherwise hidden posts please sift
|
19
20
|
# through the created posts to make sure nothing is accidently published.
|
20
|
-
QUERY = "SELECT entry_id, entry_basename, entry_text, entry_text_more,
|
21
|
+
QUERY = "SELECT entry_id, entry_basename, entry_text, entry_text_more, entry_authored_on, entry_title, entry_convert_breaks FROM mt_entry"
|
21
22
|
|
22
23
|
def self.process(dbname, user, pass, host = 'localhost')
|
23
|
-
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
24
|
+
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
|
24
25
|
|
25
26
|
FileUtils.mkdir_p "_posts"
|
26
27
|
|
27
28
|
db[QUERY].each do |post|
|
28
29
|
title = post[:entry_title]
|
29
|
-
slug = post[:entry_basename]
|
30
|
-
date = post[:
|
30
|
+
slug = post[:entry_basename].gsub(/_/, '-')
|
31
|
+
date = post[:entry_authored_on]
|
31
32
|
content = post[:entry_text]
|
32
33
|
more_content = post[:entry_text_more]
|
34
|
+
entry_convert_breaks = post[:entry_convert_breaks]
|
33
35
|
|
34
36
|
# Be sure to include the body and extended body.
|
35
37
|
if more_content != nil
|
@@ -39,12 +41,13 @@ module Jekyll
|
|
39
41
|
# Ideally, this script would determine the post format (markdown, html
|
40
42
|
# , etc) and create files with proper extensions. At this point it
|
41
43
|
# just assumes that markdown will be acceptable.
|
42
|
-
name = [date.year, date.month, date.day, slug].join('-') +
|
44
|
+
name = [date.year, date.month, date.day, slug].join('-') + '.' + self.suffix(entry_convert_breaks)
|
43
45
|
|
44
46
|
data = {
|
45
47
|
'layout' => 'post',
|
46
48
|
'title' => title.to_s,
|
47
49
|
'mt_id' => post[:entry_id],
|
50
|
+
'date' => date
|
48
51
|
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
|
49
52
|
|
50
53
|
File.open("_posts/#{name}", "w") do |f|
|
@@ -53,7 +56,22 @@ module Jekyll
|
|
53
56
|
f.puts content
|
54
57
|
end
|
55
58
|
end
|
59
|
+
end
|
56
60
|
|
61
|
+
def self.suffix(entry_type)
|
62
|
+
if entry_type.nil? || entry_type.include?("markdown")
|
63
|
+
# The markdown plugin I have saves this as "markdown_with_smarty_pants", so I just look for "markdown".
|
64
|
+
"markdown"
|
65
|
+
elsif entry_type.include?("textile")
|
66
|
+
# This is saved as "textile_2" on my installation of MT 5.1.
|
67
|
+
"textile"
|
68
|
+
elsif entry_type == "0" || entry_type.include?("richtext")
|
69
|
+
# richtext looks to me like it's saved as HTML, so I include it here.
|
70
|
+
"html"
|
71
|
+
else
|
72
|
+
# Other values might need custom work.
|
73
|
+
entry_type
|
74
|
+
end
|
57
75
|
end
|
58
76
|
end
|
59
77
|
end
|
@@ -17,7 +17,7 @@ module Jekyll
|
|
17
17
|
QUERY = "select Title, url_title, Posted, Body, Keywords from textpattern where Status = '4' or Status = '5'"
|
18
18
|
|
19
19
|
def self.process(dbname, user, pass, host = 'localhost')
|
20
|
-
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
20
|
+
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
|
21
21
|
|
22
22
|
FileUtils.mkdir_p "_posts"
|
23
23
|
|
@@ -22,7 +22,7 @@ module Jekyll
|
|
22
22
|
|
23
23
|
def self.process dbname, user, pass, host='localhost'
|
24
24
|
FileUtils.mkdir_p '_posts'
|
25
|
-
db = Sequel.mysql
|
25
|
+
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
|
26
26
|
db[SQL].each do |post|
|
27
27
|
next unless post[:state] =~ /Published/
|
28
28
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'hpricot'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
# This importer takes a wordpress.xml file,
|
6
|
+
# which can be exported from your
|
7
|
+
# wordpress.com blog (/wp-admin/export.php)
|
8
|
+
|
9
|
+
module Jekyll
|
10
|
+
module WordpressDotCom
|
11
|
+
def self.process(filename = "wordpress.xml")
|
12
|
+
FileUtils.mkdir_p "_posts"
|
13
|
+
posts = 0
|
14
|
+
|
15
|
+
doc = Hpricot::XML(File.read(filename))
|
16
|
+
|
17
|
+
(doc/:channel/:item).each do |item|
|
18
|
+
title = item.at(:title).inner_text
|
19
|
+
name = "#{Date.parse((doc/:channel/:item).first.at(:pubDate).inner_text).to_s("%Y-%m-%d")}-#{title.downcase.gsub('[^a-z0-9]', '-')}.html"
|
20
|
+
|
21
|
+
File.open("_posts/#{name}", "w") do |f|
|
22
|
+
f.puts <<-HEADER
|
23
|
+
---
|
24
|
+
layout: post
|
25
|
+
title: #{title}
|
26
|
+
---
|
27
|
+
|
28
|
+
HEADER
|
29
|
+
f.puts item.at('content:encoded').inner_text
|
30
|
+
end
|
31
|
+
|
32
|
+
posts += 1
|
33
|
+
end
|
34
|
+
|
35
|
+
"Imported #{posts} posts"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -19,7 +19,7 @@ module Jekyll
|
|
19
19
|
QUERY = "select post_title, post_name, post_date, post_content, post_excerpt, ID, guid from wp_posts where post_status = 'publish' and post_type = 'post'"
|
20
20
|
|
21
21
|
def self.process(dbname, user, pass, host = 'localhost')
|
22
|
-
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
22
|
+
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
|
23
23
|
|
24
24
|
FileUtils.mkdir_p "_posts"
|
25
25
|
|
data/lib/jekyll/page.rb
CHANGED
data/lib/jekyll/site.rb
CHANGED
@@ -3,7 +3,8 @@ module Jekyll
|
|
3
3
|
class Site
|
4
4
|
attr_accessor :config, :layouts, :posts, :pages, :static_files,
|
5
5
|
:categories, :exclude, :source, :dest, :lsi, :pygments,
|
6
|
-
:permalink_style, :tags, :time, :future, :safe, :plugins
|
6
|
+
:permalink_style, :tags, :time, :future, :safe, :plugins, :limit_posts
|
7
|
+
|
7
8
|
attr_accessor :converters, :generators
|
8
9
|
|
9
10
|
# Initialize the site
|
@@ -22,6 +23,7 @@ module Jekyll
|
|
22
23
|
self.permalink_style = config['permalink'].to_sym
|
23
24
|
self.exclude = config['exclude'] || []
|
24
25
|
self.future = config['future']
|
26
|
+
self.limit_posts = config['limit_posts'] || nil
|
25
27
|
|
26
28
|
self.reset
|
27
29
|
self.setup
|
@@ -39,6 +41,8 @@ module Jekyll
|
|
39
41
|
self.static_files = []
|
40
42
|
self.categories = Hash.new { |hash, key| hash[key] = [] }
|
41
43
|
self.tags = Hash.new { |hash, key| hash[key] = [] }
|
44
|
+
|
45
|
+
raise ArgumentError, "Limit posts must be nil or >= 1" if !self.limit_posts.nil? && self.limit_posts < 1
|
42
46
|
end
|
43
47
|
|
44
48
|
def setup
|
@@ -122,6 +126,9 @@ module Jekyll
|
|
122
126
|
end
|
123
127
|
|
124
128
|
self.posts.sort!
|
129
|
+
|
130
|
+
# limit the posts if :limit_posts option is set
|
131
|
+
self.posts = self.posts[-limit_posts, limit_posts] if limit_posts
|
125
132
|
end
|
126
133
|
|
127
134
|
def generate
|
data/lib/jekyll/tags/include.rb
CHANGED
@@ -7,11 +7,17 @@ module Jekyll
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def render(context)
|
10
|
+
includes_dir = File.join(context.registers[:site].source, '_includes')
|
11
|
+
|
12
|
+
if File.symlink?(includes_dir)
|
13
|
+
return "Includes directory '#{includes_dir}' cannot be a symlink"
|
14
|
+
end
|
15
|
+
|
10
16
|
if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./
|
11
17
|
return "Include file '#{@file}' contains invalid characters or sequences"
|
12
18
|
end
|
13
19
|
|
14
|
-
Dir.chdir(
|
20
|
+
Dir.chdir(includes_dir) do
|
15
21
|
choices = Dir['**/*'].reject { |x| File.symlink?(x) }
|
16
22
|
if choices.include?(@file)
|
17
23
|
source = File.read(@file)
|
data/test/helper.rb
CHANGED
data/test/test_filters.rb
CHANGED
@@ -45,5 +45,9 @@ class TestFilters < Test::Unit::TestCase
|
|
45
45
|
should "escape special characters" do
|
46
46
|
assert_equal "hey%21", @filter.cgi_escape("hey!")
|
47
47
|
end
|
48
|
+
|
49
|
+
should "escape space as %20" do
|
50
|
+
assert_equal "my%20things", @filter.uri_escape("my things")
|
51
|
+
end
|
48
52
|
end
|
49
53
|
end
|
data/test/test_generated_site.rb
CHANGED
@@ -41,4 +41,32 @@ class TestGeneratedSite < Test::Unit::TestCase
|
|
41
41
|
assert File.exists?(dest_dir('/contacts.html'))
|
42
42
|
end
|
43
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
|
44
72
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/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
CHANGED
@@ -16,13 +16,23 @@ class TestPage < Test::Unit::TestCase
|
|
16
16
|
stub(Jekyll).configuration { Jekyll::DEFAULTS }
|
17
17
|
@site = Site.new(Jekyll.configuration)
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
context "processing pages" do
|
21
21
|
should "create url based on filename" do
|
22
22
|
@page = setup_page('contacts.html')
|
23
23
|
assert_equal "/contacts.html", @page.url
|
24
24
|
end
|
25
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
|
+
|
26
36
|
context "with pretty url style" do
|
27
37
|
setup do
|
28
38
|
@site.permalink_style = :pretty
|
@@ -61,7 +71,7 @@ class TestPage < Test::Unit::TestCase
|
|
61
71
|
setup do
|
62
72
|
clear_dest
|
63
73
|
end
|
64
|
-
|
74
|
+
|
65
75
|
should "write properly" do
|
66
76
|
page = setup_page('contacts.html')
|
67
77
|
do_render(page)
|
@@ -73,14 +83,14 @@ class TestPage < Test::Unit::TestCase
|
|
73
83
|
|
74
84
|
should "write properly without html extension" do
|
75
85
|
page = setup_page('contacts.html')
|
76
|
-
page.site.permalink_style = :pretty
|
86
|
+
page.site.permalink_style = :pretty
|
77
87
|
do_render(page)
|
78
88
|
page.write(dest_dir)
|
79
89
|
|
80
90
|
assert File.directory?(dest_dir)
|
81
91
|
assert File.exists?(File.join(dest_dir, 'contacts', 'index.html'))
|
82
92
|
end
|
83
|
-
|
93
|
+
|
84
94
|
should "write properly with extension different from html" do
|
85
95
|
page = setup_page("sitemap.xml")
|
86
96
|
page.site.permalink_style = :pretty
|
@@ -92,7 +102,16 @@ class TestPage < Test::Unit::TestCase
|
|
92
102
|
assert File.directory?(dest_dir)
|
93
103
|
assert File.exists?(File.join(dest_dir,'sitemap.xml'))
|
94
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
|
95
114
|
end
|
96
115
|
|
97
|
-
end
|
116
|
+
end
|
98
117
|
end
|
data/test/test_tags.rb
CHANGED
@@ -112,5 +112,16 @@ CONTENT
|
|
112
112
|
assert_match %r{<em>FINISH HIM</em>}, @result
|
113
113
|
end
|
114
114
|
end
|
115
|
+
|
116
|
+
context "using Kramdown" do
|
117
|
+
setup do
|
118
|
+
create_post(@content, 'markdown' => 'kramdown')
|
119
|
+
end
|
120
|
+
|
121
|
+
should "parse correctly" do
|
122
|
+
assert_match %r{<em>FIGHT!</em>}, @result
|
123
|
+
assert_match %r{<em>FINISH HIM</em>}, @result
|
124
|
+
end
|
125
|
+
end
|
115
126
|
end
|
116
127
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 63
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 8
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.8.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tom Preston-Werner
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-22 00:00:00 -08:00
|
19
19
|
default_executable: jekyll
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -162,6 +162,22 @@ dependencies:
|
|
162
162
|
version: 4.2.1
|
163
163
|
type: :development
|
164
164
|
version_requirements: *id009
|
165
|
+
- !ruby/object:Gem::Dependency
|
166
|
+
name: kramdown
|
167
|
+
prerelease: false
|
168
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
hash: 47
|
174
|
+
segments:
|
175
|
+
- 0
|
176
|
+
- 12
|
177
|
+
- 0
|
178
|
+
version: 0.12.0
|
179
|
+
type: :development
|
180
|
+
version_requirements: *id010
|
165
181
|
description: Jekyll is a simple, blog aware, static site generator.
|
166
182
|
email: tom@mojombo.com
|
167
183
|
executables:
|
@@ -207,6 +223,7 @@ files:
|
|
207
223
|
- lib/jekyll/migrators/mt.rb
|
208
224
|
- lib/jekyll/migrators/textpattern.rb
|
209
225
|
- lib/jekyll/migrators/typo.rb
|
226
|
+
- lib/jekyll/migrators/wordpress.com.rb
|
210
227
|
- lib/jekyll/migrators/wordpress.rb
|
211
228
|
- lib/jekyll/page.rb
|
212
229
|
- lib/jekyll/plugin.rb
|
@@ -216,6 +233,7 @@ files:
|
|
216
233
|
- lib/jekyll/tags/highlight.rb
|
217
234
|
- lib/jekyll/tags/include.rb
|
218
235
|
- test/helper.rb
|
236
|
+
- test/source/.htaccess
|
219
237
|
- test/source/_includes/sig.markdown
|
220
238
|
- test/source/_layouts/default.html
|
221
239
|
- test/source/_layouts/simple.html
|
@@ -246,6 +264,7 @@ files:
|
|
246
264
|
- test/source/category/_posts/2008-9-23-categories.textile
|
247
265
|
- test/source/contacts.html
|
248
266
|
- test/source/css/screen.css
|
267
|
+
- test/source/deal.with.dots.html
|
249
268
|
- test/source/foo/_posts/bar/2008-12-12-topical-post.textile
|
250
269
|
- test/source/index.html
|
251
270
|
- test/source/sitemap.xml
|
@@ -256,6 +275,7 @@ files:
|
|
256
275
|
- test/test_core_ext.rb
|
257
276
|
- test/test_filters.rb
|
258
277
|
- test/test_generated_site.rb
|
278
|
+
- test/test_kramdown.rb
|
259
279
|
- test/test_page.rb
|
260
280
|
- test/test_pager.rb
|
261
281
|
- test/test_post.rb
|
@@ -301,6 +321,7 @@ test_files:
|
|
301
321
|
- test/test_core_ext.rb
|
302
322
|
- test/test_filters.rb
|
303
323
|
- test/test_generated_site.rb
|
324
|
+
- test/test_kramdown.rb
|
304
325
|
- test/test_page.rb
|
305
326
|
- test/test_pager.rb
|
306
327
|
- test/test_post.rb
|