utopia-gallery 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +47 -0
- data/README.md +3 -1
- data/Rakefile +5 -0
- data/install-vips.sh +36 -0
- data/lib/utopia/gallery/cache.rb +8 -0
- data/lib/utopia/gallery/container.rb +4 -0
- data/lib/utopia/gallery/process.rb +23 -4
- data/lib/utopia/gallery/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/utopia/gallery/cache_spec.rb +36 -0
- data/utopia-gallery.gemspec +3 -3
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5be9fa59f72e89a487b5f833b02ff4e9358ebd93
|
4
|
+
data.tar.gz: 38dcd9b0c8b778f03cc2ca1fc4dd86e0c738b6ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f58a9a8deeb5bcc0c7083d9e8451ec27601c67654d112122959fa826c8117ff1c876af74eee587cd366139f05af15773d9162b9cba9a32d59edcec215adc842
|
7
|
+
data.tar.gz: 195cd55dd865423a767673784768271a19941a5884aaff4d376b0dc033eda0c5eaa92285f1d0c8d490caf28cb42c09f0228a8e7a83e432c97c3dbb9ad1317695
|
data/.travis.yml
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
language: ruby
|
2
|
+
sudo: false
|
3
|
+
dist: trusty
|
4
|
+
|
5
|
+
addons:
|
6
|
+
apt:
|
7
|
+
packages:
|
8
|
+
- libxml2-dev
|
9
|
+
- gettext
|
10
|
+
- python-dev
|
11
|
+
- liblcms1-dev
|
12
|
+
- libmagickwand-dev
|
13
|
+
- libopenexr-dev
|
14
|
+
- libcfitsio3-dev
|
15
|
+
- gobject-introspection
|
16
|
+
- libgirepository1.0-dev
|
17
|
+
- libgif-dev
|
18
|
+
- libgs-dev
|
19
|
+
- libgsf-1-dev
|
20
|
+
- libmatio-dev
|
21
|
+
- libopenslide-dev
|
22
|
+
- liborc-0.4-dev
|
23
|
+
- libpango1.0-dev
|
24
|
+
- libpoppler-glib-dev
|
25
|
+
- libwebp-dev
|
26
|
+
- libglib2.0-dev
|
27
|
+
|
28
|
+
cache:
|
29
|
+
bundler: true
|
30
|
+
directories:
|
31
|
+
- $HOME/vips
|
32
|
+
|
33
|
+
before_install:
|
34
|
+
- source install-vips.sh
|
35
|
+
|
36
|
+
rvm:
|
37
|
+
- 2.2.4
|
38
|
+
- 2.3.2
|
39
|
+
- 2.4.0
|
40
|
+
- jruby-head
|
41
|
+
- ruby-head
|
42
|
+
- rbx-3.65
|
43
|
+
matrix:
|
44
|
+
allow_failures:
|
45
|
+
- rvm: rbx-3.65
|
46
|
+
- rvm: ruby-head
|
47
|
+
- rvm: jruby-head
|
data/README.md
CHANGED
@@ -51,7 +51,9 @@ Add `_photo.xnode` such as:
|
|
51
51
|
<a href="#{attributes[:src].large}" title="#{attributes[:alt]}">
|
52
52
|
<img src="#{attributes[:src].small}" alt="#{attributes[:alt]}"/>
|
53
53
|
</a>
|
54
|
-
|
54
|
+
<?r if caption = attributes[:alt].caption ?>
|
55
|
+
<figcaption>#{caption}</figcaption>
|
56
|
+
<?r end ?>
|
55
57
|
</figure>
|
56
58
|
```
|
57
59
|
|
data/Rakefile
CHANGED
data/install-vips.sh
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
|
3
|
+
export NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
4
|
+
export VIPS_SITE=http://www.vips.ecs.soton.ac.uk/supported
|
5
|
+
export VIPS_VERSION_MAJOR=8
|
6
|
+
export VIPS_VERSION_MINOR=4
|
7
|
+
export VIPS_VERSION_MICRO=5
|
8
|
+
export VIPS_VERSION=$VIPS_VERSION_MAJOR.$VIPS_VERSION_MINOR
|
9
|
+
export VIPS_VERSION_FULL=$VIPS_VERSION.$VIPS_VERSION_MICRO
|
10
|
+
export PATH=$HOME/vips/bin:$PATH
|
11
|
+
export LD_LIBRARY_PATH=$HOME/vips/lib:$LD_LIBRARY_PATH
|
12
|
+
export PKG_CONFIG_PATH=$HOME/vips/lib/pkgconfig:$PKG_CONFIG_PATH
|
13
|
+
export PYTHONPATH=$HOME/vips/lib/python2.7/site-packages:$PYTHONPATH
|
14
|
+
export GI_TYPELIB_PATH=$HOME/vips/lib/girepository-1.0:$GI_TYPELIB_PATH
|
15
|
+
|
16
|
+
set -e
|
17
|
+
|
18
|
+
# do we already have the correct vips built? early exit if yes
|
19
|
+
# we could check the configure params as well I guess
|
20
|
+
if [ -d "$HOME/vips/bin" ]; then
|
21
|
+
version=$($HOME/vips/bin/vips --version)
|
22
|
+
escaped_version="$VIPS_VERSION_MAJOR\.$VIPS_VERSION_MINOR\.$VIPS_VERSION_MICRO"
|
23
|
+
echo "Need vips-$VIPS_VERSION_FULL"
|
24
|
+
echo "Found $version"
|
25
|
+
if [[ "$version" =~ ^vips-$escaped_version ]]; then
|
26
|
+
echo "Using cached directory"
|
27
|
+
exit 0
|
28
|
+
fi
|
29
|
+
fi
|
30
|
+
|
31
|
+
rm -rf $HOME/vips
|
32
|
+
wget $VIPS_SITE/$VIPS_VERSION/vips-$VIPS_VERSION_FULL.tar.gz
|
33
|
+
tar xf vips-$VIPS_VERSION_FULL.tar.gz
|
34
|
+
cd vips-$VIPS_VERSION_FULL
|
35
|
+
CXXFLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 ./configure --prefix=$HOME/vips $*
|
36
|
+
make && make install
|
data/lib/utopia/gallery/cache.rb
CHANGED
@@ -41,6 +41,14 @@ module Utopia
|
|
41
41
|
@media.path
|
42
42
|
end
|
43
43
|
|
44
|
+
def input_path
|
45
|
+
File.join(@media_root, @media.path)
|
46
|
+
end
|
47
|
+
|
48
|
+
def output_paths
|
49
|
+
@processes.values.collect{|process| output_path_for(process)}
|
50
|
+
end
|
51
|
+
|
44
52
|
def output_path_for(process)
|
45
53
|
File.join(@cache_root, process.relative_path(@media))
|
46
54
|
end
|
@@ -21,6 +21,8 @@
|
|
21
21
|
require 'vips/thumbnail'
|
22
22
|
require 'fileutils'
|
23
23
|
|
24
|
+
require 'utopia/path'
|
25
|
+
|
24
26
|
module Utopia
|
25
27
|
module Gallery
|
26
28
|
class Process
|
@@ -36,8 +38,25 @@ module Utopia
|
|
36
38
|
File.join(File.dirname(source_path), @name.to_s, File.basename(source_path))
|
37
39
|
end
|
38
40
|
|
39
|
-
def
|
40
|
-
|
41
|
+
def self.mtime(path)
|
42
|
+
File.lstat(path).mtime
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.fresh?(input_path, output_path)
|
46
|
+
# We are not fresh if the output path doesn't exist:
|
47
|
+
return false unless File.exist?(output_path)
|
48
|
+
|
49
|
+
# We are not fresh if the input is newere than the output:
|
50
|
+
return false if mtime(input_path) > mtime(output_path)
|
51
|
+
|
52
|
+
# Otherwise, we are so fresh:
|
53
|
+
return true
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.link(input_path, output_path)
|
57
|
+
# Compute a path to input_path, relative to output_path
|
58
|
+
shortest_path = Utopia::Path.shortest_path(input_path, output_path)
|
59
|
+
FileUtils.ln_s(shortest_path, output_path, force: true)
|
41
60
|
end
|
42
61
|
end
|
43
62
|
|
@@ -55,7 +74,7 @@ module Utopia
|
|
55
74
|
media = cache.media
|
56
75
|
media_path = File.join(cache.media_root, media.path)
|
57
76
|
|
58
|
-
return if fresh?(media_path, output_path)
|
77
|
+
return if Process.fresh?(media_path, output_path)
|
59
78
|
|
60
79
|
resizer = locals[:resizer] ||= Vips::Thumbnail::Resizer.new(media_path)
|
61
80
|
|
@@ -64,7 +83,7 @@ module Utopia
|
|
64
83
|
if output_image = resizer.send(@method, @size)
|
65
84
|
output_image.write_to_file output_path, **@options
|
66
85
|
else
|
67
|
-
|
86
|
+
Process.link(media_path, output_path)
|
68
87
|
end
|
69
88
|
end
|
70
89
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -18,13 +18,49 @@ RSpec.describe Utopia::Gallery::Cache do
|
|
18
18
|
let(:container) {Utopia::Gallery::Container.new(pages_root, 'sample_images')}
|
19
19
|
|
20
20
|
subject{container.collect{|media| described_class.new(pages_root, cache_root, '/_gallery', media, processes)}}
|
21
|
+
let(:output_paths) {subject.collect{|cache| cache.output_paths}.flatten}
|
21
22
|
|
22
23
|
it "should generate thumbnails" do
|
24
|
+
expect(subject.count).to be == 4
|
25
|
+
expect(output_paths.count).to be == 8
|
26
|
+
|
23
27
|
subject.each(&:update)
|
28
|
+
|
29
|
+
output_paths.each do |output_path|
|
30
|
+
expect(File).to be_exist(output_path)
|
31
|
+
end
|
24
32
|
end
|
25
33
|
|
26
34
|
it "it should be reentrant" do
|
27
35
|
subject.each(&:update)
|
36
|
+
|
37
|
+
expect{subject.each(&:update)}.to_not raise_error
|
38
|
+
end
|
39
|
+
|
40
|
+
it "can regeneate out of date media" do
|
28
41
|
subject.each(&:update)
|
42
|
+
|
43
|
+
sleep(1)
|
44
|
+
|
45
|
+
subject.each do |cache|
|
46
|
+
# Input path becomes newer than output path:
|
47
|
+
# Exception: If output_path is a hard link to input_path.
|
48
|
+
FileUtils.touch(cache.input_path)
|
49
|
+
|
50
|
+
# It should no longer be fresh:
|
51
|
+
cache.output_paths.each do |output_path|
|
52
|
+
expect(Utopia::Gallery::Process).to_not be_fresh(cache.input_path, output_path)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Regenerate outputs:
|
57
|
+
expect{subject.each(&:update)}.to_not raise_error
|
58
|
+
|
59
|
+
# Everything should be fresh:
|
60
|
+
subject.each do |cache|
|
61
|
+
cache.output_paths.each do |output_path|
|
62
|
+
expect(Utopia::Gallery::Process).to be_fresh(cache.input_path, output_path)
|
63
|
+
end
|
64
|
+
end
|
29
65
|
end
|
30
66
|
end
|
data/utopia-gallery.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.add_dependency "utopia", "~> 2.0"
|
20
20
|
spec.add_dependency "vips-thumbnail"
|
21
21
|
|
22
|
-
spec.add_development_dependency "bundler", "~> 1.
|
23
|
-
spec.add_development_dependency "rake", "~> 10.
|
24
|
-
spec.add_development_dependency "rspec", "~> 3.
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.4"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.5"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.5"
|
25
25
|
end
|
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.2
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: utopia
|
@@ -44,42 +44,42 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.4'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
54
|
+
version: '1.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '10.
|
61
|
+
version: '10.5'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '10.
|
68
|
+
version: '10.5'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.5'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
82
|
+
version: '3.5'
|
83
83
|
description:
|
84
84
|
email:
|
85
85
|
- samuel.williams@oriontransfer.co.nz
|
@@ -89,9 +89,11 @@ extra_rdoc_files: []
|
|
89
89
|
files:
|
90
90
|
- ".gitignore"
|
91
91
|
- ".rspec"
|
92
|
+
- ".travis.yml"
|
92
93
|
- Gemfile
|
93
94
|
- README.md
|
94
95
|
- Rakefile
|
96
|
+
- install-vips.sh
|
95
97
|
- lib/utopia/gallery.rb
|
96
98
|
- lib/utopia/gallery/cache.rb
|
97
99
|
- lib/utopia/gallery/container.rb
|