jekyll-retinamagick 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c195ec71f9951af6c5fd2bfc52672e9ea1bf3b09
4
+ data.tar.gz: e745e5eed89f110adcfa08d98ac532cefc438524
5
+ SHA512:
6
+ metadata.gz: 21d6248575763aa0e8045c740a4c599f5e782ffd4c56ce5f720dd4e3503430d4fe1835587b933c9af8050031b87ad2143c43de425680e42ed322d7af8b51aa41
7
+ data.tar.gz: cd17747e21ea985a76cf5d1f04983705d1b162071ad1187c080981c4668967274f47fd3440fed8197c1b6a07be05a8203051346fcb72d9b2071c08f50e7144aa
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in jekyll-retinamagick.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,46 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jekyll-retinamagick (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
+ colorator (0.1)
14
+ commander (4.1.5)
15
+ highline (~> 1.6.11)
16
+ directory_watcher (1.4.1)
17
+ fast-stemmer (1.0.2)
18
+ highline (1.6.19)
19
+ jekyll (1.2.1)
20
+ classifier (~> 1.3)
21
+ colorator (~> 0.1)
22
+ commander (~> 4.1.3)
23
+ directory_watcher (~> 1.4.1)
24
+ liquid (~> 2.5.2)
25
+ maruku (~> 0.5)
26
+ pygments.rb (~> 0.5.0)
27
+ redcarpet (~> 2.3.0)
28
+ safe_yaml (~> 0.7.0)
29
+ liquid (2.5.2)
30
+ maruku (0.7.0)
31
+ mini_magick (3.6.0)
32
+ subexec (~> 0.2.1)
33
+ posix-spawn (0.3.6)
34
+ pygments.rb (0.5.2)
35
+ posix-spawn (~> 0.3.6)
36
+ yajl-ruby (~> 1.1.0)
37
+ redcarpet (2.3.0)
38
+ safe_yaml (0.7.1)
39
+ subexec (0.2.3)
40
+ yajl-ruby (1.1.0)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ jekyll-retinamagick!
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "jekyll-retinamagick/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "jekyll-retinamagick"
7
+ s.version = Jekyll::Retinamagick::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Brendan Tobolaski"]
10
+ s.email = ["brendan@tobolaski.com"]
11
+ s.homepage = "http://github.com/btobolaski/jekyll-retinamagick"
12
+ s.summary = %q{MiniMagick integration, including retina support, for Jekyll}
13
+ s.description = %q{Use MiniMagick to create the image sizes that you need. A fork of jekyll-minimagick.}
14
+
15
+ s.rubyforge_project = "jekyll-retinamagick"
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,5 @@
1
+ module Jekyll
2
+ module Retinamagick
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,84 @@
1
+ require 'mini_magick'
2
+
3
+ module Jekyll
4
+ module JekyllRetinamagick
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.resize arg
49
+ @size = arg
50
+ end
51
+ image.write dest_path
52
+
53
+ width, height = @size.match(/([0-9]+)x([0-9]+)/i).captures
54
+ retinaSize = "#{Integer(width) * 2}x#{Integer(height) * 2}"
55
+ filepath, extension = dest_path.match(/(.+)(\.[a-zA-Z]{3,4})/i).captures
56
+ dest_path = "#{filepath}@2x#{extension}"
57
+ retinaImage = ::MiniMagick::Image.open(path)
58
+ retinaImage.resize retinaSize
59
+ retinaImage.write dest_path
60
+
61
+ true
62
+ end
63
+
64
+ end
65
+
66
+ class MiniMagickGenerator < Generator
67
+ safe true
68
+
69
+ # Find all image files in the source directories of the presets specified
70
+ # in the site config. Add a GeneratedImageFile to the static_files stack
71
+ # for later processing.
72
+ def generate(site)
73
+ return unless site.config['retinamagick']
74
+
75
+ site.config['retinamagick'].each_pair do |name, preset|
76
+ Dir.glob(File.join(site.source, preset['source'], "*.{png,jpg,jpeg,gif}")) do |source|
77
+ site.static_files << GeneratedImageFile.new(site, site.source, preset['destination'], File.basename(source), preset.clone)
78
+ end
79
+ end
80
+ end
81
+ end
82
+
83
+ end
84
+ end
data/readme.md ADDED
@@ -0,0 +1,63 @@
1
+ # Automatic Image Resizing for Jekyll #
2
+
3
+ This gem allows you to easily use MiniMagick to resize your images and
4
+ automatically includes an @2x version for use with [retina.js][1]. This is a
5
+ forked version of [jekyll-minimagick][2] modified specifically to add the
6
+ generation of @2x versions of all of the image sizes. This is very much still a
7
+ work in progress. If you would like to help out, make a fork and then submit a
8
+ pull request.
9
+
10
+ Basic Setup
11
+ -----------
12
+
13
+ ### Requirements ###
14
+
15
+ You have to have imagemagick install on your machine. If you are using a mac
16
+ and use homebrew, you can install imagemagick by runing `brew install imagemagick`.
17
+
18
+ ### Installation ###
19
+
20
+ Install the gem:
21
+
22
+ [sudo] gem install jekyll-retinamagick
23
+
24
+ In a plugin file within your Jekyll project's _plugins directory:
25
+
26
+ # _plugins/my-plugin.rb
27
+ require "jekyll-retinamagick"
28
+
29
+ Define presets in your _config.yml file, like this:
30
+
31
+ # _config.yml
32
+ retinamagick:
33
+ thumbnail:
34
+ source: img/photos/original
35
+ destination: img/photos/thumbnail
36
+ resize: "100x100"
37
+ medium:
38
+ source: img/photos/original
39
+ destination: img/photos/medium
40
+ resize: "600x400"
41
+
42
+ This configuration will create a 100x100 thumbnail for each image in
43
+ `img/photos/original` and put it in `\_site/img/photos/thumbnail`. It will also
44
+ generate a 200x200 thumbnail and add an `@2x` between the file name and the
45
+ extention. It will also generate a 600x400 and 1200x800 image in a similar way
46
+ and then place them in `_site/img/photos/medium`.
47
+
48
+ Bundler Setup
49
+ -------------
50
+ Already using bundler to manage gems for your Jekyll project? Then just add
51
+
52
+ gem "jekyll-retinamagick"
53
+
54
+ to your gemfile and create the following plugin in your projects _plugins
55
+ directory. I've called mine bundler.rb.
56
+
57
+ # _plugins/bundler.rb
58
+ require "rubygems"
59
+ require "bundler/setup"
60
+ require "jekyll-imagemagick"
61
+
62
+ [1]:http://retinajs.com
63
+ [2]:https://github.com/zroger/jekyll-minimagick
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-retinamagick
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Brendan Tobolaski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-02 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.10.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.10.0
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: '3.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '3.3'
41
+ description: Use MiniMagick to create the image sizes that you need. A fork of jekyll-minimagick.
42
+ email:
43
+ - brendan@tobolaski.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - Rakefile
52
+ - jekyll-retinamagick.gemspec
53
+ - lib/jekyll-retinamagick.rb
54
+ - lib/jekyll-retinamagick/version.rb
55
+ - readme.md
56
+ homepage: http://github.com/btobolaski/jekyll-retinamagick
57
+ licenses: []
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project: jekyll-retinamagick
75
+ rubygems_version: 2.0.3
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: MiniMagick integration, including retina support, for Jekyll
79
+ test_files: []