jekyll 4.1.1 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -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.0"
5
5
  end
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.0
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: 2020-12-14 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.4
368
368
  signing_key:
369
369
  specification_version: 4
370
370
  summary: A simple, blog aware, static site generator.