shi-jekyll-images 0.1.0.9 → 0.1.0.14

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: c46efb41167a462a3dbdbb688427e3fce17d24c050185a064834547cf2299932
4
- data.tar.gz: cb8c641d7a054a509a6d4dee65cb831dd9c860bf52ee1e894df3dd3420937fb3
3
+ metadata.gz: eac0cef4a9dcd2d9f3d8fdffdc0b5b9335f14a77eb9d0b56e87c19e814d398f7
4
+ data.tar.gz: 73afca035a829bcc8ad48b8911df13f842e5a4d2d8deb24be0f67b74ecc4ea97
5
5
  SHA512:
6
- metadata.gz: '001189f90de0599f61f721252f4838491459c7a21ae07b8cc8db62b3fe57b29310d78aa76279eda0bb740574d73da7a98c130899a4f044775b0ee60f1648fea9'
7
- data.tar.gz: c712f7009557cf0d3c687d345d800c75c264177a085d09ccd200d46d43258871788eb49e0408d35460c44a5f6a2030d6b19dd08697827a301dae44a742c458b2
6
+ metadata.gz: e0e9e45b08f9f187e9b7aee1789cbf694f226d622c0aaec610ae96835f519b2a732340f2d617151fe2c6159faf9c049000d73c235ae9c695aedf3396c59ddf86
7
+ data.tar.gz: 24f498b6fd1ca1c903f8091d8b6b54d6c630e5dff54eae437d3118b140f3d325765e38620ea21a703c04646664e5e215d33bd48d3cf1d63a45cd4e79922fd522
data/Gemfile CHANGED
@@ -2,5 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
+ gem 'liquid', '~> 4.0'
6
+
5
7
  # Specify your gem's dependencies in shi-jekyll-images.gemspec
6
8
  gemspec
data/Gemfile.lock CHANGED
@@ -1,84 +1,176 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shi-jekyll-images (0.1.0)
4
+ shi-jekyll-images (0.1.0.9)
5
5
  jekyll (>= 4.0, < 5.0)
6
6
  liquid (~> 4.0)
7
- shi-args (~> 0.3.3.5)
8
- shi-tools (~> 0.1.0)
7
+ shi-args (~> 0.3.4.2)
8
+ shi-tools (~> 0.2.0)
9
9
 
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- addressable (2.8.1)
14
- public_suffix (>= 2.0.2, < 6.0)
13
+ addressable (2.8.7)
14
+ public_suffix (>= 2.0.2, < 7.0)
15
+ base64 (0.3.0)
16
+ bigdecimal (3.2.3)
15
17
  colorator (1.1.0)
16
- concurrent-ruby (1.1.10)
18
+ concurrent-ruby (1.3.5)
19
+ csv (3.3.5)
17
20
  em-websocket (0.5.3)
18
21
  eventmachine (>= 0.12.9)
19
22
  http_parser.rb (~> 0)
20
23
  eventmachine (1.2.7)
21
- ffi (1.15.5)
24
+ ffi (1.17.2)
25
+ ffi (1.17.2-aarch64-linux-gnu)
26
+ ffi (1.17.2-aarch64-linux-musl)
27
+ ffi (1.17.2-arm-linux-gnu)
28
+ ffi (1.17.2-arm-linux-musl)
29
+ ffi (1.17.2-arm64-darwin)
30
+ ffi (1.17.2-x86-linux-gnu)
31
+ ffi (1.17.2-x86-linux-musl)
32
+ ffi (1.17.2-x86_64-darwin)
33
+ ffi (1.17.2-x86_64-linux-gnu)
34
+ ffi (1.17.2-x86_64-linux-musl)
22
35
  forwardable-extended (2.6.0)
23
- google-protobuf (3.21.12-x86_64-linux)
36
+ google-protobuf (4.32.0)
37
+ bigdecimal
38
+ rake (>= 13)
39
+ google-protobuf (4.32.0-aarch64-linux-gnu)
40
+ bigdecimal
41
+ rake (>= 13)
42
+ google-protobuf (4.32.0-aarch64-linux-musl)
43
+ bigdecimal
44
+ rake (>= 13)
45
+ google-protobuf (4.32.0-arm64-darwin)
46
+ bigdecimal
47
+ rake (>= 13)
48
+ google-protobuf (4.32.0-x86-linux-gnu)
49
+ bigdecimal
50
+ rake (>= 13)
51
+ google-protobuf (4.32.0-x86-linux-musl)
52
+ bigdecimal
53
+ rake (>= 13)
54
+ google-protobuf (4.32.0-x86_64-darwin)
55
+ bigdecimal
56
+ rake (>= 13)
57
+ google-protobuf (4.32.0-x86_64-linux-gnu)
58
+ bigdecimal
59
+ rake (>= 13)
60
+ google-protobuf (4.32.0-x86_64-linux-musl)
61
+ bigdecimal
62
+ rake (>= 13)
24
63
  http_parser.rb (0.8.0)
25
- i18n (1.12.0)
64
+ i18n (1.14.7)
26
65
  concurrent-ruby (~> 1.0)
27
- jekyll (4.3.1)
66
+ jekyll (4.4.1)
28
67
  addressable (~> 2.4)
68
+ base64 (~> 0.2)
29
69
  colorator (~> 1.0)
70
+ csv (~> 3.0)
30
71
  em-websocket (~> 0.5)
31
72
  i18n (~> 1.0)
32
73
  jekyll-sass-converter (>= 2.0, < 4.0)
33
74
  jekyll-watch (~> 2.0)
75
+ json (~> 2.6)
34
76
  kramdown (~> 2.3, >= 2.3.1)
35
77
  kramdown-parser-gfm (~> 1.0)
36
78
  liquid (~> 4.0)
37
- mercenary (>= 0.3.6, < 0.5)
79
+ mercenary (~> 0.3, >= 0.3.6)
38
80
  pathutil (~> 0.9)
39
81
  rouge (>= 3.0, < 5.0)
40
82
  safe_yaml (~> 1.0)
41
83
  terminal-table (>= 1.8, < 4.0)
42
84
  webrick (~> 1.7)
43
- jekyll-sass-converter (3.0.0)
44
- sass-embedded (~> 1.54)
85
+ jekyll-sass-converter (3.1.0)
86
+ sass-embedded (~> 1.75)
45
87
  jekyll-watch (2.2.1)
46
88
  listen (~> 3.0)
47
- kramdown (2.4.0)
48
- rexml
89
+ json (2.13.2)
90
+ kramdown (2.5.1)
91
+ rexml (>= 3.3.9)
49
92
  kramdown-parser-gfm (1.1.0)
50
93
  kramdown (~> 2.0)
51
- liquid (4.0.3)
52
- listen (3.7.1)
94
+ liquid (4.0.4)
95
+ listen (3.9.0)
53
96
  rb-fsevent (~> 0.10, >= 0.10.3)
54
97
  rb-inotify (~> 0.9, >= 0.9.10)
55
98
  mercenary (0.4.0)
56
99
  pathutil (0.16.2)
57
100
  forwardable-extended (~> 2.6)
58
- public_suffix (5.0.1)
101
+ public_suffix (6.0.2)
102
+ rake (13.3.0)
59
103
  rb-fsevent (0.11.2)
60
- rb-inotify (0.10.1)
104
+ rb-inotify (0.11.1)
61
105
  ffi (~> 1.0)
62
- rexml (3.2.5)
63
- rouge (4.0.1)
106
+ rexml (3.4.4)
107
+ rouge (4.6.0)
64
108
  safe_yaml (1.0.5)
65
- sass-embedded (1.57.1-x86_64-linux-gnu)
66
- google-protobuf (~> 3.21)
67
- shi-args (0.3.3.5)
109
+ sass-embedded (1.92.1)
110
+ google-protobuf (~> 4.31)
111
+ rake (>= 13)
112
+ sass-embedded (1.92.1-aarch64-linux-android)
113
+ google-protobuf (~> 4.31)
114
+ sass-embedded (1.92.1-aarch64-linux-gnu)
115
+ google-protobuf (~> 4.31)
116
+ sass-embedded (1.92.1-aarch64-linux-musl)
117
+ google-protobuf (~> 4.31)
118
+ sass-embedded (1.92.1-arm-linux-androideabi)
119
+ google-protobuf (~> 4.31)
120
+ sass-embedded (1.92.1-arm-linux-gnueabihf)
121
+ google-protobuf (~> 4.31)
122
+ sass-embedded (1.92.1-arm-linux-musleabihf)
123
+ google-protobuf (~> 4.31)
124
+ sass-embedded (1.92.1-arm64-darwin)
125
+ google-protobuf (~> 4.31)
126
+ sass-embedded (1.92.1-riscv64-linux-android)
127
+ google-protobuf (~> 4.31)
128
+ sass-embedded (1.92.1-riscv64-linux-gnu)
129
+ google-protobuf (~> 4.31)
130
+ sass-embedded (1.92.1-riscv64-linux-musl)
131
+ google-protobuf (~> 4.31)
132
+ sass-embedded (1.92.1-x86_64-darwin)
133
+ google-protobuf (~> 4.31)
134
+ sass-embedded (1.92.1-x86_64-linux-android)
135
+ google-protobuf (~> 4.31)
136
+ sass-embedded (1.92.1-x86_64-linux-gnu)
137
+ google-protobuf (~> 4.31)
138
+ sass-embedded (1.92.1-x86_64-linux-musl)
139
+ google-protobuf (~> 4.31)
140
+ shi-args (0.3.4.2)
68
141
  jekyll (>= 4.0, < 5.0)
69
142
  liquid (~> 4.0)
70
- shi-tools (~> 0.1.0)
71
- shi-tools (0.1.0)
143
+ shi-tools (~> 0.2.0)
144
+ shi-tools (0.2.0)
72
145
  terminal-table (3.0.2)
73
146
  unicode-display_width (>= 1.1.1, < 3)
74
- unicode-display_width (2.4.2)
75
- webrick (1.7.0)
147
+ unicode-display_width (2.6.0)
148
+ webrick (1.9.1)
76
149
 
77
150
  PLATFORMS
78
- x86_64-linux
151
+ aarch64-linux-android
152
+ aarch64-linux-gnu
153
+ aarch64-linux-musl
154
+ arm-linux-androideabi
155
+ arm-linux-gnu
156
+ arm-linux-gnueabihf
157
+ arm-linux-musl
158
+ arm-linux-musleabihf
159
+ arm64-darwin
160
+ riscv64-linux-android
161
+ riscv64-linux-gnu
162
+ riscv64-linux-musl
163
+ ruby
164
+ x86-linux-gnu
165
+ x86-linux-musl
166
+ x86_64-darwin
167
+ x86_64-linux-android
168
+ x86_64-linux-gnu
169
+ x86_64-linux-musl
79
170
 
80
171
  DEPENDENCIES
172
+ liquid (~> 4.0)
81
173
  shi-jekyll-images!
82
174
 
83
175
  BUNDLED WITH
84
- 2.4.1
176
+ 2.7.1
@@ -1,5 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'warning'
4
+
5
+ gem_paths = Gem.path.flat_map do |path|
6
+ Dir.glob("#{path}/gems/*").select do |gem_path|
7
+ !gem_path.include?("shi-")
8
+ end
9
+ end
10
+
11
+ gem_paths.each do |path|
12
+ Warning.ignore(//, path)
13
+ end
14
+
15
+
3
16
  module Shi::Jekyll::Images::Config
4
17
  def site_config
5
18
  @@site_config ||= Jekyll::configuration || {}
@@ -26,7 +39,7 @@ module Shi::Jekyll::Images::Config
26
39
  result = config[name]
27
40
  end
28
41
  result
29
- end
42
+ end
30
43
 
31
44
  def site
32
45
  Jekyll::sites.first
@@ -13,7 +13,38 @@ module Shi::Jekyll::Images::File
13
13
  Shi::Jekyll::Images::WebPFile::create page, source, bounds, crop
14
14
  end
15
15
  end
16
+
17
+ # Восстанавливаем ранее сгенерированные файлы в site.static_files
18
+ def restore_generated_files(site)
19
+ target_root = site.config['shi_images']&.[]('target_root') || 'img'
20
+ generated_files_dir = File.join(site.dest, target_root)
21
+ return unless File.directory?(generated_files_dir)
22
+
23
+ Dir.glob(File.join(generated_files_dir, '**', '*.{webp,svg}')).each do |file_path|
24
+ relative_path = file_path.sub(/^#{site.dest}\//, '')
25
+ unless site.static_files.any? { |f| f.relative_path == relative_path }
26
+ # Создаём фиктивный StaticFile, чтобы Jekyll не удалял файл
27
+ source_file = site.static_files.find { |f| f.relative_path == File.basename(relative_path).sub(/\.webp$/, '') }
28
+ source_file ||= Jekyll::StaticFile.new(site, site.source, File.dirname(relative_path), File.basename(relative_path))
29
+
30
+ if File.extname(file_path).downcase == '.svg'
31
+ static_file = Shi::Jekyll::Images::SVGFile.new(relative_path, source_file)
32
+ else
33
+ # Для WebP используем dummy bounds/crop, так как точные значения неизвестны
34
+ static_file = Shi::Jekyll::Images::WebPFile.new(relative_path, source_file, nil, nil)
35
+ end
36
+ site.static_files << static_file unless site.static_files.include?(static_file)
37
+ end
38
+ end
39
+ end
40
+
16
41
  end
42
+
43
+ # Регистрируем хук для восстановления файлов после чтения сайта
44
+ Jekyll::Hooks.register :site, :post_read do |site|
45
+ Shi::Jekyll::Images::File.restore_generated_files(site)
46
+ end
47
+
17
48
  end
18
49
 
19
50
  class Shi::Jekyll::Images::WebPFile < Jekyll::StaticFile
@@ -62,7 +93,7 @@ class Shi::Jekyll::Images::WebPFile < Jekyll::StaticFile
62
93
  result
63
94
  end
64
95
 
65
- private :new
96
+ # private :new
66
97
  private :name_by_source, :path, :make_key, :default_bounds
67
98
  end
68
99
 
@@ -75,11 +106,14 @@ class Shi::Jekyll::Images::WebPFile < Jekyll::StaticFile
75
106
  end
76
107
 
77
108
  def modified?
78
- true
109
+ src_path = File.join(site.source, @wp_source.relative_path)
110
+ tgt_path = destination site.dest
111
+ return true unless File.exist?(tgt_path) && File.exist?(src_path)
112
+ File.mtime(src_path) > File.mtime(tgt_path)
79
113
  end
80
114
 
81
115
  def write?
82
- true
116
+ modified?
83
117
  end
84
118
 
85
119
  def cropping crop
@@ -119,13 +153,17 @@ class Shi::Jekyll::Images::WebPFile < Jekyll::StaticFile
119
153
  end
120
154
 
121
155
  def write dest
156
+ return true if !write?
157
+
122
158
  tgt_path = destination dest
123
159
  src_path = File::join site.source, @wp_source.relative_path
124
160
 
161
+ return false unless File.exist?(src_path)
162
+
125
163
  FileUtils::mkdir_p(File.dirname(tgt_path))
126
164
  FileUtils::rm(tgt_path) if File.exist?(tgt_path)
127
165
  cmd = "convert '#{src_path}' #{cropping(@wp_crop)} #{resizing(@wp_bounds)} #{qualiting} '#{tgt_path}'"
128
- system(cmd, exception: true)
166
+ system(cmd, exception: true, err: '/dev/null')
129
167
 
130
168
  true
131
169
  end
@@ -163,7 +201,7 @@ class Shi::Jekyll::Images::SVGFile < Jekyll::StaticFile
163
201
  result
164
202
  end
165
203
 
166
- private :new
204
+ # private :new
167
205
  private :path, :make_key
168
206
  end
169
207
 
@@ -174,17 +212,24 @@ class Shi::Jekyll::Images::SVGFile < Jekyll::StaticFile
174
212
  end
175
213
 
176
214
  def modified?
177
- true
215
+ src_path = File.join(site.source, @wp_source.relative_path)
216
+ tgt_path = destination site.dest
217
+ return true unless File.exist?(tgt_path) && File.exist?(src_path)
218
+ File.mtime(src_path) > File.mtime(tgt_path)
178
219
  end
179
220
 
180
221
  def write?
181
- true
222
+ modified?
182
223
  end
183
224
 
184
225
  def write dest
226
+ return true if !write?
227
+
185
228
  tgt_path = destination dest
186
229
  src_path = File::join site.source, @wp_source.relative_path
187
230
 
231
+ return false unless File.exist?(src_path)
232
+
188
233
  FileUtils::mkdir_p(File.dirname(tgt_path))
189
234
  FileUtils::rm(tgt_path) if File.exist?(tgt_path)
190
235
  FileUtils::cp(src_path, tgt_path)
@@ -1,6 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'version'
4
+ require 'fileutils'
5
+ require 'liquid'
6
+ require 'jekyll'
7
+ require 'shi/tools'
8
+ require 'shi/args'
4
9
  require_relative 'files'
5
10
 
6
11
  class Shi::Jekyll::ImageTag < Liquid::Tag
@@ -1,17 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'pp' # TODO: remove for release
3
+ # require 'pp' # TODO: remove for release
4
4
 
5
- require 'fileutils'
6
- require 'liquid'
7
- require 'jekyll'
8
- require 'shi/tools'
9
- require 'shi/args'
5
+ # require 'fileutils'
6
+ # require 'liquid'
7
+ # require 'jekyll'
8
+ # require 'shi/tools'
9
+ # require 'shi/args'
10
10
 
11
11
  module Shi
12
12
  module Jekyll
13
13
  module Images
14
- VERSION = '0.1.0.9'
14
+ VERSION = '0.1.0.14'
15
15
  end
16
16
  end
17
17
  end
metadata CHANGED
@@ -1,15 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shi-jekyll-images
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.9
4
+ version: 0.1.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Shikhalev
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-01-17 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: warning
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
13
26
  - !ruby/object:Gem::Dependency
14
27
  name: jekyll
15
28
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +85,12 @@ dependencies:
72
85
  - - "~>"
73
86
  - !ruby/object:Gem::Version
74
87
  version: 0.3.4.2
75
- description:
76
88
  email:
77
89
  - shikhalev@gmail.com
78
90
  executables: []
79
91
  extensions: []
80
92
  extra_rdoc_files: []
81
93
  files:
82
- - ".rufo"
83
94
  - Gemfile
84
95
  - Gemfile.lock
85
96
  - LICENSE.txt
@@ -99,7 +110,6 @@ licenses:
99
110
  metadata:
100
111
  homepage_uri: https://github.com/shikhalev/shi-jekyll-images
101
112
  source_code_uri: https://github.com/shikhalev/shi-jekyll-images
102
- post_install_message:
103
113
  rdoc_options: []
104
114
  require_paths:
105
115
  - lib
@@ -114,8 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
124
  - !ruby/object:Gem::Version
115
125
  version: '0'
116
126
  requirements: []
117
- rubygems_version: 3.4.3
118
- signing_key:
127
+ rubygems_version: 3.7.2
119
128
  specification_version: 4
120
129
  summary: Jekyll plugin for image manipulation
121
130
  test_files: []
data/.rufo DELETED
@@ -1,6 +0,0 @@
1
-
2
- align_case_when true
3
- parens_in_def :dynamic
4
- align_chained_calls true
5
- trailing_commas false
6
- quote_style :single