jekyll-responsive-magick 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 +4 -4
- data/lib/jekyll-responsive-magick.rb +47 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0baafa9560a330fee2b5f7cce5844e0c7c79752f806b10dbf7bb23f782c6cac
|
4
|
+
data.tar.gz: 475a8781a41e2ff224facab935e7f19aeb5c12b1fd66df9dcea951f4a07b3424
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd8e381e61b7888dbaa9482b552834fbd85c0a3f182e11c0fb4028c367558cbbe0984402320266f25cb4a6decef5da2f28fbc54accbc363753e4bab01977f8fc
|
7
|
+
data.tar.gz: eb42d09a814fe7a22532c2b1b6a340e8dac979d52e939c9106c40d85f8f7e001f3d1a23c3ca66a4e4c26beb0dfc0457cb6645f1f3a3c3b69384ca50a7bd401c7
|
@@ -18,6 +18,7 @@
|
|
18
18
|
## limitations under the License.
|
19
19
|
##
|
20
20
|
require 'fileutils'
|
21
|
+
require 'shellwords'
|
21
22
|
|
22
23
|
module Jekyll
|
23
24
|
module ResponsiveMagickFilter
|
@@ -119,6 +120,52 @@ module Jekyll
|
|
119
120
|
end
|
120
121
|
return @@sizes[input][1]
|
121
122
|
end
|
123
|
+
|
124
|
+
def size(input, width)
|
125
|
+
site = @context.registers[:site]
|
126
|
+
if not input.is_a? String || input.length == 0 || input.chr != '/'
|
127
|
+
throw "size: input must be absolute path"
|
128
|
+
end
|
129
|
+
dirname = File.dirname(input)
|
130
|
+
basename = File.basename(input, '.*')
|
131
|
+
extname = File.extname(input)
|
132
|
+
src = ".#{dirname}/#{basename}#{extname}"
|
133
|
+
|
134
|
+
if site.config['responsive']['quality']
|
135
|
+
quality = site.config['responsive']['quality']
|
136
|
+
else
|
137
|
+
quality = 80
|
138
|
+
end
|
139
|
+
if site.config['responsive']['verbose']
|
140
|
+
verbose = site.config['responsive']['verbose']
|
141
|
+
else
|
142
|
+
verbose = false
|
143
|
+
end
|
144
|
+
|
145
|
+
if File.exist?(src) and ['.jpg', '.jpeg', '.png', '.apng', '.gif'].include?(extname)
|
146
|
+
file = "#{basename}-#{width}w#{extname}"
|
147
|
+
dst = "_responsive#{dirname}/#{file}"
|
148
|
+
if not site.static_files.find{|file| file.path == dst}
|
149
|
+
site.static_files << StaticFile.new(site, "_responsive", dirname, file)
|
150
|
+
if not File.exist?(dst) or File.mtime(src) > File.mtime(dst)
|
151
|
+
FileUtils.mkdir_p(File.dirname(dst))
|
152
|
+
if extname == '.apng'
|
153
|
+
cmd = "convert apng:#{src.shellescape} -strip -quality #{quality} -resize #{width} #{dst.shellescape}"
|
154
|
+
else
|
155
|
+
cmd = "convert #{src.shellescape} -strip -quality #{quality} -resize #{width} #{dst.shellescape}"
|
156
|
+
end
|
157
|
+
if verbose
|
158
|
+
print("#{cmd}\n")
|
159
|
+
end
|
160
|
+
if not system(cmd)
|
161
|
+
throw "size: failed to execute 'convert', is ImageMagick installed?"
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
return "#{dirname}/#{file}"
|
168
|
+
end
|
122
169
|
end
|
123
170
|
end
|
124
171
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-responsive-magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lawrence Murray
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Jekyll plugin for responsive images. Adds filters for setting the srcset,
|
14
14
|
width and height attributes of HTML img elements, while automatically generating
|
@@ -45,8 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
requirements: []
|
48
|
-
|
49
|
-
rubygems_version: 2.7.6.3
|
48
|
+
rubygems_version: 3.3.5
|
50
49
|
signing_key:
|
51
50
|
specification_version: 4
|
52
51
|
summary: A Jekyll plugin for responsive images using ImageMagick. Works with Jekyll
|