jekyll 4.2.1 → 4.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +350 -350
- data/LICENSE +21 -21
- data/README.markdown +86 -86
- data/exe/jekyll +57 -57
- data/lib/blank_template/_config.yml +3 -3
- data/lib/blank_template/_layouts/default.html +12 -12
- data/lib/blank_template/_sass/main.scss +9 -9
- data/lib/blank_template/assets/css/main.scss +4 -4
- data/lib/blank_template/index.md +8 -8
- data/lib/jekyll/cache.rb +190 -190
- data/lib/jekyll/cleaner.rb +111 -111
- data/lib/jekyll/collection.rb +309 -309
- data/lib/jekyll/command.rb +105 -105
- data/lib/jekyll/commands/build.rb +93 -93
- data/lib/jekyll/commands/clean.rb +45 -45
- data/lib/jekyll/commands/doctor.rb +177 -177
- data/lib/jekyll/commands/help.rb +34 -34
- data/lib/jekyll/commands/new.rb +172 -169
- data/lib/jekyll/commands/new_theme.rb +40 -40
- data/lib/jekyll/commands/serve/live_reload_reactor.rb +122 -122
- data/lib/jekyll/commands/serve/livereload_assets/livereload.js +1183 -1183
- data/lib/jekyll/commands/serve/servlet.rb +202 -202
- data/lib/jekyll/commands/serve/websockets.rb +81 -81
- data/lib/jekyll/commands/serve.rb +362 -362
- data/lib/jekyll/configuration.rb +313 -313
- data/lib/jekyll/converter.rb +54 -54
- data/lib/jekyll/converters/identity.rb +41 -41
- data/lib/jekyll/converters/markdown/kramdown_parser.rb +199 -199
- data/lib/jekyll/converters/markdown.rb +113 -113
- data/lib/jekyll/converters/smartypants.rb +70 -70
- data/lib/jekyll/convertible.rb +257 -257
- data/lib/jekyll/deprecator.rb +50 -50
- data/lib/jekyll/document.rb +544 -544
- data/lib/jekyll/drops/collection_drop.rb +20 -20
- data/lib/jekyll/drops/document_drop.rb +70 -70
- data/lib/jekyll/drops/drop.rb +293 -293
- data/lib/jekyll/drops/excerpt_drop.rb +19 -19
- data/lib/jekyll/drops/jekyll_drop.rb +32 -32
- data/lib/jekyll/drops/site_drop.rb +66 -66
- data/lib/jekyll/drops/static_file_drop.rb +14 -14
- data/lib/jekyll/drops/unified_payload_drop.rb +26 -26
- data/lib/jekyll/drops/url_drop.rb +140 -140
- data/lib/jekyll/entry_filter.rb +121 -121
- data/lib/jekyll/errors.rb +20 -20
- data/lib/jekyll/excerpt.rb +201 -201
- data/lib/jekyll/external.rb +79 -79
- data/lib/jekyll/filters/date_filters.rb +110 -110
- data/lib/jekyll/filters/grouping_filters.rb +64 -64
- data/lib/jekyll/filters/url_filters.rb +98 -98
- data/lib/jekyll/filters.rb +535 -535
- data/lib/jekyll/frontmatter_defaults.rb +240 -240
- data/lib/jekyll/generator.rb +5 -5
- data/lib/jekyll/hooks.rb +107 -107
- data/lib/jekyll/inclusion.rb +32 -32
- data/lib/jekyll/layout.rb +67 -67
- data/lib/jekyll/liquid_extensions.rb +22 -22
- data/lib/jekyll/liquid_renderer/file.rb +77 -77
- data/lib/jekyll/liquid_renderer/table.rb +55 -55
- data/lib/jekyll/liquid_renderer.rb +80 -80
- data/lib/jekyll/log_adapter.rb +151 -151
- data/lib/jekyll/mime.types +866 -866
- data/lib/jekyll/page.rb +217 -217
- data/lib/jekyll/page_excerpt.rb +25 -25
- data/lib/jekyll/page_without_a_file.rb +14 -14
- data/lib/jekyll/path_manager.rb +74 -74
- data/lib/jekyll/plugin.rb +92 -92
- data/lib/jekyll/plugin_manager.rb +115 -115
- data/lib/jekyll/profiler.rb +58 -58
- data/lib/jekyll/publisher.rb +23 -23
- data/lib/jekyll/reader.rb +192 -192
- data/lib/jekyll/readers/collection_reader.rb +23 -23
- data/lib/jekyll/readers/data_reader.rb +79 -79
- data/lib/jekyll/readers/layout_reader.rb +62 -62
- data/lib/jekyll/readers/page_reader.rb +25 -25
- data/lib/jekyll/readers/post_reader.rb +85 -85
- data/lib/jekyll/readers/static_file_reader.rb +25 -25
- data/lib/jekyll/readers/theme_assets_reader.rb +52 -52
- data/lib/jekyll/regenerator.rb +195 -195
- data/lib/jekyll/related_posts.rb +52 -52
- data/lib/jekyll/renderer.rb +265 -265
- data/lib/jekyll/site.rb +551 -551
- data/lib/jekyll/static_file.rb +208 -208
- data/lib/jekyll/stevenson.rb +60 -60
- data/lib/jekyll/tags/highlight.rb +110 -110
- data/lib/jekyll/tags/include.rb +275 -275
- data/lib/jekyll/tags/link.rb +42 -42
- data/lib/jekyll/tags/post_url.rb +106 -106
- data/lib/jekyll/theme.rb +86 -86
- data/lib/jekyll/theme_builder.rb +121 -121
- data/lib/jekyll/url.rb +167 -167
- data/lib/jekyll/utils/ansi.rb +57 -57
- data/lib/jekyll/utils/exec.rb +26 -26
- data/lib/jekyll/utils/internet.rb +37 -37
- data/lib/jekyll/utils/platforms.rb +67 -67
- data/lib/jekyll/utils/thread_event.rb +31 -31
- data/lib/jekyll/utils/win_tz.rb +75 -75
- data/lib/jekyll/utils.rb +367 -367
- data/lib/jekyll/version.rb +5 -5
- data/lib/jekyll.rb +195 -195
- data/lib/site_template/.gitignore +5 -5
- data/lib/site_template/404.html +25 -25
- data/lib/site_template/_config.yml +55 -55
- data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +29 -29
- data/lib/site_template/about.markdown +18 -18
- data/lib/site_template/index.markdown +6 -6
- data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -74
- data/lib/theme_template/Gemfile +4 -4
- data/lib/theme_template/LICENSE.txt.erb +21 -21
- data/lib/theme_template/README.md.erb +52 -52
- data/lib/theme_template/_layouts/default.html +1 -1
- data/lib/theme_template/_layouts/page.html +5 -5
- data/lib/theme_template/_layouts/post.html +5 -5
- data/lib/theme_template/example/_config.yml.erb +1 -1
- data/lib/theme_template/example/_post.md +12 -12
- data/lib/theme_template/example/index.html +14 -14
- data/lib/theme_template/example/style.scss +7 -7
- data/lib/theme_template/gitignore.erb +6 -6
- data/lib/theme_template/theme.gemspec.erb +16 -16
- data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -149
- data/rubocop/jekyll/no_p_allowed.rb +23 -23
- data/rubocop/jekyll/no_puts_allowed.rb +23 -23
- data/rubocop/jekyll.rb +5 -5
- metadata +3 -3
data/lib/jekyll/plugin.rb
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jekyll
|
|
4
|
-
class Plugin
|
|
5
|
-
PRIORITIES = {
|
|
6
|
-
:low => -10,
|
|
7
|
-
:highest => 100,
|
|
8
|
-
:lowest => -100,
|
|
9
|
-
:normal => 0,
|
|
10
|
-
:high => 10,
|
|
11
|
-
}.freeze
|
|
12
|
-
|
|
13
|
-
#
|
|
14
|
-
|
|
15
|
-
def self.inherited(const)
|
|
16
|
-
catch_inheritance(const) do |const_|
|
|
17
|
-
catch_inheritance(const_)
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
def self.catch_inheritance(const)
|
|
24
|
-
const.define_singleton_method :inherited do |const_|
|
|
25
|
-
(@children ||= Set.new).add const_
|
|
26
|
-
yield const_ if block_given?
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
#
|
|
31
|
-
|
|
32
|
-
def self.descendants
|
|
33
|
-
@children ||= Set.new
|
|
34
|
-
out = @children.map(&:descendants)
|
|
35
|
-
out << self unless superclass == Plugin
|
|
36
|
-
Set.new(out).flatten
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# Get or set the priority of this plugin. When called without an
|
|
40
|
-
# argument it returns the priority. When an argument is given, it will
|
|
41
|
-
# set the priority.
|
|
42
|
-
#
|
|
43
|
-
# priority - The Symbol priority (default: nil). Valid options are:
|
|
44
|
-
# :lowest, :low, :normal, :high, :highest
|
|
45
|
-
#
|
|
46
|
-
# Returns the Symbol priority.
|
|
47
|
-
def self.priority(priority = nil)
|
|
48
|
-
@priority ||= nil
|
|
49
|
-
@priority = priority if priority && PRIORITIES.key?(priority)
|
|
50
|
-
@priority || :normal
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
# Get or set the safety of this plugin. When called without an argument
|
|
54
|
-
# it returns the safety. When an argument is given, it will set the
|
|
55
|
-
# safety.
|
|
56
|
-
#
|
|
57
|
-
# safe - The Boolean safety (default: nil).
|
|
58
|
-
#
|
|
59
|
-
# Returns the safety Boolean.
|
|
60
|
-
def self.safe(safe = nil)
|
|
61
|
-
@safe = safe unless defined?(@safe) && safe.nil?
|
|
62
|
-
@safe || false
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# Spaceship is priority [higher -> lower]
|
|
66
|
-
#
|
|
67
|
-
# other - The class to be compared.
|
|
68
|
-
#
|
|
69
|
-
# Returns -1, 0, 1.
|
|
70
|
-
def self.<=>(other)
|
|
71
|
-
PRIORITIES[other.priority] <=> PRIORITIES[priority]
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
# Spaceship is priority [higher -> lower]
|
|
75
|
-
#
|
|
76
|
-
# other - The class to be compared.
|
|
77
|
-
#
|
|
78
|
-
# Returns -1, 0, 1.
|
|
79
|
-
def <=>(other)
|
|
80
|
-
self.class <=> other.class
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# Initialize a new plugin. This should be overridden by the subclass.
|
|
84
|
-
#
|
|
85
|
-
# config - The Hash of configuration options.
|
|
86
|
-
#
|
|
87
|
-
# Returns a new instance.
|
|
88
|
-
def initialize(config = {})
|
|
89
|
-
# no-op for default
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jekyll
|
|
4
|
+
class Plugin
|
|
5
|
+
PRIORITIES = {
|
|
6
|
+
:low => -10,
|
|
7
|
+
:highest => 100,
|
|
8
|
+
:lowest => -100,
|
|
9
|
+
:normal => 0,
|
|
10
|
+
:high => 10,
|
|
11
|
+
}.freeze
|
|
12
|
+
|
|
13
|
+
#
|
|
14
|
+
|
|
15
|
+
def self.inherited(const)
|
|
16
|
+
catch_inheritance(const) do |const_|
|
|
17
|
+
catch_inheritance(const_)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
#
|
|
22
|
+
|
|
23
|
+
def self.catch_inheritance(const)
|
|
24
|
+
const.define_singleton_method :inherited do |const_|
|
|
25
|
+
(@children ||= Set.new).add const_
|
|
26
|
+
yield const_ if block_given?
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
#
|
|
31
|
+
|
|
32
|
+
def self.descendants
|
|
33
|
+
@children ||= Set.new
|
|
34
|
+
out = @children.map(&:descendants)
|
|
35
|
+
out << self unless superclass == Plugin
|
|
36
|
+
Set.new(out).flatten
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Get or set the priority of this plugin. When called without an
|
|
40
|
+
# argument it returns the priority. When an argument is given, it will
|
|
41
|
+
# set the priority.
|
|
42
|
+
#
|
|
43
|
+
# priority - The Symbol priority (default: nil). Valid options are:
|
|
44
|
+
# :lowest, :low, :normal, :high, :highest
|
|
45
|
+
#
|
|
46
|
+
# Returns the Symbol priority.
|
|
47
|
+
def self.priority(priority = nil)
|
|
48
|
+
@priority ||= nil
|
|
49
|
+
@priority = priority if priority && PRIORITIES.key?(priority)
|
|
50
|
+
@priority || :normal
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Get or set the safety of this plugin. When called without an argument
|
|
54
|
+
# it returns the safety. When an argument is given, it will set the
|
|
55
|
+
# safety.
|
|
56
|
+
#
|
|
57
|
+
# safe - The Boolean safety (default: nil).
|
|
58
|
+
#
|
|
59
|
+
# Returns the safety Boolean.
|
|
60
|
+
def self.safe(safe = nil)
|
|
61
|
+
@safe = safe unless defined?(@safe) && safe.nil?
|
|
62
|
+
@safe || false
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Spaceship is priority [higher -> lower]
|
|
66
|
+
#
|
|
67
|
+
# other - The class to be compared.
|
|
68
|
+
#
|
|
69
|
+
# Returns -1, 0, 1.
|
|
70
|
+
def self.<=>(other)
|
|
71
|
+
PRIORITIES[other.priority] <=> PRIORITIES[priority]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Spaceship is priority [higher -> lower]
|
|
75
|
+
#
|
|
76
|
+
# other - The class to be compared.
|
|
77
|
+
#
|
|
78
|
+
# Returns -1, 0, 1.
|
|
79
|
+
def <=>(other)
|
|
80
|
+
self.class <=> other.class
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Initialize a new plugin. This should be overridden by the subclass.
|
|
84
|
+
#
|
|
85
|
+
# config - The Hash of configuration options.
|
|
86
|
+
#
|
|
87
|
+
# Returns a new instance.
|
|
88
|
+
def initialize(config = {})
|
|
89
|
+
# no-op for default
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -1,115 +1,115 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jekyll
|
|
4
|
-
class PluginManager
|
|
5
|
-
attr_reader :site
|
|
6
|
-
|
|
7
|
-
# Create an instance of this class.
|
|
8
|
-
#
|
|
9
|
-
# site - the instance of Jekyll::Site we're concerned with
|
|
10
|
-
#
|
|
11
|
-
# Returns nothing
|
|
12
|
-
def initialize(site)
|
|
13
|
-
@site = site
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# Require all the plugins which are allowed.
|
|
17
|
-
#
|
|
18
|
-
# Returns nothing
|
|
19
|
-
def conscientious_require
|
|
20
|
-
require_theme_deps if site.theme
|
|
21
|
-
require_plugin_files
|
|
22
|
-
require_gems
|
|
23
|
-
deprecation_checks
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
# Require each of the gem plugins specified.
|
|
27
|
-
#
|
|
28
|
-
# Returns nothing.
|
|
29
|
-
def require_gems
|
|
30
|
-
Jekyll::External.require_with_graceful_fail(
|
|
31
|
-
site.gems.select { |plugin| plugin_allowed?(plugin) }
|
|
32
|
-
)
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Require each of the runtime_dependencies specified by the theme's gemspec.
|
|
36
|
-
#
|
|
37
|
-
# Returns false only if no dependencies have been specified, otherwise nothing.
|
|
38
|
-
def require_theme_deps
|
|
39
|
-
return false unless site.theme.runtime_dependencies
|
|
40
|
-
|
|
41
|
-
site.theme.runtime_dependencies.each do |dep|
|
|
42
|
-
next if dep.name == "jekyll"
|
|
43
|
-
|
|
44
|
-
External.require_with_graceful_fail(dep.name) if plugin_allowed?(dep.name)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def self.require_from_bundler
|
|
49
|
-
if !ENV["JEKYLL_NO_BUNDLER_REQUIRE"] && File.file?("Gemfile")
|
|
50
|
-
require "bundler"
|
|
51
|
-
|
|
52
|
-
Bundler.setup
|
|
53
|
-
required_gems = Bundler.require(:jekyll_plugins)
|
|
54
|
-
message = "Required #{required_gems.map(&:name).join(", ")}"
|
|
55
|
-
Jekyll.logger.debug("PluginManager:", message)
|
|
56
|
-
ENV["JEKYLL_NO_BUNDLER_REQUIRE"] = "true"
|
|
57
|
-
|
|
58
|
-
true
|
|
59
|
-
else
|
|
60
|
-
false
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
# Check whether a gem plugin is allowed to be used during this build.
|
|
65
|
-
#
|
|
66
|
-
# plugin_name - the name of the plugin
|
|
67
|
-
#
|
|
68
|
-
# Returns true if the plugin name is in the whitelist or if the site is not
|
|
69
|
-
# in safe mode.
|
|
70
|
-
def plugin_allowed?(plugin_name)
|
|
71
|
-
!site.safe || whitelist.include?(plugin_name)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
# Build an array of allowed plugin gem names.
|
|
75
|
-
#
|
|
76
|
-
# Returns an array of strings, each string being the name of a gem name
|
|
77
|
-
# that is allowed to be used.
|
|
78
|
-
def whitelist
|
|
79
|
-
@whitelist ||= Array[site.config["whitelist"]].flatten
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
# Require all .rb files if safe mode is off
|
|
83
|
-
#
|
|
84
|
-
# Returns nothing.
|
|
85
|
-
def require_plugin_files
|
|
86
|
-
unless site.safe
|
|
87
|
-
plugins_path.each do |plugin_search_path|
|
|
88
|
-
plugin_files = Utils.safe_glob(plugin_search_path, File.join("**", "*.rb"))
|
|
89
|
-
Jekyll::External.require_with_graceful_fail(plugin_files)
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# Public: Setup the plugin search path
|
|
95
|
-
#
|
|
96
|
-
# Returns an Array of plugin search paths
|
|
97
|
-
def plugins_path
|
|
98
|
-
if site.config["plugins_dir"].eql? Jekyll::Configuration::DEFAULTS["plugins_dir"]
|
|
99
|
-
[site.in_source_dir(site.config["plugins_dir"])]
|
|
100
|
-
else
|
|
101
|
-
Array(site.config["plugins_dir"]).map { |d| File.expand_path(d) }
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
def deprecation_checks
|
|
106
|
-
pagination_included = (site.config["plugins"] || []).include?("jekyll-paginate") ||
|
|
107
|
-
defined?(Jekyll::Paginate)
|
|
108
|
-
if site.config["paginate"] && !pagination_included
|
|
109
|
-
Jekyll::Deprecator.deprecation_message "You appear to have pagination " \
|
|
110
|
-
"turned on, but you haven't included the `jekyll-paginate` gem. " \
|
|
111
|
-
"Ensure you have `plugins: [jekyll-paginate]` in your configuration file."
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jekyll
|
|
4
|
+
class PluginManager
|
|
5
|
+
attr_reader :site
|
|
6
|
+
|
|
7
|
+
# Create an instance of this class.
|
|
8
|
+
#
|
|
9
|
+
# site - the instance of Jekyll::Site we're concerned with
|
|
10
|
+
#
|
|
11
|
+
# Returns nothing
|
|
12
|
+
def initialize(site)
|
|
13
|
+
@site = site
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Require all the plugins which are allowed.
|
|
17
|
+
#
|
|
18
|
+
# Returns nothing
|
|
19
|
+
def conscientious_require
|
|
20
|
+
require_theme_deps if site.theme
|
|
21
|
+
require_plugin_files
|
|
22
|
+
require_gems
|
|
23
|
+
deprecation_checks
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Require each of the gem plugins specified.
|
|
27
|
+
#
|
|
28
|
+
# Returns nothing.
|
|
29
|
+
def require_gems
|
|
30
|
+
Jekyll::External.require_with_graceful_fail(
|
|
31
|
+
site.gems.select { |plugin| plugin_allowed?(plugin) }
|
|
32
|
+
)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Require each of the runtime_dependencies specified by the theme's gemspec.
|
|
36
|
+
#
|
|
37
|
+
# Returns false only if no dependencies have been specified, otherwise nothing.
|
|
38
|
+
def require_theme_deps
|
|
39
|
+
return false unless site.theme.runtime_dependencies
|
|
40
|
+
|
|
41
|
+
site.theme.runtime_dependencies.each do |dep|
|
|
42
|
+
next if dep.name == "jekyll"
|
|
43
|
+
|
|
44
|
+
External.require_with_graceful_fail(dep.name) if plugin_allowed?(dep.name)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.require_from_bundler
|
|
49
|
+
if !ENV["JEKYLL_NO_BUNDLER_REQUIRE"] && File.file?("Gemfile")
|
|
50
|
+
require "bundler"
|
|
51
|
+
|
|
52
|
+
Bundler.setup
|
|
53
|
+
required_gems = Bundler.require(:jekyll_plugins)
|
|
54
|
+
message = "Required #{required_gems.map(&:name).join(", ")}"
|
|
55
|
+
Jekyll.logger.debug("PluginManager:", message)
|
|
56
|
+
ENV["JEKYLL_NO_BUNDLER_REQUIRE"] = "true"
|
|
57
|
+
|
|
58
|
+
true
|
|
59
|
+
else
|
|
60
|
+
false
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Check whether a gem plugin is allowed to be used during this build.
|
|
65
|
+
#
|
|
66
|
+
# plugin_name - the name of the plugin
|
|
67
|
+
#
|
|
68
|
+
# Returns true if the plugin name is in the whitelist or if the site is not
|
|
69
|
+
# in safe mode.
|
|
70
|
+
def plugin_allowed?(plugin_name)
|
|
71
|
+
!site.safe || whitelist.include?(plugin_name)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Build an array of allowed plugin gem names.
|
|
75
|
+
#
|
|
76
|
+
# Returns an array of strings, each string being the name of a gem name
|
|
77
|
+
# that is allowed to be used.
|
|
78
|
+
def whitelist
|
|
79
|
+
@whitelist ||= Array[site.config["whitelist"]].flatten
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Require all .rb files if safe mode is off
|
|
83
|
+
#
|
|
84
|
+
# Returns nothing.
|
|
85
|
+
def require_plugin_files
|
|
86
|
+
unless site.safe
|
|
87
|
+
plugins_path.each do |plugin_search_path|
|
|
88
|
+
plugin_files = Utils.safe_glob(plugin_search_path, File.join("**", "*.rb"))
|
|
89
|
+
Jekyll::External.require_with_graceful_fail(plugin_files)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Public: Setup the plugin search path
|
|
95
|
+
#
|
|
96
|
+
# Returns an Array of plugin search paths
|
|
97
|
+
def plugins_path
|
|
98
|
+
if site.config["plugins_dir"].eql? Jekyll::Configuration::DEFAULTS["plugins_dir"]
|
|
99
|
+
[site.in_source_dir(site.config["plugins_dir"])]
|
|
100
|
+
else
|
|
101
|
+
Array(site.config["plugins_dir"]).map { |d| File.expand_path(d) }
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def deprecation_checks
|
|
106
|
+
pagination_included = (site.config["plugins"] || []).include?("jekyll-paginate") ||
|
|
107
|
+
defined?(Jekyll::Paginate)
|
|
108
|
+
if site.config["paginate"] && !pagination_included
|
|
109
|
+
Jekyll::Deprecator.deprecation_message "You appear to have pagination " \
|
|
110
|
+
"turned on, but you haven't included the `jekyll-paginate` gem. " \
|
|
111
|
+
"Ensure you have `plugins: [jekyll-paginate]` in your configuration file."
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
data/lib/jekyll/profiler.rb
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jekyll
|
|
4
|
-
class Profiler
|
|
5
|
-
TERMINAL_TABLE_STYLES = {
|
|
6
|
-
:alignment => :right,
|
|
7
|
-
:border_top => false,
|
|
8
|
-
:border_bottom => false,
|
|
9
|
-
}.freeze
|
|
10
|
-
private_constant :TERMINAL_TABLE_STYLES
|
|
11
|
-
|
|
12
|
-
def self.tabulate(table_rows)
|
|
13
|
-
require "terminal-table"
|
|
14
|
-
|
|
15
|
-
rows = table_rows.dup
|
|
16
|
-
header = rows.shift
|
|
17
|
-
footer = rows.pop
|
|
18
|
-
output = +"\n"
|
|
19
|
-
|
|
20
|
-
table = Terminal::Table.new do |t|
|
|
21
|
-
t << header
|
|
22
|
-
t << :separator
|
|
23
|
-
rows.each { |row| t << row }
|
|
24
|
-
t << :separator
|
|
25
|
-
t << footer
|
|
26
|
-
t.style = TERMINAL_TABLE_STYLES
|
|
27
|
-
t.align_column(0, :left)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
output << table.to_s << "\n"
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def initialize(site)
|
|
34
|
-
@site = site
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def profile_process
|
|
38
|
-
profile_data = { "PHASE" => "TIME" }
|
|
39
|
-
total_time = 0
|
|
40
|
-
|
|
41
|
-
[:reset, :read, :generate, :render, :cleanup, :write].each do |method|
|
|
42
|
-
start_time = Time.now
|
|
43
|
-
@site.send(method)
|
|
44
|
-
end_time = (Time.now - start_time).round(4)
|
|
45
|
-
profile_data[method.to_s.upcase] = format("%.4f", end_time)
|
|
46
|
-
total_time += end_time
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
profile_data["TOTAL TIME"] = format("%.4f", total_time)
|
|
50
|
-
|
|
51
|
-
Jekyll.logger.info "\nBuild Process Summary:"
|
|
52
|
-
Jekyll.logger.info Profiler.tabulate(Array(profile_data))
|
|
53
|
-
|
|
54
|
-
Jekyll.logger.info "\nSite Render Stats:"
|
|
55
|
-
@site.print_stats
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jekyll
|
|
4
|
+
class Profiler
|
|
5
|
+
TERMINAL_TABLE_STYLES = {
|
|
6
|
+
:alignment => :right,
|
|
7
|
+
:border_top => false,
|
|
8
|
+
:border_bottom => false,
|
|
9
|
+
}.freeze
|
|
10
|
+
private_constant :TERMINAL_TABLE_STYLES
|
|
11
|
+
|
|
12
|
+
def self.tabulate(table_rows)
|
|
13
|
+
require "terminal-table"
|
|
14
|
+
|
|
15
|
+
rows = table_rows.dup
|
|
16
|
+
header = rows.shift
|
|
17
|
+
footer = rows.pop
|
|
18
|
+
output = +"\n"
|
|
19
|
+
|
|
20
|
+
table = Terminal::Table.new do |t|
|
|
21
|
+
t << header
|
|
22
|
+
t << :separator
|
|
23
|
+
rows.each { |row| t << row }
|
|
24
|
+
t << :separator
|
|
25
|
+
t << footer
|
|
26
|
+
t.style = TERMINAL_TABLE_STYLES
|
|
27
|
+
t.align_column(0, :left)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
output << table.to_s << "\n"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def initialize(site)
|
|
34
|
+
@site = site
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def profile_process
|
|
38
|
+
profile_data = { "PHASE" => "TIME" }
|
|
39
|
+
total_time = 0
|
|
40
|
+
|
|
41
|
+
[:reset, :read, :generate, :render, :cleanup, :write].each do |method|
|
|
42
|
+
start_time = Time.now
|
|
43
|
+
@site.send(method)
|
|
44
|
+
end_time = (Time.now - start_time).round(4)
|
|
45
|
+
profile_data[method.to_s.upcase] = format("%.4f", end_time)
|
|
46
|
+
total_time += end_time
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
profile_data["TOTAL TIME"] = format("%.4f", total_time)
|
|
50
|
+
|
|
51
|
+
Jekyll.logger.info "\nBuild Process Summary:"
|
|
52
|
+
Jekyll.logger.info Profiler.tabulate(Array(profile_data))
|
|
53
|
+
|
|
54
|
+
Jekyll.logger.info "\nSite Render Stats:"
|
|
55
|
+
@site.print_stats
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
data/lib/jekyll/publisher.rb
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jekyll
|
|
4
|
-
class Publisher
|
|
5
|
-
def initialize(site)
|
|
6
|
-
@site = site
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
def publish?(thing)
|
|
10
|
-
can_be_published?(thing) && !hidden_in_the_future?(thing)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def hidden_in_the_future?(thing)
|
|
14
|
-
thing.respond_to?(:date) && !@site.future && thing.date.to_i > @site.time.to_i
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
def can_be_published?(thing)
|
|
20
|
-
thing.data.fetch("published", true) || @site.unpublished
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jekyll
|
|
4
|
+
class Publisher
|
|
5
|
+
def initialize(site)
|
|
6
|
+
@site = site
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def publish?(thing)
|
|
10
|
+
can_be_published?(thing) && !hidden_in_the_future?(thing)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def hidden_in_the_future?(thing)
|
|
14
|
+
thing.respond_to?(:date) && !@site.future && thing.date.to_i > @site.time.to_i
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def can_be_published?(thing)
|
|
20
|
+
thing.data.fetch("published", true) || @site.unpublished
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|