jekyll-thumbnail 0.pre.36
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +4 -0
- data/.travis.yml +8 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +21 -0
- data/Rakefile +10 -0
- data/docs/README.md +48 -0
- data/docs/_config.yml +1 -0
- data/img/sample_rectangle.jpg +0 -0
- data/img/sample_square.jpg +0 -0
- data/img/watermark-50x50.png +0 -0
- data/jekyll-thumbnail.gemspec +28 -0
- data/lib/jekyll-thumbnail/version.rb +5 -0
- data/lib/jekyll-thumbnail.rb +77 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 84b85105511dcdb6575f7db0acd8470e407cb5965c3f144b02ab6af9fdc72a2d
|
4
|
+
data.tar.gz: '096662500fe25edd418b542a96ced02ef141a628fc721a8bdfcf5dda37683345'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7b08a9e6747ffc5e777052fc5a953f6fd86aa2c79fbbf9576857e64a23bbe7cc50bafbc9b390190c3e78039433697a03c072e4e0e54d99dbeeb7630bbe1c1510
|
7
|
+
data.tar.gz: fbda567d8787b3b71baaa98747e569c94e249283c5dbcd4d560c32af74b41202dcc8d2a2d101563b6da15bbc4f36eec58562179f4393869721ea58dc876dca97
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Dommmel
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
data/docs/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Jekyll Thumbnail
|
2
|
+
[![Build Status](https://travis-ci.org/superterran/jekyll-thumbnail.svg?branch=master)](https://travis-ci.org/superterran/jekyll-thumbnail)
|
3
|
+
[![Coverage Status](https://coveralls.io/repos/github/superterran/jekyll-thumbnail/badge.svg?branch=master)](https://coveralls.io/github/superterran/jekyll-thumbnail?branch=master)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/jekyll-thumbnail.svg)](https://badge.fury.io/rb/jekyll-thumbnail)
|
5
|
+
|
6
|
+
Adds a liquid tag that can generate thumbnails, with watermarks, at any size you dictate.
|
7
|
+
|
8
|
+
# Usage
|
9
|
+
|
10
|
+
Require the ruby gem in your Gemfile...
|
11
|
+
|
12
|
+
```
|
13
|
+
gem 'jekyll-thumbnail'
|
14
|
+
```
|
15
|
+
|
16
|
+
Then, use it in your Liquid templates as follows:
|
17
|
+
|
18
|
+
```
|
19
|
+
{{ "{% thumbnail path/to/image.jpg 50x50 " }}%}
|
20
|
+
```
|
21
|
+
This will pass the image through the thumbnailer, and generate a thumbs/ directory where the image is located.
|
22
|
+
|
23
|
+
# Thumbs directory
|
24
|
+
|
25
|
+
Images that already exist are not re-generated, so you can save yourself some work by caching these files.
|
26
|
+
|
27
|
+
# Unit Tests
|
28
|
+
|
29
|
+
Running Rake will work through all the minitest tests for this feature...
|
30
|
+
|
31
|
+
```
|
32
|
+
$ rake
|
33
|
+
```
|
34
|
+
|
35
|
+
# Installation
|
36
|
+
|
37
|
+
Inside your gemfile...
|
38
|
+
|
39
|
+
```
|
40
|
+
gem "jekyll-thumbnail"
|
41
|
+
```
|
42
|
+
|
43
|
+
# Building and Releasing
|
44
|
+
|
45
|
+
```
|
46
|
+
$ gem build jekyll-thumbnail.gemspec
|
47
|
+
$ gem push jekyll-thumbnail-0.1.18.gem
|
48
|
+
```
|
data/docs/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
theme: jekyll-theme-tactile
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "jekyll-thumbnail/version"
|
5
|
+
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "jekyll-thumbnail"
|
9
|
+
spec.version = ENV['TRAVIS_TAG'] || Jekyll::Thumbnail::VERSION
|
10
|
+
spec.version = "#{spec.version}-#{ENV['TRAVIS_BUILD_NUMBER']}" if ENV['TRAVIS']
|
11
|
+
spec.authors = ["Doug Hatcher"]
|
12
|
+
spec.email = ["superterran@gmail.com"]
|
13
|
+
|
14
|
+
spec.summary = "Provides an image thumbnailer with watermark support.
|
15
|
+
Adds a liquid tag `thumbnail` with a parmeter to set a resolution.
|
16
|
+
Can also overlay PNGs overtop for watermarking."
|
17
|
+
|
18
|
+
spec.homepage = "https://superterran.github.io/jekyll-thumbnail/"
|
19
|
+
spec.license = "MIT"
|
20
|
+
|
21
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_dependency 'jekyll'
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# Generates a thumbnail to an image and renders an image tag.
|
2
|
+
|
3
|
+
require "jekyll"
|
4
|
+
require "mini_magick"
|
5
|
+
require "jekyll-thumbnail/version"
|
6
|
+
|
7
|
+
class JekyllThumbnail < Liquid::Tag
|
8
|
+
# look up liquid variables
|
9
|
+
# source: http://stackoverflow.com/a/8771374/1489823
|
10
|
+
def look_up(context, name)
|
11
|
+
lookup = context
|
12
|
+
|
13
|
+
name.split(".").each do |value|
|
14
|
+
lookup = lookup[value]
|
15
|
+
end
|
16
|
+
|
17
|
+
lookup
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(tag_name, markup, tokens)
|
21
|
+
if /(?<source>[^\s]+)\s+(?<dimensions>[^\s]+)/i =~ markup
|
22
|
+
@source = source
|
23
|
+
@dimensions = dimensions
|
24
|
+
end
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
def render(context)
|
29
|
+
if @source
|
30
|
+
|
31
|
+
# parking
|
32
|
+
# also put the parameters into the liquid parser again, to allow variable paths
|
33
|
+
source = @source
|
34
|
+
source = look_up context, source unless File.readable?(source)
|
35
|
+
dimensions = @dimensions
|
36
|
+
|
37
|
+
source_path = "#{source}"
|
38
|
+
raise "#{source_path} is not readable" unless File.readable?(source_path)
|
39
|
+
ext = File.extname(source)
|
40
|
+
desc = dimensions.gsub(/[^\da-z]+/i, '')
|
41
|
+
dest_dir = "#{File.dirname(source)}/thumbs"
|
42
|
+
Dir.mkdir dest_dir unless Dir.exists? dest_dir
|
43
|
+
dest = "#{dest_dir}/#{File.basename(source, ext)}_#{desc}#{ext}"
|
44
|
+
dest_path = "#{dest}"
|
45
|
+
|
46
|
+
# only thumbnail the image if it doesn't exist tor is less recent than the source file
|
47
|
+
# will prevent re-processing thumbnails for a ton of images...
|
48
|
+
if !File.exists?(dest_path) || File.mtime(dest_path) <= File.mtime(source_path)
|
49
|
+
# puts ENV.inspect
|
50
|
+
|
51
|
+
puts "Thumbnailing #{source} to #{dest} (#{dimensions})"
|
52
|
+
|
53
|
+
image = MiniMagick::Image.open(source_path)
|
54
|
+
image.strip
|
55
|
+
image.resize dimensions
|
56
|
+
image.quality 60
|
57
|
+
|
58
|
+
second_image = MiniMagick::Image.new("img/watermark-#{dimensions}.png")
|
59
|
+
|
60
|
+
result = image.composite(second_image) do |c|
|
61
|
+
c.compose "Over" # OverCompositeOp
|
62
|
+
c.geometry "+20+20" # copy second_image onto first_image from (20, 20)
|
63
|
+
end
|
64
|
+
|
65
|
+
result.write dest_path
|
66
|
+
end
|
67
|
+
|
68
|
+
"""<img src='#{dest}' />"""
|
69
|
+
|
70
|
+
# TODO support relative paths
|
71
|
+
else
|
72
|
+
"Could not create thumbnail for #{source}. Usage: thumbnail /path/to/local/image.png 50x50"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
Liquid::Template.register_tag('thumbnail', JekyllThumbnail)
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-thumbnail
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.pre.36
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Doug Hatcher
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-11-25 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: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- superterran@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- Rakefile
|
67
|
+
- docs/README.md
|
68
|
+
- docs/_config.yml
|
69
|
+
- img/sample_rectangle.jpg
|
70
|
+
- img/sample_square.jpg
|
71
|
+
- img/watermark-50x50.png
|
72
|
+
- jekyll-thumbnail.gemspec
|
73
|
+
- lib/jekyll-thumbnail.rb
|
74
|
+
- lib/jekyll-thumbnail/version.rb
|
75
|
+
homepage: https://superterran.github.io/jekyll-thumbnail/
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 1.3.1
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.7.8
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Provides an image thumbnailer with watermark support. Adds a liquid tag
|
99
|
+
`thumbnail` with a parmeter to set a resolution. Can also overlay PNGs overtop
|
100
|
+
for watermarking.
|
101
|
+
test_files: []
|