jekyll 3.10.0 → 4.0.0.pre.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +27 -50
- data/LICENSE +1 -1
- data/README.markdown +46 -17
- data/lib/blank_template/_config.yml +3 -0
- data/lib/blank_template/_layouts/default.html +12 -0
- data/lib/blank_template/_sass/main.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 +183 -0
- data/lib/jekyll/cleaner.rb +2 -1
- data/lib/jekyll/collection.rb +78 -8
- data/lib/jekyll/command.rb +31 -6
- data/lib/jekyll/commands/build.rb +11 -20
- data/lib/jekyll/commands/clean.rb +2 -0
- data/lib/jekyll/commands/doctor.rb +15 -8
- data/lib/jekyll/commands/help.rb +1 -1
- data/lib/jekyll/commands/new.rb +37 -42
- data/lib/jekyll/commands/new_theme.rb +30 -28
- data/lib/jekyll/commands/serve/live_reload_reactor.rb +6 -10
- data/lib/jekyll/commands/serve/servlet.rb +15 -19
- data/lib/jekyll/commands/serve.rb +46 -86
- data/lib/jekyll/configuration.rb +26 -26
- data/lib/jekyll/converters/identity.rb +18 -0
- data/lib/jekyll/converters/markdown/kramdown_parser.rb +1 -10
- data/lib/jekyll/converters/markdown.rb +49 -40
- data/lib/jekyll/converters/smartypants.rb +34 -14
- data/lib/jekyll/convertible.rb +11 -13
- data/lib/jekyll/deprecator.rb +1 -3
- data/lib/jekyll/document.rb +44 -41
- data/lib/jekyll/drops/collection_drop.rb +2 -3
- data/lib/jekyll/drops/document_drop.rb +2 -1
- data/lib/jekyll/drops/drop.rb +3 -6
- data/lib/jekyll/drops/excerpt_drop.rb +4 -0
- data/lib/jekyll/drops/site_drop.rb +4 -13
- data/lib/jekyll/drops/unified_payload_drop.rb +1 -0
- data/lib/jekyll/drops/url_drop.rb +1 -0
- data/lib/jekyll/entry_filter.rb +2 -1
- data/lib/jekyll/excerpt.rb +45 -34
- data/lib/jekyll/external.rb +10 -5
- 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 +6 -1
- data/lib/jekyll/filters.rb +72 -31
- data/lib/jekyll/frontmatter_defaults.rb +35 -19
- data/lib/jekyll/hooks.rb +2 -3
- data/lib/jekyll/liquid_extensions.rb +0 -2
- data/lib/jekyll/liquid_renderer/file.rb +14 -3
- data/lib/jekyll/liquid_renderer/table.rb +67 -65
- data/lib/jekyll/liquid_renderer.rb +13 -1
- data/lib/jekyll/log_adapter.rb +5 -1
- data/lib/jekyll/mime.types +80 -195
- data/lib/jekyll/page.rb +10 -26
- data/lib/jekyll/page_without_a_file.rb +0 -4
- data/lib/jekyll/plugin.rb +5 -11
- data/lib/jekyll/plugin_manager.rb +2 -0
- data/lib/jekyll/reader.rb +38 -8
- data/lib/jekyll/readers/data_reader.rb +5 -5
- data/lib/jekyll/readers/layout_reader.rb +2 -12
- data/lib/jekyll/readers/post_reader.rb +29 -17
- data/lib/jekyll/readers/static_file_reader.rb +1 -1
- data/lib/jekyll/readers/theme_assets_reader.rb +7 -5
- data/lib/jekyll/regenerator.rb +4 -12
- data/lib/jekyll/renderer.rb +14 -25
- data/lib/jekyll/site.rb +78 -34
- data/lib/jekyll/static_file.rb +47 -11
- data/lib/jekyll/stevenson.rb +7 -5
- data/lib/jekyll/tags/highlight.rb +22 -52
- data/lib/jekyll/tags/include.rb +27 -48
- data/lib/jekyll/tags/link.rb +11 -7
- data/lib/jekyll/tags/post_url.rb +17 -16
- data/lib/jekyll/theme.rb +12 -23
- data/lib/jekyll/theme_builder.rb +91 -89
- data/lib/jekyll/url.rb +3 -2
- data/lib/jekyll/utils/ansi.rb +1 -1
- data/lib/jekyll/utils/exec.rb +0 -1
- data/lib/jekyll/utils/internet.rb +2 -4
- data/lib/jekyll/utils/platforms.rb +8 -8
- data/lib/jekyll/utils/thread_event.rb +1 -5
- data/lib/jekyll/utils/win_tz.rb +47 -18
- data/lib/jekyll/utils.rb +5 -4
- data/lib/jekyll/version.rb +1 -1
- data/lib/jekyll.rb +5 -0
- data/lib/site_template/.gitignore +2 -0
- data/lib/site_template/404.html +1 -0
- 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/gitignore.erb +1 -0
- data/rubocop/jekyll/assert_equal_literal_actual.rb +149 -0
- metadata +70 -71
- data/lib/jekyll/commands/serve/mime_types_charset.json +0 -71
- 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/page.rb
CHANGED
@@ -11,8 +11,6 @@ module Jekyll
|
|
11
11
|
|
12
12
|
alias_method :extname, :ext
|
13
13
|
|
14
|
-
FORWARD_SLASH = "/".freeze
|
15
|
-
|
16
14
|
# Attributes for Liquid templates
|
17
15
|
ATTRIBUTES_FOR_LIQUID = %w(
|
18
16
|
content
|
@@ -52,7 +50,7 @@ module Jekyll
|
|
52
50
|
read_yaml(File.join(base, dir), name)
|
53
51
|
|
54
52
|
data.default_proc = proc do |_, key|
|
55
|
-
site.frontmatter_defaults.find(
|
53
|
+
site.frontmatter_defaults.find(relative_path, type, key)
|
56
54
|
end
|
57
55
|
|
58
56
|
Jekyll::Hooks.trigger :pages, :post_init, self
|
@@ -64,11 +62,11 @@ module Jekyll
|
|
64
62
|
#
|
65
63
|
# Returns the String destination directory.
|
66
64
|
def dir
|
67
|
-
if url.end_with?(
|
65
|
+
if url.end_with?("/")
|
68
66
|
url
|
69
67
|
else
|
70
68
|
url_dir = File.dirname(url)
|
71
|
-
url_dir.end_with?(
|
69
|
+
url_dir.end_with?("/") ? url_dir : "#{url_dir}/"
|
72
70
|
end
|
73
71
|
end
|
74
72
|
|
@@ -97,11 +95,11 @@ module Jekyll
|
|
97
95
|
#
|
98
96
|
# Returns the String url.
|
99
97
|
def url
|
100
|
-
@url ||= URL.new(
|
98
|
+
@url ||= URL.new(
|
101
99
|
:template => template,
|
102
100
|
:placeholders => url_placeholders,
|
103
|
-
:permalink => permalink
|
104
|
-
|
101
|
+
:permalink => permalink
|
102
|
+
).to_s
|
105
103
|
end
|
106
104
|
|
107
105
|
# Returns a hash of URL placeholder names (as symbols) mapping to the
|
@@ -118,10 +116,11 @@ module Jekyll
|
|
118
116
|
#
|
119
117
|
# name - The String filename of the page file.
|
120
118
|
#
|
119
|
+
# NOTE: `String#gsub` removes all trailing periods (in comparison to `String#chomp`)
|
121
120
|
# Returns nothing.
|
122
121
|
def process(name)
|
123
122
|
self.ext = File.extname(name)
|
124
|
-
self.basename = name[0..-ext.length - 1]
|
123
|
+
self.basename = name[0..-ext.length - 1].gsub(%r!\.*\z!, "")
|
125
124
|
end
|
126
125
|
|
127
126
|
# Add any necessary layouts to this post
|
@@ -146,7 +145,7 @@ module Jekyll
|
|
146
145
|
|
147
146
|
# The path to the page source file, relative to the site source
|
148
147
|
def relative_path
|
149
|
-
File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).sub(%r!\A\/!, "")
|
148
|
+
@relative_path ||= File.join(*[@dir, @name].map(&:to_s).reject(&:empty?)).sub(%r!\A\/!, "")
|
150
149
|
end
|
151
150
|
|
152
151
|
# Obtain destination path.
|
@@ -163,7 +162,7 @@ module Jekyll
|
|
163
162
|
|
164
163
|
# Returns the object as a debug String.
|
165
164
|
def inspect
|
166
|
-
"
|
165
|
+
"#<#{self.class} @relative_path=#{relative_path.inspect}>"
|
167
166
|
end
|
168
167
|
|
169
168
|
# Returns the Boolean of whether this Page is HTML or not.
|
@@ -183,20 +182,5 @@ module Jekyll
|
|
183
182
|
def write?
|
184
183
|
true
|
185
184
|
end
|
186
|
-
|
187
|
-
# The Page excerpt_separator, from the YAML Front-Matter or site
|
188
|
-
# default excerpt_separator value
|
189
|
-
#
|
190
|
-
# Returns the document excerpt_separator
|
191
|
-
def excerpt_separator
|
192
|
-
(data["excerpt_separator"] || site.config["excerpt_separator"]).to_s
|
193
|
-
end
|
194
|
-
|
195
|
-
# Whether to generate an excerpt
|
196
|
-
#
|
197
|
-
# Returns true if the excerpt separator is configured.
|
198
|
-
def generate_excerpt?
|
199
|
-
!excerpt_separator.empty?
|
200
|
-
end
|
201
185
|
end
|
202
186
|
end
|
data/lib/jekyll/plugin.rb
CHANGED
@@ -13,7 +13,7 @@ module Jekyll
|
|
13
13
|
#
|
14
14
|
|
15
15
|
def self.inherited(const)
|
16
|
-
|
16
|
+
catch_inheritance(const) do |const_|
|
17
17
|
catch_inheritance(const_)
|
18
18
|
end
|
19
19
|
end
|
@@ -23,9 +23,7 @@ module Jekyll
|
|
23
23
|
def self.catch_inheritance(const)
|
24
24
|
const.define_singleton_method :inherited do |const_|
|
25
25
|
(@children ||= Set.new).add const_
|
26
|
-
if block_given?
|
27
|
-
yield const_
|
28
|
-
end
|
26
|
+
yield const_ if block_given?
|
29
27
|
end
|
30
28
|
end
|
31
29
|
|
@@ -48,9 +46,7 @@ module Jekyll
|
|
48
46
|
# Returns the Symbol priority.
|
49
47
|
def self.priority(priority = nil)
|
50
48
|
@priority ||= nil
|
51
|
-
if priority && PRIORITIES.key?(priority)
|
52
|
-
@priority = priority
|
53
|
-
end
|
49
|
+
@priority = priority if priority && PRIORITIES.key?(priority)
|
54
50
|
@priority || :normal
|
55
51
|
end
|
56
52
|
|
@@ -62,9 +58,7 @@ module Jekyll
|
|
62
58
|
#
|
63
59
|
# Returns the safety Boolean.
|
64
60
|
def self.safe(safe = nil)
|
65
|
-
unless defined?(@safe) && safe.nil?
|
66
|
-
@safe = safe
|
67
|
-
end
|
61
|
+
@safe = safe unless defined?(@safe) && safe.nil?
|
68
62
|
@safe || false
|
69
63
|
end
|
70
64
|
|
@@ -74,7 +68,7 @@ module Jekyll
|
|
74
68
|
#
|
75
69
|
# Returns -1, 0, 1.
|
76
70
|
def self.<=>(other)
|
77
|
-
PRIORITIES[other.priority] <=> PRIORITIES[
|
71
|
+
PRIORITIES[other.priority] <=> PRIORITIES[priority]
|
78
72
|
end
|
79
73
|
|
80
74
|
# Spaceship is priority [higher -> lower]
|
@@ -37,8 +37,10 @@ module Jekyll
|
|
37
37
|
# Returns false only if no dependencies have been specified, otherwise nothing.
|
38
38
|
def require_theme_deps
|
39
39
|
return false unless site.theme.runtime_dependencies
|
40
|
+
|
40
41
|
site.theme.runtime_dependencies.each do |dep|
|
41
42
|
next if dep.name == "jekyll"
|
43
|
+
|
42
44
|
External.require_with_graceful_fail(dep.name) if plugin_allowed?(dep.name)
|
43
45
|
end
|
44
46
|
end
|
data/lib/jekyll/reader.rb
CHANGED
@@ -14,6 +14,7 @@ module Jekyll
|
|
14
14
|
def read
|
15
15
|
@site.layouts = LayoutReader.new(site).read
|
16
16
|
read_directories
|
17
|
+
read_included_excludes
|
17
18
|
sort_files!
|
18
19
|
@site.data = DataReader.new(site).read(site.config["data_dir"])
|
19
20
|
CollectionReader.new(site).read
|
@@ -39,13 +40,21 @@ module Jekyll
|
|
39
40
|
|
40
41
|
return unless File.directory?(base)
|
41
42
|
|
43
|
+
dot_dirs = []
|
44
|
+
dot_pages = []
|
45
|
+
dot_static_files = []
|
46
|
+
|
42
47
|
dot = Dir.chdir(base) { filter_entries(Dir.entries("."), base) }
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
48
|
+
dot.each do |entry|
|
49
|
+
file_path = @site.in_source_dir(base, entry)
|
50
|
+
if File.directory?(file_path)
|
51
|
+
dot_dirs << entry
|
52
|
+
elsif Utils.has_yaml_header?(file_path)
|
53
|
+
dot_pages << entry
|
54
|
+
else
|
55
|
+
dot_static_files << entry
|
56
|
+
end
|
47
57
|
end
|
48
|
-
dot_static_files = dot_files - dot_pages
|
49
58
|
|
50
59
|
retrieve_posts(dir)
|
51
60
|
retrieve_dirs(base, dir, dot_dirs)
|
@@ -61,6 +70,7 @@ module Jekyll
|
|
61
70
|
# Returns nothing.
|
62
71
|
def retrieve_posts(dir)
|
63
72
|
return if outside_configured_directory?(dir)
|
73
|
+
|
64
74
|
site.posts.docs.concat(post_reader.read_posts(dir))
|
65
75
|
site.posts.docs.concat(post_reader.read_drafts(dir)) if site.show_drafts
|
66
76
|
end
|
@@ -76,9 +86,7 @@ module Jekyll
|
|
76
86
|
dot_dirs.each do |file|
|
77
87
|
dir_path = site.in_source_dir(dir, file)
|
78
88
|
rel_path = File.join(dir, file)
|
79
|
-
unless @site.dest.chomp("/") == dir_path
|
80
|
-
@site.reader.read_directories(rel_path)
|
81
|
-
end
|
89
|
+
@site.reader.read_directories(rel_path) unless @site.dest.chomp("/") == dir_path
|
82
90
|
end
|
83
91
|
end
|
84
92
|
|
@@ -126,6 +134,7 @@ module Jekyll
|
|
126
134
|
def get_entries(dir, subfolder)
|
127
135
|
base = site.in_source_dir(dir, subfolder)
|
128
136
|
return [] unless File.exist?(base)
|
137
|
+
|
129
138
|
entries = Dir.chdir(base) { filter_entries(Dir["**/*"], base) }
|
130
139
|
entries.delete_if { |e| File.directory?(site.in_source_dir(base, e)) }
|
131
140
|
end
|
@@ -150,5 +159,26 @@ module Jekyll
|
|
150
159
|
def post_reader
|
151
160
|
@post_reader ||= PostReader.new(site)
|
152
161
|
end
|
162
|
+
|
163
|
+
def read_included_excludes
|
164
|
+
site.include.each do |entry|
|
165
|
+
next if entry == ".htaccess"
|
166
|
+
|
167
|
+
entry_path = site.in_source_dir(entry)
|
168
|
+
next if File.directory?(entry_path)
|
169
|
+
|
170
|
+
read_included_file(entry_path) if File.file?(entry_path)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def read_included_file(entry_path)
|
175
|
+
dir = File.dirname(entry_path).sub(site.source, "")
|
176
|
+
file = Array(File.basename(entry_path))
|
177
|
+
if Utils.has_yaml_header?(entry_path)
|
178
|
+
site.pages.concat(PageReader.new(site, dir).read(file))
|
179
|
+
else
|
180
|
+
site.static_files.concat(StaticFileReader.new(site, dir).read(file))
|
181
|
+
end
|
182
|
+
end
|
153
183
|
end
|
154
184
|
end
|
@@ -55,13 +55,13 @@ module Jekyll
|
|
55
55
|
case File.extname(path).downcase
|
56
56
|
when ".csv"
|
57
57
|
CSV.read(path,
|
58
|
-
|
59
|
-
|
58
|
+
:headers => true,
|
59
|
+
:encoding => site.config["encoding"]).map(&:to_hash)
|
60
60
|
when ".tsv"
|
61
61
|
CSV.read(path,
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
:col_sep => "\t",
|
63
|
+
:headers => true,
|
64
|
+
:encoding => site.config["encoding"]).map(&:to_hash)
|
65
65
|
else
|
66
66
|
SafeYAML.load_file(path)
|
67
67
|
end
|
@@ -23,7 +23,7 @@ module Jekyll
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def layout_directory
|
26
|
-
@layout_directory ||= (
|
26
|
+
@layout_directory ||= site.in_source_dir(site.config["layouts_dir"])
|
27
27
|
end
|
28
28
|
|
29
29
|
def theme_layout_directory
|
@@ -54,18 +54,8 @@ module Jekyll
|
|
54
54
|
|
55
55
|
def within(directory)
|
56
56
|
return unless File.exist?(directory)
|
57
|
-
Dir.chdir(directory) { yield }
|
58
|
-
end
|
59
|
-
|
60
|
-
def layout_directory_inside_source
|
61
|
-
site.in_source_dir(site.config["layouts_dir"])
|
62
|
-
end
|
63
57
|
|
64
|
-
|
65
|
-
dir = Jekyll.sanitized_path(Dir.pwd, site.config["layouts_dir"])
|
66
|
-
if File.directory?(dir) && !site.safe
|
67
|
-
dir
|
68
|
-
end
|
58
|
+
Dir.chdir(directory) { yield }
|
69
59
|
end
|
70
60
|
end
|
71
61
|
end
|
@@ -34,19 +34,9 @@ module Jekyll
|
|
34
34
|
#
|
35
35
|
# Returns nothing.
|
36
36
|
def read_publishable(dir, magic_dir, matcher)
|
37
|
-
read_content(dir, magic_dir, matcher)
|
38
|
-
.
|
39
|
-
|
40
|
-
site.publisher.publish?(doc).tap do |will_publish|
|
41
|
-
if !will_publish && site.publisher.hidden_in_the_future?(doc)
|
42
|
-
Jekyll.logger.debug "Skipping:", "#{doc.relative_path} has a future date"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
else
|
46
|
-
Jekyll.logger.debug "Skipping:", "#{doc.relative_path} is not valid UTF-8"
|
47
|
-
false
|
48
|
-
end
|
49
|
-
end
|
37
|
+
read_content(dir, magic_dir, matcher)
|
38
|
+
.tap { |docs| docs.each(&:read) }
|
39
|
+
.select { |doc| processable?(doc) }
|
50
40
|
end
|
51
41
|
|
52
42
|
# Read all the content files from <source>/<dir>/magic_dir
|
@@ -61,12 +51,34 @@ module Jekyll
|
|
61
51
|
def read_content(dir, magic_dir, matcher)
|
62
52
|
@site.reader.get_entries(dir, magic_dir).map do |entry|
|
63
53
|
next unless entry =~ matcher
|
54
|
+
|
64
55
|
path = @site.in_source_dir(File.join(dir, magic_dir, entry))
|
65
|
-
Document.new(path,
|
66
|
-
|
67
|
-
|
68
|
-
})
|
56
|
+
Document.new(path,
|
57
|
+
:site => @site,
|
58
|
+
:collection => @site.posts)
|
69
59
|
end.reject(&:nil?)
|
70
60
|
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def processable?(doc)
|
65
|
+
if doc.content.nil?
|
66
|
+
Jekyll.logger.debug "Skipping:", "Content in #{doc.relative_path} is nil"
|
67
|
+
false
|
68
|
+
elsif !doc.content.valid_encoding?
|
69
|
+
Jekyll.logger.debug "Skipping:", "#{doc.relative_path} is not valid UTF-8"
|
70
|
+
false
|
71
|
+
else
|
72
|
+
publishable?(doc)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def publishable?(doc)
|
77
|
+
site.publisher.publish?(doc).tap do |will_publish|
|
78
|
+
if !will_publish && site.publisher.hidden_in_the_future?(doc)
|
79
|
+
Jekyll.logger.warn "Skipping:", "#{doc.relative_path} has a future date"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
71
83
|
end
|
72
84
|
end
|
@@ -8,10 +8,11 @@ module Jekyll
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def read
|
11
|
-
return unless site.theme
|
11
|
+
return unless site.theme&.assets_path
|
12
12
|
|
13
13
|
Find.find(site.theme.assets_path) do |path|
|
14
14
|
next if File.directory?(path)
|
15
|
+
|
15
16
|
if File.symlink?(path)
|
16
17
|
Jekyll.logger.warn "Theme reader:", "Ignored symlinked asset: #{path}"
|
17
18
|
else
|
@@ -21,6 +22,7 @@ module Jekyll
|
|
21
22
|
end
|
22
23
|
|
23
24
|
private
|
25
|
+
|
24
26
|
def read_theme_asset(path)
|
25
27
|
base = site.theme.root
|
26
28
|
dir = File.dirname(path.sub("#{site.theme.root}/", ""))
|
@@ -28,18 +30,18 @@ module Jekyll
|
|
28
30
|
|
29
31
|
if Utils.has_yaml_header?(path)
|
30
32
|
append_unless_exists site.pages,
|
31
|
-
|
33
|
+
Jekyll::Page.new(site, base, dir, name)
|
32
34
|
else
|
33
35
|
append_unless_exists site.static_files,
|
34
|
-
|
36
|
+
Jekyll::StaticFile.new(site, base, "/#{dir}", name)
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
40
|
def append_unless_exists(haystack, new_item)
|
39
41
|
if haystack.any? { |file| file.relative_path == new_item.relative_path }
|
40
42
|
Jekyll.logger.debug "Theme:",
|
41
|
-
|
42
|
-
|
43
|
+
"Ignoring #{new_item.relative_path} in theme due to existing file " \
|
44
|
+
"with that path in site."
|
43
45
|
return
|
44
46
|
end
|
45
47
|
|
data/lib/jekyll/regenerator.rb
CHANGED
@@ -21,6 +21,7 @@ module Jekyll
|
|
21
21
|
# Returns a boolean.
|
22
22
|
def regenerate?(document)
|
23
23
|
return true if disabled
|
24
|
+
|
24
25
|
case document
|
25
26
|
when Page
|
26
27
|
regenerate_page?(document)
|
@@ -28,9 +29,7 @@ module Jekyll
|
|
28
29
|
regenerate_document?(document)
|
29
30
|
else
|
30
31
|
source_path = document.respond_to?(:path) ? document.path : nil
|
31
|
-
dest_path = if document.respond_to?(:destination)
|
32
|
-
document.destination(@site.dest)
|
33
|
-
end
|
32
|
+
dest_path = document.destination(@site.dest) if document.respond_to?(:destination)
|
34
33
|
source_modified_or_dest_missing?(source_path, dest_path)
|
35
34
|
end
|
36
35
|
end
|
@@ -89,9 +88,7 @@ module Jekyll
|
|
89
88
|
return true if path.nil?
|
90
89
|
|
91
90
|
# Check for path in cache
|
92
|
-
if cache.key? path
|
93
|
-
return cache[path]
|
94
|
-
end
|
91
|
+
return cache[path] if cache.key? path
|
95
92
|
|
96
93
|
if metadata[path]
|
97
94
|
# If we have seen this file before,
|
@@ -165,7 +162,6 @@ module Jekyll
|
|
165
162
|
end
|
166
163
|
end
|
167
164
|
|
168
|
-
private
|
169
165
|
def regenerate_page?(document)
|
170
166
|
document.asset_file? || document.data["regenerate"] ||
|
171
167
|
source_modified_or_dest_missing?(
|
@@ -173,7 +169,6 @@ module Jekyll
|
|
173
169
|
)
|
174
170
|
end
|
175
171
|
|
176
|
-
private
|
177
172
|
def regenerate_document?(document)
|
178
173
|
!document.write? || document.data["regenerate"] ||
|
179
174
|
source_modified_or_dest_missing?(
|
@@ -181,14 +176,11 @@ module Jekyll
|
|
181
176
|
)
|
182
177
|
end
|
183
178
|
|
184
|
-
private
|
185
179
|
def existing_file_modified?(path)
|
186
180
|
# If one of this file dependencies have been modified,
|
187
181
|
# set the regeneration bit for both the dependency and the file to true
|
188
182
|
metadata[path]["deps"].each do |dependency|
|
189
|
-
if modified?(dependency)
|
190
|
-
return cache[dependency] = cache[path] = true
|
191
|
-
end
|
183
|
+
return cache[dependency] = cache[path] = true if modified?(dependency)
|
192
184
|
end
|
193
185
|
|
194
186
|
if File.exist?(path) && metadata[path]["mtime"].eql?(File.mtime(path))
|
data/lib/jekyll/renderer.rb
CHANGED
@@ -9,6 +9,7 @@ module Jekyll
|
|
9
9
|
@site = site
|
10
10
|
@document = document
|
11
11
|
@payload = site_payload
|
12
|
+
@layouts = nil
|
12
13
|
end
|
13
14
|
|
14
15
|
# Fetches the payload used in Liquid rendering.
|
@@ -101,8 +102,8 @@ module Jekyll
|
|
101
102
|
converter.convert output
|
102
103
|
rescue StandardError => e
|
103
104
|
Jekyll.logger.error "Conversion error:",
|
104
|
-
|
105
|
-
|
105
|
+
"#{converter.class} encountered an error while "\
|
106
|
+
"converting '#{document.relative_path}':"
|
106
107
|
Jekyll.logger.error("", e.to_s)
|
107
108
|
raise e
|
108
109
|
end
|
@@ -121,13 +122,13 @@ module Jekyll
|
|
121
122
|
template = site.liquid_renderer.file(path).parse(content)
|
122
123
|
template.warnings.each do |e|
|
123
124
|
Jekyll.logger.warn "Liquid Warning:",
|
124
|
-
|
125
|
+
LiquidRenderer.format_error(e, path || document.relative_path)
|
125
126
|
end
|
126
127
|
template.render!(payload, info)
|
127
128
|
# rubocop: disable RescueException
|
128
129
|
rescue Exception => e
|
129
130
|
Jekyll.logger.error "Liquid Exception:",
|
130
|
-
|
131
|
+
LiquidRenderer.format_error(e, path || document.relative_path)
|
131
132
|
raise e
|
132
133
|
end
|
133
134
|
# rubocop: enable RescueException
|
@@ -158,19 +159,20 @@ module Jekyll
|
|
158
159
|
output = render_layout(output, layout, info)
|
159
160
|
add_regenerator_dependencies(layout)
|
160
161
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
162
|
+
next unless (layout = site.layouts[layout.data["layout"]])
|
163
|
+
break if used.include?(layout)
|
164
|
+
|
165
|
+
used << layout
|
165
166
|
end
|
166
167
|
output
|
167
168
|
end
|
168
169
|
|
170
|
+
private
|
171
|
+
|
169
172
|
# Checks if the layout specified in the document actually exists
|
170
173
|
#
|
171
174
|
# layout - the layout to check
|
172
175
|
# Returns nothing
|
173
|
-
private
|
174
176
|
def validate_layout(layout)
|
175
177
|
if invalid_layout?(layout)
|
176
178
|
Jekyll.logger.warn(
|
@@ -187,7 +189,6 @@ module Jekyll
|
|
187
189
|
# Render layout content into document.output
|
188
190
|
#
|
189
191
|
# Returns String rendered content
|
190
|
-
private
|
191
192
|
def render_layout(output, layout, info)
|
192
193
|
payload["content"] = output
|
193
194
|
payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {})
|
@@ -200,9 +201,9 @@ module Jekyll
|
|
200
201
|
)
|
201
202
|
end
|
202
203
|
|
203
|
-
private
|
204
204
|
def add_regenerator_dependencies(layout)
|
205
205
|
return unless document.write?
|
206
|
+
|
206
207
|
site.regenerator.add_dependency(
|
207
208
|
site.in_source_dir(document.path),
|
208
209
|
layout.path
|
@@ -212,18 +213,14 @@ module Jekyll
|
|
212
213
|
# Set page content to payload and assign pager if document has one.
|
213
214
|
#
|
214
215
|
# Returns nothing
|
215
|
-
private
|
216
216
|
def assign_pages!
|
217
217
|
payload["page"] = document.to_liquid
|
218
|
-
payload["paginator"] = if document.respond_to?(:pager)
|
219
|
-
document.pager.to_liquid
|
220
|
-
end
|
218
|
+
payload["paginator"] = (document.pager.to_liquid if document.respond_to?(:pager))
|
221
219
|
end
|
222
220
|
|
223
221
|
# Set related posts to payload if document is a post.
|
224
222
|
#
|
225
223
|
# Returns nothing
|
226
|
-
private
|
227
224
|
def assign_current_document!
|
228
225
|
payload["site"].current_document = document
|
229
226
|
end
|
@@ -231,21 +228,16 @@ module Jekyll
|
|
231
228
|
# Set highlighter prefix and suffix
|
232
229
|
#
|
233
230
|
# Returns nothing
|
234
|
-
private
|
235
231
|
def assign_highlighter_options!
|
236
232
|
payload["highlighter_prefix"] = converters.first.highlighter_prefix
|
237
233
|
payload["highlighter_suffix"] = converters.first.highlighter_suffix
|
238
234
|
end
|
239
235
|
|
240
|
-
private
|
241
236
|
def assign_layout_data!
|
242
237
|
layout = layouts[document.data["layout"]]
|
243
|
-
if layout
|
244
|
-
payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {})
|
245
|
-
end
|
238
|
+
payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {}) if layout
|
246
239
|
end
|
247
240
|
|
248
|
-
private
|
249
241
|
def permalink_ext
|
250
242
|
document_permalink = document.permalink
|
251
243
|
if document_permalink && !document_permalink.end_with?("/")
|
@@ -254,7 +246,6 @@ module Jekyll
|
|
254
246
|
end
|
255
247
|
end
|
256
248
|
|
257
|
-
private
|
258
249
|
def converter_output_ext
|
259
250
|
if output_exts.size == 1
|
260
251
|
output_exts.last
|
@@ -263,14 +254,12 @@ module Jekyll
|
|
263
254
|
end
|
264
255
|
end
|
265
256
|
|
266
|
-
private
|
267
257
|
def output_exts
|
268
258
|
@output_exts ||= converters.map do |c|
|
269
259
|
c.output_ext(document.extname)
|
270
260
|
end.compact
|
271
261
|
end
|
272
262
|
|
273
|
-
private
|
274
263
|
def liquid_options
|
275
264
|
@liquid_options ||= site.config["liquid"]
|
276
265
|
end
|