middleman-dragonfly_thumbnailer 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +39 -0
- data/Rakefile +1 -0
- data/lib/middleman/dragonfly_thumbnailer.rb +2 -0
- data/lib/middleman/dragonfly_thumbnailer/extension.rb +79 -0
- data/lib/middleman/dragonfly_thumbnailer/version.rb +5 -0
- data/middleman-dragonfly_thumbnailer.gemspec +26 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 99888cd3370da2921862490f89a42b838f11e823
|
4
|
+
data.tar.gz: 299790fcde5c14787cc94285b26f6fcb199fbc3e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e322b5874f8880a307be58ead5ad53c04273d310464f8b3ce07939b6fe3894360ad2f3e034ef5ecc59aff5003ebe1ffebba6db8919303c15f6e499a5ced6cca
|
7
|
+
data.tar.gz: 3527d3b1caf240b43d669f8427573a9d78b1a8589b5b26e8131142b080120aeb591a824a81faba7246b35f77035931f22dc8b75798da78315f9f53eafb3baa1f
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
vendor/bundle/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Andrew
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Middleman Dragonfly Thumbnailer
|
2
|
+
|
3
|
+
Middleman Dragonfly Thumbnailer is a Middleman extension that lets you easily create thumbnails using Dragonfly's fantastic thumb processor.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'middleman-dragonfly_thumbnailer'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install middleman-dragonfly_thumbnailer
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
<%= thumb_tag 'image.png', '100x100#', class: 'thumbnail' %>
|
22
|
+
|
23
|
+
The second argument is a geometry string which specifies the dimensions and options such as aspect ratio and cropping. Have a look at http://markevans.github.io/dragonfly/imagemagick/ for examples of what you can do.
|
24
|
+
|
25
|
+
When running Middleman in development, thumbnails will be generated on the fly and encoded in data URLs.
|
26
|
+
|
27
|
+
During a build, the thumbnails will be saved next to original image in a sub directory named from the geometry string, so the thumbnail for `images/image.png` will be saved as `images/100x100/image.png`.
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it ( https://github.com/scarypine/middleman-dragonfly_thumbnailer/fork )
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create a new Pull Request
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
Copyright (c) 2014 Andrew White. MIT Licensed, see LICENSE.txt for details.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'dragonfly'
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
module DragonflyThumbnailer
|
5
|
+
class Extension < Middleman::Extension
|
6
|
+
attr_accessor :images
|
7
|
+
|
8
|
+
def initialize(app, options_hash = {}, &block)
|
9
|
+
super
|
10
|
+
@images = []
|
11
|
+
configure_dragonfly
|
12
|
+
end
|
13
|
+
|
14
|
+
def absolute_source_path(path)
|
15
|
+
File.join(app.config[:source], app.config[:images_dir], path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def build_path(image)
|
19
|
+
dir = File.dirname(image.meta['original_path'])
|
20
|
+
subdir = image.meta['geometry'].gsub(/[^a-zA-Z0-9\-]/, '')
|
21
|
+
File.join(dir, subdir, image.name)
|
22
|
+
end
|
23
|
+
|
24
|
+
def absolute_build_path(image)
|
25
|
+
File.join(app.config[:build_dir], app.config[:images_dir],
|
26
|
+
build_path(image))
|
27
|
+
end
|
28
|
+
|
29
|
+
def thumb(path, geometry)
|
30
|
+
absolute_path = absolute_source_path path
|
31
|
+
return unless File.exist?(absolute_path)
|
32
|
+
|
33
|
+
image = ::Dragonfly.app.fetch_file(absolute_path)
|
34
|
+
image.meta['original_path'] = path
|
35
|
+
image.meta['geometry'] = geometry
|
36
|
+
image = image.thumb(geometry)
|
37
|
+
images << image
|
38
|
+
image
|
39
|
+
end
|
40
|
+
|
41
|
+
def after_build(builder)
|
42
|
+
images.each do |image|
|
43
|
+
builder.say_status :create, build_path(image)
|
44
|
+
path = absolute_build_path(image)
|
45
|
+
image.to_file(path).close
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
helpers do
|
50
|
+
def thumb_tag(path, geometry, options = {})
|
51
|
+
image = extensions[:dragonfly_thumbnailer].thumb(path, geometry)
|
52
|
+
return unless image
|
53
|
+
|
54
|
+
if environment == :development
|
55
|
+
url = image.b64_data
|
56
|
+
else
|
57
|
+
url = extensions[:dragonfly_thumbnailer].build_path(image)
|
58
|
+
end
|
59
|
+
|
60
|
+
image_tag(url, options)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def configure_dragonfly
|
67
|
+
::Dragonfly.app.configure do
|
68
|
+
datastore :memory
|
69
|
+
plugin :imagemagick
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
::Middleman::Extensions.register(
|
77
|
+
:dragonfly_thumbnailer,
|
78
|
+
Middleman::DragonflyThumbnailer::Extension
|
79
|
+
)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'middleman/dragonfly_thumbnailer/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'middleman-dragonfly_thumbnailer'
|
8
|
+
spec.version = Middleman::DragonflyThumbnailer::VERSION
|
9
|
+
spec.authors = ['Andrew White']
|
10
|
+
spec.email = ['andrew@vohm.com']
|
11
|
+
spec.summary = 'Thumbnail generation with Dragonfly'
|
12
|
+
spec.description = "Middleman Dragonfly Thumbnailer is a Middleman extension that lets you easily create thumbnails using Dragonfly's thumb processor."
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
|
24
|
+
spec.add_runtime_dependency('middleman-core', ['~> 3.2'])
|
25
|
+
spec.add_runtime_dependency('dragonfly', ['>= 1.0.0'])
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-dragonfly_thumbnailer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew White
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: middleman-core
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dragonfly
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.0.0
|
69
|
+
description: Middleman Dragonfly Thumbnailer is a Middleman extension that lets you
|
70
|
+
easily create thumbnails using Dragonfly's thumb processor.
|
71
|
+
email:
|
72
|
+
- andrew@vohm.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- lib/middleman/dragonfly_thumbnailer.rb
|
83
|
+
- lib/middleman/dragonfly_thumbnailer/extension.rb
|
84
|
+
- lib/middleman/dragonfly_thumbnailer/version.rb
|
85
|
+
- middleman-dragonfly_thumbnailer.gemspec
|
86
|
+
homepage: ''
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.2.2
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Thumbnail generation with Dragonfly
|
110
|
+
test_files: []
|