jekyll-resize 0.0.1
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 +7 -0
- data/lib/jekyll-resize.rb +40 -0
- metadata +72 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 219ce892853ff8b99c579093b9b558dbf5a1305e85b2112dd32526b0aaf28e19
|
4
|
+
data.tar.gz: 3f6c5dd2106708c310ad3b6f5a01093002a1479899740de883e6b753796ba2a2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 75eafa15566f5d51b8c4cb213243a7d565f641a1ff2bb7cb6eb6ac086006649584438ed77227e1421cbb81fc2931c69180944f2fe5ce2417b981754722e44ba9
|
7
|
+
data.tar.gz: 0d8d6bab22980dff1ade89c1f60dbf83a54fc217d46d50d7fd239d846d70c8a124caf79a47230345dc356b4a553ea0eda5163c61e6c30907a895769284161399
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'digest'
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module Resize
|
5
|
+
def resize(source, options)
|
6
|
+
site = @context.registers[:site]
|
7
|
+
|
8
|
+
source_path = site.source + source
|
9
|
+
raise "#{source_[path]} is not readable" unless File.readable?(source_path)
|
10
|
+
|
11
|
+
destination_path = "/cache/resize/"
|
12
|
+
destination = site.source + destination_path
|
13
|
+
|
14
|
+
FileUtils.mkdir_p destination
|
15
|
+
|
16
|
+
ext = File.extname(source)
|
17
|
+
desc = options.gsub(/[^\da-z]+/i, '')
|
18
|
+
|
19
|
+
sha = Digest::SHA256.file source_path
|
20
|
+
|
21
|
+
destination_file_name = "#{sha}_#{desc}#{ext}"
|
22
|
+
destination += destination_file_name
|
23
|
+
|
24
|
+
if !File.exist?(destination) || File.mtime(destination) <= File.mtime(source_path)
|
25
|
+
|
26
|
+
puts "Thumbnailing #{source_path} to #{destination} (#{options})"
|
27
|
+
|
28
|
+
image = MiniMagick::Image.open(source_path)
|
29
|
+
image.strip
|
30
|
+
image.resize options
|
31
|
+
image.write destination
|
32
|
+
site.static_files << Jekyll::StaticFile.new(site, site.source, destination_path, destination_file_name)
|
33
|
+
end
|
34
|
+
|
35
|
+
destination_path + destination_file_name
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
Liquid::Template.register_filter(Jekyll::Resize)
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-resize
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Neumegen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-01-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mini_magick
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.8.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.8.0
|
41
|
+
description: ''
|
42
|
+
email: mike@cloudcannon.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- lib/jekyll-resize.rb
|
48
|
+
homepage: http://rubygems.org/gems/jekyll-resize
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata: {}
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 2.7.4
|
69
|
+
signing_key:
|
70
|
+
specification_version: 4
|
71
|
+
summary: Liquid filter to resize images
|
72
|
+
test_files: []
|