jekyll 4.2.1 → 4.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +474 -350
- data/LICENSE +21 -21
- data/README.markdown +83 -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 → base.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 +186 -190
- data/lib/jekyll/cleaner.rb +111 -111
- data/lib/jekyll/collection.rb +310 -309
- data/lib/jekyll/command.rb +105 -105
- data/lib/jekyll/commands/build.rb +82 -93
- data/lib/jekyll/commands/clean.rb +44 -45
- data/lib/jekyll/commands/doctor.rb +177 -177
- data/lib/jekyll/commands/help.rb +34 -34
- data/lib/jekyll/commands/new.rb +168 -169
- data/lib/jekyll/commands/new_theme.rb +39 -40
- data/lib/jekyll/commands/serve/live_reload_reactor.rb +119 -122
- data/lib/jekyll/commands/serve/livereload_assets/livereload.js +1183 -1183
- data/lib/jekyll/commands/serve/mime_types_charset.json +71 -0
- data/lib/jekyll/commands/serve/servlet.rb +206 -202
- data/lib/jekyll/commands/serve/websockets.rb +81 -81
- data/lib/jekyll/commands/serve.rb +367 -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 +197 -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 +543 -544
- data/lib/jekyll/drops/collection_drop.rb +20 -20
- data/lib/jekyll/drops/document_drop.rb +74 -70
- data/lib/jekyll/drops/drop.rb +293 -293
- data/lib/jekyll/drops/excerpt_drop.rb +23 -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/theme_drop.rb +36 -0
- data/lib/jekyll/drops/unified_payload_drop.rb +30 -26
- data/lib/jekyll/drops/url_drop.rb +140 -140
- data/lib/jekyll/entry_filter.rb +117 -121
- data/lib/jekyll/errors.rb +20 -20
- data/lib/jekyll/excerpt.rb +200 -201
- data/lib/jekyll/external.rb +75 -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 +532 -535
- data/lib/jekyll/frontmatter_defaults.rb +238 -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 +55 -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 +45 -55
- data/lib/jekyll/liquid_renderer.rb +80 -80
- data/lib/jekyll/log_adapter.rb +151 -151
- data/lib/jekyll/mime.types +939 -866
- data/lib/jekyll/page.rb +215 -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 +123 -115
- data/lib/jekyll/profiler.rb +51 -58
- data/lib/jekyll/publisher.rb +23 -23
- data/lib/jekyll/reader.rb +209 -192
- data/lib/jekyll/readers/collection_reader.rb +23 -23
- data/lib/jekyll/readers/data_reader.rb +113 -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 +263 -265
- data/lib/jekyll/site.rb +576 -551
- data/lib/jekyll/static_file.rb +205 -208
- data/lib/jekyll/stevenson.rb +60 -60
- data/lib/jekyll/tags/highlight.rb +114 -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 +90 -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 +46 -75
- data/lib/jekyll/utils.rb +371 -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 +50 -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 +64 -18
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,123 @@
|
|
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"] &&
|
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
|
65
|
-
#
|
66
|
-
#
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
85
|
-
def
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
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"] && gemfile_exists?
|
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 for the existence of a Gemfile.
|
65
|
+
#
|
66
|
+
# Returns true if a Gemfile exists in the places bundler will look
|
67
|
+
def self.gemfile_exists?
|
68
|
+
File.file?("Gemfile") || (ENV["BUNDLE_GEMFILE"] && File.file?(ENV["BUNDLE_GEMFILE"]))
|
69
|
+
end
|
70
|
+
|
71
|
+
# Check whether a gem plugin is allowed to be used during this build.
|
72
|
+
#
|
73
|
+
# plugin_name - the name of the plugin
|
74
|
+
#
|
75
|
+
# Returns true if the plugin name is in the whitelist or if the site is not
|
76
|
+
# in safe mode.
|
77
|
+
def plugin_allowed?(plugin_name)
|
78
|
+
!site.safe || whitelist.include?(plugin_name)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Build an array of allowed plugin gem names.
|
82
|
+
#
|
83
|
+
# Returns an array of strings, each string being the name of a gem name
|
84
|
+
# that is allowed to be used.
|
85
|
+
def whitelist
|
86
|
+
@whitelist ||= Array[site.config["whitelist"]].flatten
|
87
|
+
end
|
88
|
+
|
89
|
+
# Require all .rb files if safe mode is off
|
90
|
+
#
|
91
|
+
# Returns nothing.
|
92
|
+
def require_plugin_files
|
93
|
+
unless site.safe
|
94
|
+
plugins_path.each do |plugin_search_path|
|
95
|
+
plugin_files = Utils.safe_glob(plugin_search_path, File.join("**", "*.rb"))
|
96
|
+
Jekyll::External.require_with_graceful_fail(plugin_files)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
# Public: Setup the plugin search path
|
102
|
+
#
|
103
|
+
# Returns an Array of plugin search paths
|
104
|
+
def plugins_path
|
105
|
+
if site.config["plugins_dir"].eql? Jekyll::Configuration::DEFAULTS["plugins_dir"]
|
106
|
+
[site.in_source_dir(site.config["plugins_dir"])]
|
107
|
+
else
|
108
|
+
Array(site.config["plugins_dir"]).map { |d| File.expand_path(d) }
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def deprecation_checks
|
113
|
+
pagination_included = (site.config["plugins"] || []).include?("jekyll-paginate") ||
|
114
|
+
defined?(Jekyll::Paginate)
|
115
|
+
if site.config["paginate"] && !pagination_included
|
116
|
+
Jekyll::Deprecator.deprecation_message <<~MSG
|
117
|
+
You appear to have pagination turned on, but you haven't included the `jekyll-paginate`
|
118
|
+
gem. Ensure you have `plugins: [jekyll-paginate]` in your configuration file.
|
119
|
+
MSG
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/lib/jekyll/profiler.rb
CHANGED
@@ -1,58 +1,51 @@
|
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
t <<
|
22
|
-
t <<
|
23
|
-
|
24
|
-
t
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
+
output = +"\n"
|
18
|
+
|
19
|
+
table = Terminal::Table.new do |t|
|
20
|
+
t << header
|
21
|
+
t << :separator
|
22
|
+
rows.each { |row| t << row }
|
23
|
+
t.style = TERMINAL_TABLE_STYLES
|
24
|
+
t.align_column(0, :left)
|
25
|
+
end
|
26
|
+
|
27
|
+
output << table.to_s << "\n"
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(site)
|
31
|
+
@site = site
|
32
|
+
end
|
33
|
+
|
34
|
+
def profile_process
|
35
|
+
profile_data = { "PHASE" => "TIME" }
|
36
|
+
|
37
|
+
[:reset, :read, :generate, :render, :cleanup, :write].each do |method|
|
38
|
+
start_time = Time.now
|
39
|
+
@site.send(method)
|
40
|
+
end_time = (Time.now - start_time).round(4)
|
41
|
+
profile_data[method.to_s.upcase] = format("%.4f", end_time)
|
42
|
+
end
|
43
|
+
|
44
|
+
Jekyll.logger.info "\nBuild Process Summary:"
|
45
|
+
Jekyll.logger.info Profiler.tabulate(Array(profile_data))
|
46
|
+
|
47
|
+
Jekyll.logger.info "\nSite Render Stats:"
|
48
|
+
@site.print_stats
|
49
|
+
end
|
50
|
+
end
|
51
|
+
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
|