jekyll_flexible_include 2.0.23 → 2.0.25

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2bbd3d775f087cefca7f18e68966dc58afb1b19099154b7e56dce5fba9b6f25
4
- data.tar.gz: '065912548161e1cce5d139566f370cabe68ad0521e87e7dd50f424e3a8e958f0'
3
+ metadata.gz: c1c41e1810d12f5452b662944c1903eff7b04d944497ce8565e9bd0f7cf42902
4
+ data.tar.gz: b5b8592e381e6e5b494018e340cc5e59c8f4422195e719c5c60e9e7252ca37f3
5
5
  SHA512:
6
- metadata.gz: 6c965faec3f89eb9d005dc2ad7fea3847f77d716039b9f903f8f84ea20e49ba991f016664013826d0fb4e044203a7ae82338aca7b1b7a699a8d1e59ae18f4f62
7
- data.tar.gz: b4fb7d8c8b0afddef8f0c5d359b5bbe7077ae4418b38641e6f52dd537005a75c7a47a2eb371ea3de24cc4269295e423f8ff8a3b1c719e2f8b8c862f9ed4f8b20
6
+ metadata.gz: 7b49278506aa5230d915bd2bd919c94e5fa111cf1c5414ae0b1cf4d961e12a510b4b22904b50e9bb21b596784cea498a0f982a90c4a443db9fa0b5817cb00fae
7
+ data.tar.gz: 3bd38e8915a07260bd17d8eab24c35671b1c7067e9d556cb1b76b9fd75c6c11e471e434f1177cd5dd4b40553bc0fd6addfe19de28ce4cd69d179b599b658d4c2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.0.25 / 2024-12-11
4
+
5
+ * Fixed `from` / `to` / `until` issue
6
+
7
+
8
+ ## 2.0.24 / 2024-00-20
9
+
10
+ * Made compatible with `jekyll_plugin_support` v1.0.2
11
+
12
+
3
13
  ## 2.0.23 / 2024-07-22
4
14
 
5
15
  * Made compatible with `jekyll_plugin_support` v1.0.0
data/README.md CHANGED
@@ -185,6 +185,8 @@ and a red error message will be logged on the console that says something like:
185
185
 
186
186
  ## Installation
187
187
 
188
+ ### Gem
189
+
188
190
  1. Add the following to `Gemfile`, inside the `jekyll_plugins` group:
189
191
 
190
192
  ```ruby
@@ -213,6 +215,36 @@ and a red error message will be logged on the console that says something like:
213
215
  $ bundle
214
216
  ```
215
217
 
218
+ ### CSS and Assets
219
+
220
+ Copy assets and CSS from the demo/ directory of the jekyll_pre GitHub project.
221
+
222
+ - Copy `demo/assets/images/clippy.svg` to a directory of the same name in your Jekyll project.
223
+ - Copy `demo/assets/css/jekyll_plugin_support.css` to your Jekyll project assets directory.
224
+ - Copy `demo/assets/css/shared_include_pre.css` to your Jekyll project assets directory.
225
+ - Copy `demo/assets/css/jekyll_flexible_include.css` to your Jekyll project assets directory.
226
+ - Incorporate the CSS stylesheets into the appropriate layout in your Jekyll project:
227
+
228
+ ```html
229
+ {% assign nowMillis = site.time | date: '%s' %}
230
+ <link rel="stylesheet" href="{{ '/assets/css/jekyll_plugin_support.css?v=' | append: nowMillis }}" type="text/css">
231
+ <link rel="stylesheet" href="{{ '/assets/css/shared_include_pre.css?v=' | append: nowMillis }}" type="text/css">
232
+ <link rel="stylesheet" href="{{ '/assets/css/jekyll_flexible_include.css?v=' | append: nowMillis }}" type="text/css">
233
+ ```
234
+
235
+
236
+ ### JavaScript
237
+
238
+ Copy `demo/assets/js/clipboard.min.js` from the `jekyll_flexible_include_plugin` GitHub project
239
+ to your Jekyll project’s JavaScript directory.
240
+
241
+ Modify the Jekyll layout or selected pages to load the JavaScript.
242
+ You can load it from your project, as shown below, or from a CDN.
243
+
244
+ ```html
245
+ <script defer src="/assets/js/clipboard.min.js"></script>
246
+ ```
247
+
216
248
 
217
249
  ## Examples
218
250
 
@@ -35,8 +35,8 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
35
35
  spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
36
36
  spec.version = JekyllFlexibleIncludePluginVersion::VERSION
37
37
 
38
- spec.add_dependency 'jekyll_from_to_until'
39
- spec.add_dependency 'jekyll_plugin_support', '>= 1.0.0'
38
+ spec.add_dependency 'jekyll_from_to_until', '>= 1.0.5'
39
+ spec.add_dependency 'jekyll_plugin_support', '>= 1.0.3'
40
40
  spec.add_dependency 'jekyll-sass-converter', '= 2.2.0'
41
41
  spec.add_dependency 'rugged'
42
42
  end
@@ -1,3 +1,3 @@
1
1
  module JekyllFlexibleIncludePluginVersion
2
- VERSION = '2.0.23'.freeze
2
+ VERSION = '2.0.25'.freeze
3
3
  end
@@ -12,6 +12,8 @@ class String
12
12
  end
13
13
 
14
14
  module FlexibleInclude
15
+ include FlexiblePrivateMethods
16
+
15
17
  FlexibleIncludeError = JekyllSupport.define_error
16
18
 
17
19
  PLUGIN_NAME = 'flexible_include'.freeze
@@ -23,6 +25,15 @@ module FlexibleInclude
23
25
  include FlexibleClassMethods
24
26
  end
25
27
 
28
+ def html_message(error)
29
+ <<~END_MSG
30
+ <div class='#{error.class.name.snakecase}'>
31
+ #{self.class} raised in #{calling_file} while processing line #{line_number} (after front matter) of #{path}
32
+ #{message}
33
+ </div>
34
+ END_MSG
35
+ end
36
+
26
37
  def render_impl
27
38
  setup
28
39
  @path = ::JekyllSupport::JekyllPluginHelper.expand_env @filename, @logger
@@ -30,32 +41,26 @@ module FlexibleInclude
30
41
  render_completion
31
42
  rescue Errno::EACCES => e
32
43
  e.shorten_backtrace
33
- msg = format_error_message e.message
34
- @logger.error msg
35
-
36
- if @die_on_file_error
37
- e2 = Errno::EACCES.new msg
38
- e2.set_backtrace e.backtrace
39
- raise e2
40
- end
44
+ @logger.error { "#{e.class.name}: #{e.message}" }
45
+ exit! 1 if @die_on_file_error
41
46
 
42
- "<div class='custom_error'>#{e.class} raised in #{self.class};\n#{msg}</div>"
47
+ html_message
43
48
  rescue Errno::ENOENT => e
44
49
  e.shorten_backtrace
45
- msg = format_error_message e.message
46
- @logger.error msg
50
+ @logger.error { "#{e.class.name}: #{e.message}" }
51
+ exit! 1 if @die_on_path_denied
47
52
 
48
- if @die_on_path_denied
49
- e2 = Errno::ENOENT.new msg
50
- e2.set_backtrace e.backtrace
51
- raise e2
52
- end
53
-
54
- "<div class='custom_error'>#{e.class} raised in #{self.class};\n#{msg}</div>"
53
+ html_message
55
54
  rescue FlexibleIncludeError => e
56
- e.shorten_backtrace
57
- @logger.error e.message
58
- raise e
55
+ @logger.error { e.logger_message }
56
+ exit! if @die_on_other_error
57
+
58
+ html_message
59
+ # rescue StandardError => e
60
+ # @logger.error { e.full_message }
61
+ # exit! 4
62
+
63
+ # html_message
59
64
  end
60
65
 
61
66
  private
@@ -1,12 +1,16 @@
1
1
  require 'pathname'
2
2
  require 'English'
3
+ require 'facets/string/camelcase'
4
+ require 'facets/string/snakecase'
3
5
  require 'jekyll_from_to_until'
4
6
 
5
7
  module FlexibleInclude
6
8
  module FlexiblePrivateMethods
9
+ include FromToUntil
10
+
7
11
  def denied(msg)
8
12
  msg_no_html = remove_html_tags(msg)
9
- @logger.error("#{@page['path']} - #{msg_no_html}")
13
+ @logger.error { "#{@page['path']} - #{msg_no_html}" }
10
14
  raise FlexibleIncludeError, "#{@page['path']} - #{msg_no_html}".red, [] if @die_on_path_denied
11
15
 
12
16
  "<p class='flexible_error'>#{msg}</p>"
@@ -19,9 +23,8 @@ module FlexibleInclude
19
23
  end
20
24
 
21
25
  def maybe_raise_error(msg, throw_error: true)
22
- fmsg = format_error_message msg
23
- @logger.error fmsg
24
- return "<span class='flexible_error'>#{fmsg}</span>" unless throw_error
26
+ @logger.error { msg }
27
+ return "<span class='flexible_error'>#{msg}</span>" unless throw_error
25
28
 
26
29
  raise FlexibleIncludeError, msg, []
27
30
  end
@@ -61,16 +64,28 @@ module FlexibleInclude
61
64
  end
62
65
 
63
66
  def render_completion
64
- unless @path.start_with? '!'
65
- maybe_raise_error("#{@path} does not exist", throw_error: @die_on_file_error) unless File.exist? @path
66
- maybe_raise_error("#{@path} is not readable", throw_error: @die_on_file_error) unless Pathname.new(@path).readable?
67
+ unless @path.start_with?('!')
68
+ unless File.exist?(@path) && Dir.exist?(File.dirname(@path))
69
+ return maybe_raise_error(
70
+ "#{@path} does not exist, referenced on line #{@line_number} (after front matter) of #{@page['path']}",
71
+ throw_error: @die_on_file_error
72
+ )
73
+ end
74
+
75
+ unless Pathname.new(@path).readable?
76
+ return maybe_raise_error(
77
+ "#{@path} is not readable, referenced on line #{@line_number} (after front matter) of #{@page['path']}",
78
+ throw_error: @die_on_file_error
79
+ )
80
+ end
67
81
 
68
82
  @contents = File.read @path
69
83
  unless @contents.instance_of? String
70
- maybe_raise_error("contents has type a #{@contents.class}, not a String",
84
+ maybe_raise_error("contents has type #{@contents.class}, not a String",
71
85
  throw_error: @die_on_file_error)
72
86
  end
73
87
  end
88
+
74
89
  @contents = FromToUntil.from(@contents, @from) if @from
75
90
  @contents = FromToUntil.to(@contents, @to) if @to
76
91
  @contents = FromToUntil.until(@contents, @until) if @until
@@ -96,8 +111,11 @@ module FlexibleInclude
96
111
  @logger.debug { "Executing #{cmd}" }
97
112
  %x[#{cmd}].chomp
98
113
  rescue FlexibleIncludeError => e
99
- raise e
100
- rescue StandardError => e
114
+ @logger.error { e.logger_message }
115
+ exit! 1 if @die_on_any_flexible_include_error
116
+
117
+ e.html_message
118
+ rescue StandardError => e # Assumes the wasa the result of running a command; this might not be a valid assumption. Awaiting a bug report.
101
119
  @do_not_escape = true
102
120
  e = e.exception "'#{e.message}' while executing '#{cmd}'"
103
121
  maybe_reraise_error(e, throw_error: @die_on_run_error)
@@ -113,6 +131,7 @@ module FlexibleInclude
113
131
  @die_on_other_error = config['die_on_other_error'] == true
114
132
  @die_on_path_denied = config['die_on_path_denied'] == true
115
133
  @die_on_run_error = config['die_on_run_error'] == true
134
+ @die_on_any_flexible_include_error = @die_on_file_error || @die_on_other_error || @die_on_path_denied || @die_on_run_error
116
135
  end
117
136
 
118
137
  parse_args
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_flexible_include
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.23
4
+ version: 2.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Slinn
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2024-07-26 00:00:00.000000000 Z
13
+ date: 2024-12-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jekyll_from_to_until
@@ -18,28 +18,28 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 1.0.5
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '0'
28
+ version: 1.0.5
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: jekyll_plugin_support
31
31
  requirement: !ruby/object:Gem::Requirement
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: 1.0.0
35
+ version: 1.0.3
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 1.0.0
42
+ version: 1.0.3
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: jekyll-sass-converter
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
- rubygems_version: 3.5.16
124
+ rubygems_version: 3.5.23
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: Jekyll plugin supports various ways to include content into the generated