jekyll 3.9.3 → 4.4.1
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 +511 -89
- data/LICENSE +1 -1
- data/README.markdown +48 -27
- data/lib/blank_template/_config.yml +3 -0
- data/lib/blank_template/_layouts/default.html +12 -0
- data/lib/blank_template/_sass/base.scss +9 -0
- data/lib/blank_template/assets/css/main.scss +4 -0
- data/lib/blank_template/index.md +8 -0
- data/lib/jekyll/cache.rb +186 -0
- data/lib/jekyll/cleaner.rb +8 -7
- data/lib/jekyll/collection.rb +84 -11
- data/lib/jekyll/command.rb +33 -6
- data/lib/jekyll/commands/build.rb +8 -28
- data/lib/jekyll/commands/clean.rb +3 -2
- data/lib/jekyll/commands/doctor.rb +46 -35
- data/lib/jekyll/commands/help.rb +1 -1
- data/lib/jekyll/commands/new.rb +44 -50
- data/lib/jekyll/commands/new_theme.rb +27 -28
- data/lib/jekyll/commands/serve/live_reload_reactor.rb +9 -16
- data/lib/jekyll/commands/serve/servlet.rb +21 -22
- data/lib/jekyll/commands/serve/websockets.rb +1 -1
- data/lib/jekyll/commands/serve.rb +75 -97
- data/lib/jekyll/configuration.rb +66 -158
- data/lib/jekyll/converters/identity.rb +18 -0
- data/lib/jekyll/converters/markdown/kramdown_parser.rb +83 -33
- data/lib/jekyll/converters/markdown.rb +49 -40
- data/lib/jekyll/converters/smartypants.rb +34 -14
- data/lib/jekyll/convertible.rb +36 -34
- data/lib/jekyll/deprecator.rb +2 -4
- data/lib/jekyll/document.rb +107 -72
- data/lib/jekyll/drops/collection_drop.rb +3 -4
- data/lib/jekyll/drops/document_drop.rb +9 -3
- data/lib/jekyll/drops/drop.rb +115 -33
- data/lib/jekyll/drops/excerpt_drop.rb +8 -0
- data/lib/jekyll/drops/site_drop.rb +9 -8
- data/lib/jekyll/drops/static_file_drop.rb +4 -4
- data/lib/jekyll/drops/theme_drop.rb +39 -0
- data/lib/jekyll/drops/unified_payload_drop.rb +7 -2
- data/lib/jekyll/drops/url_drop.rb +55 -3
- data/lib/jekyll/entry_filter.rb +42 -51
- data/lib/jekyll/excerpt.rb +48 -38
- data/lib/jekyll/external.rb +20 -19
- data/lib/jekyll/filters/date_filters.rb +6 -3
- data/lib/jekyll/filters/grouping_filters.rb +1 -2
- data/lib/jekyll/filters/url_filters.rb +50 -15
- data/lib/jekyll/filters.rb +211 -50
- data/lib/jekyll/frontmatter_defaults.rb +45 -36
- data/lib/jekyll/hooks.rb +26 -26
- data/lib/jekyll/inclusion.rb +32 -0
- data/lib/jekyll/layout.rb +12 -19
- data/lib/jekyll/liquid_extensions.rb +0 -2
- data/lib/jekyll/liquid_renderer/file.rb +24 -3
- data/lib/jekyll/liquid_renderer/table.rb +26 -77
- data/lib/jekyll/liquid_renderer.rb +31 -16
- data/lib/jekyll/log_adapter.rb +5 -1
- data/lib/jekyll/page.rb +51 -23
- data/lib/jekyll/page_excerpt.rb +25 -0
- data/lib/jekyll/page_without_a_file.rb +0 -4
- data/lib/jekyll/path_manager.rb +74 -0
- data/lib/jekyll/plugin.rb +5 -11
- data/lib/jekyll/plugin_manager.rb +15 -5
- data/lib/jekyll/profiler.rb +51 -0
- data/lib/jekyll/reader.rb +65 -10
- data/lib/jekyll/readers/collection_reader.rb +1 -0
- data/lib/jekyll/readers/data_reader.rb +48 -10
- data/lib/jekyll/readers/layout_reader.rb +3 -12
- data/lib/jekyll/readers/page_reader.rb +5 -5
- data/lib/jekyll/readers/post_reader.rb +32 -19
- data/lib/jekyll/readers/static_file_reader.rb +4 -4
- data/lib/jekyll/readers/theme_assets_reader.rb +8 -5
- data/lib/jekyll/regenerator.rb +4 -12
- data/lib/jekyll/related_posts.rb +1 -1
- data/lib/jekyll/renderer.rb +34 -49
- data/lib/jekyll/site.rb +151 -58
- data/lib/jekyll/static_file.rb +64 -28
- data/lib/jekyll/stevenson.rb +4 -8
- data/lib/jekyll/tags/highlight.rb +44 -57
- data/lib/jekyll/tags/include.rb +114 -80
- data/lib/jekyll/tags/link.rb +12 -7
- data/lib/jekyll/tags/post_url.rb +33 -30
- data/lib/jekyll/theme.rb +20 -18
- data/lib/jekyll/theme_builder.rb +91 -89
- data/lib/jekyll/url.rb +18 -10
- data/lib/jekyll/utils/ansi.rb +2 -2
- data/lib/jekyll/utils/exec.rb +0 -1
- data/lib/jekyll/utils/internet.rb +2 -4
- data/lib/jekyll/utils/platforms.rb +37 -52
- data/lib/jekyll/utils/thread_event.rb +1 -5
- data/lib/jekyll/utils.rb +29 -28
- data/lib/jekyll/version.rb +1 -1
- data/lib/jekyll.rb +9 -14
- data/lib/site_template/.gitignore +2 -0
- data/lib/site_template/404.html +2 -1
- data/lib/site_template/_config.yml +17 -5
- data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +5 -1
- data/lib/theme_template/README.md.erb +1 -3
- data/lib/theme_template/gitignore.erb +1 -0
- data/lib/theme_template/theme.gemspec.erb +1 -4
- data/rubocop/jekyll/assert_equal_literal_actual.rb +150 -0
- data/rubocop/jekyll/no_p_allowed.rb +5 -6
- data/rubocop/jekyll/no_puts_allowed.rb +5 -6
- metadata +149 -37
- data/lib/jekyll/converters/markdown/rdiscount_parser.rb +0 -37
- data/lib/jekyll/converters/markdown/redcarpet_parser.rb +0 -112
- data/lib/jekyll/utils/rouge.rb +0 -22
- /data/lib/site_template/{about.md → about.markdown} +0 -0
- /data/lib/site_template/{index.md → index.markdown} +0 -0
data/lib/jekyll/theme.rb
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
module Jekyll
|
|
4
4
|
class Theme
|
|
5
5
|
extend Forwardable
|
|
6
|
-
attr_reader
|
|
6
|
+
attr_reader :name
|
|
7
|
+
|
|
7
8
|
def_delegator :gemspec, :version, :version
|
|
8
9
|
|
|
9
10
|
def initialize(name)
|
|
10
11
|
@name = name.downcase.strip
|
|
11
12
|
Jekyll.logger.debug "Theme:", name
|
|
12
13
|
Jekyll.logger.debug "Theme source:", root
|
|
13
|
-
configure_sass
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
def root
|
|
@@ -18,30 +18,33 @@ module Jekyll
|
|
|
18
18
|
# Otherwise, Jekyll.sanitized path with prepend the unresolved root
|
|
19
19
|
@root ||= File.realpath(gemspec.full_gem_path)
|
|
20
20
|
rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP
|
|
21
|
-
raise "Path #{gemspec.full_gem_path} does not exist, is not accessible "\
|
|
22
|
-
|
|
21
|
+
raise "Path #{gemspec.full_gem_path} does not exist, is not accessible or includes " \
|
|
22
|
+
"a symbolic link loop"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# The name of theme directory
|
|
26
|
+
def basename
|
|
27
|
+
@basename ||= File.basename(root)
|
|
23
28
|
end
|
|
24
29
|
|
|
25
30
|
def includes_path
|
|
26
|
-
@includes_path ||= path_for "_includes"
|
|
31
|
+
@includes_path ||= path_for "_includes"
|
|
27
32
|
end
|
|
28
33
|
|
|
29
34
|
def layouts_path
|
|
30
|
-
@layouts_path ||= path_for "_layouts"
|
|
35
|
+
@layouts_path ||= path_for "_layouts"
|
|
31
36
|
end
|
|
32
37
|
|
|
33
38
|
def sass_path
|
|
34
|
-
@sass_path ||= path_for "_sass"
|
|
39
|
+
@sass_path ||= path_for "_sass"
|
|
35
40
|
end
|
|
36
41
|
|
|
37
42
|
def assets_path
|
|
38
|
-
@assets_path ||= path_for "assets"
|
|
43
|
+
@assets_path ||= path_for "assets"
|
|
39
44
|
end
|
|
40
45
|
|
|
41
|
-
def
|
|
42
|
-
|
|
43
|
-
External.require_with_graceful_fail("sass") unless defined?(Sass)
|
|
44
|
-
Sass.load_paths << sass_path
|
|
46
|
+
def data_path
|
|
47
|
+
@data_path ||= path_for "_data"
|
|
45
48
|
end
|
|
46
49
|
|
|
47
50
|
def runtime_dependencies
|
|
@@ -56,9 +59,9 @@ module Jekyll
|
|
|
56
59
|
end
|
|
57
60
|
|
|
58
61
|
def realpath_for(folder)
|
|
59
|
-
# This resolves all symlinks for the theme subfolder and then ensures
|
|
60
|
-
#
|
|
61
|
-
#
|
|
62
|
+
# This resolves all symlinks for the theme subfolder and then ensures that the directory
|
|
63
|
+
# remains inside the theme root. This prevents the use of symlinks for theme subfolders to
|
|
64
|
+
# escape the theme root.
|
|
62
65
|
# However, symlinks are allowed to point to other directories within the theme.
|
|
63
66
|
Jekyll.sanitized_path(root, File.realpath(Jekyll.sanitized_path(root, folder.to_s)))
|
|
64
67
|
rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP => e
|
|
@@ -73,8 +76,7 @@ module Jekyll
|
|
|
73
76
|
when Errno::EACCES
|
|
74
77
|
Jekyll.logger.error "Theme error:", "Directory '#{folder}' is not accessible."
|
|
75
78
|
when Errno::ELOOP
|
|
76
|
-
Jekyll.logger.error "Theme error:",
|
|
77
|
-
"Directory '#{folder}' includes a symbolic link loop."
|
|
79
|
+
Jekyll.logger.error "Theme error:", "Directory '#{folder}' includes a symbolic link loop."
|
|
78
80
|
end
|
|
79
81
|
end
|
|
80
82
|
|
|
@@ -82,7 +84,7 @@ module Jekyll
|
|
|
82
84
|
@gemspec ||= Gem::Specification.find_by_name(name)
|
|
83
85
|
rescue Gem::LoadError
|
|
84
86
|
raise Jekyll::Errors::MissingDependencyException,
|
|
85
|
-
|
|
87
|
+
"The #{name} theme could not be found."
|
|
86
88
|
end
|
|
87
89
|
end
|
|
88
90
|
end
|
data/lib/jekyll/theme_builder.rb
CHANGED
|
@@ -1,119 +1,121 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
module Jekyll
|
|
4
|
+
class ThemeBuilder
|
|
5
|
+
SCAFFOLD_DIRECTORIES = %w(
|
|
6
|
+
assets _data _layouts _includes _sass
|
|
7
|
+
).freeze
|
|
8
|
+
|
|
9
|
+
attr_reader :name, :path, :code_of_conduct
|
|
10
|
+
|
|
11
|
+
def initialize(theme_name, opts)
|
|
12
|
+
@name = theme_name.to_s.tr(" ", "_").squeeze("_")
|
|
13
|
+
@path = Pathname.new(File.expand_path(name, Dir.pwd))
|
|
14
|
+
@code_of_conduct = !!opts["code_of_conduct"]
|
|
15
|
+
end
|
|
9
16
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
def create!
|
|
18
|
+
create_directories
|
|
19
|
+
create_starter_files
|
|
20
|
+
create_gemspec
|
|
21
|
+
create_accessories
|
|
22
|
+
initialize_git_repo
|
|
23
|
+
end
|
|
15
24
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
create_gemspec
|
|
20
|
-
create_accessories
|
|
21
|
-
initialize_git_repo
|
|
22
|
-
end
|
|
25
|
+
def user_name
|
|
26
|
+
@user_name ||= `git config user.name`.chomp
|
|
27
|
+
end
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
def user_email
|
|
30
|
+
@user_email ||= `git config user.email`.chomp
|
|
31
|
+
end
|
|
27
32
|
|
|
28
|
-
|
|
29
|
-
@user_email ||= `git config user.email`.chomp
|
|
30
|
-
end
|
|
33
|
+
private
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
def root
|
|
36
|
+
@root ||= Pathname.new(File.expand_path("../", __dir__))
|
|
37
|
+
end
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
def template_file(filename)
|
|
40
|
+
[
|
|
41
|
+
root.join("theme_template", "#{filename}.erb"),
|
|
42
|
+
root.join("theme_template", filename.to_s),
|
|
43
|
+
].find(&:exist?)
|
|
44
|
+
end
|
|
37
45
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
root.join("theme_template", filename.to_s),
|
|
42
|
-
].find(&:exist?)
|
|
43
|
-
end
|
|
46
|
+
def template(filename)
|
|
47
|
+
erb.render(template_file(filename).read)
|
|
48
|
+
end
|
|
44
49
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
def erb
|
|
51
|
+
@erb ||= ERBRenderer.new(self)
|
|
52
|
+
end
|
|
48
53
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
54
|
+
def mkdir_p(directories)
|
|
55
|
+
Array(directories).each do |directory|
|
|
56
|
+
full_path = path.join(directory)
|
|
57
|
+
Jekyll.logger.info "create", full_path.to_s
|
|
58
|
+
FileUtils.mkdir_p(full_path)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
52
61
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
full_path = path.join(directory)
|
|
62
|
+
def write_file(filename, contents)
|
|
63
|
+
full_path = path.join(filename)
|
|
56
64
|
Jekyll.logger.info "create", full_path.to_s
|
|
57
|
-
|
|
65
|
+
File.write(full_path, contents)
|
|
58
66
|
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def write_file(filename, contents)
|
|
62
|
-
full_path = path.join(filename)
|
|
63
|
-
Jekyll.logger.info "create", full_path.to_s
|
|
64
|
-
File.write(full_path, contents)
|
|
65
|
-
end
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
def create_directories
|
|
69
|
+
mkdir_p(SCAFFOLD_DIRECTORIES)
|
|
70
|
+
end
|
|
70
71
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
def create_starter_files
|
|
73
|
+
%w(page post default).each do |layout|
|
|
74
|
+
write_file("_layouts/#{layout}.html", template("_layouts/#{layout}.html"))
|
|
75
|
+
end
|
|
74
76
|
end
|
|
75
|
-
end
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
def create_gemspec
|
|
79
|
+
write_file("Gemfile", template("Gemfile"))
|
|
80
|
+
write_file("#{name}.gemspec", template("theme.gemspec"))
|
|
81
|
+
end
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
def create_accessories
|
|
84
|
+
accessories = %w(README.md LICENSE.txt)
|
|
85
|
+
accessories << "CODE_OF_CONDUCT.md" if code_of_conduct
|
|
86
|
+
accessories.each do |filename|
|
|
87
|
+
write_file(filename, template(filename))
|
|
88
|
+
end
|
|
87
89
|
end
|
|
88
|
-
end
|
|
89
90
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
def initialize_git_repo
|
|
92
|
+
Jekyll.logger.info "initialize", path.join(".git").to_s
|
|
93
|
+
Dir.chdir(path.to_s) { `git init` }
|
|
94
|
+
write_file(".gitignore", template("gitignore"))
|
|
95
|
+
end
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
|
|
97
|
+
class ERBRenderer
|
|
98
|
+
extend Forwardable
|
|
98
99
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
def_delegator :@theme_builder, :name, :theme_name
|
|
101
|
+
def_delegator :@theme_builder, :user_name, :user_name
|
|
102
|
+
def_delegator :@theme_builder, :user_email, :user_email
|
|
102
103
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
def initialize(theme_builder)
|
|
105
|
+
@theme_builder = theme_builder
|
|
106
|
+
end
|
|
106
107
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
def jekyll_version_with_minor
|
|
109
|
+
Jekyll::VERSION.split(".").take(2).join(".")
|
|
110
|
+
end
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
def theme_directories
|
|
113
|
+
SCAFFOLD_DIRECTORIES
|
|
114
|
+
end
|
|
114
115
|
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
def render(contents)
|
|
117
|
+
ERB.new(contents).result binding
|
|
118
|
+
end
|
|
117
119
|
end
|
|
118
120
|
end
|
|
119
121
|
end
|
data/lib/jekyll/url.rb
CHANGED
|
@@ -68,6 +68,7 @@ module Jekyll
|
|
|
68
68
|
def generate_url_from_hash(template)
|
|
69
69
|
@placeholders.inject(template) do |result, token|
|
|
70
70
|
break result if result.index(":").nil?
|
|
71
|
+
|
|
71
72
|
if token.last.nil?
|
|
72
73
|
# Remove leading "/" to avoid generating urls with `//`
|
|
73
74
|
result.gsub("/:#{token.first}", "")
|
|
@@ -93,28 +94,31 @@ module Jekyll
|
|
|
93
94
|
|
|
94
95
|
def generate_url_from_drop(template)
|
|
95
96
|
template.gsub(%r!:([a-z_]+)!) do |match|
|
|
96
|
-
|
|
97
|
+
name = Regexp.last_match(1)
|
|
98
|
+
pool = name.end_with?("_") ? [name, name.chomp!("_")] : [name]
|
|
97
99
|
|
|
98
100
|
winner = pool.find { |key| @placeholders.key?(key) }
|
|
99
101
|
if winner.nil?
|
|
100
102
|
raise NoMethodError,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
+
"The URL template doesn't have #{pool.join(" or ")} keys. " \
|
|
104
|
+
"Check your permalink template!"
|
|
103
105
|
end
|
|
104
106
|
|
|
105
107
|
value = @placeholders[winner]
|
|
106
108
|
value = "" if value.nil?
|
|
107
109
|
replacement = self.class.escape_path(value)
|
|
108
110
|
|
|
109
|
-
match.sub(":#{winner}", replacement)
|
|
110
|
-
end
|
|
111
|
+
match.sub!(":#{winner}", replacement)
|
|
112
|
+
end
|
|
111
113
|
end
|
|
112
114
|
|
|
113
115
|
# Returns a sanitized String URL, stripping "../../" and multiples of "/",
|
|
114
116
|
# as well as the beginning "/" so we can enforce and ensure it.
|
|
115
|
-
|
|
116
117
|
def sanitize_url(str)
|
|
117
|
-
"/#{str}".gsub("..", "/").
|
|
118
|
+
"/#{str}".gsub("..", "/").tap do |result|
|
|
119
|
+
result.gsub!("./", "")
|
|
120
|
+
result.squeeze!("/")
|
|
121
|
+
end
|
|
118
122
|
end
|
|
119
123
|
|
|
120
124
|
# Escapes a path to be a valid URL path segment
|
|
@@ -128,6 +132,8 @@ module Jekyll
|
|
|
128
132
|
#
|
|
129
133
|
# Returns the escaped path.
|
|
130
134
|
def self.escape_path(path)
|
|
135
|
+
return path if path.empty? || %r!^[a-zA-Z0-9./-]+$!.match?(path)
|
|
136
|
+
|
|
131
137
|
# Because URI.escape doesn't escape "?", "[" and "]" by default,
|
|
132
138
|
# specify unsafe string (except unreserved, sub-delims, ":", "@" and "/").
|
|
133
139
|
#
|
|
@@ -138,8 +144,7 @@ module Jekyll
|
|
|
138
144
|
# pct-encoded = "%" HEXDIG HEXDIG
|
|
139
145
|
# sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
|
|
140
146
|
# / "*" / "+" / "," / ";" / "="
|
|
141
|
-
|
|
142
|
-
path.encode("utf-8").sub("#", "%23")
|
|
147
|
+
Addressable::URI.encode(path).encode("utf-8").sub("#", "%23")
|
|
143
148
|
end
|
|
144
149
|
|
|
145
150
|
# Unescapes a URL path segment
|
|
@@ -153,7 +158,10 @@ module Jekyll
|
|
|
153
158
|
#
|
|
154
159
|
# Returns the unescaped path.
|
|
155
160
|
def self.unescape_path(path)
|
|
156
|
-
|
|
161
|
+
path = path.encode("utf-8")
|
|
162
|
+
return path unless path.include?("%")
|
|
163
|
+
|
|
164
|
+
Addressable::URI.unencode(path)
|
|
157
165
|
end
|
|
158
166
|
end
|
|
159
167
|
end
|
data/lib/jekyll/utils/ansi.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Jekyll
|
|
4
4
|
module Utils
|
|
@@ -6,7 +6,7 @@ module Jekyll
|
|
|
6
6
|
extend self
|
|
7
7
|
|
|
8
8
|
ESCAPE = format("%c", 27)
|
|
9
|
-
MATCH = %r!#{ESCAPE}\[(?:\d+)(?:;\d+)*(j|k|m|s|u|A|B|G)|\e\(B\e\[m!ix
|
|
9
|
+
MATCH = %r!#{ESCAPE}\[(?:\d+)(?:;\d+)*(j|k|m|s|u|A|B|G)|\e\(B\e\[m!ix.freeze
|
|
10
10
|
COLORS = {
|
|
11
11
|
:red => 31,
|
|
12
12
|
:green => 32,
|
data/lib/jekyll/utils/exec.rb
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
module Jekyll
|
|
4
4
|
module Utils
|
|
5
5
|
module Internet
|
|
6
|
-
|
|
7
6
|
# Public: Determine whether the present device has a connection to
|
|
8
7
|
# the Internet. This allows plugin writers which require the outside
|
|
9
8
|
# world to have a neat fallback mechanism for offline building.
|
|
@@ -18,13 +17,13 @@ module Jekyll
|
|
|
18
17
|
# end
|
|
19
18
|
#
|
|
20
19
|
# Returns true if a DNS call can successfully be made, or false if not.
|
|
20
|
+
|
|
21
21
|
module_function
|
|
22
|
+
|
|
22
23
|
def connected?
|
|
23
24
|
!dns("example.com").nil?
|
|
24
25
|
end
|
|
25
26
|
|
|
26
|
-
private
|
|
27
|
-
module_function
|
|
28
27
|
def dns(domain)
|
|
29
28
|
require "resolv"
|
|
30
29
|
Resolv::DNS.open do |resolver|
|
|
@@ -33,7 +32,6 @@ module Jekyll
|
|
|
33
32
|
rescue Resolv::ResolvError, Resolv::ResolvTimeout
|
|
34
33
|
nil
|
|
35
34
|
end
|
|
36
|
-
|
|
37
35
|
end
|
|
38
36
|
end
|
|
39
37
|
end
|
|
@@ -5,77 +5,62 @@ module Jekyll
|
|
|
5
5
|
module Platforms
|
|
6
6
|
extend self
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
def jruby?
|
|
9
|
+
RUBY_ENGINE == "jruby"
|
|
10
|
+
end
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
::RUBY_ENGINE == v
|
|
15
|
-
end
|
|
12
|
+
def mri?
|
|
13
|
+
RUBY_ENGINE == "ruby"
|
|
16
14
|
end
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# /proc/version returns nothing to us.
|
|
22
|
-
# --
|
|
16
|
+
def windows?
|
|
17
|
+
vanilla_windows? || bash_on_windows?
|
|
18
|
+
end
|
|
23
19
|
|
|
20
|
+
# Not a Windows Subsystem for Linux (WSL)
|
|
24
21
|
def vanilla_windows?
|
|
25
|
-
|
|
26
|
-
!proc_version
|
|
22
|
+
rbconfig_host.match?(%r!mswin|mingw|cygwin!) && proc_version.empty?
|
|
27
23
|
end
|
|
24
|
+
alias_method :really_windows?, :vanilla_windows?
|
|
28
25
|
|
|
29
|
-
#
|
|
30
|
-
# XXX: Remove in 4.0
|
|
31
|
-
# --
|
|
32
|
-
|
|
33
|
-
alias_method :really_windows?, \
|
|
34
|
-
:vanilla_windows?
|
|
35
|
-
|
|
36
|
-
#
|
|
37
|
-
|
|
26
|
+
# Determine if Windows Subsystem for Linux (WSL)
|
|
38
27
|
def bash_on_windows?
|
|
39
|
-
|
|
40
|
-
proc_version =~ %r!microsoft!i
|
|
28
|
+
linux_os? && microsoft_proc_version?
|
|
41
29
|
end
|
|
42
30
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
def windows?
|
|
46
|
-
vanilla_windows? || bash_on_windows?
|
|
31
|
+
def linux?
|
|
32
|
+
linux_os? && !microsoft_proc_version?
|
|
47
33
|
end
|
|
48
34
|
|
|
49
|
-
|
|
35
|
+
def osx?
|
|
36
|
+
rbconfig_host.match?(%r!darwin|mac os!)
|
|
37
|
+
end
|
|
50
38
|
|
|
51
|
-
def
|
|
52
|
-
|
|
53
|
-
proc_version !~ %r!microsoft!i
|
|
39
|
+
def unix?
|
|
40
|
+
rbconfig_host.match?(%r!solaris|bsd!)
|
|
54
41
|
end
|
|
55
42
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def proc_version
|
|
46
|
+
@proc_version ||= \
|
|
47
|
+
begin
|
|
48
|
+
File.read("/proc/version").downcase
|
|
49
|
+
rescue Errno::ENOENT, Errno::EACCES
|
|
50
|
+
""
|
|
51
|
+
end
|
|
52
|
+
end
|
|
59
53
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
!!(
|
|
63
|
-
RbConfig::CONFIG["host_os"] =~ v
|
|
64
|
-
)
|
|
65
|
-
end
|
|
54
|
+
def rbconfig_host
|
|
55
|
+
@rbconfig_host ||= RbConfig::CONFIG["host_os"].downcase
|
|
66
56
|
end
|
|
67
57
|
|
|
68
|
-
|
|
58
|
+
def linux_os?
|
|
59
|
+
rbconfig_host.include?("linux")
|
|
60
|
+
end
|
|
69
61
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
@proc_version ||= begin
|
|
73
|
-
File.read(
|
|
74
|
-
"/proc/version"
|
|
75
|
-
).downcase
|
|
76
|
-
rescue Errno::ENOENT
|
|
77
|
-
nil
|
|
78
|
-
end
|
|
62
|
+
def microsoft_proc_version?
|
|
63
|
+
proc_version.include?("microsoft")
|
|
79
64
|
end
|
|
80
65
|
end
|
|
81
66
|
end
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "thread"
|
|
4
|
-
|
|
5
3
|
module Jekyll
|
|
6
4
|
module Utils
|
|
7
5
|
# Based on the pattern and code from
|
|
@@ -25,9 +23,7 @@ module Jekyll
|
|
|
25
23
|
|
|
26
24
|
def wait
|
|
27
25
|
@lock.synchronize do
|
|
28
|
-
unless @flag
|
|
29
|
-
@cond.wait(@lock)
|
|
30
|
-
end
|
|
26
|
+
@cond.wait(@lock) unless @flag
|
|
31
27
|
end
|
|
32
28
|
end
|
|
33
29
|
end
|