jekyll-minimagick 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.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +34 -0
- data/Rakefile +2 -0
- data/jekyll-minimagick.gemspec +24 -0
- data/lib/jekyll-minimagick.rb +75 -0
- data/lib/jekyll-minimagick/version.rb +5 -0
- data/readme.md +48 -0
- metadata +100 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jekyll-minimagick (0.0.1)
|
5
|
+
jekyll (>= 0.10.0)
|
6
|
+
mini_magick (>= 3.3)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
classifier (1.3.3)
|
12
|
+
fast-stemmer (>= 1.0.0)
|
13
|
+
directory_watcher (1.4.0)
|
14
|
+
fast-stemmer (1.0.0)
|
15
|
+
jekyll (0.10.0)
|
16
|
+
classifier (>= 1.3.1)
|
17
|
+
directory_watcher (>= 1.1.1)
|
18
|
+
liquid (>= 1.9.0)
|
19
|
+
maruku (>= 0.5.9)
|
20
|
+
liquid (2.2.2)
|
21
|
+
maruku (0.6.0)
|
22
|
+
syntax (>= 1.0.0)
|
23
|
+
mini_magick (3.3)
|
24
|
+
subexec (~> 0.1.0)
|
25
|
+
subexec (0.1.0)
|
26
|
+
syntax (1.0.0)
|
27
|
+
|
28
|
+
PLATFORMS
|
29
|
+
ruby
|
30
|
+
|
31
|
+
DEPENDENCIES
|
32
|
+
jekyll (>= 0.10.0)
|
33
|
+
jekyll-minimagick!
|
34
|
+
mini_magick (>= 3.3)
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "jekyll-minimagick/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "jekyll-minimagick"
|
7
|
+
s.version = Jekyll::Minimagick::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Roger López"]
|
10
|
+
s.email = ["roger@zroger.com"]
|
11
|
+
s.homepage = "http://github.com/zroger/jekyll-minimagick"
|
12
|
+
s.summary = %q{MiniMagick integration for Jekyll}
|
13
|
+
s.description = %q{Use MiniMagick to crop and resize images in your Jekyll project.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "jekyll-minimagick"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_runtime_dependency('jekyll', [">= 0.10.0"])
|
23
|
+
s.add_runtime_dependency('mini_magick', [">= 3.3"])
|
24
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'mini_magick'
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module JekyllMinimagick
|
5
|
+
|
6
|
+
class GeneratedImageFile < Jekyll::StaticFile
|
7
|
+
# Initialize a new GeneratedImage.
|
8
|
+
# +site+ is the Site
|
9
|
+
# +base+ is the String path to the <source>
|
10
|
+
# +dir+ is the String path between <source> and the file
|
11
|
+
# +name+ is the String filename of the file
|
12
|
+
# +preset+ is the Preset hash from the config.
|
13
|
+
#
|
14
|
+
# Returns <GeneratedImageFile>
|
15
|
+
def initialize(site, base, dir, name, preset)
|
16
|
+
@site = site
|
17
|
+
@base = base
|
18
|
+
@dir = dir
|
19
|
+
@name = name
|
20
|
+
@dst_dir = preset.delete('destination')
|
21
|
+
@src_dir = preset.delete('source')
|
22
|
+
@commands = preset
|
23
|
+
end
|
24
|
+
|
25
|
+
# Obtains source file path by substituting the preset's source directory
|
26
|
+
# for the destination directory.
|
27
|
+
#
|
28
|
+
# Returns source file path.
|
29
|
+
def path
|
30
|
+
File.join(@base, @dir.sub(@dst_dir, @src_dir), @name)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Use MiniMagick to create a derivative image at the destination
|
34
|
+
# specified (if the original is modified).
|
35
|
+
# +dest+ is the String path to the destination dir
|
36
|
+
#
|
37
|
+
# Returns false if the file was not modified since last time (no-op).
|
38
|
+
def write(dest)
|
39
|
+
dest_path = destination(dest)
|
40
|
+
|
41
|
+
return false if File.exist? dest_path and !modified?
|
42
|
+
|
43
|
+
@@mtimes[path] = mtime
|
44
|
+
|
45
|
+
FileUtils.mkdir_p(File.dirname(dest_path))
|
46
|
+
image = ::MiniMagick::Image.open(path)
|
47
|
+
@commands.each_pair do |command, arg|
|
48
|
+
image.send command, arg
|
49
|
+
end
|
50
|
+
image.write dest_path
|
51
|
+
|
52
|
+
true
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
class MiniMagickGenerator < Generator
|
58
|
+
safe true
|
59
|
+
|
60
|
+
# Find all image files in the source directories of the presets specified
|
61
|
+
# in the site config. Add a GeneratedImageFile to the static_files stack
|
62
|
+
# for later processing.
|
63
|
+
def generate(site)
|
64
|
+
return unless site.config['mini_magick']
|
65
|
+
|
66
|
+
site.config['mini_magick'].each_pair do |name, preset|
|
67
|
+
Dir.glob(File.join(preset['source'], "*.{png,jpg,jpeg,gif}")) do |source|
|
68
|
+
site.static_files << GeneratedImageFile.new(site, site.source, preset['destination'], File.basename(source), preset)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
data/readme.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
MiniMagick integration for Jekyll
|
2
|
+
=================================
|
3
|
+
|
4
|
+
This gem allows you to easily use MiniMagick to crop and resize images in your
|
5
|
+
Jekyll project, according to a preset defined in your config file.
|
6
|
+
|
7
|
+
Basic Setup
|
8
|
+
-----------
|
9
|
+
Install the gem:
|
10
|
+
|
11
|
+
[sudo] gem install jekyll-minimagick
|
12
|
+
|
13
|
+
In a plugin file within your Jekyll project's _plugins directory:
|
14
|
+
|
15
|
+
# _plugins/my-plugin.rb
|
16
|
+
require "jekyll-minimagick"
|
17
|
+
|
18
|
+
Define presets in your _config.yml file, like this:
|
19
|
+
|
20
|
+
# _config.yml
|
21
|
+
mini_magick:
|
22
|
+
thumbnail:
|
23
|
+
source: img/photos/original
|
24
|
+
destination: img/photos/thumbnail
|
25
|
+
resize: "100x100"
|
26
|
+
medium:
|
27
|
+
source: img/photos/original
|
28
|
+
destination: img/photos/medium
|
29
|
+
resize: "600x400"
|
30
|
+
|
31
|
+
This configuration will create a 100x100 thumbnail for each image in
|
32
|
+
_img/photos/original_ and put it in _\_site/img/photos/thumbnail_ and a 600x400
|
33
|
+
image in _\_site/img/photos/medium_.
|
34
|
+
|
35
|
+
Bundler Setup
|
36
|
+
-------------
|
37
|
+
Already using bundler to manage gems for your Jekyll project? Then just add
|
38
|
+
|
39
|
+
gem "jekyll-minimagick"
|
40
|
+
|
41
|
+
to your gemfile and create the following plugin in your projects _plugins
|
42
|
+
directory. I've called mine bundler.rb. This will automatically require all
|
43
|
+
of the gems specified in your Gemfile.
|
44
|
+
|
45
|
+
# _plugins/bundler.rb
|
46
|
+
require "rubygems"
|
47
|
+
require "bundler/setup"
|
48
|
+
Bundler.require(:default)
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-minimagick
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- "Roger L\xC3\xB3pez"
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-07-08 00:00:00 -04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: jekyll
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
- 10
|
31
|
+
- 0
|
32
|
+
version: 0.10.0
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: mini_magick
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 3
|
45
|
+
- 3
|
46
|
+
version: "3.3"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
description: Use MiniMagick to crop and resize images in your Jekyll project.
|
50
|
+
email:
|
51
|
+
- roger@zroger.com
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
58
|
+
files:
|
59
|
+
- .gitignore
|
60
|
+
- Gemfile
|
61
|
+
- Gemfile.lock
|
62
|
+
- Rakefile
|
63
|
+
- jekyll-minimagick.gemspec
|
64
|
+
- lib/jekyll-minimagick.rb
|
65
|
+
- lib/jekyll-minimagick/version.rb
|
66
|
+
- readme.md
|
67
|
+
has_rdoc: true
|
68
|
+
homepage: http://github.com/zroger/jekyll-minimagick
|
69
|
+
licenses: []
|
70
|
+
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
version: "0"
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
version: "0"
|
92
|
+
requirements: []
|
93
|
+
|
94
|
+
rubyforge_project: jekyll-minimagick
|
95
|
+
rubygems_version: 1.3.7
|
96
|
+
signing_key:
|
97
|
+
specification_version: 3
|
98
|
+
summary: MiniMagick integration for Jekyll
|
99
|
+
test_files: []
|
100
|
+
|