sixones-jekyll 0.4.1 → 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 +48 -8
- data/Rakefile +91 -0
- data/VERSION.yml +2 -2
- data/bin/jekyll +63 -59
- 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 +9 -7
- 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 +105 -43
- data/lib/jekyll/tags/highlight.rb +12 -9
- data/lib/jekyll/tags/include.rb +5 -5
- data/lib/jekyll.rb +50 -34
- 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 +31 -31
- data/test/test_generated_site.rb +31 -25
- data/test/test_post.rb +129 -119
- data/test/test_site.rb +49 -37
- data/test/test_tags.rb +17 -13
- metadata +19 -68
- data/lib/jekyll/custom_filters.rb +0 -13
- 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,44 @@ 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
|
+
custom_filters: false
|
204
|
+
|
205
|
+
maruku:
|
206
|
+
use_tex: false
|
207
|
+
use_divs: false
|
208
|
+
png_dir: images/latex
|
209
|
+
png_url: /images/latex
|
210
|
+
|
211
|
+
Parameters set in a configuration file override the default values. Parameters
|
212
|
+
set using command line options override both the default values and those set
|
213
|
+
in a configuration file.
|
214
|
+
|
177
215
|
h2. Data
|
178
216
|
|
179
217
|
Jekyll traverses your site looking for files to process. Any files with YAML
|
@@ -333,12 +371,6 @@ Convert an array into a sentence.
|
|
333
371
|
becomes
|
334
372
|
|
335
373
|
foo, bar, and baz
|
336
|
-
|
337
|
-
h3. Textilize
|
338
|
-
|
339
|
-
Convert a Textile-formatted string into HTML, formatted via RedCloth
|
340
|
-
|
341
|
-
{{ page.excerpt | textilize }}
|
342
374
|
|
343
375
|
h3. Custom Filters
|
344
376
|
|
@@ -367,9 +399,17 @@ You would then be able to use the filter inside your templates:
|
|
367
399
|
|
368
400
|
{{ "arg" | my_filter }}
|
369
401
|
|
370
|
-
Custom filters can be
|
402
|
+
Custom filters can be enable by running Jekyll with the flag:
|
371
403
|
|
372
|
-
$ jekyll --
|
404
|
+
$ jekyll --custom-filters
|
405
|
+
|
406
|
+
You can also use the <code>custom_filters</code> property in the YML config.
|
407
|
+
|
408
|
+
h3. Textilize
|
409
|
+
|
410
|
+
Convert a Textile-formatted string into HTML, formatted via RedCloth
|
411
|
+
|
412
|
+
{{ page.excerpt | textilize }}
|
373
413
|
|
374
414
|
h3. Include (Tag)
|
375
415
|
|
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,66 +9,82 @@ 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
|
26
28
|
end
|
27
|
-
|
29
|
+
|
30
|
+
opts.on("--no-auto", "No auto-regenerate") do
|
31
|
+
options['auto'] = false
|
32
|
+
end
|
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
|
-
opts.on("--
|
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
|
47
|
+
opts.on("--custom-filters", "Use custom filters in the _filters dir") do
|
48
|
+
options['custom_filters'] = true
|
49
49
|
end
|
50
|
-
|
51
|
-
opts.on("--
|
52
|
-
|
50
|
+
|
51
|
+
opts.on("--rdiscount", "Use rdiscount gem for Markdown") do
|
52
|
+
options['markdown'] = 'rdiscount'
|
53
53
|
end
|
54
|
-
|
55
|
-
opts.on("--
|
56
|
-
|
54
|
+
|
55
|
+
opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
|
56
|
+
options['permalink'] = style unless style.nil?
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
opts.on("--version", "Display current version") do
|
60
60
|
puts "Jekyll " + Jekyll.version
|
61
61
|
exit 0
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
+
# Read command line options into `options` hash
|
65
66
|
opts.parse!
|
66
67
|
|
67
|
-
|
68
|
-
|
69
|
-
|
68
|
+
# Get source and destintation from command line
|
69
|
+
case ARGV.size
|
70
|
+
when 0
|
71
|
+
when 1
|
72
|
+
options['destination'] = ARGV[0]
|
73
|
+
when 2
|
74
|
+
options['source'] = ARGV[0]
|
75
|
+
options['destination'] = ARGV[1]
|
76
|
+
else
|
77
|
+
puts "Invalid options. Run `jekyll --help` for assistance."
|
78
|
+
exit(1)
|
70
79
|
end
|
71
80
|
|
81
|
+
options = Jekyll.configuration(options)
|
82
|
+
|
83
|
+
# Get source and destination directories (possibly set by config file)
|
84
|
+
source = options['source']
|
85
|
+
destination = options['destination']
|
86
|
+
|
87
|
+
# Files to watch
|
72
88
|
def globs(source)
|
73
89
|
Dir.chdir(source) do
|
74
90
|
dirs = Dir['*'].select { |x| File.directory?(x) }
|
@@ -78,63 +94,51 @@ def globs(source)
|
|
78
94
|
end
|
79
95
|
end
|
80
96
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
case ARGV.size
|
85
|
-
when 0
|
86
|
-
source = '.'
|
87
|
-
destination = File.join('.', '_site')
|
88
|
-
when 1
|
89
|
-
source = '.'
|
90
|
-
destination = ARGV[0]
|
91
|
-
when 2
|
92
|
-
source = ARGV[0]
|
93
|
-
destination = ARGV[1]
|
94
|
-
else
|
95
|
-
puts "Invalid options. Run `jekyll --help` for assistance."
|
96
|
-
exit(1)
|
97
|
-
end
|
97
|
+
# Create the Site
|
98
|
+
site = Jekyll::Site.new(options)
|
98
99
|
|
99
|
-
if
|
100
|
+
# Run the directory watcher for auto-generation, if required
|
101
|
+
if options['auto']
|
100
102
|
require 'directory_watcher'
|
101
103
|
|
102
104
|
puts "Auto-regenerating enabled: #{source} -> #{destination}"
|
103
|
-
|
105
|
+
|
104
106
|
dw = DirectoryWatcher.new(source)
|
105
107
|
dw.interval = 1
|
106
108
|
dw.glob = globs(source)
|
107
|
-
|
109
|
+
|
108
110
|
dw.add_observer do |*args|
|
109
111
|
t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
110
112
|
puts "[#{t}] regeneration: #{args.size} files changed"
|
111
|
-
|
113
|
+
site.process
|
112
114
|
end
|
113
|
-
|
115
|
+
|
114
116
|
dw.start
|
115
|
-
|
116
|
-
unless options[
|
117
|
+
|
118
|
+
unless options['server']
|
117
119
|
loop { sleep 1000 }
|
118
120
|
end
|
119
121
|
else
|
120
|
-
|
121
|
-
|
122
|
+
puts "Building site: #{source} -> #{destination}"
|
123
|
+
site.process
|
124
|
+
puts "Successfully generated site: #{source} -> #{destination}"
|
122
125
|
end
|
123
126
|
|
124
|
-
if
|
127
|
+
# Run the server on the specified port, if required
|
128
|
+
if options['server']
|
125
129
|
require 'webrick'
|
126
130
|
include WEBrick
|
127
|
-
|
131
|
+
|
128
132
|
FileUtils.mkdir_p(destination)
|
129
133
|
|
130
134
|
s = HTTPServer.new(
|
131
|
-
:Port => options[
|
135
|
+
:Port => options['server_port'],
|
132
136
|
:DocumentRoot => destination
|
133
137
|
)
|
134
138
|
t = Thread.new {
|
135
139
|
s.start
|
136
140
|
}
|
137
|
-
|
141
|
+
|
138
142
|
trap("INT") { s.shutdown }
|
139
143
|
t.join()
|
140
144
|
end
|
data/lib/jekyll/albino.rb
CHANGED
@@ -13,7 +13,7 @@ require File.join(File.dirname(__FILE__),"csv.rb")
|
|
13
13
|
# installed, running the following commands should work:
|
14
14
|
# $ sudo gem install sequel
|
15
15
|
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
16
|
-
|
16
|
+
|
17
17
|
module Jekyll
|
18
18
|
module Mephisto
|
19
19
|
#Accepts a hash with database config variables, exports mephisto posts into a csv
|
@@ -38,24 +38,24 @@ module Jekyll
|
|
38
38
|
# through the created posts to make sure nothing is accidently published.
|
39
39
|
|
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
43
|
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
44
|
-
|
44
|
+
|
45
45
|
FileUtils.mkdir_p "_posts"
|
46
|
-
|
46
|
+
|
47
47
|
db[QUERY].each do |post|
|
48
48
|
title = post[:title]
|
49
49
|
slug = post[:permalink]
|
50
50
|
date = post[:published_at]
|
51
51
|
content = post[:body]
|
52
52
|
# more_content = ''
|
53
|
-
|
53
|
+
|
54
54
|
# Be sure to include the body and extended body.
|
55
55
|
# if more_content != nil
|
56
56
|
# content = content + " \n" + more_content
|
57
57
|
# end
|
58
|
-
|
58
|
+
|
59
59
|
# Ideally, this script would determine the post format (markdown, html
|
60
60
|
# , etc) and create files with proper extensions. At this point it
|
61
61
|
# just assumes that markdown will be acceptable.
|
@@ -66,14 +66,14 @@ module Jekyll
|
|
66
66
|
'title' => title.to_s,
|
67
67
|
'mt_id' => post[:entry_id],
|
68
68
|
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
|
69
|
-
|
69
|
+
|
70
70
|
File.open("_posts/#{name}", "w") do |f|
|
71
71
|
f.puts data
|
72
72
|
f.puts "---"
|
73
73
|
f.puts content
|
74
74
|
end
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
data/lib/jekyll/converters/mt.rb
CHANGED
@@ -11,31 +11,31 @@ require 'fileutils'
|
|
11
11
|
# installed, running the following commands should work:
|
12
12
|
# $ sudo gem install sequel
|
13
13
|
# $ sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
|
14
|
-
|
14
|
+
|
15
15
|
module Jekyll
|
16
16
|
module MT
|
17
17
|
# This query will pull blog posts from all entries across all blogs. If
|
18
18
|
# you've got unpublished, deleted or otherwise hidden posts please sift
|
19
19
|
# through the created posts to make sure nothing is accidently published.
|
20
20
|
QUERY = "SELECT entry_id, entry_basename, entry_text, entry_text_more, entry_created_on, entry_title FROM mt_entry"
|
21
|
-
|
21
|
+
|
22
22
|
def self.process(dbname, user, pass, host = 'localhost')
|
23
23
|
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
24
|
-
|
24
|
+
|
25
25
|
FileUtils.mkdir_p "_posts"
|
26
|
-
|
26
|
+
|
27
27
|
db[QUERY].each do |post|
|
28
28
|
title = post[:entry_title]
|
29
29
|
slug = post[:entry_basename]
|
30
30
|
date = post[:entry_created_on]
|
31
31
|
content = post[:entry_text]
|
32
32
|
more_content = post[:entry_text_more]
|
33
|
-
|
33
|
+
|
34
34
|
# Be sure to include the body and extended body.
|
35
35
|
if more_content != nil
|
36
36
|
content = content + " \n" + more_content
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
# Ideally, this script would determine the post format (markdown, html
|
40
40
|
# , etc) and create files with proper extensions. At this point it
|
41
41
|
# just assumes that markdown will be acceptable.
|
@@ -46,14 +46,14 @@ module Jekyll
|
|
46
46
|
'title' => title.to_s,
|
47
47
|
'mt_id' => post[:entry_id],
|
48
48
|
}.delete_if { |k,v| v.nil? || v == ''}.to_yaml
|
49
|
-
|
49
|
+
|
50
50
|
File.open("_posts/#{name}", "w") do |f|
|
51
51
|
f.puts data
|
52
52
|
f.puts "---"
|
53
53
|
f.puts content
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -18,20 +18,20 @@ module Jekyll
|
|
18
18
|
|
19
19
|
def self.process(dbname, user, pass, host = 'localhost')
|
20
20
|
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host)
|
21
|
-
|
21
|
+
|
22
22
|
FileUtils.mkdir_p "_posts"
|
23
|
-
|
23
|
+
|
24
24
|
db[QUERY].each do |post|
|
25
25
|
# Get required fields and construct Jekyll compatible name
|
26
26
|
title = post[:Title]
|
27
27
|
slug = post[:url_title]
|
28
28
|
date = post[:Posted]
|
29
29
|
content = post[:Body]
|
30
|
-
|
30
|
+
|
31
31
|
name = [date.strftime("%Y-%m-%d"), slug].join('-') + ".textile"
|
32
32
|
|
33
33
|
# Get the relevant fields as a hash, delete empty fields and convert
|
34
|
-
# to YAML for the header
|
34
|
+
# to YAML for the header
|
35
35
|
data = {
|
36
36
|
'layout' => 'post',
|
37
37
|
'title' => title.to_s,
|
@@ -2,22 +2,22 @@
|
|
2
2
|
require 'fileutils'
|
3
3
|
require 'rubygems'
|
4
4
|
require 'sequel'
|
5
|
-
|
5
|
+
|
6
6
|
module Jekyll
|
7
7
|
module Typo
|
8
|
-
# this SQL *should* work for both MySQL and PostgreSQL, but I haven't
|
8
|
+
# this SQL *should* work for both MySQL and PostgreSQL, but I haven't
|
9
9
|
# tested PostgreSQL yet (as of 2008-12-16)
|
10
10
|
SQL = <<-EOS
|
11
11
|
SELECT c.id id,
|
12
|
-
c.title title,
|
13
|
-
c.permalink slug,
|
12
|
+
c.title title,
|
13
|
+
c.permalink slug,
|
14
14
|
c.body body,
|
15
|
-
c.published_at date,
|
15
|
+
c.published_at date,
|
16
16
|
c.state state,
|
17
17
|
COALESCE(tf.name, 'html') filter
|
18
|
-
FROM contents c
|
18
|
+
FROM contents c
|
19
19
|
LEFT OUTER JOIN text_filters tf
|
20
|
-
ON c.text_filter_id = tf.id
|
20
|
+
ON c.text_filter_id = tf.id
|
21
21
|
EOS
|
22
22
|
|
23
23
|
def self.process dbname, user, pass, host='localhost'
|
@@ -30,7 +30,7 @@ module Jekyll
|
|
30
30
|
sprintf("%.02d", post[:date].month),
|
31
31
|
sprintf("%.02d", post[:date].day),
|
32
32
|
post[:slug].strip ].join('-')
|
33
|
-
# Can have more than one text filter in this field, but we just want
|
33
|
+
# Can have more than one text filter in this field, but we just want
|
34
34
|
# the first one for this
|
35
35
|
name += '.' + post[:filter].split(' ')[0]
|
36
36
|
|
data/lib/jekyll/convertible.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
+
# Convertible provides methods for converting a pagelike item
|
2
|
+
# from a certain type of markup into actual content
|
3
|
+
#
|
4
|
+
# Requires
|
5
|
+
# self.site -> Jekyll::Site
|
1
6
|
module Jekyll
|
2
7
|
module Convertible
|
3
8
|
# Return the contents as a string
|
4
9
|
def to_s
|
5
10
|
self.content || ''
|
6
11
|
end
|
7
|
-
|
12
|
+
|
8
13
|
# Read the YAML frontmatter
|
9
14
|
# +base+ is the String path to the dir containing the file
|
10
15
|
# +name+ is the String filename of the file
|
@@ -12,58 +17,64 @@ module Jekyll
|
|
12
17
|
# Returns nothing
|
13
18
|
def read_yaml(base, name)
|
14
19
|
self.content = File.read(File.join(base, name))
|
15
|
-
|
20
|
+
|
16
21
|
if self.content =~ /^(---\s*\n.*?)\n---\s*\n/m
|
17
22
|
self.content = self.content[($1.size + 5)..-1]
|
18
|
-
|
23
|
+
|
19
24
|
self.data = YAML.load($1)
|
20
25
|
end
|
21
26
|
end
|
22
|
-
|
27
|
+
|
23
28
|
# Transform the contents based on the file extension.
|
24
29
|
#
|
25
30
|
# Returns nothing
|
26
31
|
def transform
|
27
|
-
case
|
28
|
-
when
|
32
|
+
case self.content_type
|
33
|
+
when 'textile'
|
29
34
|
self.ext = ".html"
|
30
|
-
self.content =
|
31
|
-
when
|
35
|
+
self.content = self.site.textile(self.content)
|
36
|
+
when 'markdown'
|
32
37
|
self.ext = ".html"
|
33
|
-
self.content =
|
38
|
+
self.content = self.site.markdown(self.content)
|
34
39
|
end
|
35
40
|
end
|
36
|
-
|
37
|
-
|
41
|
+
|
42
|
+
# Determine which formatting engine to use based on this convertible's
|
43
|
+
# extension
|
44
|
+
#
|
45
|
+
# Returns one of :textile, :markdown or :unknown
|
46
|
+
def content_type
|
38
47
|
case self.ext[1..-1]
|
39
48
|
when /textile/i
|
40
|
-
return
|
49
|
+
return 'textile'
|
41
50
|
when /markdown/i, /mkdn/i, /md/i
|
42
|
-
return
|
43
|
-
end
|
44
|
-
return
|
51
|
+
return 'markdown'
|
52
|
+
end
|
53
|
+
return 'unknown'
|
45
54
|
end
|
46
|
-
|
55
|
+
|
47
56
|
# Add any necessary layouts to this convertible document
|
48
57
|
# +layouts+ is a Hash of {"name" => "layout"}
|
49
58
|
# +site_payload+ is the site payload hash
|
50
59
|
#
|
51
60
|
# Returns nothing
|
52
61
|
def do_layout(payload, layouts)
|
62
|
+
info = { :filters => [Jekyll::Filters, Jekyll::Filters::Custom.extensions], :registers => { :site => self.site } }
|
63
|
+
|
53
64
|
# render and transform content (this becomes the final content of the object)
|
54
|
-
|
55
|
-
self.content = Liquid::Template.parse(self.content).render(payload,
|
65
|
+
payload["content_type"] = self.content_type
|
66
|
+
self.content = Liquid::Template.parse(self.content).render(payload, info)
|
56
67
|
self.transform
|
57
|
-
|
68
|
+
|
58
69
|
# output keeps track of what will finally be written
|
59
70
|
self.output = self.content
|
60
|
-
|
71
|
+
|
61
72
|
# recursively render layouts
|
62
73
|
layout = layouts[self.data["layout"]]
|
63
74
|
while layout
|
64
75
|
payload = payload.deep_merge({"content" => self.output, "page" => layout.data})
|
65
|
-
self.output = Liquid::Template.parse(layout.content).render(payload,
|
66
|
-
|
76
|
+
self.output = Liquid::Template.parse(layout.content).render(payload, info)
|
77
|
+
|
67
78
|
layout = layouts[layout.data["layout"]]
|
68
79
|
end
|
69
80
|
end
|