jekyll 3.1.6 → 3.2.0.pre.beta1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of jekyll might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +200 -74
- data/README.markdown +13 -13
- data/lib/jekyll.rb +12 -8
- data/lib/jekyll/cleaner.rb +11 -8
- data/lib/jekyll/collection.rb +3 -3
- data/lib/jekyll/commands/build.rb +15 -12
- data/lib/jekyll/commands/clean.rb +15 -16
- data/lib/jekyll/commands/doctor.rb +7 -7
- data/lib/jekyll/commands/help.rb +4 -3
- data/lib/jekyll/commands/new.rb +49 -14
- data/lib/jekyll/commands/new_theme.rb +33 -0
- data/lib/jekyll/commands/serve.rb +33 -27
- data/lib/jekyll/commands/serve/servlet.rb +2 -3
- data/lib/jekyll/configuration.rb +10 -34
- data/lib/jekyll/converter.rb +6 -2
- data/lib/jekyll/converters/markdown.rb +1 -1
- data/lib/jekyll/converters/markdown/kramdown_parser.rb +1 -0
- data/lib/jekyll/convertible.rb +6 -9
- data/lib/jekyll/document.rb +5 -1
- data/lib/jekyll/drops/document_drop.rb +7 -33
- data/lib/jekyll/drops/drop.rb +2 -26
- data/lib/jekyll/drops/jekyll_drop.rb +0 -12
- data/lib/jekyll/drops/site_drop.rb +1 -1
- data/lib/jekyll/entry_filter.rb +61 -15
- data/lib/jekyll/errors.rb +6 -0
- data/lib/jekyll/excerpt.rb +5 -2
- data/lib/jekyll/filters.rb +49 -8
- data/lib/jekyll/frontmatter_defaults.rb +2 -2
- data/lib/jekyll/hooks.rb +1 -0
- data/lib/jekyll/layout.rb +16 -1
- data/lib/jekyll/page.rb +1 -0
- data/lib/jekyll/plugin.rb +1 -1
- data/lib/jekyll/plugin_manager.rb +5 -5
- data/lib/jekyll/publisher.rb +4 -4
- data/lib/jekyll/readers/data_reader.rb +3 -2
- data/lib/jekyll/readers/layout_reader.rb +19 -3
- data/lib/jekyll/readers/post_reader.rb +5 -1
- data/lib/jekyll/regenerator.rb +5 -3
- data/lib/jekyll/renderer.rb +4 -6
- data/lib/jekyll/site.rb +47 -18
- data/lib/jekyll/static_file.rb +5 -1
- data/lib/jekyll/tags/include.rb +33 -31
- data/lib/jekyll/tags/link.rb +26 -0
- data/lib/jekyll/tags/post_url.rb +18 -8
- data/lib/jekyll/theme.rb +56 -0
- data/lib/jekyll/theme_builder.rb +117 -0
- data/lib/jekyll/utils.rb +2 -14
- data/lib/jekyll/version.rb +1 -1
- data/lib/site_template/_config.yml +8 -2
- data/lib/site_template/_includes/footer.html +3 -3
- data/lib/site_template/_includes/head.html +2 -2
- data/lib/site_template/_includes/header.html +3 -3
- data/lib/site_template/_layouts/default.html +3 -3
- data/lib/site_template/_layouts/page.html +1 -1
- data/lib/site_template/_layouts/post.html +1 -1
- data/lib/site_template/_sass/_base.scss +11 -17
- data/lib/site_template/index.html +1 -1
- data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -0
- data/lib/theme_template/Gemfile +2 -0
- data/lib/theme_template/LICENSE.txt.erb +21 -0
- data/lib/theme_template/README.md.erb +46 -0
- data/lib/theme_template/Rakefile.erb +74 -0
- data/lib/theme_template/example/_config.yml.erb +1 -0
- data/lib/theme_template/example/_post.md +13 -0
- data/lib/theme_template/example/index.html +14 -0
- data/lib/theme_template/example/style.scss +7 -0
- data/lib/theme_template/theme.gemspec.erb +22 -0
- metadata +34 -7
- data/lib/jekyll/drops/excerpt_drop.rb +0 -15
data/lib/jekyll/collection.rb
CHANGED
@@ -78,7 +78,7 @@ module Jekyll
|
|
78
78
|
def entries
|
79
79
|
return [] unless exists?
|
80
80
|
@entries ||=
|
81
|
-
Utils.safe_glob(collection_dir, ["**", "
|
81
|
+
Utils.safe_glob(collection_dir, ["**", "*"]).map do |entry|
|
82
82
|
entry["#{collection_dir}/"] = ''
|
83
83
|
entry
|
84
84
|
end
|
@@ -94,7 +94,7 @@ module Jekyll
|
|
94
94
|
Dir.chdir(directory) do
|
95
95
|
entry_filter.filter(entries).reject do |f|
|
96
96
|
path = collection_dir(f)
|
97
|
-
File.directory?(path) ||
|
97
|
+
File.directory?(path) || entry_filter.symlink?(f)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -135,7 +135,7 @@ module Jekyll
|
|
135
135
|
# Returns false if the directory doesn't exist or if it's a symlink
|
136
136
|
# and we're in safe mode.
|
137
137
|
def exists?
|
138
|
-
File.directory?(directory) && !
|
138
|
+
File.directory?(directory) && !entry_filter.symlink?(directory)
|
139
139
|
end
|
140
140
|
|
141
141
|
# The entry filter for this collection.
|
@@ -5,8 +5,8 @@ module Jekyll
|
|
5
5
|
# Create the Mercenary command for the Jekyll CLI for this Command
|
6
6
|
def init_with_program(prog)
|
7
7
|
prog.command(:build) do |c|
|
8
|
-
c.syntax
|
9
|
-
c.description
|
8
|
+
c.syntax "build [options]"
|
9
|
+
c.description "Build your site"
|
10
10
|
c.alias :b
|
11
11
|
|
12
12
|
add_build_options(c)
|
@@ -27,15 +27,17 @@ module Jekyll
|
|
27
27
|
options = configuration_from_options(options)
|
28
28
|
site = Jekyll::Site.new(options)
|
29
29
|
|
30
|
-
if options.fetch(
|
31
|
-
Jekyll.logger.warn "Build Warning:", "Skipping the initial build.
|
30
|
+
if options.fetch("skip_initial_build", false)
|
31
|
+
Jekyll.logger.warn "Build Warning:", "Skipping the initial build." \
|
32
|
+
" This may result in an out-of-date site."
|
32
33
|
else
|
33
34
|
build(site, options)
|
34
35
|
end
|
35
36
|
|
36
|
-
if options.fetch(
|
37
|
-
Jekyll.logger.info "Auto-regeneration:",
|
38
|
-
|
37
|
+
if options.fetch("detach", false)
|
38
|
+
Jekyll.logger.info "Auto-regeneration:",
|
39
|
+
"disabled when running server detached."
|
40
|
+
elsif options.fetch("watch", false)
|
39
41
|
watch(site, options)
|
40
42
|
else
|
41
43
|
Jekyll.logger.info "Auto-regeneration:", "disabled. Use --watch to enable."
|
@@ -50,12 +52,13 @@ module Jekyll
|
|
50
52
|
# Returns nothing.
|
51
53
|
def build(site, options)
|
52
54
|
t = Time.now
|
53
|
-
source = options[
|
54
|
-
destination = options[
|
55
|
-
incremental = options[
|
55
|
+
source = options["source"]
|
56
|
+
destination = options["destination"]
|
57
|
+
incremental = options["incremental"]
|
56
58
|
Jekyll.logger.info "Source:", source
|
57
59
|
Jekyll.logger.info "Destination:", destination
|
58
|
-
Jekyll.logger.info "Incremental build:",
|
60
|
+
Jekyll.logger.info "Incremental build:",
|
61
|
+
(incremental ? "enabled" : "disabled. Enable with --incremental")
|
59
62
|
Jekyll.logger.info "Generating..."
|
60
63
|
process_site(site)
|
61
64
|
Jekyll.logger.info "", "done in #{(Time.now - t).round(3)} seconds."
|
@@ -68,7 +71,7 @@ module Jekyll
|
|
68
71
|
#
|
69
72
|
# Returns nothing.
|
70
73
|
def watch(_site, options)
|
71
|
-
External.require_with_graceful_fail
|
74
|
+
External.require_with_graceful_fail "jekyll-watch"
|
72
75
|
Jekyll::Watcher.watch(options)
|
73
76
|
end
|
74
77
|
end # end of class << self
|
@@ -4,8 +4,9 @@ module Jekyll
|
|
4
4
|
class << self
|
5
5
|
def init_with_program(prog)
|
6
6
|
prog.command(:clean) do |c|
|
7
|
-
c.syntax
|
8
|
-
c.description
|
7
|
+
c.syntax "clean [subcommand]"
|
8
|
+
c.description "Clean the site " \
|
9
|
+
"(removes site output and metadata file) without building."
|
9
10
|
|
10
11
|
add_build_options(c)
|
11
12
|
|
@@ -17,23 +18,21 @@ module Jekyll
|
|
17
18
|
|
18
19
|
def process(options)
|
19
20
|
options = configuration_from_options(options)
|
20
|
-
destination = options[
|
21
|
-
metadata_file = File.join(options[
|
21
|
+
destination = options["destination"]
|
22
|
+
metadata_file = File.join(options["source"], ".jekyll-metadata")
|
23
|
+
sass_cache = File.join(options["source"], ".sass-cache")
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
else
|
28
|
-
Jekyll.logger.info "Nothing to do for #{destination}."
|
29
|
-
end
|
25
|
+
remove(destination, :checker_func => :directory?)
|
26
|
+
remove(metadata_file, :checker_func => :file?)
|
27
|
+
remove(sass_cache, :checker_func => :directory?)
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
def remove(filename, checker_func: :file?)
|
31
|
+
if File.public_send(checker_func, filename)
|
32
|
+
Jekyll.logger.info "Cleaner:", "Removing #{filename}..."
|
33
|
+
FileUtils.rm_rf(filename)
|
35
34
|
else
|
36
|
-
Jekyll.logger.info "Nothing to do for #{
|
35
|
+
Jekyll.logger.info "Cleaner:", "Nothing to do for #{filename}."
|
37
36
|
end
|
38
37
|
end
|
39
38
|
end
|
@@ -4,11 +4,12 @@ module Jekyll
|
|
4
4
|
class << self
|
5
5
|
def init_with_program(prog)
|
6
6
|
prog.command(:doctor) do |c|
|
7
|
-
c.syntax
|
8
|
-
c.description
|
7
|
+
c.syntax "doctor"
|
8
|
+
c.description "Search site and print specific deprecation warnings"
|
9
9
|
c.alias(:hyde)
|
10
10
|
|
11
|
-
c.option
|
11
|
+
c.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]", Array,
|
12
|
+
"Custom configuration file"
|
12
13
|
|
13
14
|
c.action do |_, options|
|
14
15
|
Jekyll::Commands::Doctor.process(options)
|
@@ -37,7 +38,7 @@ module Jekyll
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def deprecated_relative_permalinks(site)
|
40
|
-
if site.config[
|
41
|
+
if site.config["relative_permalinks"]
|
41
42
|
Jekyll::Deprecator.deprecation_message "Your site still uses relative" \
|
42
43
|
" permalinks, which was removed in" \
|
43
44
|
" Jekyll v3.0.0."
|
@@ -78,7 +79,7 @@ module Jekyll
|
|
78
79
|
def urls_only_differ_by_case(site)
|
79
80
|
urls_only_differ_by_case = false
|
80
81
|
urls = case_insensitive_urls(site.pages + site.docs_to_write, site.dest)
|
81
|
-
urls.each do |
|
82
|
+
urls.each do |_case_insensitive_url, real_urls|
|
82
83
|
next unless real_urls.uniq.size > 1
|
83
84
|
urls_only_differ_by_case = true
|
84
85
|
Jekyll.logger.warn "Warning:", "The following URLs only differ" \
|
@@ -102,10 +103,9 @@ module Jekyll
|
|
102
103
|
end
|
103
104
|
|
104
105
|
def case_insensitive_urls(things, destination)
|
105
|
-
things.
|
106
|
+
things.each_with_object({}) do |thing, memo|
|
106
107
|
dest = thing.destination(destination)
|
107
108
|
(memo[dest.downcase] ||= []) << dest
|
108
|
-
memo
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
data/lib/jekyll/commands/help.rb
CHANGED
@@ -4,8 +4,8 @@ module Jekyll
|
|
4
4
|
class << self
|
5
5
|
def init_with_program(prog)
|
6
6
|
prog.command(:help) do |c|
|
7
|
-
c.syntax
|
8
|
-
c.description
|
7
|
+
c.syntax "help [subcommand]"
|
8
|
+
c.description "Show the help message, optionally for a given subcommand."
|
9
9
|
|
10
10
|
c.action do |args, _|
|
11
11
|
cmd = (args.first || "").to_sym
|
@@ -22,7 +22,8 @@ module Jekyll
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def invalid_command(prog, cmd)
|
25
|
-
Jekyll.logger.error "Error:",
|
25
|
+
Jekyll.logger.error "Error:",
|
26
|
+
"Hmm... we don't know what the '#{cmd}' command is."
|
26
27
|
Jekyll.logger.info "Valid commands:", prog.commands.keys.join(", ")
|
27
28
|
end
|
28
29
|
end
|
data/lib/jekyll/commands/new.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "erb"
|
2
2
|
|
3
3
|
module Jekyll
|
4
4
|
module Commands
|
@@ -6,11 +6,11 @@ module Jekyll
|
|
6
6
|
class << self
|
7
7
|
def init_with_program(prog)
|
8
8
|
prog.command(:new) do |c|
|
9
|
-
c.syntax
|
10
|
-
c.description
|
9
|
+
c.syntax "new PATH"
|
10
|
+
c.description "Creates a new Jekyll site scaffold in PATH"
|
11
11
|
|
12
|
-
c.option
|
13
|
-
c.option
|
12
|
+
c.option "force", "--force", "Force creation even if PATH already exists"
|
13
|
+
c.option "blank", "--blank", "Creates scaffolding but with empty files"
|
14
14
|
|
15
15
|
c.action do |args, options|
|
16
16
|
Jekyll::Commands::New.process(args, options)
|
@@ -19,22 +19,19 @@ module Jekyll
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def process(args, options = {})
|
22
|
-
raise ArgumentError
|
22
|
+
raise ArgumentError, "You must specify a path." if args.empty?
|
23
23
|
|
24
24
|
new_blog_path = File.expand_path(args.join(" "), Dir.pwd)
|
25
25
|
FileUtils.mkdir_p new_blog_path
|
26
26
|
if preserve_source_location?(new_blog_path, options)
|
27
|
-
Jekyll.logger.abort_with "Conflict:",
|
27
|
+
Jekyll.logger.abort_with "Conflict:",
|
28
|
+
"#{new_blog_path} exists and is not empty."
|
28
29
|
end
|
29
30
|
|
30
31
|
if options["blank"]
|
31
32
|
create_blank_site new_blog_path
|
32
33
|
else
|
33
|
-
|
34
|
-
|
35
|
-
File.open(File.expand_path(initialized_post_name, new_blog_path), "w") do |f|
|
36
|
-
f.write(scaffold_post_content)
|
37
|
-
end
|
34
|
+
create_site new_blog_path
|
38
35
|
end
|
39
36
|
|
40
37
|
Jekyll.logger.info "New jekyll site installed in #{new_blog_path}."
|
@@ -55,17 +52,55 @@ module Jekyll
|
|
55
52
|
#
|
56
53
|
# Returns the filename of the sample post, as a String
|
57
54
|
def initialized_post_name
|
58
|
-
"_posts/#{Time.now.strftime(
|
55
|
+
"_posts/#{Time.now.strftime("%Y-%m-%d")}-welcome-to-jekyll.markdown"
|
59
56
|
end
|
60
57
|
|
61
58
|
private
|
62
59
|
|
60
|
+
def gemfile_contents
|
61
|
+
<<-RUBY
|
62
|
+
source "https://rubygems.org"
|
63
|
+
ruby RUBY_VERSION
|
64
|
+
|
65
|
+
# Hello! This is where you manage which Jekyll version is used to run.
|
66
|
+
# When you want to use a different version, change it below, save the
|
67
|
+
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
|
68
|
+
#
|
69
|
+
# bundle exec jekyll serve
|
70
|
+
#
|
71
|
+
# This will help ensure the proper Jekyll version is running.
|
72
|
+
# Happy Jekylling!
|
73
|
+
gem "jekyll", "#{Jekyll::VERSION}"
|
74
|
+
|
75
|
+
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
|
76
|
+
# uncomment the line below. To upgrade, run `bundle update github-pages`.
|
77
|
+
# gem "github-pages", group: :jekyll_plugins
|
78
|
+
|
79
|
+
# If you have any plugins, put them here!
|
80
|
+
# group :jekyll_plugins do
|
81
|
+
# gem "jekyll-github-metadata", "~> 1.0"
|
82
|
+
# end
|
83
|
+
RUBY
|
84
|
+
end
|
85
|
+
|
86
|
+
def create_site(new_blog_path)
|
87
|
+
create_sample_files new_blog_path
|
88
|
+
|
89
|
+
File.open(File.expand_path(initialized_post_name, new_blog_path), "w") do |f|
|
90
|
+
f.write(scaffold_post_content)
|
91
|
+
end
|
92
|
+
|
93
|
+
File.open(File.expand_path("Gemfile", new_blog_path), "w") do |f|
|
94
|
+
f.write(gemfile_contents)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
63
98
|
def preserve_source_location?(path, options)
|
64
99
|
!options["force"] && !Dir["#{path}/**/*"].empty?
|
65
100
|
end
|
66
101
|
|
67
102
|
def create_sample_files(path)
|
68
|
-
FileUtils.cp_r site_template +
|
103
|
+
FileUtils.cp_r site_template + "/.", path
|
69
104
|
FileUtils.rm File.expand_path(scaffold_path, path)
|
70
105
|
end
|
71
106
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "erb"
|
2
|
+
|
3
|
+
class Jekyll::Commands::NewTheme < Jekyll::Command
|
4
|
+
class << self
|
5
|
+
def init_with_program(prog)
|
6
|
+
prog.command(:"new-theme") do |c|
|
7
|
+
c.syntax "new-theme NAME"
|
8
|
+
c.description "Creates a new Jekyll theme scaffold"
|
9
|
+
|
10
|
+
c.action do |args, _|
|
11
|
+
Jekyll::Commands::NewTheme.process(args)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def process(args)
|
17
|
+
if !args || args.empty?
|
18
|
+
raise Jekyll::Errors::InvalidThemeName, "You must specify a theme name."
|
19
|
+
end
|
20
|
+
|
21
|
+
new_theme_name = args.join("_")
|
22
|
+
theme = Jekyll::ThemeBuilder.new(new_theme_name)
|
23
|
+
if theme.path.exist?
|
24
|
+
Jekyll.logger.abort_with "Conflict:", "#{theme.path} already exists."
|
25
|
+
end
|
26
|
+
|
27
|
+
theme.create!
|
28
|
+
Jekyll.logger.info "Your new Jekyll theme, #{theme.name}," \
|
29
|
+
" is ready for you in #{theme.path}!"
|
30
|
+
Jekyll.logger.info "For help getting started, read #{theme.path}/README.md."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -3,16 +3,18 @@ module Jekyll
|
|
3
3
|
class Serve < Command
|
4
4
|
class << self
|
5
5
|
COMMAND_OPTIONS = {
|
6
|
-
"ssl_cert"
|
7
|
-
"host"
|
8
|
-
"open_url"
|
9
|
-
"detach"
|
10
|
-
"ssl_key"
|
11
|
-
"port"
|
12
|
-
"baseurl"
|
6
|
+
"ssl_cert" => ["--ssl-cert [CERT]", "X.509 (SSL) certificate."],
|
7
|
+
"host" => ["host", "-H", "--host [HOST]", "Host to bind to"],
|
8
|
+
"open_url" => ["-o", "--open-url", "Launch your site in a browser"],
|
9
|
+
"detach" => ["-B", "--detach", "Run the server in the background"],
|
10
|
+
"ssl_key" => ["--ssl-key [KEY]", "X.509 (SSL) Private Key."],
|
11
|
+
"port" => ["-P", "--port [PORT]", "Port to listen on"],
|
12
|
+
"baseurl" => ["-b", "--baseurl [URL]", "Base URL"],
|
13
|
+
"show_dir_listing" => ["--show-dir-listing",
|
14
|
+
"Show a directory listing instead of loading your index file."],
|
13
15
|
"skip_initial_build" => ["skip_initial_build", "--skip-initial-build",
|
14
16
|
"Skips the initial site build which occurs before the server is started."]
|
15
|
-
}
|
17
|
+
}.freeze
|
16
18
|
|
17
19
|
#
|
18
20
|
|
@@ -91,6 +93,8 @@ module Jekyll
|
|
91
93
|
)
|
92
94
|
}
|
93
95
|
|
96
|
+
opts[:DirectoryIndex] = [] if opts[:JekyllOptions]["show_dir_listing"]
|
97
|
+
|
94
98
|
enable_ssl(opts)
|
95
99
|
enable_logging(opts)
|
96
100
|
opts
|
@@ -103,7 +107,7 @@ module Jekyll
|
|
103
107
|
WEBrick::Config::FileHandler.merge({
|
104
108
|
:FancyIndexing => true,
|
105
109
|
:NondisclosureName => [
|
106
|
-
|
110
|
+
".ht*", "~*"
|
107
111
|
]
|
108
112
|
})
|
109
113
|
end
|
@@ -112,27 +116,24 @@ module Jekyll
|
|
112
116
|
|
113
117
|
private
|
114
118
|
def server_address(server, opts)
|
115
|
-
"%{prefix}://%{address}:%{port}%{baseurl}"
|
116
|
-
:prefix
|
119
|
+
format("%{prefix}://%{address}:%{port}%{baseurl}", {
|
120
|
+
:prefix => server.config[:SSLEnable] ? "https" : "http",
|
117
121
|
:baseurl => opts["baseurl"] ? "#{opts["baseurl"]}/" : "",
|
118
122
|
:address => server.config[:BindAddress],
|
119
|
-
:port
|
120
|
-
}
|
123
|
+
:port => server.config[:Port]
|
124
|
+
})
|
121
125
|
end
|
122
126
|
|
123
127
|
#
|
124
128
|
|
125
129
|
private
|
126
130
|
def launch_browser(server, opts)
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
"xdg-open"
|
134
|
-
end
|
135
|
-
system command, server_address(server, opts)
|
131
|
+
address = server_address(server, opts)
|
132
|
+
return system "start", address if Utils::Platforms.windows?
|
133
|
+
return system "xdg-open", address if Utils::Platforms.linux?
|
134
|
+
return system "open", address if Utils::Platforms.osx?
|
135
|
+
Jekyll.logger.error "Refusing to launch browser; " \
|
136
|
+
"Platform launcher unknown."
|
136
137
|
end
|
137
138
|
|
138
139
|
# Keep in our area with a thread or detach the server as requested
|
@@ -170,22 +171,27 @@ module Jekyll
|
|
170
171
|
# forget to add one of the certificates.
|
171
172
|
|
172
173
|
private
|
174
|
+
# rubocop:disable Metrics/AbcSize
|
173
175
|
def enable_ssl(opts)
|
174
176
|
return if !opts[:JekyllOptions]["ssl_cert"] && !opts[:JekyllOptions]["ssl_key"]
|
175
177
|
if !opts[:JekyllOptions]["ssl_cert"] || !opts[:JekyllOptions]["ssl_key"]
|
178
|
+
# rubocop:disable Style/RedundantException
|
176
179
|
raise RuntimeError, "--ssl-cert or --ssl-key missing."
|
177
180
|
end
|
178
|
-
|
179
181
|
require "openssl"
|
180
182
|
require "webrick/https"
|
181
|
-
source_key = Jekyll.sanitized_path(opts[:JekyllOptions]["source"],
|
182
|
-
|
183
|
-
opts[:
|
183
|
+
source_key = Jekyll.sanitized_path(opts[:JekyllOptions]["source"], \
|
184
|
+
opts[:JekyllOptions]["ssl_key" ])
|
185
|
+
source_certificate = Jekyll.sanitized_path(opts[:JekyllOptions]["source"], \
|
186
|
+
opts[:JekyllOptions]["ssl_cert"])
|
187
|
+
opts[:SSLCertificate] =
|
188
|
+
OpenSSL::X509::Certificate.new(File.read(source_certificate))
|
184
189
|
opts[:SSLPrivateKey ] = OpenSSL::PKey::RSA.new(File.read(source_key))
|
185
190
|
opts[:SSLEnable] = true
|
186
191
|
end
|
187
192
|
|
188
193
|
private
|
194
|
+
|
189
195
|
def start_callback(detached)
|
190
196
|
unless detached
|
191
197
|
proc do
|
@@ -196,7 +202,7 @@ module Jekyll
|
|
196
202
|
|
197
203
|
private
|
198
204
|
def mime_types
|
199
|
-
file = File.expand_path(
|
205
|
+
file = File.expand_path("../mime.types", File.dirname(__FILE__))
|
200
206
|
WEBrick::HTTPUtils.load_mime_types(file)
|
201
207
|
end
|
202
208
|
end
|