matflores-jekyll 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -1
- data/README.textile +37 -0
- data/Rakefile +91 -0
- data/VERSION.yml +2 -2
- data/bin/jekyll +60 -56
- data/lib/jekyll.rb +48 -32
- data/lib/jekyll/albino.rb +1 -1
- data/lib/jekyll/converters/mephisto.rb +8 -8
- data/lib/jekyll/converters/mt.rb +8 -8
- data/lib/jekyll/converters/textpattern.rb +4 -4
- data/lib/jekyll/converters/typo.rb +8 -8
- data/lib/jekyll/converters/wordpress.rb +0 -1
- data/lib/jekyll/convertible.rb +33 -22
- data/lib/jekyll/core_ext.rb +5 -5
- data/lib/jekyll/filters.rb +6 -6
- data/lib/jekyll/layout.rb +9 -6
- data/lib/jekyll/page.rb +13 -10
- data/lib/jekyll/post.rb +37 -33
- data/lib/jekyll/site.rb +92 -27
- data/lib/jekyll/tags/highlight.rb +12 -9
- data/lib/jekyll/tags/include.rb +5 -5
- data/test/helper.rb +15 -5
- 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/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/test_filters.rb +30 -30
- data/test/test_generated_site.rb +58 -55
- data/test/test_post.rb +128 -124
- data/test/test_site.rb +49 -37
- data/test/test_tags.rb +17 -13
- metadata +19 -25
- data/test/test_jekyll.rb +0 -0
data/History.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
==
|
1
|
+
== 0.5.0 / 2009-04-07
|
2
2
|
* Minor Enhancements
|
3
3
|
* Ability to set post categories via YAML [github.com/qrush]
|
4
4
|
* Ability to set prevent a post from publishing via YAML [github.com/qrush]
|
@@ -13,6 +13,8 @@
|
|
13
13
|
* Prevent _posts from being copied to the destination directory [github.com/bdimcheff]
|
14
14
|
* Refactors
|
15
15
|
* Factored the filtering code into a method [github.com/Chrononaut]
|
16
|
+
* Fix tests and convert to Shoulda [github.com/qrush, github.com/technicalpickles]
|
17
|
+
* Add Cucumber acceptance test suite [github.com/qrush, github.com/technicalpickles]
|
16
18
|
|
17
19
|
== 0.4.1
|
18
20
|
* Minor Enhancements
|
data/README.textile
CHANGED
@@ -174,6 +174,43 @@ leaf directory resulting in URLs like 2008/11/17/blogging-like-a-hacker/.
|
|
174
174
|
|
175
175
|
$ jekyll --permalink [date|none|pretty]
|
176
176
|
|
177
|
+
h2. Configuration File
|
178
|
+
|
179
|
+
All of the options listed above can be specified on a site-by-site basis in
|
180
|
+
a '_config.yml' file at the root of the site's source. As the filename
|
181
|
+
suggests, the configuration is given in "YAML":http://www.yaml.org/. As
|
182
|
+
well as all of the options discussed in the last section, there are a few
|
183
|
+
additional options:
|
184
|
+
|
185
|
+
destination: [PATH] # Specify where the site should be rendered
|
186
|
+
markdown: [maruku|rdiscount] # Which markdown renderer to use?
|
187
|
+
|
188
|
+
maruku: # This is a YAML hash for Maruku settings
|
189
|
+
use_divs: [BOOLEAN] # Use the div element Maruku extension
|
190
|
+
use_tex: [BOOLEAN] # Use the LaTeX extension to Maruku
|
191
|
+
png_dir: [PATH] # Where should the math PNGs be stored?
|
192
|
+
png_url: [URL] # A relative URL for the PNGs
|
193
|
+
|
194
|
+
The default configuration is shown below as in YAML format:
|
195
|
+
|
196
|
+
destination: ./_site
|
197
|
+
auto: false
|
198
|
+
lsi: false
|
199
|
+
server_port: 4000
|
200
|
+
pygments: false
|
201
|
+
markdown: maruku
|
202
|
+
permalink: date
|
203
|
+
|
204
|
+
maruku:
|
205
|
+
use_tex: false
|
206
|
+
use_divs: false
|
207
|
+
png_dir: images/latex
|
208
|
+
png_url: /images/latex
|
209
|
+
|
210
|
+
Parameters set in a configuration file override the default values. Parameters
|
211
|
+
set using command line options override both the default values and those set
|
212
|
+
in a configuration file.
|
213
|
+
|
177
214
|
h2. Data
|
178
215
|
|
179
216
|
Jekyll traverses your site looking for files to process. Any files with YAML
|
data/Rakefile
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
begin
|
6
|
+
gem 'jeweler', '>= 0.11.0'
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |s|
|
9
|
+
s.name = "jekyll"
|
10
|
+
s.summary = %Q{Jekyll is a simple, blog aware, static site generator.}
|
11
|
+
s.email = "tom@mojombo.com"
|
12
|
+
s.homepage = "http://github.com/mojombo/jekyll"
|
13
|
+
s.description = "Jekyll is a simple, blog aware, static site generator."
|
14
|
+
s.authors = ["Tom Preston-Werner"]
|
15
|
+
s.rubyforge_project = "jekyll"
|
16
|
+
s.files.exclude 'test/dest'
|
17
|
+
s.test_files.exclude 'test/dest'
|
18
|
+
s.add_dependency('RedCloth', '>= 4.0.4')
|
19
|
+
s.add_dependency('liquid', '>= 1.9.0')
|
20
|
+
s.add_dependency('classifier', '>= 1.3.1')
|
21
|
+
s.add_dependency('maruku', '>= 0.5.9')
|
22
|
+
s.add_dependency('directory_watcher', '>= 1.1.1')
|
23
|
+
s.add_dependency('open4', '>= 0.9.6')
|
24
|
+
end
|
25
|
+
rescue LoadError
|
26
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler --version '>= 0.11.0'"
|
27
|
+
exit(1)
|
28
|
+
end
|
29
|
+
|
30
|
+
Rake::TestTask.new do |t|
|
31
|
+
t.libs << 'lib'
|
32
|
+
t.pattern = 'test/**/test_*.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
Rake::RDocTask.new do |rdoc|
|
37
|
+
rdoc.rdoc_dir = 'rdoc'
|
38
|
+
rdoc.title = 'jekyll'
|
39
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
40
|
+
rdoc.rdoc_files.include('README*')
|
41
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
42
|
+
end
|
43
|
+
|
44
|
+
begin
|
45
|
+
require 'rcov/rcovtask'
|
46
|
+
Rcov::RcovTask.new do |t|
|
47
|
+
t.libs << 'test'
|
48
|
+
t.test_files = FileList['test/**/test_*.rb']
|
49
|
+
t.verbose = true
|
50
|
+
end
|
51
|
+
rescue LoadError
|
52
|
+
end
|
53
|
+
|
54
|
+
task :default => [:test, :features]
|
55
|
+
|
56
|
+
# console
|
57
|
+
|
58
|
+
desc "Open an irb session preloaded with this library"
|
59
|
+
task :console do
|
60
|
+
sh "irb -rubygems -I lib -r jekyll.rb"
|
61
|
+
end
|
62
|
+
|
63
|
+
# converters
|
64
|
+
|
65
|
+
namespace :convert do
|
66
|
+
desc "Migrate from mephisto in the current directory"
|
67
|
+
task :mephisto do
|
68
|
+
sh %q(ruby -r './lib/jekyll/converters/mephisto' -e 'Jekyll::Mephisto.postgres(:database => "#{ENV["DB"]}")')
|
69
|
+
end
|
70
|
+
desc "Migrate from Movable Type in the current directory"
|
71
|
+
task :mt do
|
72
|
+
sh %q(ruby -r './lib/jekyll/converters/mt' -e 'Jekyll::MT.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")')
|
73
|
+
end
|
74
|
+
desc "Migrate from Typo in the current directory"
|
75
|
+
task :typo do
|
76
|
+
sh %q(ruby -r './lib/jekyll/converters/typo' -e 'Jekyll::Typo.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
begin
|
81
|
+
require 'cucumber/rake/task'
|
82
|
+
|
83
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
84
|
+
t.cucumber_opts = "--format pretty"
|
85
|
+
end
|
86
|
+
rescue LoadError
|
87
|
+
desc 'Cucumber rake task not available'
|
88
|
+
task :features do
|
89
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
90
|
+
end
|
91
|
+
end
|
data/VERSION.yml
CHANGED
data/bin/jekyll
CHANGED
@@ -9,62 +9,78 @@ Basic Command Line Usage:
|
|
9
9
|
jekyll # . -> ./_site
|
10
10
|
jekyll <path to write generated site> # . -> <path>
|
11
11
|
jekyll <path to source> <path to write generated site> # <path> -> <path>
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
Configuration is read from '<source>/_config.yaml' but can be overriden
|
14
|
+
using the following options:
|
15
|
+
|
14
16
|
HELP
|
15
17
|
|
16
18
|
require 'optparse'
|
17
19
|
require 'jekyll'
|
18
20
|
|
21
|
+
exec = {}
|
19
22
|
options = {}
|
20
|
-
|
21
23
|
opts = OptionParser.new do |opts|
|
22
24
|
opts.banner = help
|
23
25
|
|
24
26
|
opts.on("--auto", "Auto-regenerate") do
|
25
|
-
options[
|
27
|
+
options['auto'] = true
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on("--no-auto", "No auto-regenerate") do
|
31
|
+
options['auto'] = false
|
26
32
|
end
|
27
|
-
|
33
|
+
|
28
34
|
opts.on("--server [PORT]", "Start web server (default port 4000)") do |port|
|
29
|
-
options[
|
30
|
-
options[
|
35
|
+
options['server'] = true
|
36
|
+
options['server_port'] = port unless port.nil?
|
31
37
|
end
|
32
|
-
|
38
|
+
|
33
39
|
opts.on("--lsi", "Use LSI for better related posts") do
|
34
|
-
|
40
|
+
options['lsi'] = true
|
35
41
|
end
|
36
|
-
|
42
|
+
|
37
43
|
opts.on("--pygments", "Use pygments to highlight code") do
|
38
|
-
|
44
|
+
options['pygments'] = true
|
39
45
|
end
|
40
|
-
|
46
|
+
|
41
47
|
opts.on("--rdiscount", "Use rdiscount gem for Markdown") do
|
42
|
-
|
43
|
-
require 'rdiscount'
|
44
|
-
Jekyll.markdown_proc = Proc.new { |x| RDiscount.new(x).to_html }
|
45
|
-
puts 'Using rdiscount for Markdown'
|
46
|
-
rescue LoadError
|
47
|
-
puts 'You must have the rdiscount gem installed first'
|
48
|
-
end
|
48
|
+
options['markdown'] = 'rdiscount'
|
49
49
|
end
|
50
|
-
|
51
|
-
opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
|
52
|
-
|
50
|
+
|
51
|
+
opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
|
52
|
+
options['permalink'] = style unless style.nil?
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
opts.on("--version", "Display current version") do
|
56
56
|
puts "Jekyll " + Jekyll.version
|
57
57
|
exit 0
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
# Read command line options into `options` hash
|
61
62
|
opts.parse!
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
# Get source and destintation from command line
|
65
|
+
case ARGV.size
|
66
|
+
when 0
|
67
|
+
when 1
|
68
|
+
options['destination'] = ARGV[0]
|
69
|
+
when 2
|
70
|
+
options['source'] = ARGV[0]
|
71
|
+
options['destination'] = ARGV[1]
|
72
|
+
else
|
73
|
+
puts "Invalid options. Run `jekyll --help` for assistance."
|
74
|
+
exit(1)
|
66
75
|
end
|
67
76
|
|
77
|
+
options = Jekyll.configuration(options)
|
78
|
+
|
79
|
+
# Get source and destination directories (possibly set by config file)
|
80
|
+
source = options['source']
|
81
|
+
destination = options['destination']
|
82
|
+
|
83
|
+
# Files to watch
|
68
84
|
def globs(source)
|
69
85
|
Dir.chdir(source) do
|
70
86
|
dirs = Dir['*'].select { |x| File.directory?(x) }
|
@@ -74,63 +90,51 @@ def globs(source)
|
|
74
90
|
end
|
75
91
|
end
|
76
92
|
|
77
|
-
|
78
|
-
|
93
|
+
# Create the Site
|
94
|
+
site = Jekyll::Site.new(options)
|
79
95
|
|
80
|
-
|
81
|
-
|
82
|
-
source = '.'
|
83
|
-
destination = File.join('.', '_site')
|
84
|
-
when 1
|
85
|
-
source = '.'
|
86
|
-
destination = ARGV[0]
|
87
|
-
when 2
|
88
|
-
source = ARGV[0]
|
89
|
-
destination = ARGV[1]
|
90
|
-
else
|
91
|
-
puts "Invalid options. Run `jekyll --help` for assistance."
|
92
|
-
exit(1)
|
93
|
-
end
|
94
|
-
|
95
|
-
if options[:auto]
|
96
|
+
# Run the directory watcher for auto-generation, if required
|
97
|
+
if options['auto']
|
96
98
|
require 'directory_watcher'
|
97
99
|
|
98
100
|
puts "Auto-regenerating enabled: #{source} -> #{destination}"
|
99
|
-
|
101
|
+
|
100
102
|
dw = DirectoryWatcher.new(source)
|
101
103
|
dw.interval = 1
|
102
104
|
dw.glob = globs(source)
|
103
|
-
|
105
|
+
|
104
106
|
dw.add_observer do |*args|
|
105
107
|
t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
106
108
|
puts "[#{t}] regeneration: #{args.size} files changed"
|
107
|
-
|
109
|
+
site.process
|
108
110
|
end
|
109
|
-
|
111
|
+
|
110
112
|
dw.start
|
111
|
-
|
112
|
-
unless options[
|
113
|
+
|
114
|
+
unless options['server']
|
113
115
|
loop { sleep 1000 }
|
114
116
|
end
|
115
117
|
else
|
116
|
-
|
117
|
-
|
118
|
+
puts "Building site: #{source} -> #{destination}"
|
119
|
+
site.process
|
120
|
+
puts "Successfully generated site: #{source} -> #{destination}"
|
118
121
|
end
|
119
122
|
|
120
|
-
if
|
123
|
+
# Run the server on the specified port, if required
|
124
|
+
if options['server']
|
121
125
|
require 'webrick'
|
122
126
|
include WEBrick
|
123
|
-
|
127
|
+
|
124
128
|
FileUtils.mkdir_p(destination)
|
125
129
|
|
126
130
|
s = HTTPServer.new(
|
127
|
-
:Port => options[
|
131
|
+
:Port => options['server_port'],
|
128
132
|
:DocumentRoot => destination
|
129
133
|
)
|
130
134
|
t = Thread.new {
|
131
135
|
s.start
|
132
136
|
}
|
133
|
-
|
137
|
+
|
134
138
|
trap("INT") { s.shutdown }
|
135
139
|
t.join()
|
136
140
|
end
|
data/lib/jekyll.rb
CHANGED
@@ -13,22 +13,6 @@ require 'yaml'
|
|
13
13
|
# 3rd party
|
14
14
|
require 'liquid'
|
15
15
|
require 'redcloth'
|
16
|
-
begin
|
17
|
-
require 'maruku'
|
18
|
-
require 'maruku/ext/math'
|
19
|
-
# Switch off MathML output
|
20
|
-
MaRuKu::Globals[:html_math_output_mathml] = false
|
21
|
-
MaRuKu::Globals[:html_math_engine] = 'none'
|
22
|
-
|
23
|
-
# Turn on math to PNG support with blahtex
|
24
|
-
# Resulting PNGs stored in `images/latex`
|
25
|
-
MaRuKu::Globals[:html_math_output_png] = true
|
26
|
-
MaRuKu::Globals[:html_png_engine] = 'blahtex'
|
27
|
-
MaRuKu::Globals[:html_png_dir] = 'images/latex'
|
28
|
-
MaRuKu::Globals[:html_png_url] = '/images/latex/'
|
29
|
-
rescue LoadError
|
30
|
-
puts "The maruku gem is required for markdown support!"
|
31
|
-
end
|
32
16
|
|
33
17
|
# internal requires
|
34
18
|
require 'jekyll/core_ext'
|
@@ -45,23 +29,55 @@ require 'jekyll/tags/include'
|
|
45
29
|
require 'jekyll/albino'
|
46
30
|
|
47
31
|
module Jekyll
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
32
|
+
# Default options. Overriden by values in _config.yaml or command-line opts.
|
33
|
+
# (Strings rather symbols used for compatability with YAML)
|
34
|
+
DEFAULTS = {
|
35
|
+
'auto' => false,
|
36
|
+
'server' => false,
|
37
|
+
'server_port' => 4000,
|
38
|
+
|
39
|
+
'source' => '.',
|
40
|
+
'destination' => File.join('.', '_site'),
|
41
|
+
|
42
|
+
'lsi' => false,
|
43
|
+
'pygments' => false,
|
44
|
+
'markdown' => 'maruku',
|
45
|
+
'permalink' => 'date',
|
46
|
+
|
47
|
+
'maruku' => {
|
48
|
+
'use_tex' => false,
|
49
|
+
'use_divs' => false,
|
50
|
+
'png_engine' => 'blahtex',
|
51
|
+
'png_dir' => 'images/latex',
|
52
|
+
'png_url' => '/images/latex'
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
# Generate a Jekyll configuration Hash by merging the default options
|
57
|
+
# with anything in _config.yml, and adding the given options on top
|
58
|
+
# +override+ is a Hash of config directives
|
59
|
+
#
|
60
|
+
# Returns Hash
|
61
|
+
def self.configuration(override)
|
62
|
+
# _config.yml may override default source location, but until
|
63
|
+
# then, we need to know where to look for _config.yml
|
64
|
+
source = override['source'] || Jekyll::DEFAULTS['source']
|
65
|
+
|
66
|
+
# Get configuration from <source>/_config.yaml
|
67
|
+
config = {}
|
68
|
+
config_file = File.join(source, '_config.yml')
|
69
|
+
begin
|
70
|
+
config = YAML.load_file(config_file)
|
71
|
+
puts "Configuration from #{config_file}"
|
72
|
+
rescue => err
|
73
|
+
puts "WARNING: Could not read configuration. Using defaults (and options)."
|
74
|
+
puts "\t" + err
|
75
|
+
end
|
76
|
+
|
77
|
+
# Merge DEFAULTS < _config.yml < override
|
78
|
+
Jekyll::DEFAULTS.deep_merge(config).deep_merge(override)
|
63
79
|
end
|
64
|
-
|
80
|
+
|
65
81
|
def self.version
|
66
82
|
yml = YAML.load(File.read(File.join(File.dirname(__FILE__), *%w[.. VERSION.yml])))
|
67
83
|
"#{yml[:major]}.#{yml[:minor]}.#{yml[:patch]}"
|