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/command.rb
CHANGED
|
@@ -1,105 +1,105 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jekyll
|
|
4
|
-
class Command
|
|
5
|
-
class << self
|
|
6
|
-
# A list of subclasses of Jekyll::Command
|
|
7
|
-
def subclasses
|
|
8
|
-
@subclasses ||= []
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
# Keep a list of subclasses of Jekyll::Command every time it's inherited
|
|
12
|
-
# Called automatically.
|
|
13
|
-
#
|
|
14
|
-
# base - the subclass
|
|
15
|
-
#
|
|
16
|
-
# Returns nothing
|
|
17
|
-
def inherited(base)
|
|
18
|
-
subclasses << base
|
|
19
|
-
super(base)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# Run Site#process and catch errors
|
|
23
|
-
#
|
|
24
|
-
# site - the Jekyll::Site object
|
|
25
|
-
#
|
|
26
|
-
# Returns nothing
|
|
27
|
-
def process_site(site)
|
|
28
|
-
site.process
|
|
29
|
-
rescue Jekyll::Errors::FatalException => e
|
|
30
|
-
Jekyll.logger.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:"
|
|
31
|
-
Jekyll.logger.error "", "------------------------------------"
|
|
32
|
-
Jekyll.logger.error "", e.message
|
|
33
|
-
exit(1)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
# Create a full Jekyll configuration with the options passed in as overrides
|
|
37
|
-
#
|
|
38
|
-
# options - the configuration overrides
|
|
39
|
-
#
|
|
40
|
-
# Returns a full Jekyll configuration
|
|
41
|
-
def configuration_from_options(options)
|
|
42
|
-
return options if options.is_a?(Jekyll::Configuration)
|
|
43
|
-
|
|
44
|
-
Jekyll.configuration(options)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# Add common options to a command for building configuration
|
|
48
|
-
#
|
|
49
|
-
# cmd - the Jekyll::Command to add these options to
|
|
50
|
-
#
|
|
51
|
-
# Returns nothing
|
|
52
|
-
# rubocop:disable Metrics/MethodLength
|
|
53
|
-
def add_build_options(cmd)
|
|
54
|
-
cmd.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]",
|
|
55
|
-
Array, "Custom configuration file"
|
|
56
|
-
cmd.option "destination", "-d", "--destination DESTINATION",
|
|
57
|
-
"The current folder will be generated into DESTINATION"
|
|
58
|
-
cmd.option "source", "-s", "--source SOURCE", "Custom source directory"
|
|
59
|
-
cmd.option "future", "--future", "Publishes posts with a future date"
|
|
60
|
-
cmd.option "limit_posts", "--limit_posts MAX_POSTS", Integer,
|
|
61
|
-
"Limits the number of posts to parse and publish"
|
|
62
|
-
cmd.option "watch", "-w", "--[no-]watch", "Watch for changes and rebuild"
|
|
63
|
-
cmd.option "baseurl", "-b", "--baseurl URL",
|
|
64
|
-
"Serve the website from the given base URL"
|
|
65
|
-
cmd.option "force_polling", "--force_polling", "Force watch to use polling"
|
|
66
|
-
cmd.option "lsi", "--lsi", "Use LSI for improved related posts"
|
|
67
|
-
cmd.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder"
|
|
68
|
-
cmd.option "unpublished", "--unpublished",
|
|
69
|
-
"Render posts that were marked as unpublished"
|
|
70
|
-
cmd.option "disable_disk_cache", "--disable-disk-cache",
|
|
71
|
-
"Disable caching to disk in non-safe mode"
|
|
72
|
-
cmd.option "quiet", "-q", "--quiet", "Silence output."
|
|
73
|
-
cmd.option "verbose", "-V", "--verbose", "Print verbose output."
|
|
74
|
-
cmd.option "incremental", "-I", "--incremental", "Enable incremental rebuild."
|
|
75
|
-
cmd.option "strict_front_matter", "--strict_front_matter",
|
|
76
|
-
"Fail if errors are present in front matter"
|
|
77
|
-
end
|
|
78
|
-
# rubocop:enable Metrics/MethodLength
|
|
79
|
-
|
|
80
|
-
# Run ::process method in a given set of Jekyll::Command subclasses and suggest
|
|
81
|
-
# re-running the associated command with --trace switch to obtain any additional
|
|
82
|
-
# information or backtrace regarding the encountered Exception.
|
|
83
|
-
#
|
|
84
|
-
# cmd - the Jekyll::Command to be handled
|
|
85
|
-
# options - configuration overrides
|
|
86
|
-
# klass - an array of Jekyll::Command subclasses associated with the command
|
|
87
|
-
#
|
|
88
|
-
# Note that all exceptions are rescued..
|
|
89
|
-
# rubocop: disable Lint/RescueException
|
|
90
|
-
def process_with_graceful_fail(cmd, options, *klass)
|
|
91
|
-
klass.each { |k| k.process(options) if k.respond_to?(:process) }
|
|
92
|
-
rescue Exception => e
|
|
93
|
-
raise e if cmd.trace
|
|
94
|
-
|
|
95
|
-
msg = " Please append `--trace` to the `#{cmd.name}` command "
|
|
96
|
-
dashes = "-" * msg.length
|
|
97
|
-
Jekyll.logger.error "", dashes
|
|
98
|
-
Jekyll.logger.error "Jekyll #{Jekyll::VERSION} ", msg
|
|
99
|
-
Jekyll.logger.error "", " for any additional information or backtrace. "
|
|
100
|
-
Jekyll.logger.abort_with "", dashes
|
|
101
|
-
end
|
|
102
|
-
# rubocop: enable Lint/RescueException
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jekyll
|
|
4
|
+
class Command
|
|
5
|
+
class << self
|
|
6
|
+
# A list of subclasses of Jekyll::Command
|
|
7
|
+
def subclasses
|
|
8
|
+
@subclasses ||= []
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Keep a list of subclasses of Jekyll::Command every time it's inherited
|
|
12
|
+
# Called automatically.
|
|
13
|
+
#
|
|
14
|
+
# base - the subclass
|
|
15
|
+
#
|
|
16
|
+
# Returns nothing
|
|
17
|
+
def inherited(base)
|
|
18
|
+
subclasses << base
|
|
19
|
+
super(base)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Run Site#process and catch errors
|
|
23
|
+
#
|
|
24
|
+
# site - the Jekyll::Site object
|
|
25
|
+
#
|
|
26
|
+
# Returns nothing
|
|
27
|
+
def process_site(site)
|
|
28
|
+
site.process
|
|
29
|
+
rescue Jekyll::Errors::FatalException => e
|
|
30
|
+
Jekyll.logger.error "ERROR:", "YOUR SITE COULD NOT BE BUILT:"
|
|
31
|
+
Jekyll.logger.error "", "------------------------------------"
|
|
32
|
+
Jekyll.logger.error "", e.message
|
|
33
|
+
exit(1)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Create a full Jekyll configuration with the options passed in as overrides
|
|
37
|
+
#
|
|
38
|
+
# options - the configuration overrides
|
|
39
|
+
#
|
|
40
|
+
# Returns a full Jekyll configuration
|
|
41
|
+
def configuration_from_options(options)
|
|
42
|
+
return options if options.is_a?(Jekyll::Configuration)
|
|
43
|
+
|
|
44
|
+
Jekyll.configuration(options)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Add common options to a command for building configuration
|
|
48
|
+
#
|
|
49
|
+
# cmd - the Jekyll::Command to add these options to
|
|
50
|
+
#
|
|
51
|
+
# Returns nothing
|
|
52
|
+
# rubocop:disable Metrics/MethodLength
|
|
53
|
+
def add_build_options(cmd)
|
|
54
|
+
cmd.option "config", "--config CONFIG_FILE[,CONFIG_FILE2,...]",
|
|
55
|
+
Array, "Custom configuration file"
|
|
56
|
+
cmd.option "destination", "-d", "--destination DESTINATION",
|
|
57
|
+
"The current folder will be generated into DESTINATION"
|
|
58
|
+
cmd.option "source", "-s", "--source SOURCE", "Custom source directory"
|
|
59
|
+
cmd.option "future", "--future", "Publishes posts with a future date"
|
|
60
|
+
cmd.option "limit_posts", "--limit_posts MAX_POSTS", Integer,
|
|
61
|
+
"Limits the number of posts to parse and publish"
|
|
62
|
+
cmd.option "watch", "-w", "--[no-]watch", "Watch for changes and rebuild"
|
|
63
|
+
cmd.option "baseurl", "-b", "--baseurl URL",
|
|
64
|
+
"Serve the website from the given base URL"
|
|
65
|
+
cmd.option "force_polling", "--force_polling", "Force watch to use polling"
|
|
66
|
+
cmd.option "lsi", "--lsi", "Use LSI for improved related posts"
|
|
67
|
+
cmd.option "show_drafts", "-D", "--drafts", "Render posts in the _drafts folder"
|
|
68
|
+
cmd.option "unpublished", "--unpublished",
|
|
69
|
+
"Render posts that were marked as unpublished"
|
|
70
|
+
cmd.option "disable_disk_cache", "--disable-disk-cache",
|
|
71
|
+
"Disable caching to disk in non-safe mode"
|
|
72
|
+
cmd.option "quiet", "-q", "--quiet", "Silence output."
|
|
73
|
+
cmd.option "verbose", "-V", "--verbose", "Print verbose output."
|
|
74
|
+
cmd.option "incremental", "-I", "--incremental", "Enable incremental rebuild."
|
|
75
|
+
cmd.option "strict_front_matter", "--strict_front_matter",
|
|
76
|
+
"Fail if errors are present in front matter"
|
|
77
|
+
end
|
|
78
|
+
# rubocop:enable Metrics/MethodLength
|
|
79
|
+
|
|
80
|
+
# Run ::process method in a given set of Jekyll::Command subclasses and suggest
|
|
81
|
+
# re-running the associated command with --trace switch to obtain any additional
|
|
82
|
+
# information or backtrace regarding the encountered Exception.
|
|
83
|
+
#
|
|
84
|
+
# cmd - the Jekyll::Command to be handled
|
|
85
|
+
# options - configuration overrides
|
|
86
|
+
# klass - an array of Jekyll::Command subclasses associated with the command
|
|
87
|
+
#
|
|
88
|
+
# Note that all exceptions are rescued..
|
|
89
|
+
# rubocop: disable Lint/RescueException
|
|
90
|
+
def process_with_graceful_fail(cmd, options, *klass)
|
|
91
|
+
klass.each { |k| k.process(options) if k.respond_to?(:process) }
|
|
92
|
+
rescue Exception => e
|
|
93
|
+
raise e if cmd.trace
|
|
94
|
+
|
|
95
|
+
msg = " Please append `--trace` to the `#{cmd.name}` command "
|
|
96
|
+
dashes = "-" * msg.length
|
|
97
|
+
Jekyll.logger.error "", dashes
|
|
98
|
+
Jekyll.logger.error "Jekyll #{Jekyll::VERSION} ", msg
|
|
99
|
+
Jekyll.logger.error "", " for any additional information or backtrace. "
|
|
100
|
+
Jekyll.logger.abort_with "", dashes
|
|
101
|
+
end
|
|
102
|
+
# rubocop: enable Lint/RescueException
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jekyll
|
|
4
|
-
module Commands
|
|
5
|
-
class Build < Command
|
|
6
|
-
class << self
|
|
7
|
-
# Create the Mercenary command for the Jekyll CLI for this Command
|
|
8
|
-
def init_with_program(prog)
|
|
9
|
-
prog.command(:build) do |c|
|
|
10
|
-
c.syntax "build [options]"
|
|
11
|
-
c.description "Build your site"
|
|
12
|
-
c.alias :b
|
|
13
|
-
|
|
14
|
-
add_build_options(c)
|
|
15
|
-
|
|
16
|
-
c.action do |_, options|
|
|
17
|
-
options["serving"] = false
|
|
18
|
-
process_with_graceful_fail(c, options, self)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Build your jekyll site
|
|
24
|
-
# Continuously watch if `watch` is set to true in the config.
|
|
25
|
-
def process(options)
|
|
26
|
-
# Adjust verbosity quickly
|
|
27
|
-
Jekyll.logger.adjust_verbosity(options)
|
|
28
|
-
|
|
29
|
-
options = configuration_from_options(options)
|
|
30
|
-
site = Jekyll::Site.new(options)
|
|
31
|
-
|
|
32
|
-
if options.fetch("skip_initial_build", false)
|
|
33
|
-
Jekyll.logger.warn "Build Warning:", "Skipping the initial build." \
|
|
34
|
-
" This may result in an out-of-date site."
|
|
35
|
-
else
|
|
36
|
-
build(site, options)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
if options.fetch("detach", false)
|
|
40
|
-
Jekyll.logger.info "Auto-regeneration:",
|
|
41
|
-
"disabled when running server detached."
|
|
42
|
-
elsif options.fetch("watch", false)
|
|
43
|
-
watch(site, options)
|
|
44
|
-
else
|
|
45
|
-
Jekyll.logger.info "Auto-regeneration:", "disabled. Use --watch to enable."
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# Build your Jekyll site.
|
|
50
|
-
#
|
|
51
|
-
# site - the Jekyll::Site instance to build
|
|
52
|
-
# options - A Hash of options passed to the command
|
|
53
|
-
#
|
|
54
|
-
# Returns nothing.
|
|
55
|
-
def build(site, options)
|
|
56
|
-
t = Time.now
|
|
57
|
-
source = File.expand_path(options["source"])
|
|
58
|
-
destination = File.expand_path(options["destination"])
|
|
59
|
-
incremental = options["incremental"]
|
|
60
|
-
Jekyll.logger.info "Source:", source
|
|
61
|
-
Jekyll.logger.info "Destination:", destination
|
|
62
|
-
Jekyll.logger.info "Incremental build:",
|
|
63
|
-
(incremental ? "enabled" : "disabled. Enable with --incremental")
|
|
64
|
-
Jekyll.logger.info "Generating..."
|
|
65
|
-
process_site(site)
|
|
66
|
-
Jekyll.logger.info "", "done in #{(Time.now - t).round(3)} seconds."
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# Private: Watch for file changes and rebuild the site.
|
|
70
|
-
#
|
|
71
|
-
# site - A Jekyll::Site instance
|
|
72
|
-
# options - A Hash of options passed to the command
|
|
73
|
-
#
|
|
74
|
-
# Returns nothing.
|
|
75
|
-
def watch(site, options)
|
|
76
|
-
# Warn Windows users that they might need to upgrade.
|
|
77
|
-
if Utils::Platforms.bash_on_windows?
|
|
78
|
-
Jekyll.logger.warn "",
|
|
79
|
-
"Auto-regeneration may not work on some Windows versions."
|
|
80
|
-
Jekyll.logger.warn "",
|
|
81
|
-
"Please see: https://github.com/Microsoft/BashOnWindows/issues/216"
|
|
82
|
-
Jekyll.logger.warn "",
|
|
83
|
-
"If it does not work, please upgrade Bash on Windows or "\
|
|
84
|
-
"run Jekyll with --no-watch."
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
External.require_with_graceful_fail "jekyll-watch"
|
|
88
|
-
Jekyll::Watcher.watch(options, site)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jekyll
|
|
4
|
+
module Commands
|
|
5
|
+
class Build < Command
|
|
6
|
+
class << self
|
|
7
|
+
# Create the Mercenary command for the Jekyll CLI for this Command
|
|
8
|
+
def init_with_program(prog)
|
|
9
|
+
prog.command(:build) do |c|
|
|
10
|
+
c.syntax "build [options]"
|
|
11
|
+
c.description "Build your site"
|
|
12
|
+
c.alias :b
|
|
13
|
+
|
|
14
|
+
add_build_options(c)
|
|
15
|
+
|
|
16
|
+
c.action do |_, options|
|
|
17
|
+
options["serving"] = false
|
|
18
|
+
process_with_graceful_fail(c, options, self)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Build your jekyll site
|
|
24
|
+
# Continuously watch if `watch` is set to true in the config.
|
|
25
|
+
def process(options)
|
|
26
|
+
# Adjust verbosity quickly
|
|
27
|
+
Jekyll.logger.adjust_verbosity(options)
|
|
28
|
+
|
|
29
|
+
options = configuration_from_options(options)
|
|
30
|
+
site = Jekyll::Site.new(options)
|
|
31
|
+
|
|
32
|
+
if options.fetch("skip_initial_build", false)
|
|
33
|
+
Jekyll.logger.warn "Build Warning:", "Skipping the initial build." \
|
|
34
|
+
" This may result in an out-of-date site."
|
|
35
|
+
else
|
|
36
|
+
build(site, options)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
if options.fetch("detach", false)
|
|
40
|
+
Jekyll.logger.info "Auto-regeneration:",
|
|
41
|
+
"disabled when running server detached."
|
|
42
|
+
elsif options.fetch("watch", false)
|
|
43
|
+
watch(site, options)
|
|
44
|
+
else
|
|
45
|
+
Jekyll.logger.info "Auto-regeneration:", "disabled. Use --watch to enable."
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Build your Jekyll site.
|
|
50
|
+
#
|
|
51
|
+
# site - the Jekyll::Site instance to build
|
|
52
|
+
# options - A Hash of options passed to the command
|
|
53
|
+
#
|
|
54
|
+
# Returns nothing.
|
|
55
|
+
def build(site, options)
|
|
56
|
+
t = Time.now
|
|
57
|
+
source = File.expand_path(options["source"])
|
|
58
|
+
destination = File.expand_path(options["destination"])
|
|
59
|
+
incremental = options["incremental"]
|
|
60
|
+
Jekyll.logger.info "Source:", source
|
|
61
|
+
Jekyll.logger.info "Destination:", destination
|
|
62
|
+
Jekyll.logger.info "Incremental build:",
|
|
63
|
+
(incremental ? "enabled" : "disabled. Enable with --incremental")
|
|
64
|
+
Jekyll.logger.info "Generating..."
|
|
65
|
+
process_site(site)
|
|
66
|
+
Jekyll.logger.info "", "done in #{(Time.now - t).round(3)} seconds."
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Private: Watch for file changes and rebuild the site.
|
|
70
|
+
#
|
|
71
|
+
# site - A Jekyll::Site instance
|
|
72
|
+
# options - A Hash of options passed to the command
|
|
73
|
+
#
|
|
74
|
+
# Returns nothing.
|
|
75
|
+
def watch(site, options)
|
|
76
|
+
# Warn Windows users that they might need to upgrade.
|
|
77
|
+
if Utils::Platforms.bash_on_windows?
|
|
78
|
+
Jekyll.logger.warn "",
|
|
79
|
+
"Auto-regeneration may not work on some Windows versions."
|
|
80
|
+
Jekyll.logger.warn "",
|
|
81
|
+
"Please see: https://github.com/Microsoft/BashOnWindows/issues/216"
|
|
82
|
+
Jekyll.logger.warn "",
|
|
83
|
+
"If it does not work, please upgrade Bash on Windows or "\
|
|
84
|
+
"run Jekyll with --no-watch."
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
External.require_with_graceful_fail "jekyll-watch"
|
|
88
|
+
Jekyll::Watcher.watch(options, site)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Jekyll
|
|
4
|
-
module Commands
|
|
5
|
-
class Clean < Command
|
|
6
|
-
class << self
|
|
7
|
-
def init_with_program(prog)
|
|
8
|
-
prog.command(:clean) do |c|
|
|
9
|
-
c.syntax "clean [subcommand]"
|
|
10
|
-
c.description "Clean the site " \
|
|
11
|
-
"(removes site output and metadata file) without building."
|
|
12
|
-
|
|
13
|
-
add_build_options(c)
|
|
14
|
-
|
|
15
|
-
c.action do |_, options|
|
|
16
|
-
Jekyll::Commands::Clean.process(options)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def process(options)
|
|
22
|
-
options = configuration_from_options(options)
|
|
23
|
-
destination = options["destination"]
|
|
24
|
-
metadata_file = File.join(options["source"], ".jekyll-metadata")
|
|
25
|
-
cache_dir = File.join(options["source"], options["cache_dir"])
|
|
26
|
-
sass_cache = ".sass-cache"
|
|
27
|
-
|
|
28
|
-
remove(destination, :checker_func => :directory?)
|
|
29
|
-
remove(metadata_file, :checker_func => :file?)
|
|
30
|
-
remove(cache_dir, :checker_func => :directory?)
|
|
31
|
-
remove(sass_cache, :checker_func => :directory?)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def remove(filename, checker_func: :file?)
|
|
35
|
-
if File.public_send(checker_func, filename)
|
|
36
|
-
Jekyll.logger.info "Cleaner:", "Removing #{filename}..."
|
|
37
|
-
FileUtils.rm_rf(filename)
|
|
38
|
-
else
|
|
39
|
-
Jekyll.logger.info "Cleaner:", "Nothing to do for #{filename}."
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jekyll
|
|
4
|
+
module Commands
|
|
5
|
+
class Clean < Command
|
|
6
|
+
class << self
|
|
7
|
+
def init_with_program(prog)
|
|
8
|
+
prog.command(:clean) do |c|
|
|
9
|
+
c.syntax "clean [subcommand]"
|
|
10
|
+
c.description "Clean the site " \
|
|
11
|
+
"(removes site output and metadata file) without building."
|
|
12
|
+
|
|
13
|
+
add_build_options(c)
|
|
14
|
+
|
|
15
|
+
c.action do |_, options|
|
|
16
|
+
Jekyll::Commands::Clean.process(options)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def process(options)
|
|
22
|
+
options = configuration_from_options(options)
|
|
23
|
+
destination = options["destination"]
|
|
24
|
+
metadata_file = File.join(options["source"], ".jekyll-metadata")
|
|
25
|
+
cache_dir = File.join(options["source"], options["cache_dir"])
|
|
26
|
+
sass_cache = ".sass-cache"
|
|
27
|
+
|
|
28
|
+
remove(destination, :checker_func => :directory?)
|
|
29
|
+
remove(metadata_file, :checker_func => :file?)
|
|
30
|
+
remove(cache_dir, :checker_func => :directory?)
|
|
31
|
+
remove(sass_cache, :checker_func => :directory?)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def remove(filename, checker_func: :file?)
|
|
35
|
+
if File.public_send(checker_func, filename)
|
|
36
|
+
Jekyll.logger.info "Cleaner:", "Removing #{filename}..."
|
|
37
|
+
FileUtils.rm_rf(filename)
|
|
38
|
+
else
|
|
39
|
+
Jekyll.logger.info "Cleaner:", "Nothing to do for #{filename}."
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|