jekyll 4.1.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.
data/lib/jekyll/site.rb CHANGED
@@ -117,6 +117,7 @@ module Jekyll
117
117
 
118
118
  Jekyll::Cache.clear_if_config_changed config
119
119
  Jekyll::Hooks.trigger :site, :after_reset, self
120
+ nil
120
121
  end
121
122
  # rubocop:enable Metrics/MethodLength
122
123
  # rubocop:enable Metrics/AbcSize
@@ -180,6 +181,7 @@ module Jekyll
180
181
  reader.read
181
182
  limit_posts!
182
183
  Jekyll::Hooks.trigger :site, :post_read, self
184
+ nil
183
185
  end
184
186
 
185
187
  # Run each of the Generators.
@@ -192,6 +194,7 @@ module Jekyll
192
194
  Jekyll.logger.debug "Generating:",
193
195
  "#{generator.class} finished in #{Time.now - start} seconds."
194
196
  end
197
+ nil
195
198
  end
196
199
 
197
200
  # Render the site to the destination.
@@ -208,6 +211,7 @@ module Jekyll
208
211
  render_pages(payload)
209
212
 
210
213
  Jekyll::Hooks.trigger :site, :post_render, self, payload
214
+ nil
211
215
  end
212
216
 
213
217
  # Remove orphaned files and empty directories in destination.
@@ -215,17 +219,20 @@ module Jekyll
215
219
  # Returns nothing.
216
220
  def cleanup
217
221
  site_cleaner.cleanup!
222
+ nil
218
223
  end
219
224
 
220
225
  # Write static files, pages, and posts.
221
226
  #
222
227
  # Returns nothing.
223
228
  def write
229
+ Jekyll::Commands::Doctor.conflicting_urls(self)
224
230
  each_site_file do |item|
225
231
  item.write(dest) if regenerator.regenerate?(item)
226
232
  end
227
233
  regenerator.write_metadata
228
234
  Jekyll::Hooks.trigger :site, :post_write, self
235
+ nil
229
236
  end
230
237
 
231
238
  def posts
@@ -309,8 +316,9 @@ module Jekyll
309
316
  # passed in as argument.
310
317
 
311
318
  def instantiate_subclasses(klass)
312
- klass.descendants.select { |c| !safe || c.safe }.sort.map do |c|
313
- c.new(config)
319
+ klass.descendants.select { |c| !safe || c.safe }.tap do |result|
320
+ result.sort!
321
+ result.map! { |c| c.new(config) }
314
322
  end
315
323
  end
316
324
 
@@ -434,6 +442,13 @@ module Jekyll
434
442
  @collections_path ||= dir_str.empty? ? source : in_source_dir(dir_str)
435
443
  end
436
444
 
445
+ # Public
446
+ #
447
+ # Returns the object as a debug String.
448
+ def inspect
449
+ "#<#{self.class} @source=#{@source}>"
450
+ end
451
+
437
452
  private
438
453
 
439
454
  def load_theme_configuration(config)
@@ -55,8 +55,8 @@ module Jekyll
55
55
  #
56
56
  # Returns destination file path.
57
57
  def destination(dest)
58
- dest = @site.in_dest_dir(dest)
59
- @site.in_dest_dir(dest, Jekyll::URL.unescape_path(url))
58
+ @destination ||= {}
59
+ @destination[dest] ||= @site.in_dest_dir(dest, Jekyll::URL.unescape_path(url))
60
60
  end
61
61
 
62
62
  def destination_rel_dir
@@ -36,20 +36,16 @@ module Jekyll
36
36
 
37
37
  def parse_params(context)
38
38
  params = {}
39
- markup = @params
40
-
41
- while (match = VALID_SYNTAX.match(markup))
42
- markup = markup[match.end(0)..-1]
43
-
44
- value = if match[2]
45
- match[2].gsub('\\"', '"')
46
- elsif match[3]
47
- match[3].gsub("\\'", "'")
48
- elsif match[4]
49
- context[match[4]]
39
+ @params.scan(VALID_SYNTAX) do |key, d_quoted, s_quoted, variable|
40
+ value = if d_quoted
41
+ d_quoted.include?('\\"') ? d_quoted.gsub('\\"', '"') : d_quoted
42
+ elsif s_quoted
43
+ s_quoted.include?("\\'") ? s_quoted.gsub("\\'", "'") : s_quoted
44
+ elsif variable
45
+ context[variable]
50
46
  end
51
47
 
52
- params[match[1]] = value
48
+ params[key] = value
53
49
  end
54
50
  params
55
51
  end
@@ -205,7 +201,7 @@ module Jekyll
205
201
  @site.inclusions[file] ||= locate_include_file(file)
206
202
  inclusion = @site.inclusions[file]
207
203
 
208
- add_include_to_dependency(inclusion, context) if @site.incremental?
204
+ add_include_to_dependency(inclusion, context) if @site.config["incremental"]
209
205
 
210
206
  context.stack do
211
207
  context["include"] = parse_params(context) if @params
@@ -238,12 +234,17 @@ module Jekyll
238
234
  end
239
235
 
240
236
  def add_include_to_dependency(inclusion, context)
241
- return unless context.registers[:page]&.key?("path")
237
+ page = context.registers[:page]
238
+ return unless page&.key?("path")
239
+
240
+ absolute_path = \
241
+ if page["collection"]
242
+ @site.in_source_dir(@site.config["collections_dir"], page["path"])
243
+ else
244
+ @site.in_source_dir(page["path"])
245
+ end
242
246
 
243
- @site.regenerator.add_dependency(
244
- @site.in_source_dir(context.registers[:page]["path"]),
245
- inclusion.path
246
- )
247
+ @site.regenerator.add_dependency(absolute_path, inclusion.path)
247
248
  end
248
249
  end
249
250
 
@@ -253,20 +254,18 @@ module Jekyll
253
254
  end
254
255
 
255
256
  def page_path(context)
256
- if context.registers[:page].nil?
257
- context.registers[:site].source
258
- else
259
- site = context.registers[:site]
260
- page_payload = context.registers[:page]
261
- resource_path = \
262
- if page_payload["collection"].nil?
263
- page_payload["path"]
264
- else
265
- File.join(site.config["collections_dir"], page_payload["path"])
266
- end
267
- resource_path.sub!(%r!/#excerpt\z!, "")
268
- site.in_source_dir File.dirname(resource_path)
269
- end
257
+ page, site = context.registers.values_at(:page, :site)
258
+ return site.source unless page
259
+
260
+ site.in_source_dir File.dirname(resource_path(page, site))
261
+ end
262
+
263
+ private
264
+
265
+ def resource_path(page, site)
266
+ path = page["path"]
267
+ path = File.join(site.config["collections_dir"], path) if page["collection"]
268
+ path.sub(%r!/#excerpt\z!, "")
270
269
  end
271
270
  end
272
271
  end
@@ -21,11 +21,12 @@ module Jekyll
21
21
  @context = context
22
22
  site = context.registers[:site]
23
23
  relative_path = Liquid::Template.parse(@relative_path).render(context)
24
+ relative_path_with_leading_slash = PathManager.join("", relative_path)
24
25
 
25
26
  site.each_site_file do |item|
26
27
  return relative_url(item) if item.relative_path == relative_path
27
28
  # This takes care of the case for static files that have a leading /
28
- return relative_url(item) if item.relative_path == "/#{relative_path}"
29
+ return relative_url(item) if item.relative_path == relative_path_with_leading_slash
29
30
  end
30
31
 
31
32
  raise ArgumentError, <<~MSG
@@ -16,9 +16,8 @@ module Jekyll
16
16
  "'#{name}' does not contain valid date and/or title."
17
17
  end
18
18
 
19
- escaped_slug = Regexp.escape(slug)
20
- @name_regex = %r!^_posts/#{path}#{date}-#{escaped_slug}\.[^.]+|
21
- ^#{path}_posts/?#{date}-#{escaped_slug}\.[^.]+!x
19
+ basename_pattern = "#{date}-#{Regexp.escape(slug)}\\.[^.]+"
20
+ @name_regex = %r!^_posts/#{path}#{basename_pattern}|^#{path}_posts/?#{basename_pattern}!
22
21
  end
23
22
 
24
23
  def post_date
@@ -51,7 +50,7 @@ module Jekyll
51
50
  if path.nil? || path == ""
52
51
  other.data["slug"]
53
52
  else
54
- path + "/" + other.data["slug"]
53
+ "#{path}/#{other.data["slug"]}"
55
54
  end
56
55
  end
57
56
  end
data/lib/jekyll/url.rb CHANGED
@@ -94,7 +94,8 @@ module Jekyll
94
94
 
95
95
  def generate_url_from_drop(template)
96
96
  template.gsub(%r!:([a-z_]+)!) do |match|
97
- pool = possible_keys(match.sub(":", ""))
97
+ name = Regexp.last_match(1)
98
+ pool = name.end_with?("_") ? [name, name.chomp!("_")] : [name]
98
99
 
99
100
  winner = pool.find { |key| @placeholders.key?(key) }
100
101
  if winner.nil?
@@ -107,15 +108,17 @@ module Jekyll
107
108
  value = "" if value.nil?
108
109
  replacement = self.class.escape_path(value)
109
110
 
110
- match.sub(":#{winner}", replacement)
111
- end.squeeze("/")
111
+ match.sub!(":#{winner}", replacement)
112
+ end
112
113
  end
113
114
 
114
115
  # Returns a sanitized String URL, stripping "../../" and multiples of "/",
115
116
  # as well as the beginning "/" so we can enforce and ensure it.
116
-
117
117
  def sanitize_url(str)
118
- "/#{str}".gsub("..", "/").gsub("./", "").squeeze("/")
118
+ "/#{str}".gsub("..", "/").tap do |result|
119
+ result.gsub!("./", "")
120
+ result.squeeze!("/")
121
+ end
119
122
  end
120
123
 
121
124
  # Escapes a path to be a valid URL path segment
@@ -5,78 +5,63 @@ module Jekyll
5
5
  module Platforms
6
6
  extend self
7
7
 
8
- # Provides jruby? and mri? which respectively detect these two types of
9
- # tested Engines we support, in the future we might probably support the
10
- # other one that everyone used to talk about.
8
+ def jruby?
9
+ RUBY_ENGINE == "jruby"
10
+ end
11
11
 
12
- { :jruby? => "jruby", :mri? => "ruby" }.each do |k, v|
13
- define_method k do
14
- ::RUBY_ENGINE == v
15
- end
12
+ def mri?
13
+ RUBY_ENGINE == "ruby"
16
14
  end
17
15
 
18
- # --
19
- # Allows you to detect "real" Windows, or what we would consider
20
- # "real" Windows. That is, that we can pass the basic test and the
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
- RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i && \
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
- RbConfig::CONFIG["host_os"] =~ %r!linux! && \
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?
47
- end
48
-
49
- #
50
-
51
31
  def linux?
52
- RbConfig::CONFIG["host_os"] =~ %r!linux! && \
53
- proc_version !~ %r!microsoft!i
32
+ linux_os? && !microsoft_proc_version?
54
33
  end
55
34
 
56
- # Provides windows?, linux?, osx?, unix? so that we can detect
57
- # platforms. This is mostly useful for `jekyll doctor` and for testing
58
- # where we kick off certain tests based on the platform.
59
-
60
- { :osx? => %r!darwin|mac os!, :unix? => %r!solaris|bsd! }.each do |k, v|
61
- define_method k do
62
- !!(
63
- RbConfig::CONFIG["host_os"] =~ v
64
- )
65
- end
35
+ def osx?
36
+ rbconfig_host.match?(%r!darwin|mac os!)
66
37
  end
67
38
 
68
- #
39
+ def unix?
40
+ rbconfig_host.match?(%r!solaris|bsd!)
41
+ end
69
42
 
70
43
  private
71
44
 
72
45
  def proc_version
73
- @proc_version ||=
46
+ @proc_version ||= \
74
47
  begin
75
- File.read("/proc/version")
48
+ File.read("/proc/version").downcase
76
49
  rescue Errno::ENOENT, Errno::EACCES
77
- nil
50
+ ""
78
51
  end
79
52
  end
53
+
54
+ def rbconfig_host
55
+ @rbconfig_host ||= RbConfig::CONFIG["host_os"].downcase
56
+ end
57
+
58
+ def linux_os?
59
+ rbconfig_host.include?("linux")
60
+ end
61
+
62
+ def microsoft_proc_version?
63
+ proc_version.include?("microsoft")
64
+ end
80
65
  end
81
66
  end
82
67
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jekyll
4
- VERSION = "4.1.1"
4
+ VERSION = "4.2.2"
5
5
  end
data/lib/jekyll.rb CHANGED
@@ -173,23 +173,9 @@ module Jekyll
173
173
  # Returns the sanitized path.
174
174
  def sanitized_path(base_directory, questionable_path)
175
175
  return base_directory if base_directory.eql?(questionable_path)
176
+ return base_directory if questionable_path.nil?
176
177
 
177
- clean_path = questionable_path.dup
178
- clean_path.insert(0, "/") if clean_path.start_with?("~")
179
- clean_path = File.expand_path(clean_path, "/")
180
-
181
- return clean_path if clean_path.eql?(base_directory)
182
-
183
- # remove any remaining extra leading slashes not stripped away by calling
184
- # `File.expand_path` above.
185
- clean_path.squeeze!("/")
186
-
187
- if clean_path.start_with?(base_directory.sub(%r!\z!, "/"))
188
- clean_path
189
- else
190
- clean_path.sub!(%r!\A\w:/!, "/")
191
- File.join(base_directory, clean_path)
192
- end
178
+ +Jekyll::PathManager.sanitized_path(base_directory, questionable_path)
193
179
  end
194
180
 
195
181
  # Conditional optimizations
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.1
4
+ version: 4.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2020-06-24 00:00:00.000000000 Z
13
+ date: 2022-03-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -102,14 +102,14 @@ dependencies:
102
102
  requirements:
103
103
  - - "~>"
104
104
  - !ruby/object:Gem::Version
105
- version: '2.1'
105
+ version: '2.3'
106
106
  type: :runtime
107
107
  prerelease: false
108
108
  version_requirements: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - "~>"
111
111
  - !ruby/object:Gem::Version
112
- version: '2.1'
112
+ version: '2.3'
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: kramdown-parser-gfm
115
115
  requirement: !ruby/object:Gem::Requirement
@@ -200,14 +200,14 @@ dependencies:
200
200
  requirements:
201
201
  - - "~>"
202
202
  - !ruby/object:Gem::Version
203
- version: '1.8'
203
+ version: '2.0'
204
204
  type: :runtime
205
205
  prerelease: false
206
206
  version_requirements: !ruby/object:Gem::Requirement
207
207
  requirements:
208
208
  - - "~>"
209
209
  - !ruby/object:Gem::Version
210
- version: '1.8'
210
+ version: '2.0'
211
211
  description: Jekyll is a simple, blog aware, static site generator.
212
212
  email:
213
213
  - maintainers@jekyllrb.com
@@ -364,7 +364,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
364
364
  - !ruby/object:Gem::Version
365
365
  version: 2.7.0
366
366
  requirements: []
367
- rubygems_version: 3.1.2
367
+ rubygems_version: 3.1.6
368
368
  signing_key:
369
369
  specification_version: 4
370
370
  summary: A simple, blog aware, static site generator.