jekyll_draft 2.1.0 → 3.0.0
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 +1 -1
- data/CHANGELOG.md +5 -0
- data/README.md +4 -4
- data/jekyll_draft.gemspec +5 -4
- data/lib/jekyll_draft/common/else.rb +0 -2
- data/lib/jekyll_draft/common/module_functions.rb +28 -9
- data/lib/jekyll_draft/other_page/if_draft.rb +48 -19
- data/lib/jekyll_draft/version.rb +1 -1
- data/lib/jekyll_draft.rb +5 -3
- data/spec/status_persistence.txt +1 -1
- metadata +24 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bccff30e811690f02c8b5d429c7bd3ed98e78ccd704d7baf440426be26ef1a0
|
4
|
+
data.tar.gz: 99b14ff0b6237d8b97cc5e21f3a4ec7f777b4f49727ad8c01b9f16df38568ecc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6451f0a15a14ade6305c7876f51387d00ecb913e619a7a6d116af445ce4564d0f2f11a4620eac66185be15bc0187f6e15b5297d6ccdd5794aeadd633c2a454c6
|
7
|
+
data.tar.gz: 6925ed553fc89df595f6b181ca6b255bae43759df8c48b809267159b05af9a03dc3878ff06a25b5ba4639b0011f71b9bf112a31c8439e93525404f5afcd3f0f9
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 3.0.0 / In process
|
4
|
+
|
5
|
+
* Now requires [Jekyll 4.4.1](https://jekyllrb.com/news/2025/01/29/jekyll-4-4-1-released/) or later, and Ruby 3.2.0 or later
|
6
|
+
|
7
|
+
|
3
8
|
## 2.1.0 / 2025-02-07
|
4
9
|
|
5
10
|
* Added ability to return a page in any collection, or those not in a collection,
|
data/README.md
CHANGED
@@ -93,8 +93,8 @@ so you can learn how to write Jekyll pages that include this functionality.
|
|
93
93
|
|
94
94
|
```ruby
|
95
95
|
group :jekyll_plugins do
|
96
|
-
gem '
|
97
|
-
gem 'jekyll_draft', '>=
|
96
|
+
gem 'jekyll_plugin_support', '>= 3.0.0'
|
97
|
+
gem 'jekyll_draft', '>=3.0.0'
|
98
98
|
end
|
99
99
|
```
|
100
100
|
|
@@ -112,8 +112,8 @@ so you can learn how to write Jekyll pages that include this functionality.
|
|
112
112
|
1. Add the following to your gem’s `.gemspec`:
|
113
113
|
|
114
114
|
```ruby
|
115
|
-
spec.add_dependency '
|
116
|
-
spec.add_dependency 'jekyll_draft', '>=
|
115
|
+
spec.add_dependency 'jekyll_plugin_support', '>= 3.0.0'
|
116
|
+
spec.add_dependency 'jekyll_draft', '>=3.0.0'
|
117
117
|
```
|
118
118
|
|
119
119
|
2. Type:
|
data/jekyll_draft.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative 'lib/jekyll_draft/version'
|
2
2
|
|
3
|
-
Gem::Specification.new do |spec|
|
3
|
+
Gem::Specification.new do |spec|
|
4
4
|
github = 'https://github.com/mslinn/jekyll_draft'
|
5
5
|
|
6
6
|
spec.authors = ['Mike Slinn']
|
@@ -27,11 +27,12 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
27
27
|
|
28
28
|
END_MESSAGE
|
29
29
|
spec.require_paths = ['lib']
|
30
|
-
spec.required_ruby_version = '>= 2.
|
30
|
+
spec.required_ruby_version = '>= 3.2.0'
|
31
31
|
spec.summary = 'This Jekyll filter detects draft documents.'
|
32
32
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
33
33
|
spec.version = DraftVersion::VERSION
|
34
34
|
|
35
|
-
spec.add_dependency 'jekyll', '>=
|
36
|
-
spec.add_dependency 'jekyll_plugin_support', '>=
|
35
|
+
spec.add_dependency 'jekyll', '>= 4.4.0'
|
36
|
+
spec.add_dependency 'jekyll_plugin_support', '>=3.0.0'
|
37
|
+
spec.add_dependency 'sorted_set'
|
37
38
|
end
|
@@ -24,7 +24,12 @@ module Jekyll
|
|
24
24
|
|
25
25
|
false
|
26
26
|
rescue StandardError => e
|
27
|
-
|
27
|
+
msg = e.full_message
|
28
|
+
if msg.length < 250
|
29
|
+
Draft.logger.error { msg }
|
30
|
+
else
|
31
|
+
Draft.logger.error { "#{msg[0..125]} ... #{msg[-125..msg.length]}" }
|
32
|
+
end
|
28
33
|
false
|
29
34
|
end
|
30
35
|
|
@@ -35,25 +40,27 @@ module Jekyll
|
|
35
40
|
|
36
41
|
" <i class='jekyll_draft'>Draft</i>"
|
37
42
|
rescue StandardError => e
|
38
|
-
|
43
|
+
msg = e.full_message
|
44
|
+
if msg.length < 250
|
45
|
+
Draft.logger.error { msg }
|
46
|
+
else
|
47
|
+
Draft.logger.error { "#{msg[0..125]} ... #{msg[-125..msg.length]}" }
|
48
|
+
end
|
39
49
|
''
|
40
50
|
end
|
41
51
|
|
42
|
-
# This is a computationally intense method, and really slows down site generation.
|
43
|
-
# TODO: implement cache in front of sorted objects containing paths and page reference
|
44
|
-
# This cache is also needed by compute_link_and_text in jekyll_href
|
45
52
|
# @return APage whose href uniquely contains path_portion,
|
46
53
|
# or `path_portion` as a String for non-local URLs.
|
47
54
|
def page_match(path_portion, error_if_no_match: true, verify_unique_match: false)
|
48
55
|
return :non_local_url if path_portion.start_with? 'http:', 'https:', 'mailto'
|
49
56
|
|
50
57
|
matching_pages = if verify_unique_match
|
51
|
-
::AllCollectionsHooks.sorted_lru_files.
|
58
|
+
::AllCollectionsHooks.sorted_lru_files.find(path_portion)
|
52
59
|
else
|
53
|
-
match = ::AllCollectionsHooks.sorted_lru_files.find
|
60
|
+
match = ::AllCollectionsHooks.sorted_lru_files.find(path_portion)
|
54
61
|
match.nil? ? [] : [match]
|
55
62
|
end
|
56
|
-
case matching_pages.
|
63
|
+
case matching_pages.size
|
57
64
|
when 0
|
58
65
|
return '' unless error_if_no_match
|
59
66
|
|
@@ -70,7 +77,12 @@ module Jekyll
|
|
70
77
|
exit! 2 # The user should fix this problem before allowing the website to generate
|
71
78
|
end
|
72
79
|
rescue StandardError => e
|
73
|
-
|
80
|
+
msg = e.full_message
|
81
|
+
if msg.length < 250
|
82
|
+
Draft.logger.error { msg }
|
83
|
+
else
|
84
|
+
Draft.logger.error { "#{msg[0..125]} ... #{msg[-125..msg.length]}" }
|
85
|
+
end
|
74
86
|
end
|
75
87
|
|
76
88
|
# @return path to root of the collection that doc is a member of
|
@@ -83,6 +95,13 @@ module Jekyll
|
|
83
95
|
return index.href if index
|
84
96
|
|
85
97
|
docs.min.href
|
98
|
+
rescue StandardError => e
|
99
|
+
msg = e.full_message
|
100
|
+
if msg.length < 250
|
101
|
+
Draft.logger.error { msg }
|
102
|
+
else
|
103
|
+
Draft.logger.error { "#{msg[0..150]} ... #{msg[-150..msg.length]}" }
|
104
|
+
end
|
86
105
|
end
|
87
106
|
|
88
107
|
module_function :draft?, :draft_html, :page_match, :root
|
@@ -34,7 +34,12 @@ class DraftPageBase < JekyllSupport::JekyllBlock
|
|
34
34
|
end
|
35
35
|
process_variables clause_value
|
36
36
|
rescue StandardError => e
|
37
|
-
|
37
|
+
msg = e.full_message
|
38
|
+
if msg.length < 250
|
39
|
+
@logger.error { msg }
|
40
|
+
else
|
41
|
+
@logger.error { "#{msg[0..125]} ... #{msg[-125..msg.length]}" }
|
42
|
+
end
|
38
43
|
exit!
|
39
44
|
end
|
40
45
|
|
@@ -46,7 +51,7 @@ class DraftPageBase < JekyllSupport::JekyllBlock
|
|
46
51
|
@error_if_no_match = tag_config['error_if_no_match'] # defaults true
|
47
52
|
@error_if_no_match = @error_if_no_match ? @error_if_no_match == true : true
|
48
53
|
|
49
|
-
@verify_unique_match
|
54
|
+
@verify_unique_match = true # tag_config['verify_unique_match'] == true # defaults false
|
50
55
|
else
|
51
56
|
@logger.warn { "There is no entry for #{@tag_name} in _config.yml; default values were applied." }
|
52
57
|
end
|
@@ -58,31 +63,55 @@ class DraftPageBase < JekyllSupport::JekyllBlock
|
|
58
63
|
@verify_unique_match = env_var != 'false' if env_var
|
59
64
|
end
|
60
65
|
|
66
|
+
# @param markup [String] might contain <<path_portion>> or <<matched_page.url>>
|
61
67
|
def process_variables(markup)
|
62
68
|
return '' unless markup
|
63
69
|
|
64
70
|
path_portion = @path_portion # add this to the binding
|
65
|
-
matched_page = @matched_page # add this to the binding
|
71
|
+
matched_page = @matched_page.instance_of?(Enumerator) ? @matched_page.first : @matched_page # add this to the binding
|
66
72
|
_ = path_portion == matched_page # Just to keep the lint checker happy
|
67
|
-
markup.gsub!(/(<<([^<>]*)>>)/) do
|
68
|
-
|
69
|
-
expression = Regexp.last_match[2]
|
70
|
-
if expression == 'matched_page' && matched_page.class != String
|
71
|
-
@logger.warn do
|
72
|
-
expression = 'matched_page.href'
|
73
|
-
<<~END_MSG
|
74
|
-
The expression #{token} should either specify a property, for example <<matched_page.href>>,
|
75
|
-
or a hash value, for example <<matched_page['title']>>.
|
76
|
-
The expression was modified to <<matched_page.href>> for you.
|
77
|
-
END_MSG
|
78
|
-
end
|
79
|
-
end
|
80
|
-
result = eval expression, binding # rubocop:disable Security/Eval
|
81
|
-
result.to_s
|
73
|
+
markup.gsub!(/(<<([^<>]*)>>)/) do # gsub replaces token with the return value of this block
|
74
|
+
replace_token Regexp.last_match[1], Regexp.last_match[2], binding
|
82
75
|
end
|
83
76
|
markup
|
84
77
|
rescue StandardError => e
|
85
|
-
|
78
|
+
msg = e.full_message
|
79
|
+
if msg.length < 250
|
80
|
+
@logger.error { msg }
|
81
|
+
else
|
82
|
+
@logger.error { "#{msg[0..125]} ... #{msg[-125..msg.length]}" }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def replace_token(token, expression, binding)
|
87
|
+
if expression == 'matched_page'
|
88
|
+
expression = case matched_page
|
89
|
+
when String
|
90
|
+
matched_page
|
91
|
+
when APage
|
92
|
+
'matched_page&.href'
|
93
|
+
when LruFile
|
94
|
+
'matched_page&.url'
|
95
|
+
else
|
96
|
+
@logger.warn do
|
97
|
+
<<~END_MSG
|
98
|
+
The type #{matched_page.class} has an invalid valueexpression #{token}.
|
99
|
+
END_MSG
|
100
|
+
end
|
101
|
+
exit!
|
102
|
+
end
|
103
|
+
@logger.warn do
|
104
|
+
<<~END_MSG
|
105
|
+
The expression #{token} should either specify a property, for example <<matched_page&.href>>,
|
106
|
+
or a hash value, for example <<matched_page['title']>>.
|
107
|
+
The expression was modified to <<#{expression}>> for you.
|
108
|
+
END_MSG
|
109
|
+
end
|
110
|
+
else
|
111
|
+
puts expression
|
112
|
+
end
|
113
|
+
result = eval expression, binding # rubocop:disable Security/Eval
|
114
|
+
result.to_s
|
86
115
|
end
|
87
116
|
end
|
88
117
|
|
data/lib/jekyll_draft/version.rb
CHANGED
data/lib/jekyll_draft.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
if ENV['USE_JPS_SOURCE']
|
2
|
+
require_relative "#{ENV.fetch('jekyll_plugin_support')}/lib/jekyll_plugin_support"
|
3
|
+
else
|
4
|
+
require 'jekyll_plugin_support'
|
5
|
+
end
|
4
6
|
require 'yaml'
|
5
7
|
require_relative 'jekyll_draft/version' unless defined?(VERSION)
|
6
8
|
|
data/spec/status_persistence.txt
CHANGED
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll_draft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Slinn
|
8
|
+
autorequire:
|
8
9
|
bindir: exe
|
9
10
|
cert_chain: []
|
10
|
-
date: 2025-
|
11
|
+
date: 2025-03-06 00:00:00.000000000 Z
|
11
12
|
dependencies:
|
12
13
|
- !ruby/object:Gem::Dependency
|
13
14
|
name: jekyll
|
@@ -15,28 +16,42 @@ dependencies:
|
|
15
16
|
requirements:
|
16
17
|
- - ">="
|
17
18
|
- !ruby/object:Gem::Version
|
18
|
-
version:
|
19
|
+
version: 4.4.0
|
19
20
|
type: :runtime
|
20
21
|
prerelease: false
|
21
22
|
version_requirements: !ruby/object:Gem::Requirement
|
22
23
|
requirements:
|
23
24
|
- - ">="
|
24
25
|
- !ruby/object:Gem::Version
|
25
|
-
version:
|
26
|
+
version: 4.4.0
|
26
27
|
- !ruby/object:Gem::Dependency
|
27
28
|
name: jekyll_plugin_support
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
31
|
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
33
|
+
version: 3.0.0
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
36
|
version_requirements: !ruby/object:Gem::Requirement
|
36
37
|
requirements:
|
37
38
|
- - ">="
|
38
39
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
40
|
+
version: 3.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sorted_set
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
40
55
|
description: 'This Jekyll filter detects draft documents.
|
41
56
|
|
42
57
|
'
|
@@ -86,14 +101,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
101
|
requirements:
|
87
102
|
- - ">="
|
88
103
|
- !ruby/object:Gem::Version
|
89
|
-
version: 2.
|
104
|
+
version: 3.2.0
|
90
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
106
|
requirements:
|
92
107
|
- - ">="
|
93
108
|
- !ruby/object:Gem::Version
|
94
109
|
version: '0'
|
95
110
|
requirements: []
|
96
|
-
rubygems_version: 3.
|
111
|
+
rubygems_version: 3.5.22
|
112
|
+
signing_key:
|
97
113
|
specification_version: 4
|
98
114
|
summary: This Jekyll filter detects draft documents.
|
99
115
|
test_files:
|