riiif 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/riiif/image.rb +5 -1
- data/app/views/riiif/images/view.html.erb +3 -3
- data/config/routes.rb +2 -2
- data/lib/riiif/file_system_file_resolver.rb +1 -1
- data/lib/riiif/version.rb +1 -1
- data/spec/models/file_system_file_resolver_spec.rb +4 -0
- data/spec/routing/resize_routes_spec.rb +16 -2
- 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: 905d7f9639fc63f7764759b985ea235a4e369645
|
4
|
+
data.tar.gz: e73244b575876cd67008082a497a5cc9d339777f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4e8952000bb0374601d4b6d33e4d5428d721c69f30ef8bf5400e86021a4ce8214e764858401eb74779fe69380f51201ff968a3b678ae879caa7b066e2c7d77c
|
7
|
+
data.tar.gz: 4b46ed4fd0b9d004123b7fd181702a89f25019a9c891b6573b891ca0c6b0c1432a5814963b65d6cc4a25f63df8c84d7be2027d05e71c12efd6cd9db961237652
|
data/app/models/riiif/image.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'digest/md5'
|
1
2
|
module Riiif
|
2
3
|
class Image
|
3
4
|
|
@@ -16,7 +17,10 @@ module Riiif
|
|
16
17
|
|
17
18
|
def render(args)
|
18
19
|
options = decode_options!(args)
|
19
|
-
|
20
|
+
# Use a MD5 digest to ensure the keys aren't too long.
|
21
|
+
digest = Digest::MD5.hexdigest(options.merge(id: id).to_s)
|
22
|
+
puts digest
|
23
|
+
Rails.cache.fetch(digest, compress: true, expires_in: 3.days) do
|
20
24
|
image.extract(options)
|
21
25
|
end
|
22
26
|
end
|
@@ -6,9 +6,9 @@
|
|
6
6
|
prefixUrl: "/assets/openseadragon/",
|
7
7
|
tileSources: [{
|
8
8
|
"image_host": "http://localhost:8080/image-service",
|
9
|
-
"identifier": "
|
10
|
-
"width":
|
11
|
-
"height":
|
9
|
+
"identifier": "<%= @image.id %>",
|
10
|
+
"width": <%= @image.info[:width] %>,
|
11
|
+
"height": <%= @image.info[:height] %>,
|
12
12
|
"scale_factors": [1, 2, 3, 4, 5],
|
13
13
|
"tile_width": 1024,
|
14
14
|
"tile_height": 1024,
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Riiif::Engine.routes.draw do
|
2
2
|
ALLOW_DOTS ||= /[\w.]+/
|
3
|
-
|
3
|
+
SIZES ||= /(pct:)?[\w.,]+/
|
4
4
|
get "/:id/:region/:size/:rotation/:quality(.:format)" => "images#show",
|
5
|
-
constraints: { rotation: ALLOW_DOTS, size:
|
5
|
+
constraints: { rotation: ALLOW_DOTS, size: SIZES}
|
6
6
|
get "/:id/info(.:format)" => "images#info", :constraints => { :format => /json/}
|
7
7
|
get "/:id/view(.:format)" => "images#view"
|
8
8
|
end
|
@@ -12,7 +12,7 @@ module Riiif
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.pattern(id)
|
15
|
-
raise ArgumentException, "Invalid characters in id `#{id}`" unless
|
15
|
+
raise ArgumentException, "Invalid characters in id `#{id}`" unless /^[\w-]+$/.match(id)
|
16
16
|
::File.join(base_path, "#{id}.{#{input_types.join(',')}}")
|
17
17
|
end
|
18
18
|
|
data/lib/riiif/version.rb
CHANGED
@@ -8,4 +8,8 @@ describe Riiif::FileSystemFileResolver do
|
|
8
8
|
it "should get the jpeg2000 file" do
|
9
9
|
expect(subject.find('world')).to eq Riiif::FileSystemFileResolver.root + '/spec/samples/world.jp2'
|
10
10
|
end
|
11
|
+
|
12
|
+
it "should accept ids with dashes" do
|
13
|
+
subject.pattern('foo-bar-baz')
|
14
|
+
end
|
11
15
|
end
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe "routes" do
|
4
4
|
routes { Riiif::Engine.routes }
|
5
5
|
|
6
|
-
describe 'for
|
6
|
+
describe 'for conversion' do
|
7
7
|
it "routes GET /abcd1234/full/full/0/native.jpg" do
|
8
8
|
expect(
|
9
9
|
get: "/abcd1234/full/full/0/native.jpg"
|
@@ -12,13 +12,27 @@ describe "routes" do
|
|
12
12
|
quality: 'native', format: 'jpg')
|
13
13
|
end
|
14
14
|
|
15
|
-
it "routes requests with
|
15
|
+
it "routes requests with floating point percent size" do
|
16
16
|
expect(
|
17
17
|
get: "/abcd1234/full/pct:12.5/22.5/native.jpg"
|
18
18
|
).to route_to(controller: "riiif/images", id: 'abcd1234', action: "show",
|
19
19
|
region: 'full', size: 'pct:12.5', rotation: '22.5',
|
20
20
|
quality: 'native', format: 'jpg')
|
21
21
|
end
|
22
|
+
it "routes requests with pixel size" do
|
23
|
+
expect(
|
24
|
+
get: "/abcd1234/full/100,50/22.5/native.jpg"
|
25
|
+
).to route_to(controller: "riiif/images", id: 'abcd1234', action: "show",
|
26
|
+
region: 'full', size: '100,50', rotation: '22.5',
|
27
|
+
quality: 'native', format: 'jpg')
|
28
|
+
end
|
29
|
+
it "routes requests with dashes in the id" do
|
30
|
+
expect(
|
31
|
+
get: "/abcd-1234-5678/full/full/0/native.jpg"
|
32
|
+
).to route_to(controller: "riiif/images", id: 'abcd-1234-5678', action: "show",
|
33
|
+
region: 'full', size: 'full', rotation: '0',
|
34
|
+
quality: 'native', format: 'jpg')
|
35
|
+
end
|
22
36
|
end
|
23
37
|
|
24
38
|
describe "for info" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riiif
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|