load plugins under safe mode
This commit is contained in:
parent
31c65c56f4
commit
cb77a5287b
|
@ -1,6 +1,7 @@
|
||||||
== Edge
|
== Edge
|
||||||
* Major Enhancements
|
* Major Enhancements
|
||||||
* Proper plugin system (#19, #100)
|
* Proper plugin system (#19, #100)
|
||||||
|
* Add safe mode so unsafe converters/generators can be added
|
||||||
* Minor Enhancements
|
* Minor Enhancements
|
||||||
* Inclusion/exclusion of future dated posts (#59)
|
* Inclusion/exclusion of future dated posts (#59)
|
||||||
* Generation for a specific time (#59)
|
* Generation for a specific time (#59)
|
||||||
|
|
|
@ -23,6 +23,10 @@ options = {}
|
||||||
opts = OptionParser.new do |opts|
|
opts = OptionParser.new do |opts|
|
||||||
opts.banner = help
|
opts.banner = help
|
||||||
|
|
||||||
|
opts.on("--safe", "Safe mode (default unsafe)") do
|
||||||
|
options['safe'] = true
|
||||||
|
end
|
||||||
|
|
||||||
opts.on("--auto", "Auto-regenerate") do
|
opts.on("--auto", "Auto-regenerate") do
|
||||||
options['auto'] = true
|
options['auto'] = true
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,12 +49,14 @@ module Jekyll
|
||||||
# Default options. Overriden by values in _config.yml or command-line opts.
|
# Default options. Overriden by values in _config.yml or command-line opts.
|
||||||
# (Strings rather symbols used for compatability with YAML).
|
# (Strings rather symbols used for compatability with YAML).
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
|
'safe' => false,
|
||||||
'auto' => false,
|
'auto' => false,
|
||||||
'server' => false,
|
'server' => false,
|
||||||
'server_port' => 4000,
|
'server_port' => 4000,
|
||||||
|
|
||||||
'source' => '.',
|
'source' => '.',
|
||||||
'destination' => File.join('.', '_site'),
|
'destination' => File.join('.', '_site'),
|
||||||
|
'plugins' => File.join('.', '_plugins'),
|
||||||
|
|
||||||
'future' => true,
|
'future' => true,
|
||||||
'lsi' => false,
|
'lsi' => false,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class IdentityConverter < Converter
|
class IdentityConverter < Converter
|
||||||
|
safe true
|
||||||
|
|
||||||
priority :lowest
|
priority :lowest
|
||||||
|
|
||||||
def matches(ext)
|
def matches(ext)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class MarkdownConverter < Converter
|
class MarkdownConverter < Converter
|
||||||
|
safe true
|
||||||
|
|
||||||
pygments_prefix '\n'
|
pygments_prefix '\n'
|
||||||
pygments_suffix '\n'
|
pygments_suffix '\n'
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class TextileConverter < Converter
|
class TextileConverter < Converter
|
||||||
|
safe true
|
||||||
|
|
||||||
pygments_prefix '<notextile>'
|
pygments_prefix '<notextile>'
|
||||||
pygments_suffix '</notextile>'
|
pygments_suffix '</notextile>'
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class Pagination < Generator
|
class Pagination < Generator
|
||||||
|
safe true
|
||||||
|
|
||||||
def generate(site)
|
def generate(site)
|
||||||
site.pages.dup.each do |page|
|
site.pages.dup.each do |page|
|
||||||
|
|
|
@ -25,7 +25,7 @@ module Jekyll
|
||||||
@subclasses ||= []
|
@subclasses ||= []
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get or set the priority of this converter. When called without an
|
# Get or set the priority of this plugin. When called without an
|
||||||
# argument it returns the priority. When an argument is given, it will
|
# argument it returns the priority. When an argument is given, it will
|
||||||
# set the priority.
|
# set the priority.
|
||||||
#
|
#
|
||||||
|
@ -40,6 +40,20 @@ module Jekyll
|
||||||
@priority || :normal
|
@priority || :normal
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Get or set the safety of this plugin. When called without an argument
|
||||||
|
# it returns the safety. When an argument is given, it will set the
|
||||||
|
# safety.
|
||||||
|
#
|
||||||
|
# safe - The Boolean safety (default: nil).
|
||||||
|
#
|
||||||
|
# Returns the safety Boolean.
|
||||||
|
def self.safe(safe = nil)
|
||||||
|
if safe
|
||||||
|
@safe = safe
|
||||||
|
end
|
||||||
|
@safe || false
|
||||||
|
end
|
||||||
|
|
||||||
# Spaceship is priority [higher -> lower]
|
# Spaceship is priority [higher -> lower]
|
||||||
#
|
#
|
||||||
# other - The class to be compared.
|
# other - The class to be compared.
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
module Jekyll
|
module Jekyll
|
||||||
|
|
||||||
class Site
|
class Site
|
||||||
attr_accessor :config, :layouts, :posts, :pages, :static_files, :categories, :exclude,
|
attr_accessor :config, :layouts, :posts, :pages, :static_files,
|
||||||
:source, :dest, :lsi, :pygments, :permalink_style, :tags, :time,
|
:categories, :exclude, :source, :dest, :lsi, :pygments,
|
||||||
:future
|
:permalink_style, :tags, :time, :future, :safe, :plugins
|
||||||
attr_accessor :converters, :generators
|
attr_accessor :converters, :generators
|
||||||
|
|
||||||
# Initialize the site
|
# Initialize the site
|
||||||
|
@ -13,8 +13,10 @@ module Jekyll
|
||||||
def initialize(config)
|
def initialize(config)
|
||||||
self.config = config.clone
|
self.config = config.clone
|
||||||
|
|
||||||
|
self.safe = config['safe']
|
||||||
self.source = File.expand_path(config['source'])
|
self.source = File.expand_path(config['source'])
|
||||||
self.dest = config['destination']
|
self.dest = config['destination']
|
||||||
|
self.plugins = File.expand_path(config['plugins'])
|
||||||
self.lsi = config['lsi']
|
self.lsi = config['lsi']
|
||||||
self.pygments = config['pygments']
|
self.pygments = config['pygments']
|
||||||
self.permalink_style = config['permalink'].to_sym
|
self.permalink_style = config['permalink'].to_sym
|
||||||
|
@ -38,11 +40,23 @@ module Jekyll
|
||||||
def setup
|
def setup
|
||||||
require 'classifier' if self.lsi
|
require 'classifier' if self.lsi
|
||||||
|
|
||||||
self.converters = Jekyll::Converter.subclasses.map do |c|
|
# If safe mode is off, load in any ruby files under the plugins
|
||||||
|
# directory.
|
||||||
|
unless self.safe
|
||||||
|
Dir[File.join(self.plugins, "**/*.rb")].each do |f|
|
||||||
|
require f
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
self.converters = Jekyll::Converter.subclasses.select do |c|
|
||||||
|
!self.safe || c.safe
|
||||||
|
end.map do |c|
|
||||||
c.new(self.config)
|
c.new(self.config)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.generators = Jekyll::Generator.subclasses.map do |c|
|
self.generators = Jekyll::Generator.subclasses.select do |c|
|
||||||
|
!self.safe || c.safe
|
||||||
|
end.map do |c|
|
||||||
c.new(self.config)
|
c.new(self.config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue