Huge refactor to move all config into Jekyll::Site
This commit makes Jekyll threadsafe (or at least makes it possible to be so). It also makes it a ton easier to use Jekyll as a library for scripted site transformation. I did, however, break all the tests. =(
This commit is contained in:
parent
cb13ea3000
commit
73d42b24ad
|
@ -177,7 +177,7 @@ leaf directory resulting in URLs like 2008/11/17/blogging-like-a-hacker/.
|
||||||
h2. Configuration File
|
h2. Configuration File
|
||||||
|
|
||||||
All of the options listed above can be specified on a site-by-site basis in
|
All of the options listed above can be specified on a site-by-site basis in
|
||||||
a '_config.yaml' file at the root of the site's source. As the filename
|
a '_config.yml' file at the root of the site's source. As the filename
|
||||||
suggests, the configuration is given in "YAML":http://www.yaml.org/. As
|
suggests, the configuration is given in "YAML":http://www.yaml.org/. As
|
||||||
well as all of the options discussed in the last section, there are a few
|
well as all of the options discussed in the last section, there are a few
|
||||||
additional options:
|
additional options:
|
||||||
|
|
31
bin/jekyll
31
bin/jekyll
|
@ -61,36 +61,20 @@ end
|
||||||
# Read command line options into `options` hash
|
# Read command line options into `options` hash
|
||||||
opts.parse!
|
opts.parse!
|
||||||
|
|
||||||
# Temporarily set source and destination options to read in config file
|
|
||||||
source = Jekyll::DEFAULTS['source']
|
|
||||||
destination = Jekyll::DEFAULTS['destination']
|
|
||||||
|
|
||||||
# Get source and destintation from command line
|
# Get source and destintation from command line
|
||||||
case ARGV.size
|
case ARGV.size
|
||||||
when 0
|
when 0
|
||||||
when 1
|
when 1
|
||||||
destination = options['destination'] = ARGV[0]
|
options['destination'] = ARGV[0]
|
||||||
when 2
|
when 2
|
||||||
source = options['source'] = ARGV[0]
|
options['source'] = ARGV[0]
|
||||||
destination = options['destination'] = ARGV[1]
|
options['destination'] = ARGV[1]
|
||||||
else
|
else
|
||||||
puts "Invalid options. Run `jekyll --help` for assistance."
|
puts "Invalid options. Run `jekyll --help` for assistance."
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get configuration from <source>/_config.yaml
|
options = Jekyll.configuration(options)
|
||||||
config = {}
|
|
||||||
config_file = File.join(source, '_config.yaml')
|
|
||||||
begin
|
|
||||||
config = YAML.load_file( config_file )
|
|
||||||
puts "Configuration from #{config_file}"
|
|
||||||
rescue => err
|
|
||||||
puts "WARNING: Could not read configuration. Using defaults (and options)."
|
|
||||||
puts "\t" + err
|
|
||||||
end
|
|
||||||
|
|
||||||
# Merge DEFAULTS < config file < command line options
|
|
||||||
options = Jekyll::DEFAULTS.deep_merge(config).deep_merge(options)
|
|
||||||
|
|
||||||
# Get source and destination directories (possibly set by config file)
|
# Get source and destination directories (possibly set by config file)
|
||||||
source = options['source']
|
source = options['source']
|
||||||
|
@ -106,6 +90,9 @@ def globs(source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Create the Site
|
||||||
|
site = Jekyll::Site.new(options)
|
||||||
|
|
||||||
# Run the directory watcher for auto-generation, if required
|
# Run the directory watcher for auto-generation, if required
|
||||||
if options['auto']
|
if options['auto']
|
||||||
require 'directory_watcher'
|
require 'directory_watcher'
|
||||||
|
@ -119,7 +106,7 @@ if options['auto']
|
||||||
dw.add_observer do |*args|
|
dw.add_observer do |*args|
|
||||||
t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
puts "[#{t}] regeneration: #{args.size} files changed"
|
puts "[#{t}] regeneration: #{args.size} files changed"
|
||||||
Jekyll.process(options)
|
site.process
|
||||||
end
|
end
|
||||||
|
|
||||||
dw.start
|
dw.start
|
||||||
|
@ -129,7 +116,7 @@ if options['auto']
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
puts "Building site: #{source} -> #{destination}"
|
puts "Building site: #{source} -> #{destination}"
|
||||||
Jekyll.process(options)
|
site.process
|
||||||
puts "Successfully generated site: #{source} -> #{destination}"
|
puts "Successfully generated site: #{source} -> #{destination}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,6 @@ require 'jekyll/tags/include'
|
||||||
require 'jekyll/albino'
|
require 'jekyll/albino'
|
||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
VERSION = '0.3.0'
|
|
||||||
|
|
||||||
# Default options. Overriden by values in _config.yaml or command-line opts.
|
# Default options. Overriden by values in _config.yaml or command-line opts.
|
||||||
# (Strings rather symbols used for compatability with YAML)
|
# (Strings rather symbols used for compatability with YAML)
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
|
@ -53,80 +51,29 @@ module Jekyll
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class << self
|
# Generate a Jekyll configuration Hash by merging the default options
|
||||||
attr_accessor :source,:dest,:lsi,:pygments,:permalink_style
|
# with anything in _config.yml, and adding the given options on top
|
||||||
end
|
# +override+ is a Hash of config directives
|
||||||
|
#
|
||||||
|
# Returns Hash
|
||||||
|
def self.configuration(override)
|
||||||
|
# _config.yml may override default source location, but until
|
||||||
|
# then, we need to know where to look for _config.yml
|
||||||
|
source = override['source'] || Jekyll::DEFAULTS['source']
|
||||||
|
|
||||||
# Initializes some global Jekyll parameters
|
# Get configuration from <source>/_config.yaml
|
||||||
def self.configure(options)
|
config = {}
|
||||||
# Interpret the simple options and configure Jekyll appropriately
|
config_file = File.join(source, '_config.yml')
|
||||||
Jekyll.source = options['source']
|
begin
|
||||||
Jekyll.dest = options['destination']
|
config = YAML.load_file(config_file)
|
||||||
Jekyll.lsi = options['lsi']
|
puts "Configuration from #{config_file}"
|
||||||
Jekyll.pygments = options['pygments']
|
rescue => err
|
||||||
Jekyll.permalink_style = options['permalink'].to_sym
|
puts "WARNING: Could not read configuration. Using defaults (and options)."
|
||||||
|
puts "\t" + err
|
||||||
# Check to see if LSI is enabled.
|
|
||||||
require 'classifier' if Jekyll.lsi
|
|
||||||
|
|
||||||
# Set the Markdown interpreter (and Maruku options, if necessary)
|
|
||||||
case options['markdown']
|
|
||||||
|
|
||||||
when 'rdiscount'
|
|
||||||
begin
|
|
||||||
require 'rdiscount'
|
|
||||||
|
|
||||||
def self.markdown(content)
|
|
||||||
RDiscount.new(content).to_html
|
|
||||||
end
|
|
||||||
|
|
||||||
puts 'Using rdiscount for Markdown'
|
|
||||||
rescue LoadError
|
|
||||||
puts 'You must have the rdiscount gem installed first'
|
|
||||||
end
|
|
||||||
|
|
||||||
when 'maruku'
|
|
||||||
begin
|
|
||||||
require 'maruku'
|
|
||||||
|
|
||||||
def self.markdown(content)
|
|
||||||
Maruku.new(content).to_html
|
|
||||||
end
|
|
||||||
|
|
||||||
if options['maruku']['use_divs']
|
|
||||||
require 'maruku/ext/div'
|
|
||||||
puts 'Maruku: Using extended syntax for div elements.'
|
|
||||||
end
|
|
||||||
|
|
||||||
if options['maruku']['use_tex']
|
|
||||||
require 'maruku/ext/math'
|
|
||||||
puts "Maruku: Using LaTeX extension. Images in `#{options['maruku']['png_dir']}`."
|
|
||||||
|
|
||||||
# Switch off MathML output
|
|
||||||
MaRuKu::Globals[:html_math_output_mathml] = false
|
|
||||||
MaRuKu::Globals[:html_math_engine] = 'none'
|
|
||||||
|
|
||||||
# Turn on math to PNG support with blahtex
|
|
||||||
# Resulting PNGs stored in `images/latex`
|
|
||||||
MaRuKu::Globals[:html_math_output_png] = true
|
|
||||||
MaRuKu::Globals[:html_png_engine] = options['maruku']['png_engine']
|
|
||||||
MaRuKu::Globals[:html_png_dir] = options['maruku']['png_dir']
|
|
||||||
MaRuKu::Globals[:html_png_url] = options['maruku']['png_url']
|
|
||||||
end
|
|
||||||
rescue LoadError
|
|
||||||
puts "The maruku gem is required for markdown support!"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
# Merge DEFAULTS < _config.yml < override
|
||||||
|
Jekyll::DEFAULTS.deep_merge(config).deep_merge(override)
|
||||||
def self.textile(content)
|
|
||||||
RedCloth.new(content).to_html
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.process(config)
|
|
||||||
Jekyll.configure(config)
|
|
||||||
Jekyll::Site.new(config).process
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.version
|
def self.version
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
# Convertible provides methods for converting a pagelike item
|
||||||
|
# from a certain type of markup into actual content
|
||||||
|
#
|
||||||
|
# Requires
|
||||||
|
# self.site -> Jekyll::Site
|
||||||
module Jekyll
|
module Jekyll
|
||||||
module Convertible
|
module Convertible
|
||||||
# Return the contents as a string
|
# Return the contents as a string
|
||||||
|
@ -27,10 +32,10 @@ module Jekyll
|
||||||
case self.content_type
|
case self.content_type
|
||||||
when 'textile'
|
when 'textile'
|
||||||
self.ext = ".html"
|
self.ext = ".html"
|
||||||
self.content = Jekyll.textile(self.content)
|
self.content = self.site.textile(self.content)
|
||||||
when 'markdown'
|
when 'markdown'
|
||||||
self.ext = ".html"
|
self.ext = ".html"
|
||||||
self.content = Jekyll.markdown(self.content)
|
self.content = self.site.markdown(self.content)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,9 +59,11 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns nothing
|
# Returns nothing
|
||||||
def do_layout(payload, layouts)
|
def do_layout(payload, layouts)
|
||||||
|
info = { :filters => [Jekyll::Filters], :registers => { :site => self.site } }
|
||||||
|
|
||||||
# render and transform content (this becomes the final content of the object)
|
# render and transform content (this becomes the final content of the object)
|
||||||
payload["content_type"] = self.content_type
|
payload["content_type"] = self.content_type
|
||||||
self.content = Liquid::Template.parse(self.content).render(payload, [Jekyll::Filters])
|
self.content = Liquid::Template.parse(self.content).render(payload, info)
|
||||||
self.transform
|
self.transform
|
||||||
|
|
||||||
# output keeps track of what will finally be written
|
# output keeps track of what will finally be written
|
||||||
|
@ -66,7 +73,7 @@ module Jekyll
|
||||||
layout = layouts[self.data["layout"]]
|
layout = layouts[self.data["layout"]]
|
||||||
while layout
|
while layout
|
||||||
payload = payload.deep_merge({"content" => self.output, "page" => layout.data})
|
payload = payload.deep_merge({"content" => self.output, "page" => layout.data})
|
||||||
self.output = Liquid::Template.parse(layout.content).render(payload, [Jekyll::Filters])
|
self.output = Liquid::Template.parse(layout.content).render(payload, info)
|
||||||
|
|
||||||
layout = layouts[layout.data["layout"]]
|
layout = layouts[layout.data["layout"]]
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,15 +3,18 @@ module Jekyll
|
||||||
class Layout
|
class Layout
|
||||||
include Convertible
|
include Convertible
|
||||||
|
|
||||||
|
attr_accessor :site
|
||||||
attr_accessor :ext
|
attr_accessor :ext
|
||||||
attr_accessor :data, :content
|
attr_accessor :data, :content
|
||||||
|
|
||||||
# Initialize a new Layout.
|
# Initialize a new Layout.
|
||||||
|
# +site+ is the Site
|
||||||
# +base+ is the String path to the <source>
|
# +base+ is the String path to the <source>
|
||||||
# +name+ is the String filename of the post file
|
# +name+ is the String filename of the post file
|
||||||
#
|
#
|
||||||
# Returns <Page>
|
# Returns <Page>
|
||||||
def initialize(base, name)
|
def initialize(site, base, name)
|
||||||
|
@site = site
|
||||||
@base = base
|
@base = base
|
||||||
@name = name
|
@name = name
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,19 @@ module Jekyll
|
||||||
class Page
|
class Page
|
||||||
include Convertible
|
include Convertible
|
||||||
|
|
||||||
|
attr_accessor :site
|
||||||
attr_accessor :ext
|
attr_accessor :ext
|
||||||
attr_accessor :data, :content, :output
|
attr_accessor :data, :content, :output
|
||||||
|
|
||||||
# Initialize a new Page.
|
# Initialize a new Page.
|
||||||
|
# +site+ is the Site
|
||||||
# +base+ is the String path to the <source>
|
# +base+ is the String path to the <source>
|
||||||
# +dir+ is the String path between <source> and the file
|
# +dir+ is the String path between <source> and the file
|
||||||
# +name+ is the String filename of the file
|
# +name+ is the String filename of the file
|
||||||
#
|
#
|
||||||
# Returns <Page>
|
# Returns <Page>
|
||||||
def initialize(base, dir, name)
|
def initialize(site, base, dir, name)
|
||||||
|
@site = site
|
||||||
@base = base
|
@base = base
|
||||||
@dir = dir
|
@dir = dir
|
||||||
@name = name
|
@name = name
|
||||||
|
|
|
@ -18,16 +18,19 @@ module Jekyll
|
||||||
name =~ MATCHER
|
name =~ MATCHER
|
||||||
end
|
end
|
||||||
|
|
||||||
|
attr_accessor :site
|
||||||
attr_accessor :date, :slug, :ext, :categories, :topics, :published
|
attr_accessor :date, :slug, :ext, :categories, :topics, :published
|
||||||
attr_accessor :data, :content, :output
|
attr_accessor :data, :content, :output
|
||||||
|
|
||||||
# Initialize this Post instance.
|
# Initialize this Post instance.
|
||||||
|
# +site+ is the Site
|
||||||
# +base+ is the String path to the dir containing the post file
|
# +base+ is the String path to the dir containing the post file
|
||||||
# +name+ is the String filename of the post file
|
# +name+ is the String filename of the post file
|
||||||
# +categories+ is an Array of Strings for the categories for this post
|
# +categories+ is an Array of Strings for the categories for this post
|
||||||
#
|
#
|
||||||
# Returns <Post>
|
# Returns <Post>
|
||||||
def initialize(source, dir, name)
|
def initialize(site, source, dir, name)
|
||||||
|
@site = site
|
||||||
@base = File.join(source, dir, '_posts')
|
@base = File.join(source, dir, '_posts')
|
||||||
@name = name
|
@name = name
|
||||||
|
|
||||||
|
@ -39,11 +42,11 @@ module Jekyll
|
||||||
self.process(name)
|
self.process(name)
|
||||||
self.read_yaml(@base, name)
|
self.read_yaml(@base, name)
|
||||||
|
|
||||||
if self.data.has_key?('published') && self.data['published'] == false
|
if self.data.has_key?('published') && self.data['published'] == false
|
||||||
self.published = false
|
self.published = false
|
||||||
else
|
else
|
||||||
self.published = true
|
self.published = true
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.categories.empty?
|
if self.categories.empty?
|
||||||
if self.data.has_key?('category')
|
if self.data.has_key?('category')
|
||||||
|
@ -89,7 +92,7 @@ module Jekyll
|
||||||
permalink.to_s.split("/")[0..-2].join("/") + '/'
|
permalink.to_s.split("/")[0..-2].join("/") + '/'
|
||||||
else
|
else
|
||||||
prefix = self.categories.empty? ? '' : '/' + self.categories.join('/')
|
prefix = self.categories.empty? ? '' : '/' + self.categories.join('/')
|
||||||
if [:date, :pretty].include?(Jekyll.permalink_style)
|
if [:date, :pretty].include?(self.site.permalink_style)
|
||||||
prefix + date.strftime("/%Y/%m/%d/")
|
prefix + date.strftime("/%Y/%m/%d/")
|
||||||
else
|
else
|
||||||
prefix + '/'
|
prefix + '/'
|
||||||
|
@ -111,7 +114,7 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns <String>
|
# Returns <String>
|
||||||
def url
|
def url
|
||||||
ext = Jekyll.permalink_style == :pretty ? '' : '.html'
|
ext = self.site.permalink_style == :pretty ? '' : '.html'
|
||||||
permalink || self.id + ext
|
permalink || self.id + ext
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -129,7 +132,7 @@ module Jekyll
|
||||||
def related_posts(posts)
|
def related_posts(posts)
|
||||||
return [] unless posts.size > 1
|
return [] unless posts.size > 1
|
||||||
|
|
||||||
if Jekyll.lsi
|
if self.site.lsi
|
||||||
self.class.lsi ||= begin
|
self.class.lsi ||= begin
|
||||||
puts "Running the classifier... this could take a while."
|
puts "Running the classifier... this could take a while."
|
||||||
lsi = Classifier::LSI.new
|
lsi = Classifier::LSI.new
|
||||||
|
@ -171,7 +174,7 @@ module Jekyll
|
||||||
|
|
||||||
path = File.join(dest, self.url)
|
path = File.join(dest, self.url)
|
||||||
|
|
||||||
if Jekyll.permalink_style == :pretty
|
if self.site.permalink_style == :pretty
|
||||||
FileUtils.mkdir_p(path)
|
FileUtils.mkdir_p(path)
|
||||||
path = File.join(path, "index.html")
|
path = File.join(path, "index.html")
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,23 +2,83 @@ module Jekyll
|
||||||
|
|
||||||
class Site
|
class Site
|
||||||
attr_accessor :config, :layouts, :posts, :categories
|
attr_accessor :config, :layouts, :posts, :categories
|
||||||
|
attr_accessor :source, :dest, :lsi, :pygments, :permalink_style
|
||||||
|
|
||||||
# Initialize the site
|
# Initialize the site
|
||||||
# +config+ is a Hash containing site configurations details
|
# +config+ is a Hash containing site configurations details
|
||||||
#
|
#
|
||||||
# Returns <Site>
|
# Returns <Site>
|
||||||
def initialize(config)
|
def initialize(config)
|
||||||
self.config = config.clone
|
self.config = config.clone
|
||||||
self.layouts = {}
|
|
||||||
self.posts = []
|
self.source = config['source']
|
||||||
self.categories = Hash.new { |hash, key| hash[key] = Array.new }
|
self.dest = config['destination']
|
||||||
|
self.lsi = config['lsi']
|
||||||
|
self.pygments = config['pygments']
|
||||||
|
self.permalink_style = config['permalink'].to_sym
|
||||||
|
|
||||||
|
self.layouts = {}
|
||||||
|
self.posts = []
|
||||||
|
self.categories = Hash.new { |hash, key| hash[key] = Array.new }
|
||||||
|
|
||||||
|
self.setup
|
||||||
end
|
end
|
||||||
|
|
||||||
# The directory containing the proto-site.
|
def setup
|
||||||
def source; self.config['source']; end
|
# Check to see if LSI is enabled.
|
||||||
|
require 'classifier' if self.lsi
|
||||||
|
|
||||||
# Where the completed site should be written.
|
# Set the Markdown interpreter (and Maruku self.config, if necessary)
|
||||||
def dest; self.config['destination']; end
|
case self.config['markdown']
|
||||||
|
when 'rdiscount'
|
||||||
|
begin
|
||||||
|
require 'rdiscount'
|
||||||
|
|
||||||
|
def markdown(content)
|
||||||
|
RDiscount.new(content).to_html
|
||||||
|
end
|
||||||
|
|
||||||
|
puts 'Using rdiscount for Markdown'
|
||||||
|
rescue LoadError
|
||||||
|
puts 'You must have the rdiscount gem installed first'
|
||||||
|
end
|
||||||
|
when 'maruku'
|
||||||
|
begin
|
||||||
|
require 'maruku'
|
||||||
|
|
||||||
|
def markdown(content)
|
||||||
|
Maruku.new(content).to_html
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.config['maruku']['use_divs']
|
||||||
|
require 'maruku/ext/div'
|
||||||
|
puts 'Maruku: Using extended syntax for div elements.'
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.config['maruku']['use_tex']
|
||||||
|
require 'maruku/ext/math'
|
||||||
|
puts "Maruku: Using LaTeX extension. Images in `#{self.config['maruku']['png_dir']}`."
|
||||||
|
|
||||||
|
# Switch off MathML output
|
||||||
|
MaRuKu::Globals[:html_math_output_mathml] = false
|
||||||
|
MaRuKu::Globals[:html_math_engine] = 'none'
|
||||||
|
|
||||||
|
# Turn on math to PNG support with blahtex
|
||||||
|
# Resulting PNGs stored in `images/latex`
|
||||||
|
MaRuKu::Globals[:html_math_output_png] = true
|
||||||
|
MaRuKu::Globals[:html_png_engine] = self.config['maruku']['png_engine']
|
||||||
|
MaRuKu::Globals[:html_png_dir] = self.config['maruku']['png_dir']
|
||||||
|
MaRuKu::Globals[:html_png_url] = self.config['maruku']['png_url']
|
||||||
|
end
|
||||||
|
rescue LoadError
|
||||||
|
puts "The maruku gem is required for markdown support!"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def textile(content)
|
||||||
|
RedCloth.new(content).to_html
|
||||||
|
end
|
||||||
|
|
||||||
# Do the actual work of processing the site and generating the
|
# Do the actual work of processing the site and generating the
|
||||||
# real deal.
|
# real deal.
|
||||||
|
@ -40,7 +100,7 @@ module Jekyll
|
||||||
|
|
||||||
entries.each do |f|
|
entries.each do |f|
|
||||||
name = f.split(".")[0..-2].join(".")
|
name = f.split(".")[0..-2].join(".")
|
||||||
self.layouts[name] = Layout.new(base, f)
|
self.layouts[name] = Layout.new(self, base, f)
|
||||||
end
|
end
|
||||||
rescue Errno::ENOENT => e
|
rescue Errno::ENOENT => e
|
||||||
# ignore missing layout dir
|
# ignore missing layout dir
|
||||||
|
@ -57,7 +117,7 @@ module Jekyll
|
||||||
# first pass processes, but does not yet render post content
|
# first pass processes, but does not yet render post content
|
||||||
entries.each do |f|
|
entries.each do |f|
|
||||||
if Post.valid?(f)
|
if Post.valid?(f)
|
||||||
post = Post.new(self.source, dir, f)
|
post = Post.new(self, self.source, dir, f)
|
||||||
|
|
||||||
if post.published
|
if post.published
|
||||||
self.posts << post
|
self.posts << post
|
||||||
|
@ -117,7 +177,7 @@ module Jekyll
|
||||||
|
|
||||||
if first3 == "---"
|
if first3 == "---"
|
||||||
# file appears to have a YAML header so process it as a page
|
# file appears to have a YAML header so process it as a page
|
||||||
page = Page.new(self.source, dir, f)
|
page = Page.new(self, self.source, dir, f)
|
||||||
page.render(self.layouts, site_payload)
|
page.render(self.layouts, site_payload)
|
||||||
page.write(self.dest)
|
page.write(self.dest)
|
||||||
else
|
else
|
||||||
|
|
|
@ -2,6 +2,7 @@ module Jekyll
|
||||||
|
|
||||||
class HighlightBlock < Liquid::Block
|
class HighlightBlock < Liquid::Block
|
||||||
include Liquid::StandardFilters
|
include Liquid::StandardFilters
|
||||||
|
|
||||||
# we need a language, but the linenos argument is optional.
|
# we need a language, but the linenos argument is optional.
|
||||||
SYNTAX = /(\w+)\s?(:?linenos)?\s?/
|
SYNTAX = /(\w+)\s?(:?linenos)?\s?/
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def render(context)
|
def render(context)
|
||||||
if Jekyll.pygments
|
if context.registers[:site].pygments
|
||||||
render_pygments(context, super.to_s)
|
render_pygments(context, super.to_s)
|
||||||
else
|
else
|
||||||
render_codehighlighter(context, super.to_s)
|
render_codehighlighter(context, super.to_s)
|
||||||
|
@ -31,7 +32,7 @@ module Jekyll
|
||||||
def render_pygments(context, code)
|
def render_pygments(context, code)
|
||||||
if context["content_type"] == :markdown
|
if context["content_type"] == :markdown
|
||||||
return "\n" + Albino.new(code, @lang).to_s(@options) + "\n"
|
return "\n" + Albino.new(code, @lang).to_s(@options) + "\n"
|
||||||
elsif content["content_type"] == :textile
|
elsif context["content_type"] == :textile
|
||||||
return "<notextile>" + Albino.new(code, @lang).to_s(@options) + "</notextile>"
|
return "<notextile>" + Albino.new(code, @lang).to_s(@options) + "</notextile>"
|
||||||
else
|
else
|
||||||
return Albino.new(code, @lang).to_s(@options)
|
return Albino.new(code, @lang).to_s(@options)
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Jekyll
|
||||||
return "Include file '#{@file}' contains invalid characters or sequences"
|
return "Include file '#{@file}' contains invalid characters or sequences"
|
||||||
end
|
end
|
||||||
|
|
||||||
Dir.chdir(File.join(Jekyll.source, '_includes')) do
|
Dir.chdir(File.join('.', '_includes')) do
|
||||||
choices = Dir['**/*'].reject { |x| File.symlink?(x) }
|
choices = Dir['**/*'].reject { |x| File.symlink?(x) }
|
||||||
if choices.include?(@file)
|
if choices.include?(@file)
|
||||||
source = File.read(@file)
|
source = File.read(@file)
|
||||||
|
|
Loading…
Reference in New Issue