utopia-gallery 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/README.md +16 -0
- data/lib/utopia/gallery/cache.rb +8 -0
- data/lib/utopia/gallery/process.rb +4 -0
- data/lib/utopia/gallery/version.rb +1 -1
- data/spec/utopia/gallery/cache_spec.rb +20 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03fb77bfb663311263c588d8b8f8fe3aaaab4aa0
|
4
|
+
data.tar.gz: 502e44584091b100cd4dcda5b11f49001da757b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c991284fd407efa94e5f9013446e6a557837c0612e47656a8647ae39e57e47d42bdf993cd2679f5c7a8e39f399fcae9c0c010df6d440cd4ac2773e195ef00443
|
7
|
+
data.tar.gz: 4f33aa3535e26ad29a208154095766354b36c307927cc86537b4d3eb1b25c20a1776c6c36c0f4079b7566f7a2cf3fc7b351302b1bd131832c670907fdfa86a6b
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -57,6 +57,22 @@ Add `_photo.xnode` such as:
|
|
57
57
|
</figure>
|
58
58
|
```
|
59
59
|
|
60
|
+
Or, if you prefer the `<picture>` element:
|
61
|
+
|
62
|
+
```html
|
63
|
+
<figure class="photo">
|
64
|
+
<a href="#{attributes[:src].large}" title="#{attributes[:alt]}">
|
65
|
+
<picture>
|
66
|
+
<source srcset="#{attributes[:src].small}, #{attributes[:src].medium} 2x"/>
|
67
|
+
<img src="#{attributes[:src].small}" alt="#{attributes[:alt]}"/>
|
68
|
+
</picture>
|
69
|
+
</a>
|
70
|
+
<?r if caption = attributes[:alt].caption ?>
|
71
|
+
<figcaption>#{caption}</figcaption>
|
72
|
+
<?r end ?>
|
73
|
+
</figure>
|
74
|
+
```
|
75
|
+
|
60
76
|
### Adding Captions
|
61
77
|
|
62
78
|
You can add captions and other metadata by adding a `gallery.yaml` file:
|
data/lib/utopia/gallery/cache.rb
CHANGED
@@ -49,6 +49,14 @@ module Utopia
|
|
49
49
|
@processes.values.collect{|process| output_path_for(process)}
|
50
50
|
end
|
51
51
|
|
52
|
+
def outputs
|
53
|
+
return to_enum(:outputs) unless block_given?
|
54
|
+
|
55
|
+
@processes.values do |process|
|
56
|
+
yield process, output_path_for(process)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
52
60
|
def output_path_for(process)
|
53
61
|
File.join(@cache_root, process.relative_path(@media))
|
54
62
|
end
|
@@ -3,7 +3,7 @@ RSpec.describe Utopia::Gallery::Cache do
|
|
3
3
|
let(:pages_root) {File.join(__dir__, 'site/pages')}
|
4
4
|
let(:cache_root) {File.join(__dir__, 'site/public/_gallery')}
|
5
5
|
|
6
|
-
before(:each) do
|
6
|
+
before(:each) do
|
7
7
|
FileUtils.rm_rf cache_root
|
8
8
|
end
|
9
9
|
|
@@ -31,6 +31,25 @@ RSpec.describe Utopia::Gallery::Cache do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
it "should preserve aspect ratio" do
|
35
|
+
subject.each do |cache|
|
36
|
+
cache.update
|
37
|
+
|
38
|
+
input_image = Vips::Image.new_from_file(cache.input_path)
|
39
|
+
input_image.autorot
|
40
|
+
input_aspect_ratio = Rational(input_image.width, input_image.height)
|
41
|
+
|
42
|
+
cache.outputs do |process, output_path|
|
43
|
+
next unless process.method == :resize_to_fit
|
44
|
+
|
45
|
+
output_image = Vips::Image.new_from_file(output_path)
|
46
|
+
output_aspect_ratio = Rational(output_image.width, output_image.height)
|
47
|
+
|
48
|
+
expect(output_aspect_ratio).to be_within(0.01).of(input_aspect_ratio)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
34
53
|
it "it should be reentrant" do
|
35
54
|
subject.each(&:update)
|
36
55
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: utopia-gallery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: utopia
|