jekyll-remote-theme 0.6.2 → 0.6.3
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/lib/jekyll-remote-theme/munger.rb +9 -1
- data/lib/jekyll-remote-theme/theme.rb +39 -4
- data/lib/jekyll-remote-theme/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e03229a94b9e765b76cb5dee2b5838ab13a58098e33fa73d5e5733570102e828
|
|
4
|
+
data.tar.gz: 77020e301b78ebe789c608a29e7217f722c53b25275afec32c876a8c9bf2d370
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3a79a33a692b97472f6cdd2a42af44f623bf769772beee69f0488611d0e47a5e55697a7baf9e17be88841a1d712288bdf73e91e3e98f42dc57830037f224be7
|
|
7
|
+
data.tar.gz: f368911a263cc85af35d168a64e20796c0c81b906b68e7dca041a7bb81f1c58ee9daaa2bd4bcff236f3ff2afd3dff85ffc8535e7184f49625c667e7df6ac78af
|
|
@@ -15,7 +15,7 @@ module Jekyll
|
|
|
15
15
|
return unless raw_theme
|
|
16
16
|
|
|
17
17
|
unless theme.valid?
|
|
18
|
-
Jekyll.logger.error LOG_KEY,
|
|
18
|
+
Jekyll.logger.error LOG_KEY, invalid_theme_message
|
|
19
19
|
return
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -33,6 +33,14 @@ module Jekyll
|
|
|
33
33
|
|
|
34
34
|
private
|
|
35
35
|
|
|
36
|
+
def invalid_theme_message
|
|
37
|
+
message = "#{raw_theme.inspect} is not a valid remote theme"
|
|
38
|
+
return message unless theme.disallowed_host?
|
|
39
|
+
|
|
40
|
+
"#{message}; host #{theme.host.inspect} is not allowed. " \
|
|
41
|
+
"Set PAGES_GITHUB_HOSTNAME or GITHUB_HOSTNAME to #{theme.host.inspect}"
|
|
42
|
+
end
|
|
43
|
+
|
|
36
44
|
def munged?
|
|
37
45
|
site.theme&.is_a?(Jekyll::RemoteTheme::Theme)
|
|
38
46
|
end
|
|
@@ -5,8 +5,14 @@ module Jekyll
|
|
|
5
5
|
class Theme < Jekyll::Theme
|
|
6
6
|
OWNER_REGEX = %r!(?<owner>[a-z0-9\-]+)!i.freeze
|
|
7
7
|
NAME_REGEX = %r!(?<name>[a-z0-9\._\-]+)!i.freeze
|
|
8
|
-
|
|
8
|
+
# A ref segment can't be "." or "..": the ref goes into a normalized download
|
|
9
|
+
# URL, where those segments would point at a different path.
|
|
10
|
+
REF_SEGMENT_REGEX = %r!(?\!\.\.?(?:/|\z))[a-z0-9\._\-]+!i.freeze
|
|
11
|
+
# May be a branch, tag, commit, or "latest". Branches may contain "/", as in
|
|
12
|
+
# "feature/new-layout", but not at the start or end, or twice in a row.
|
|
13
|
+
REF_REGEX = %r!@(?<ref>#{REF_SEGMENT_REGEX}(?:/#{REF_SEGMENT_REGEX})*)!i.freeze
|
|
9
14
|
THEME_REGEX = %r!\A#{OWNER_REGEX}/#{NAME_REGEX}(?:#{REF_REGEX})?\z!i.freeze
|
|
15
|
+
REF_SUFFIX_REGEX = %r!\A#{REF_REGEX}\z!.freeze
|
|
10
16
|
|
|
11
17
|
# Initializes a new Jekyll::RemoteTheme::Theme
|
|
12
18
|
#
|
|
@@ -27,7 +33,7 @@ module Jekyll
|
|
|
27
33
|
@site = site
|
|
28
34
|
original_theme = raw_theme.to_s.strip
|
|
29
35
|
local_path = looks_like_local_path?(original_theme)
|
|
30
|
-
@raw_theme = local_path ? original_theme : original_theme
|
|
36
|
+
@raw_theme = local_path ? original_theme : normalize_remote_theme(original_theme)
|
|
31
37
|
super(@raw_theme)
|
|
32
38
|
end
|
|
33
39
|
|
|
@@ -67,11 +73,17 @@ module Jekyll
|
|
|
67
73
|
|
|
68
74
|
parsed_ref = theme_parts[:ref]
|
|
69
75
|
return "HEAD" unless parsed_ref
|
|
70
|
-
return resolve_latest_release if parsed_ref
|
|
76
|
+
return resolve_latest_release if parsed_ref.casecmp?("latest")
|
|
71
77
|
|
|
72
78
|
parsed_ref
|
|
73
79
|
end
|
|
74
80
|
|
|
81
|
+
def disallowed_host?
|
|
82
|
+
return false unless uri && theme_parts && name && owner
|
|
83
|
+
|
|
84
|
+
host && !valid_hosts.include?(host)
|
|
85
|
+
end
|
|
86
|
+
|
|
75
87
|
def root
|
|
76
88
|
return (expanded_local_path if local_path_valid?) if local_theme?
|
|
77
89
|
|
|
@@ -98,6 +110,16 @@ module Jekyll
|
|
|
98
110
|
super
|
|
99
111
|
end
|
|
100
112
|
|
|
113
|
+
# Owners and repo names are case-insensitive on GitHub, so normalize them,
|
|
114
|
+
# but leave the git ref alone: branch and tag names are case-sensitive, and
|
|
115
|
+
# downcasing them points codeload at a ref that doesn't exist.
|
|
116
|
+
def normalize_remote_theme(theme)
|
|
117
|
+
theme_without_ref, separator, ref = theme.rpartition("@")
|
|
118
|
+
return theme.downcase if separator.empty? || !"@#{ref}".match?(REF_SUFFIX_REGEX)
|
|
119
|
+
|
|
120
|
+
"#{theme_without_ref.downcase}@#{ref}"
|
|
121
|
+
end
|
|
122
|
+
|
|
101
123
|
def looks_like_local_path?(path)
|
|
102
124
|
# Check if it looks like a local path
|
|
103
125
|
# Supports: /, ./, ../, ~/ (Unix-style) and drive letters (Windows-style)
|
|
@@ -172,7 +194,7 @@ module Jekyll
|
|
|
172
194
|
if response.is_a?(Net::HTTPSuccess)
|
|
173
195
|
parse_tag_from_response(response)
|
|
174
196
|
else
|
|
175
|
-
|
|
197
|
+
log_failed_response_warning(response)
|
|
176
198
|
nil
|
|
177
199
|
end
|
|
178
200
|
rescue StandardError => e
|
|
@@ -221,6 +243,19 @@ module Jekyll
|
|
|
221
243
|
"No releases found for #{name_with_owner}, using HEAD"
|
|
222
244
|
end
|
|
223
245
|
|
|
246
|
+
def log_failed_response_warning(response)
|
|
247
|
+
if response.code == "404"
|
|
248
|
+
log_no_releases_warning
|
|
249
|
+
else
|
|
250
|
+
message = "Unexpected HTTP #{response.code} response " \
|
|
251
|
+
"for #{name_with_owner}, using HEAD"
|
|
252
|
+
if %w(403 429).include?(response.code)
|
|
253
|
+
message += "; this is likely caused by GitHub API rate limiting"
|
|
254
|
+
end
|
|
255
|
+
Jekyll.logger.warn LOG_KEY, message
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
224
259
|
def log_api_error(error)
|
|
225
260
|
Jekyll.logger.warn LOG_KEY,
|
|
226
261
|
"Failed to fetch latest release for #{name_with_owner}: " \
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jekyll-remote-theme
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben Balter
|
|
@@ -159,6 +159,20 @@ dependencies:
|
|
|
159
159
|
- - "~>"
|
|
160
160
|
- !ruby/object:Gem::Version
|
|
161
161
|
version: '0.11'
|
|
162
|
+
- !ruby/object:Gem::Dependency
|
|
163
|
+
name: rake
|
|
164
|
+
requirement: !ruby/object:Gem::Requirement
|
|
165
|
+
requirements:
|
|
166
|
+
- - "~>"
|
|
167
|
+
- !ruby/object:Gem::Version
|
|
168
|
+
version: '13.0'
|
|
169
|
+
type: :development
|
|
170
|
+
prerelease: false
|
|
171
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
172
|
+
requirements:
|
|
173
|
+
- - "~>"
|
|
174
|
+
- !ruby/object:Gem::Version
|
|
175
|
+
version: '13.0'
|
|
162
176
|
- !ruby/object:Gem::Dependency
|
|
163
177
|
name: rspec
|
|
164
178
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -308,7 +322,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
308
322
|
- !ruby/object:Gem::Version
|
|
309
323
|
version: '0'
|
|
310
324
|
requirements: []
|
|
311
|
-
rubygems_version:
|
|
325
|
+
rubygems_version: 4.0.20
|
|
312
326
|
specification_version: 4
|
|
313
327
|
summary: Jekyll plugin for building Jekyll sites with any GitHub-hosted theme
|
|
314
328
|
test_files: []
|