jekyll_include_plugin 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54bfb570062a4da31cc5867a42c04e27dbc9805fa5264e8c58e981767f0a278a
4
- data.tar.gz: '09e7d4a74aed13c6b35989488f17f6585738a44040bdd67249d8adc63d692312'
3
+ metadata.gz: 1ab41eee4ee062ebf7ff40d8af0a74b1f8c62290917d9a8f7cefff42da0448eb
4
+ data.tar.gz: 33baf168b4e8135a1764c87331440fe0b99708ed03ae0c785b05f83a460e7dbc
5
5
  SHA512:
6
- metadata.gz: 6af90891514917916f37065d5478949692627bad43ab9155f2ff49dc564b9ff8feb3c9bf16de62732faa038292e553d84dfa9d39e87dbe8b19c65df414cefbbb
7
- data.tar.gz: 21f27c73ba69245773207cf8ed917fb97b13b0fc34e57be8564ffa928ca3fc720525dfcabe73eb6c3587e4d77bf8b18a849130c51b0dead09356debc740d1c0e
6
+ metadata.gz: 273307ca8e1c63524efaed172e0175fb92296184940d8456cf143303363662652eb11648d352c93c0a7e667ac3f51f366ebb001829347bef1b22a9de8c8b38e1
7
+ data.tar.gz: b1ed24b4640b5897660f76d340b9067b9a936bf209c32037b647c7c5f378ea0a7effec85c7bc2272c001238c6bc3ee35d0c4da9e0018ecc7e43194fbb369e397
@@ -1,16 +1,19 @@
1
1
  name: Ruby
2
2
 
3
- on: [push,pull_request]
3
+ on: [push, pull_request]
4
4
 
5
5
  jobs:
6
6
  build:
7
7
  runs-on: ubuntu-latest
8
+ strategy:
9
+ matrix:
10
+ ruby: [2.6.10, 2.7.6, 3.0.4, 3.1.2, 3.2.0, 3.4.2]
8
11
  steps:
9
12
  - uses: actions/checkout@v2
10
13
  - name: Set up Ruby
11
14
  uses: ruby/setup-ruby@v1
12
15
  with:
13
- ruby-version: 2.6.5
16
+ ruby-version: ${{ matrix.ruby }}
14
17
  bundler-cache: true
15
18
  - name: Run the default task
16
19
  run: bundle exec rake
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jekyll_include_plugin (1.1.0)
4
+ jekyll_include_plugin (1.2.0)
5
5
  jekyll (>= 3.5, < 5.0)
6
6
  liquid (~> 4.0)
7
7
 
@@ -59,7 +59,8 @@ GEM
59
59
  rb-fsevent (0.11.0)
60
60
  rb-inotify (0.10.1)
61
61
  ffi (~> 1.0)
62
- rexml (3.2.5)
62
+ rexml (3.2.8)
63
+ strscan (>= 3.0.9)
63
64
  rouge (3.26.0)
64
65
  rspec (3.10.0)
65
66
  rspec-core (~> 3.10.0)
@@ -79,6 +80,7 @@ GEM
79
80
  ffi (~> 1.9)
80
81
  sassc (2.4.0-x64-mingw32)
81
82
  ffi (~> 1.9)
83
+ strscan (3.1.0)
82
84
  terminal-table (2.0.0)
83
85
  unicode-display_width (~> 1.1, >= 1.1.1)
84
86
  unicode-display_width (1.7.0)
@@ -93,4 +95,4 @@ DEPENDENCIES
93
95
  rspec (~> 3.0)
94
96
 
95
97
  BUNDLED WITH
96
- 2.2.20
98
+ 2.6.6
data/README.md CHANGED
@@ -60,6 +60,19 @@ Dynamic parameters:
60
60
  {% include_file "{{ $templatingAllowedHere }}/Dockerfile" snippet="{{ $hereToo }}" %}
61
61
  ```
62
62
 
63
+ ## Plugin options in `_config.yml`
64
+
65
+ Default options:
66
+ ```yml
67
+ jekyll_include_plugin:
68
+ snippet_prefix: '...'
69
+ ```
70
+
71
+ ### `snippet_prefix`
72
+ Type: `string` Default: `...`
73
+
74
+ Prepends the prefix at the end of included snippet to differentiate whole file includes vs partial file includes (snippet)
75
+
63
76
  ## Installation
64
77
 
65
78
  Add this line to your application's Gemfile:
@@ -10,16 +10,18 @@ module JekyllIncludePlugin
10
10
  def initialize(tag_name, raw_markup, tokens)
11
11
  super
12
12
  @raw_markup = raw_markup
13
+ @config = {}
13
14
  @params = {}
14
15
  end
15
16
 
16
17
  def render(context)
18
+ read_config(context)
17
19
  parse_params(context)
18
20
 
19
21
  file_contents = get_raw_file_contents(context)
20
22
 
21
23
  if @params["snippet"]
22
- file_contents = pick_snippet(file_contents, @params["snippet"])
24
+ file_contents = pick_snippet(file_contents, @config['snippet_prefix'], @params["snippet"])
23
25
  else
24
26
  file_contents = remove_all_snippets(file_contents)
25
27
  end
@@ -34,6 +36,13 @@ module JekyllIncludePlugin
34
36
 
35
37
  private
36
38
 
39
+ def read_config(context)
40
+ site = context.registers[:site]
41
+ plugin_config = site.config["jekyll_include_plugin"] || {}
42
+
43
+ @config["snippet_prefix"] = plugin_config['snippet_prefix'] || '...'
44
+ end
45
+
37
46
  def parse_params(context)
38
47
  rendered_markup = Liquid::Template
39
48
  .parse(@raw_markup)
@@ -92,7 +101,7 @@ module JekyllIncludePlugin
92
101
  def get_remote_file_contents()
93
102
  begin
94
103
  debug("Getting contents of specified remote file: #{@params["abs_file_url"]}")
95
- return open(@params["abs_file_url"]).read
104
+ return URI.open(@params["abs_file_url"]).read
96
105
  rescue OpenURI::HTTPError => e
97
106
  abort("Can't get the contents of specified remote file '#{@params["abs_file_url"]}': #{e.message}")
98
107
  end
@@ -16,7 +16,7 @@ module JekyllIncludePlugin
16
16
  module TextUtils
17
17
  include Utils
18
18
 
19
- def pick_snippet(text, snippet_name)
19
+ def pick_snippet(text, snippet_prefix, snippet_name)
20
20
  snippet_content = ""
21
21
  snippet_start_found = false
22
22
  snippet_end_found = false
@@ -42,8 +42,10 @@ module JekyllIncludePlugin
42
42
  abort("End of the snippet '#{snippet_name}' has not been found.") unless snippet_end_found
43
43
  abort("Snippet '#{snippet_name}' appears to be empty. Fix and retry.") if snippet_content.empty?
44
44
 
45
+ return snippet_content if snippet_prefix.empty?
46
+
45
47
  first_line_indent = %r!^\s*!.match(snippet_content)[0]
46
- return "#{first_line_indent}...\n#{snippet_content}"
48
+ return "#{first_line_indent}#{snippet_prefix}\n#{snippet_content}"
47
49
  end
48
50
 
49
51
  def remove_all_snippets(text)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JekyllIncludePlugin
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll_include_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Lesikov
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2021-11-18 00:00:00.000000000 Z
10
+ date: 2025-03-15 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: liquid
@@ -72,7 +71,6 @@ dependencies:
72
71
  - - "~>"
73
72
  - !ruby/object:Gem::Version
74
73
  version: '3.0'
75
- description:
76
74
  email:
77
75
  - ilya@lesikov.com
78
76
  executables: []
@@ -101,7 +99,6 @@ licenses:
101
99
  metadata:
102
100
  homepage_uri: https://github.com/flant/jekyll_include_plugin
103
101
  source_code_uri: https://github.com/flant/jekyll_include_plugin
104
- post_install_message:
105
102
  rdoc_options: []
106
103
  require_paths:
107
104
  - lib
@@ -116,8 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
113
  - !ruby/object:Gem::Version
117
114
  version: '0'
118
115
  requirements: []
119
- rubygems_version: 3.0.8
120
- signing_key:
116
+ rubygems_version: 3.6.2
121
117
  specification_version: 4
122
118
  summary: Plugin for including contents of local/remote plain text files (or parts
123
119
  of them) into your pages. Allows for multilang comments in the included files.