jekyll-reloaded 0.12
Sign up to get free protection for your applications and to get access to all the features.
- 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,118 @@
|
|
1
|
+
module Jekyll
|
2
|
+
|
3
|
+
# Highlights code using Pygments.rb
|
4
|
+
#
|
5
|
+
# The syntax for the tag is "highlight <lang> [<opt>[=<value>], ...]".
|
6
|
+
#
|
7
|
+
# See `pygmentize -L lexers` for the list of available languages.
|
8
|
+
#
|
9
|
+
# Options:
|
10
|
+
#
|
11
|
+
# cssclass - CSS class for the wrapping DIV tag (default: 'highlight')
|
12
|
+
# classprefix - string to prepend to all generated CSS class names
|
13
|
+
# (default: '')
|
14
|
+
# hl_lines - list of lines to be highlighted (default: none)
|
15
|
+
# linenos - show line numbers in "inline" style; when set to "table"
|
16
|
+
# render line numbers in a separate table column
|
17
|
+
# (default: false)
|
18
|
+
# linenostart - initial line number (default: 1)
|
19
|
+
# lineanchors - a string prefix that triggers wrapping each output line
|
20
|
+
# in an anchor tag with name in "<prefix>-<line>" format
|
21
|
+
# (default: none)
|
22
|
+
# anchorlinenos - in combination with `linenos=table` and `lineanchors`, turn
|
23
|
+
# line numbers into links to individual lines (default: false)
|
24
|
+
#
|
25
|
+
# Examples
|
26
|
+
#
|
27
|
+
# {% highlight ruby %}
|
28
|
+
# ... ruby code ...
|
29
|
+
# {% endhighlight %}
|
30
|
+
#
|
31
|
+
# # Show line numbers:
|
32
|
+
# {% highlight js linenos linenostart=5 %}
|
33
|
+
#
|
34
|
+
# # Highlight lines 1,3,5:
|
35
|
+
# {% highlight css hl_lines=1_3_5 %}
|
36
|
+
#
|
37
|
+
class HighlightBlock < Liquid::Block
|
38
|
+
include Liquid::StandardFilters
|
39
|
+
|
40
|
+
# The regular expression syntax checker. Start with the language specifier.
|
41
|
+
# Follow that by zero or more space separated options that take one of two
|
42
|
+
# forms:
|
43
|
+
#
|
44
|
+
# 1. name
|
45
|
+
# 2. name=value
|
46
|
+
SYNTAX = /^([a-zA-Z0-9.+#-]+)((\s+\w+(=[\w-]+)?)*)$/
|
47
|
+
|
48
|
+
def initialize(tag_name, markup, tokens)
|
49
|
+
super
|
50
|
+
@options = { :encoding => 'utf-8' }
|
51
|
+
if markup.strip =~ SYNTAX
|
52
|
+
@lang = $1
|
53
|
+
$2.to_s.split.inject(@options) do |opts, opt|
|
54
|
+
process_option(*opt.split('=', 2)) do |key, value|
|
55
|
+
opts[key] = value
|
56
|
+
end
|
57
|
+
opts
|
58
|
+
end
|
59
|
+
else
|
60
|
+
raise SyntaxError.new("Syntax Error in 'highlight' - Valid syntax: highlight <lang> [linenos]")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Validates option for Pygments.
|
65
|
+
#
|
66
|
+
# Yields key, value if the option has value.
|
67
|
+
#
|
68
|
+
# Raises ArgumentError for unsupported options.
|
69
|
+
def process_option(key, value = nil)
|
70
|
+
case key
|
71
|
+
when 'linenos' then value ||= 'inline'
|
72
|
+
when 'hl_lines' then value = value.to_s.split(/\D/)
|
73
|
+
when 'anchorlinenos' then value ||= true
|
74
|
+
when 'lineanchors', 'linenostart', 'cssclass', 'classprefix'
|
75
|
+
# these have a string value
|
76
|
+
else
|
77
|
+
raise ArgumentError, "unsupported Pygments option: #{key}"
|
78
|
+
end
|
79
|
+
|
80
|
+
yield key, value unless value.nil?
|
81
|
+
end
|
82
|
+
|
83
|
+
def render(context)
|
84
|
+
if context.registers[:site].pygments
|
85
|
+
render_pygments(context, super)
|
86
|
+
else
|
87
|
+
render_codehighlighter(context, super)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def render_pygments(context, code)
|
92
|
+
pretty = Pygments.highlight code, :lexer => @lang, :options => @options
|
93
|
+
output = add_code_tags(pretty, @lang)
|
94
|
+
output = context["pygments_prefix"] + output if context["pygments_prefix"]
|
95
|
+
output = output + context["pygments_suffix"] if context["pygments_suffix"]
|
96
|
+
output
|
97
|
+
end
|
98
|
+
|
99
|
+
def render_codehighlighter(context, code)
|
100
|
+
#The div is required because RDiscount blows ass
|
101
|
+
<<-HTML
|
102
|
+
<div>
|
103
|
+
<pre><code class='#{@lang}'>#{h(code).strip}</code></pre>
|
104
|
+
</div>
|
105
|
+
HTML
|
106
|
+
end
|
107
|
+
|
108
|
+
def add_code_tags(code, lang)
|
109
|
+
# Add nested <code> tags to code blocks
|
110
|
+
code = code.sub(/<pre>/,'<pre><code class="' + lang + '">')
|
111
|
+
code = code.sub(/<\/pre>/,"</code></pre>")
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
Liquid::Template.register_tag('highlight', Jekyll::HighlightBlock)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Jekyll
|
2
|
+
|
3
|
+
class IncludeTag < Liquid::Tag
|
4
|
+
def initialize(tag_name, file, tokens)
|
5
|
+
super
|
6
|
+
@file = file.strip
|
7
|
+
end
|
8
|
+
|
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
|
+
|
16
|
+
if @file !~ /^[a-zA-Z0-9_\/\.-]+$/ || @file =~ /\.\// || @file =~ /\/\./
|
17
|
+
return "Include file '#{@file}' contains invalid characters or sequences"
|
18
|
+
end
|
19
|
+
|
20
|
+
Dir.chdir(includes_dir) do
|
21
|
+
choices = Dir['**/*'].reject { |x| File.symlink?(x) }
|
22
|
+
if choices.include?(@file)
|
23
|
+
source = File.read(@file)
|
24
|
+
partial = Liquid::Template.parse(source)
|
25
|
+
context.stack do
|
26
|
+
partial.render(context)
|
27
|
+
end
|
28
|
+
else
|
29
|
+
"Included file '#{@file}' not found in _includes directory"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
Liquid::Template.register_tag('include', Jekyll::IncludeTag)
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Jekyll
|
2
|
+
|
3
|
+
class PostComparer
|
4
|
+
MATCHER = /^(?:.+\/)*(\d+-\d+-\d+)-(.*)$/
|
5
|
+
|
6
|
+
attr_accessor :date, :slug
|
7
|
+
|
8
|
+
def initialize(name)
|
9
|
+
_, date, slug = *name.match(MATCHER)
|
10
|
+
@slug = slug
|
11
|
+
@date = Time.parse(date)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class PostUrl < Liquid::Tag
|
16
|
+
def initialize(tag_name, post, tokens)
|
17
|
+
super
|
18
|
+
@orig_post = post.strip
|
19
|
+
@post = PostComparer.new(@orig_post)
|
20
|
+
end
|
21
|
+
|
22
|
+
def render(context)
|
23
|
+
site = context.registers[:site]
|
24
|
+
|
25
|
+
site.posts.each do |p|
|
26
|
+
if p == @post
|
27
|
+
return p.url
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
puts "ERROR: post_url: \"#{@orig_post}\" could not be found"
|
32
|
+
|
33
|
+
return "#"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Liquid::Template.register_tag('post_url', Jekyll::PostUrl)
|
data/lib/jekyll.rb
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
# Require all of the Ruby files in the given directory.
|
2
|
+
#
|
3
|
+
# path - The String relative path from here to the directory.
|
4
|
+
#
|
5
|
+
# Returns nothing.
|
6
|
+
def require_all(path)
|
7
|
+
glob = File.join(File.dirname(__FILE__), path, '*.rb')
|
8
|
+
Dir[glob].each do |f|
|
9
|
+
require f
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# rubygems
|
14
|
+
require 'rubygems'
|
15
|
+
|
16
|
+
# stdlib
|
17
|
+
require 'fileutils'
|
18
|
+
require 'time'
|
19
|
+
require 'yaml'
|
20
|
+
require 'English'
|
21
|
+
|
22
|
+
# 3rd party
|
23
|
+
require 'liquid'
|
24
|
+
require 'maruku'
|
25
|
+
require 'pygments'
|
26
|
+
|
27
|
+
# internal requires
|
28
|
+
require 'jekyll/core_ext'
|
29
|
+
require 'jekyll/site'
|
30
|
+
require 'jekyll/convertible'
|
31
|
+
require 'jekyll/layout'
|
32
|
+
require 'jekyll/page'
|
33
|
+
require 'jekyll/post'
|
34
|
+
require 'jekyll/filters'
|
35
|
+
require 'jekyll/static_file'
|
36
|
+
require 'jekyll/errors'
|
37
|
+
|
38
|
+
# extensions
|
39
|
+
require 'jekyll/plugin'
|
40
|
+
require 'jekyll/converter'
|
41
|
+
require 'jekyll/generator'
|
42
|
+
require_all 'jekyll/converters'
|
43
|
+
require_all 'jekyll/generators'
|
44
|
+
require_all 'jekyll/tags'
|
45
|
+
|
46
|
+
module Jekyll
|
47
|
+
VERSION = '0.12'
|
48
|
+
|
49
|
+
# Default options. Overriden by values in _config.yml or command-line opts.
|
50
|
+
# (Strings rather symbols used for compatability with YAML).
|
51
|
+
DEFAULTS = {
|
52
|
+
'safe' => false,
|
53
|
+
'auto' => false,
|
54
|
+
'server' => false,
|
55
|
+
'server_port' => 4000,
|
56
|
+
|
57
|
+
'source' => Dir.pwd,
|
58
|
+
'destination' => File.join(Dir.pwd, '_site'),
|
59
|
+
'plugins' => File.join(Dir.pwd, '_plugins'),
|
60
|
+
|
61
|
+
'future' => true,
|
62
|
+
'lsi' => false,
|
63
|
+
'pygments' => false,
|
64
|
+
'markdown' => 'maruku',
|
65
|
+
'permalink' => 'date',
|
66
|
+
'include' => ['.htaccess'],
|
67
|
+
|
68
|
+
'markdown_ext' => 'markdown,mkd,mkdn,md',
|
69
|
+
'textile_ext' => 'textile',
|
70
|
+
|
71
|
+
'maruku' => {
|
72
|
+
'use_tex' => false,
|
73
|
+
'use_divs' => false,
|
74
|
+
'png_engine' => 'blahtex',
|
75
|
+
'png_dir' => 'images/latex',
|
76
|
+
'png_url' => '/images/latex'
|
77
|
+
},
|
78
|
+
'rdiscount' => {
|
79
|
+
'extensions' => []
|
80
|
+
},
|
81
|
+
'redcarpet' => {
|
82
|
+
'extensions' => []
|
83
|
+
},
|
84
|
+
'kramdown' => {
|
85
|
+
'auto_ids' => true,
|
86
|
+
'footnote_nr' => 1,
|
87
|
+
'entity_output' => 'as_char',
|
88
|
+
'toc_levels' => '1..6',
|
89
|
+
'use_coderay' => false,
|
90
|
+
|
91
|
+
'coderay' => {
|
92
|
+
'coderay_wrap' => 'div',
|
93
|
+
'coderay_line_numbers' => 'inline',
|
94
|
+
'coderay_line_number_start' => 1,
|
95
|
+
'coderay_tab_width' => 4,
|
96
|
+
'coderay_bold_every' => 10,
|
97
|
+
'coderay_css' => 'style'
|
98
|
+
}
|
99
|
+
},
|
100
|
+
'redcloth' => {
|
101
|
+
'hard_breaks' => true
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
# Public: Generate a Jekyll configuration Hash by merging the default
|
106
|
+
# options with anything in _config.yml, and adding the given options on top.
|
107
|
+
#
|
108
|
+
# override - A Hash of config directives that override any options in both
|
109
|
+
# the defaults and the config file. See Jekyll::DEFAULTS for a
|
110
|
+
# list of option names and their defaults.
|
111
|
+
#
|
112
|
+
# Returns the final configuration Hash.
|
113
|
+
def self.configuration(override)
|
114
|
+
# _config.yml may override default source location, but until
|
115
|
+
# then, we need to know where to look for _config.yml
|
116
|
+
source = override['source'] || Jekyll::DEFAULTS['source']
|
117
|
+
|
118
|
+
# Get configuration from <source>/_config.yml
|
119
|
+
config_file = File.join(source, '_config.yml')
|
120
|
+
begin
|
121
|
+
config = YAML.load_file(config_file)
|
122
|
+
raise "Invalid configuration - #{config_file}" if !config.is_a?(Hash)
|
123
|
+
$stdout.puts "Configuration from #{config_file}"
|
124
|
+
rescue => err
|
125
|
+
$stderr.puts "WARNING: Could not read configuration. " +
|
126
|
+
"Using defaults (and options)."
|
127
|
+
$stderr.puts "\t" + err.to_s
|
128
|
+
config = {}
|
129
|
+
end
|
130
|
+
|
131
|
+
# Merge DEFAULTS < _config.yml < override
|
132
|
+
Jekyll::DEFAULTS.deep_merge(config).deep_merge(override)
|
133
|
+
end
|
134
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'RedCloth', '>= 4.2.1'
|
3
|
+
|
4
|
+
require 'jekyll'
|
5
|
+
|
6
|
+
require 'RedCloth'
|
7
|
+
require 'rdiscount'
|
8
|
+
require 'kramdown'
|
9
|
+
require 'redcarpet'
|
10
|
+
|
11
|
+
require 'redgreen' if RUBY_VERSION < '1.9'
|
12
|
+
require 'shoulda'
|
13
|
+
require 'rr'
|
14
|
+
|
15
|
+
include Jekyll
|
16
|
+
|
17
|
+
# Send STDERR into the void to suppress program output messages
|
18
|
+
STDERR.reopen(test(?e, '/dev/null') ? '/dev/null' : 'NUL:')
|
19
|
+
|
20
|
+
class Test::Unit::TestCase
|
21
|
+
include RR::Adapters::TestUnit
|
22
|
+
|
23
|
+
def dest_dir(*subdirs)
|
24
|
+
File.join(File.dirname(__FILE__), 'dest', *subdirs)
|
25
|
+
end
|
26
|
+
|
27
|
+
def source_dir(*subdirs)
|
28
|
+
File.join(File.dirname(__FILE__), 'source', *subdirs)
|
29
|
+
end
|
30
|
+
|
31
|
+
def clear_dest
|
32
|
+
FileUtils.rm_rf(dest_dir)
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
|
7
|
+
<title>{{ page.title }}</title>
|
8
|
+
<meta name="author" content="<%= @page.author %>" />
|
9
|
+
|
10
|
+
<!-- CodeRay syntax highlighting CSS -->
|
11
|
+
<link rel="stylesheet" href="/css/coderay.css" type="text/css" />
|
12
|
+
|
13
|
+
<!-- Homepage CSS -->
|
14
|
+
<link rel="stylesheet" href="/css/screen.css" type="text/css" media="screen, projection" />
|
15
|
+
</head>
|
16
|
+
<body>
|
17
|
+
|
18
|
+
<div class="site">
|
19
|
+
<div class="title">
|
20
|
+
Tom Preston-Werner
|
21
|
+
</div>
|
22
|
+
|
23
|
+
{{ content }}
|
24
|
+
</div>
|
25
|
+
|
26
|
+
</body>
|
27
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<<< {{ content }} >>>
|
@@ -0,0 +1 @@
|
|
1
|
+
No YAML.
|
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
date: 2011-04-12 13:07:09
|
3
|
+
---
|
4
|
+
|
5
|
+
under default configuration, this post should get processed by the identity converter. By changing
|
6
|
+
textile extension or markdown extension configuration parameters, you should be able to associate
|
7
|
+
it with either of those converters
|
File without changes
|