gabrielg-jekyll 0.2.2
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/History.txt +72 -0
- data/Manifest.txt +32 -0
- data/README.textile +378 -0
- data/Rakefile +21 -0
- data/bin/jekyll +130 -0
- data/jekyll.gemspec +51 -0
- data/lib/jekyll.rb +62 -0
- data/lib/jekyll/albino.rb +116 -0
- data/lib/jekyll/converters/csv.rb +26 -0
- data/lib/jekyll/converters/mephisto.rb +24 -0
- data/lib/jekyll/convertible.rb +62 -0
- data/lib/jekyll/filters.rb +24 -0
- data/lib/jekyll/layout.rb +48 -0
- data/lib/jekyll/page.rb +64 -0
- data/lib/jekyll/post.rb +165 -0
- data/lib/jekyll/site.rb +134 -0
- data/lib/jekyll/tags/highlight.rb +37 -0
- data/lib/jekyll/tags/include.rb +27 -0
- data/test/helper.rb +13 -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-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/css/screen.css +76 -0
- data/test/source/index.html +12 -0
- data/test/suite.rb +9 -0
- data/test/test_jekyll.rb +0 -0
- data/test/test_post.rb +95 -0
- data/test/test_site.rb +30 -0
- metadata +151 -0
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'hoe'
|
3
|
+
require 'lib/jekyll'
|
4
|
+
|
5
|
+
Hoe.new('jekyll', Jekyll::VERSION) do |p|
|
6
|
+
p.developer('Tom Preston-Werner', 'tom@mojombo.com')
|
7
|
+
p.summary = "Jekyll is a simple, blog aware, static site generator."
|
8
|
+
p.extra_deps = ['RedCloth', 'liquid', 'classifier', 'maruku', 'directory_watcher', 'open4']
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Open an irb session preloaded with this library"
|
12
|
+
task :console do
|
13
|
+
sh "irb -rubygems -r ./lib/jekyll.rb"
|
14
|
+
end
|
15
|
+
|
16
|
+
namespace :convert do
|
17
|
+
desc "Migrate from mephisto in the current directory"
|
18
|
+
task :mephisto do
|
19
|
+
sh %q(ruby -r './lib/jekyll/converters/mephisto' -e 'Jekyll::Mephisto.postgres(:database => "#{ENV["DB"]}")')
|
20
|
+
end
|
21
|
+
end
|
data/bin/jekyll
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
4
|
+
|
5
|
+
help = <<HELP
|
6
|
+
Jekyll is a blog-aware, static site generator.
|
7
|
+
|
8
|
+
Basic Command Line Usage:
|
9
|
+
jekyll # . -> ./_site
|
10
|
+
jekyll <path to write generated site> # . -> <path>
|
11
|
+
jekyll <path to source> <path to write generated site> # <path> -> <path>
|
12
|
+
|
13
|
+
Options:
|
14
|
+
HELP
|
15
|
+
|
16
|
+
require 'optparse'
|
17
|
+
require 'jekyll'
|
18
|
+
require 'pathname'
|
19
|
+
jekyllrc = Pathname.new(ENV['HOME']) + ".jekyllrc"
|
20
|
+
require jekyllrc.to_s if jekyllrc.exist?
|
21
|
+
|
22
|
+
options = {}
|
23
|
+
|
24
|
+
opts = OptionParser.new do |opts|
|
25
|
+
opts.banner = help
|
26
|
+
|
27
|
+
opts.on("--auto", "Auto-regenerate") do
|
28
|
+
options[:auto] = true
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on("--server [PORT]", "Start web server (default port 4000)") do |port|
|
32
|
+
options[:server] = true
|
33
|
+
options[:server_port] = port || 4000
|
34
|
+
end
|
35
|
+
|
36
|
+
opts.on("--lsi", "Use LSI for better related posts") do
|
37
|
+
Jekyll.lsi = true
|
38
|
+
end
|
39
|
+
|
40
|
+
opts.on("--pygments", "Use pygments to highlight code") do
|
41
|
+
Jekyll.pygments = true
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on("--rdiscount", "Use rdiscount gem for Markdown") do
|
45
|
+
begin
|
46
|
+
require 'rdiscount'
|
47
|
+
Jekyll.markdown_proc = Proc.new { |x| RDiscount.new(x).to_html }
|
48
|
+
puts 'Using rdiscount for Markdown'
|
49
|
+
rescue LoadError
|
50
|
+
puts 'You must have the rdiscount gem installed first'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
opts.parse!
|
56
|
+
|
57
|
+
def clean(dest)
|
58
|
+
FileUtils.rm_rf(dest)
|
59
|
+
FileUtils.mkdir_p(dest)
|
60
|
+
end
|
61
|
+
|
62
|
+
def globs(source)
|
63
|
+
Dir.chdir(source) do
|
64
|
+
dirs = Dir['*'].select { |x| File.directory?(x) }
|
65
|
+
dirs -= ['_site']
|
66
|
+
dirs = dirs.map { |x| "#{x}/**/*" }
|
67
|
+
dirs += ['*']
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
source = nil
|
72
|
+
destination = nil
|
73
|
+
|
74
|
+
case ARGV.size
|
75
|
+
when 0
|
76
|
+
source = '.'
|
77
|
+
destination = File.join('.', '_site')
|
78
|
+
when 1
|
79
|
+
source = '.'
|
80
|
+
destination = ARGV[0]
|
81
|
+
when 2
|
82
|
+
source = ARGV[0]
|
83
|
+
destination = ARGV[1]
|
84
|
+
else
|
85
|
+
puts "Invalid options. Run `jekyll --help` for assistance."
|
86
|
+
exit(1)
|
87
|
+
end
|
88
|
+
|
89
|
+
if options[:auto]
|
90
|
+
require 'directory_watcher'
|
91
|
+
|
92
|
+
puts "Auto-regenerating enabled: #{source} -> #{destination}"
|
93
|
+
|
94
|
+
dw = DirectoryWatcher.new(source)
|
95
|
+
dw.interval = 1
|
96
|
+
dw.glob = globs(source)
|
97
|
+
|
98
|
+
dw.add_observer do |*args|
|
99
|
+
t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
100
|
+
puts "[#{t}] regeneration: #{args.size} files changed"
|
101
|
+
Jekyll.process(source, destination)
|
102
|
+
end
|
103
|
+
|
104
|
+
dw.start
|
105
|
+
|
106
|
+
unless options[:server]
|
107
|
+
loop { sleep 1000 }
|
108
|
+
end
|
109
|
+
else
|
110
|
+
Jekyll.process(source, destination)
|
111
|
+
puts "Successfully generated site in #{destination}"
|
112
|
+
end
|
113
|
+
|
114
|
+
if options[:server]
|
115
|
+
require 'webrick'
|
116
|
+
include WEBrick
|
117
|
+
|
118
|
+
FileUtils.mkdir_p(destination)
|
119
|
+
|
120
|
+
s = HTTPServer.new(
|
121
|
+
:Port => options[:server_port],
|
122
|
+
:DocumentRoot => destination
|
123
|
+
)
|
124
|
+
t = Thread.new {
|
125
|
+
s.start
|
126
|
+
}
|
127
|
+
|
128
|
+
trap("INT") { s.shutdown }
|
129
|
+
t.join()
|
130
|
+
end
|
data/jekyll.gemspec
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = %q{jekyll}
|
3
|
+
s.version = "0.2.2"
|
4
|
+
|
5
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
|
+
s.authors = ["Tom Preston-Werner"]
|
7
|
+
s.date = %q{2008-12-15}
|
8
|
+
s.default_executable = %q{jekyll}
|
9
|
+
s.email = ["tom@mojombo.com"]
|
10
|
+
s.executables = ["jekyll"]
|
11
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt"]
|
12
|
+
s.files = ["History.txt", "Manifest.txt", "README.textile", "Rakefile", "bin/jekyll", "jekyll.gemspec", "lib/jekyll.rb", "lib/jekyll/albino.rb", "lib/jekyll/converters/csv.rb", "lib/jekyll/converters/mephisto.rb", "lib/jekyll/convertible.rb", "lib/jekyll/filters.rb", "lib/jekyll/layout.rb", "lib/jekyll/page.rb", "lib/jekyll/post.rb", "lib/jekyll/site.rb", "lib/jekyll/tags/highlight.rb", "lib/jekyll/tags/include.rb", "test/helper.rb", "test/source/_includes/sig.markdown", "test/source/_layouts/default.html", "test/source/_layouts/simple.html", "test/source/_posts/2008-10-18-foo-bar.textile", "test/source/_posts/2008-11-21-complex.textile", "test/source/_posts/2008-12-13-include.markdown", "test/source/css/screen.css", "test/source/index.html", "test/source/_posts/2008-12-03-permalinked-post.textile", "test/suite.rb", "test/test_jekyll.rb", "test/test_post.rb", "test/test_site.rb"]
|
13
|
+
s.has_rdoc = true
|
14
|
+
s.rdoc_options = ["--main", "README.txt"]
|
15
|
+
s.require_paths = ["lib"]
|
16
|
+
s.rubyforge_project = %q{jekyll}
|
17
|
+
s.rubygems_version = %q{1.3.0}
|
18
|
+
s.summary = %q{Jekyll is a simple, blog aware, static site generator.}
|
19
|
+
s.test_files = ["test/test_jekyll.rb", "test/test_post.rb", "test/test_site.rb"]
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 2
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
s.add_runtime_dependency(%q<RedCloth>, [">= 0"])
|
27
|
+
s.add_runtime_dependency(%q<liquid>, [">= 0"])
|
28
|
+
s.add_runtime_dependency(%q<classifier>, [">= 0"])
|
29
|
+
s.add_runtime_dependency(%q<maruku>, [">= 0"])
|
30
|
+
s.add_runtime_dependency(%q<directory_watcher>, [">= 0"])
|
31
|
+
s.add_runtime_dependency(%q<open4>, [">= 0"])
|
32
|
+
s.add_development_dependency(%q<hoe>, [">= 1.8.0"])
|
33
|
+
else
|
34
|
+
s.add_dependency(%q<RedCloth>, [">= 0"])
|
35
|
+
s.add_dependency(%q<liquid>, [">= 0"])
|
36
|
+
s.add_dependency(%q<classifier>, [">= 0"])
|
37
|
+
s.add_dependency(%q<maruku>, [">= 0"])
|
38
|
+
s.add_dependency(%q<directory_watcher>, [">= 0"])
|
39
|
+
s.add_dependency(%q<open4>, [">= 0"])
|
40
|
+
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
41
|
+
end
|
42
|
+
else
|
43
|
+
s.add_dependency(%q<RedCloth>, [">= 0"])
|
44
|
+
s.add_dependency(%q<liquid>, [">= 0"])
|
45
|
+
s.add_dependency(%q<classifier>, [">= 0"])
|
46
|
+
s.add_dependency(%q<maruku>, [">= 0"])
|
47
|
+
s.add_dependency(%q<directory_watcher>, [">= 0"])
|
48
|
+
s.add_dependency(%q<open4>, [">= 0"])
|
49
|
+
s.add_dependency(%q<hoe>, [">= 1.8.0"])
|
50
|
+
end
|
51
|
+
end
|
data/lib/jekyll.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
|
2
|
+
|
3
|
+
# rubygems
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
# core
|
7
|
+
require 'fileutils'
|
8
|
+
require 'time'
|
9
|
+
require 'yaml'
|
10
|
+
|
11
|
+
# stdlib
|
12
|
+
|
13
|
+
# 3rd party
|
14
|
+
require 'liquid'
|
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
|
+
|
33
|
+
# internal requires
|
34
|
+
require 'jekyll/site'
|
35
|
+
require 'jekyll/convertible'
|
36
|
+
require 'jekyll/layout'
|
37
|
+
require 'jekyll/page'
|
38
|
+
require 'jekyll/post'
|
39
|
+
require 'jekyll/filters'
|
40
|
+
require 'jekyll/tags/highlight'
|
41
|
+
require 'jekyll/tags/include'
|
42
|
+
require 'jekyll/albino'
|
43
|
+
|
44
|
+
module Jekyll
|
45
|
+
VERSION = '0.2.1'
|
46
|
+
|
47
|
+
class << self
|
48
|
+
attr_accessor :source, :dest, :lsi, :pygments, :markdown_proc
|
49
|
+
end
|
50
|
+
|
51
|
+
Jekyll.lsi = false
|
52
|
+
Jekyll.pygments = false
|
53
|
+
Jekyll.markdown_proc = Proc.new { |x| Maruku.new(x).to_html }
|
54
|
+
|
55
|
+
def self.process(source, dest)
|
56
|
+
require 'classifier' if Jekyll.lsi
|
57
|
+
|
58
|
+
Jekyll.source = source
|
59
|
+
Jekyll.dest = dest
|
60
|
+
Jekyll::Site.new(source, dest).process
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
##
|
2
|
+
# Wrapper for the Pygments command line tool, pygmentize.
|
3
|
+
#
|
4
|
+
# Pygments: http://pygments.org/
|
5
|
+
#
|
6
|
+
# Assumes pygmentize is in the path. If not, set its location
|
7
|
+
# with Albino.bin = '/path/to/pygmentize'
|
8
|
+
#
|
9
|
+
# Use like so:
|
10
|
+
#
|
11
|
+
# @syntaxer = Albino.new('/some/file.rb', :ruby)
|
12
|
+
# puts @syntaxer.colorize
|
13
|
+
#
|
14
|
+
# This'll print out an HTMLized, Ruby-highlighted version
|
15
|
+
# of '/some/file.rb'.
|
16
|
+
#
|
17
|
+
# To use another formatter, pass it as the third argument:
|
18
|
+
#
|
19
|
+
# @syntaxer = Albino.new('/some/file.rb', :ruby, :bbcode)
|
20
|
+
# puts @syntaxer.colorize
|
21
|
+
#
|
22
|
+
# You can also use the #colorize class method:
|
23
|
+
#
|
24
|
+
# puts Albino.colorize('/some/file.rb', :ruby)
|
25
|
+
#
|
26
|
+
# Another also: you get a #to_s, for somewhat nicer use in Rails views.
|
27
|
+
#
|
28
|
+
# ... helper file ...
|
29
|
+
# def highlight(text)
|
30
|
+
# Albino.new(text, :ruby)
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# ... view file ...
|
34
|
+
# <%= highlight text %>
|
35
|
+
#
|
36
|
+
# The default lexer is 'text'. You need to specify a lexer yourself;
|
37
|
+
# because we are using STDIN there is no auto-detect.
|
38
|
+
#
|
39
|
+
# To see all lexers and formatters available, run `pygmentize -L`.
|
40
|
+
#
|
41
|
+
# Chris Wanstrath // chris@ozmm.org
|
42
|
+
# GitHub // http://github.com
|
43
|
+
#
|
44
|
+
require 'open4'
|
45
|
+
|
46
|
+
class Albino
|
47
|
+
@@bin = Rails.development? ? 'pygmentize' : '/usr/bin/pygmentize' rescue 'pygmentize'
|
48
|
+
|
49
|
+
def self.bin=(path)
|
50
|
+
@@bin = path
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.colorize(*args)
|
54
|
+
new(*args).colorize
|
55
|
+
end
|
56
|
+
|
57
|
+
def initialize(target, lexer = :text, format = :html)
|
58
|
+
@target = File.exists?(target) ? File.read(target) : target rescue target
|
59
|
+
@options = { :l => lexer, :f => format }
|
60
|
+
end
|
61
|
+
|
62
|
+
def execute(command)
|
63
|
+
pid, stdin, stdout, stderr = Open4.popen4(command)
|
64
|
+
stdin.puts @target
|
65
|
+
stdin.close
|
66
|
+
stdout.read.strip
|
67
|
+
end
|
68
|
+
|
69
|
+
def colorize(options = {})
|
70
|
+
execute @@bin + convert_options(options)
|
71
|
+
end
|
72
|
+
alias_method :to_s, :colorize
|
73
|
+
|
74
|
+
def convert_options(options = {})
|
75
|
+
@options.merge(options).inject('') do |string, (flag, value)|
|
76
|
+
string + " -#{flag} #{value}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
if $0 == __FILE__
|
82
|
+
require 'rubygems'
|
83
|
+
require 'test/spec'
|
84
|
+
require 'mocha'
|
85
|
+
begin require 'redgreen'; rescue LoadError; end
|
86
|
+
|
87
|
+
context "Albino" do
|
88
|
+
setup do
|
89
|
+
@syntaxer = Albino.new(__FILE__, :ruby)
|
90
|
+
end
|
91
|
+
|
92
|
+
specify "defaults to text" do
|
93
|
+
syntaxer = Albino.new(__FILE__)
|
94
|
+
syntaxer.expects(:execute).with('pygmentize -f html -l text').returns(true)
|
95
|
+
syntaxer.colorize
|
96
|
+
end
|
97
|
+
|
98
|
+
specify "accepts options" do
|
99
|
+
@syntaxer.expects(:execute).with('pygmentize -f html -l ruby').returns(true)
|
100
|
+
@syntaxer.colorize
|
101
|
+
end
|
102
|
+
|
103
|
+
specify "works with strings" do
|
104
|
+
syntaxer = Albino.new('class New; end', :ruby)
|
105
|
+
assert_match %r(highlight), syntaxer.colorize
|
106
|
+
end
|
107
|
+
|
108
|
+
specify "aliases to_s" do
|
109
|
+
assert_equal @syntaxer.colorize, @syntaxer.to_s
|
110
|
+
end
|
111
|
+
|
112
|
+
specify "class method colorize" do
|
113
|
+
assert_equal @syntaxer.colorize, Albino.colorize(__FILE__, :ruby)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module CSV
|
3
|
+
#Reads a csv with title, permalink, body, published_at, and filter.
|
4
|
+
#It creates a post file for each row in the csv
|
5
|
+
def self.process(file = "posts.csv")
|
6
|
+
FileUtils.mkdir_p "_posts"
|
7
|
+
posts = 0
|
8
|
+
FasterCSV.foreach(file) do |row|
|
9
|
+
next if row[0] == "title"
|
10
|
+
posts += 1
|
11
|
+
name = row[3].split(" ")[0]+"-"+row[1]+(row[4] =~ /markdown/ ? ".markdown" : ".textile")
|
12
|
+
File.open("_posts/#{name}", "w") do |f|
|
13
|
+
f.puts <<-HEADER
|
14
|
+
---
|
15
|
+
layout: post
|
16
|
+
title: #{row[0]}
|
17
|
+
---
|
18
|
+
|
19
|
+
HEADER
|
20
|
+
f.puts row[2]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
"Created #{posts} posts!"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'fastercsv'
|
3
|
+
require 'fileutils'
|
4
|
+
require File.join(File.dirname(__FILE__),"csv.rb")
|
5
|
+
module Jekyll
|
6
|
+
module Mephisto
|
7
|
+
#Accepts a hash with database config variables, exports mephisto posts into a csv
|
8
|
+
#export PGPASSWORD if you must
|
9
|
+
def self.postgres(c)
|
10
|
+
sql = <<-SQL
|
11
|
+
BEGIN;
|
12
|
+
CREATE TEMP TABLE jekyll AS
|
13
|
+
SELECT title, permalink, body, published_at, filter FROM contents
|
14
|
+
WHERE user_id = 1 AND type = 'Article' ORDER BY published_at;
|
15
|
+
COPY jekyll TO STDOUT WITH CSV HEADER;
|
16
|
+
ROLLBACK;
|
17
|
+
SQL
|
18
|
+
command = %Q(psql -h #{c[:host] || "localhost"} -c "#{sql.strip}" #{c[:database]} #{c[:username]} -o #{c[:filename] || "posts.csv"})
|
19
|
+
puts command
|
20
|
+
`#{command}`
|
21
|
+
CSV.process
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Jekyll
|
2
|
+
module Convertible
|
3
|
+
# Return the contents as a string
|
4
|
+
def to_s
|
5
|
+
self.content || ''
|
6
|
+
end
|
7
|
+
|
8
|
+
# Read the YAML frontmatter
|
9
|
+
# +base+ is the String path to the dir containing the file
|
10
|
+
# +name+ is the String filename of the file
|
11
|
+
#
|
12
|
+
# Returns nothing
|
13
|
+
def read_yaml(base, name)
|
14
|
+
self.content = File.read(File.join(base, name))
|
15
|
+
|
16
|
+
if self.content =~ /^(---\s*\n.*?)\n---\s*\n/m
|
17
|
+
self.content = self.content[($1.size + 5)..-1]
|
18
|
+
|
19
|
+
self.data = YAML.load($1)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Transform the contents based on the file extension.
|
24
|
+
#
|
25
|
+
# Returns nothing
|
26
|
+
def transform
|
27
|
+
case self.ext
|
28
|
+
when ".textile":
|
29
|
+
self.ext = ".html"
|
30
|
+
self.content = RedCloth.new(self.content).to_html
|
31
|
+
when ".markdown":
|
32
|
+
self.ext = ".html"
|
33
|
+
self.content = Jekyll.markdown_proc.call(self.content)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Add any necessary layouts to this convertible document
|
38
|
+
# +layouts+ is a Hash of {"name" => "layout"}
|
39
|
+
# +site_payload+ is the site payload hash
|
40
|
+
#
|
41
|
+
# Returns nothing
|
42
|
+
def do_layout(payload, layouts, site_payload)
|
43
|
+
# construct payload
|
44
|
+
payload = payload.merge(site_payload)
|
45
|
+
# render content
|
46
|
+
self.content = Liquid::Template.parse(self.content).render(payload, [Jekyll::Filters])
|
47
|
+
self.transform
|
48
|
+
|
49
|
+
# output keeps track of what will finally be written
|
50
|
+
self.output = self.content
|
51
|
+
|
52
|
+
# recursively render layouts
|
53
|
+
layout = layouts[self.data["layout"]]
|
54
|
+
while layout
|
55
|
+
payload = payload.merge({"content" => self.output, "page" => payload['page']})
|
56
|
+
self.output = Liquid::Template.parse(layout.content).render(payload, [Jekyll::Filters])
|
57
|
+
|
58
|
+
layout = layouts[layout.data["layout"]]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|