jekyll-retinamagick 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c195ec71f9951af6c5fd2bfc52672e9ea1bf3b09
4
- data.tar.gz: e745e5eed89f110adcfa08d98ac532cefc438524
3
+ metadata.gz: 1f059a36c0d5a85e6ea78310cc4d7981cf2a3013
4
+ data.tar.gz: 301979a3cf3257a1cc1132a31a234ff1e4b449da
5
5
  SHA512:
6
- metadata.gz: 21d6248575763aa0e8045c740a4c599f5e782ffd4c56ce5f720dd4e3503430d4fe1835587b933c9af8050031b87ad2143c43de425680e42ed322d7af8b51aa41
7
- data.tar.gz: cd17747e21ea985a76cf5d1f04983705d1b162071ad1187c080981c4668967274f47fd3440fed8197c1b6a07be05a8203051346fcb72d9b2071c08f50e7144aa
6
+ metadata.gz: 15be8a6357ddd63372e12d83599caa02896321b12db0a7a2ecb443a983b009fa1f30dff284851d2103e441fa56aa43c8aa21737bba7918c0d1cd28e8e614c809
7
+ data.tar.gz: 8d164bede5fc3a86400ca20c05f821b8460d83aaaf9d6c1ce4a19d3ea265dea341666e942654384f7f0b8f7ad27049cc2310b3164296dfbf3afffc42b420aa24
@@ -12,7 +12,7 @@ module Jekyll
12
12
  # +preset+ is the Preset hash from the config.
13
13
  #
14
14
  # Returns <GeneratedImageFile>
15
- def initialize(site, base, dir, name, preset)
15
+ def initialize(site, base, dir, name, preset, retina)
16
16
  @site = site
17
17
  @base = base
18
18
  @dir = dir
@@ -20,6 +20,7 @@ module Jekyll
20
20
  @dst_dir = preset.delete('destination')
21
21
  @src_dir = preset.delete('source')
22
22
  @commands = preset
23
+ @retina = retina
23
24
  end
24
25
 
25
26
  # Obtains source file path by substituting the preset's source directory
@@ -37,6 +38,10 @@ module Jekyll
37
38
  # Returns false if the file was not modified since last time (no-op).
38
39
  def write(dest)
39
40
  dest_path = destination(dest)
41
+ if @retina
42
+ filepath, extension = dest_path.match(/(.+)(\.[a-zA-Z]{3,4})/i).captures
43
+ dest_path = "#{filepath}@2x#{extension}"
44
+ end
40
45
 
41
46
  return false if File.exist? dest_path and !modified?
42
47
 
@@ -45,19 +50,14 @@ module Jekyll
45
50
  FileUtils.mkdir_p(File.dirname(dest_path))
46
51
  image = ::MiniMagick::Image.open(path)
47
52
  @commands.each_pair do |command, arg|
53
+ if @retina
54
+ width, height = arg.match(/([0-9]+)x([0-9]+)/i).captures
55
+ arg = "#{Integer(width) * 2}x#{Integer(height) * 2}"
56
+ end
48
57
  image.resize arg
49
- @size = arg
50
58
  end
51
59
  image.write dest_path
52
60
 
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
61
  true
62
62
  end
63
63
 
@@ -74,7 +74,8 @@ module Jekyll
74
74
 
75
75
  site.config['retinamagick'].each_pair do |name, preset|
76
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)
77
+ site.static_files << GeneratedImageFile.new(site, site.source, preset['destination'], File.basename(source), preset.clone, false)
78
+ site.static_files << GeneratedImageFile.new(site, site.source, preset['destination'], File.basename(source), preset.clone, true)
78
79
  end
79
80
  end
80
81
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Retinamagick
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
data/readme.md CHANGED
@@ -40,7 +40,7 @@ Define presets in your _config.yml file, like this:
40
40
  resize: "600x400"
41
41
 
42
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
43
+ `img/photos/original` and put it in `_site/img/photos/thumbnail`. It will also
44
44
  generate a 200x200 thumbnail and add an `@2x` between the file name and the
45
45
  extention. It will also generate a 600x400 and 1200x800 image in a similar way
46
46
  and then place them in `_site/img/photos/medium`.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-retinamagick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brendan Tobolaski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-02 00:00:00.000000000 Z
11
+ date: 2013-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll