riiif 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/app/controllers/riiif/images_controller.rb +16 -0
- data/lib/riiif/version.rb +1 -1
- data/spec/controllers/riiif/images_controller_spec.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8772e4a904c4e4a561352a0e1a449da790347522
|
4
|
+
data.tar.gz: adffd5861fe1daa395c5d012936208a623b2829c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0498ffb73c9552a33819a7131ddfe0089525f95b273cd4eba70d8412ce1eb6598b4b8c9aee011b8cb43bb001f47ffeafc24b6a2ce3ae9a02e0a6190c338d0ff
|
7
|
+
data.tar.gz: 20150a2e02553cbff87f5cacc20868245ff12418763f9c046625ec45df6bf0503e119447e7ad493903bf673b88c0939adf19710463a0ee6471a72b6618beacf4
|
data/README.md
CHANGED
@@ -157,7 +157,12 @@ end
|
|
157
157
|
|
158
158
|
Riiif::Engine.config.cache_duration_in_days = 30
|
159
159
|
```
|
160
|
-
|
160
|
+
#### Special note for Passenger and Apache users
|
161
|
+
If you are running riiif in Passenger under Apache, you must set `AllowEncodedSlashes NoDecode` in your virtual host definition. For some uses, even with that directive set, the above configuration won't work for you. You may need to explicitly decode the url, like this:
|
162
|
+
```ruby
|
163
|
+
require "uri"
|
164
|
+
fs_id = URI.decode(id).sub(/\A([^\/]*)\/.*/, '\1')
|
165
|
+
```
|
161
166
|
|
162
167
|
## Running the tests
|
163
168
|
First, build the engine
|
@@ -22,6 +22,8 @@ module Riiif
|
|
22
22
|
|
23
23
|
data = image.render(image_request_params)
|
24
24
|
headers['Access-Control-Allow-Origin'] = '*'
|
25
|
+
# Set a Cache-Control header
|
26
|
+
expires_in cache_expires, public: false if status == :ok
|
25
27
|
send_data data,
|
26
28
|
status: status,
|
27
29
|
type: Mime::Type.lookup_by_extension(params[:format]),
|
@@ -32,6 +34,8 @@ module Riiif
|
|
32
34
|
image = model.new(image_id)
|
33
35
|
if authorization_service.can?(:info, image)
|
34
36
|
headers['Access-Control-Allow-Origin'] = '*'
|
37
|
+
# Set a Cache-Control header
|
38
|
+
expires_in cache_expires, public: false
|
35
39
|
render json: image.info.to_h.merge(server_info), content_type: 'application/ld+json'
|
36
40
|
else
|
37
41
|
render json: { error: 'unauthorized' }, status: :unauthorized
|
@@ -48,6 +52,18 @@ module Riiif
|
|
48
52
|
|
49
53
|
LEVEL1 = 'http://iiif.io/api/image/2/level1.json'.freeze
|
50
54
|
|
55
|
+
# @return seconds before the request expires. Defaults to 1 year.
|
56
|
+
def cache_expires
|
57
|
+
1.year
|
58
|
+
end
|
59
|
+
|
60
|
+
# Should the Cache-Control header be public? Override this if you want to have a
|
61
|
+
# public Cache-Control set.
|
62
|
+
# @return FalseClass
|
63
|
+
def public_cache?
|
64
|
+
false
|
65
|
+
end
|
66
|
+
|
51
67
|
def model
|
52
68
|
params.fetch(:model, 'riiif/image').camelize.constantize
|
53
69
|
end
|
data/lib/riiif/version.rb
CHANGED
@@ -18,6 +18,7 @@ describe Riiif::ImagesController do
|
|
18
18
|
expect(response.body).to eq 'IMAGEDATA'
|
19
19
|
expect(response.headers['Link']).to eq '<http://iiif.io/api/image/2/level1.json>;rel="profile"'
|
20
20
|
expect(response.headers['Access-Control-Allow-Origin']).to eq '*'
|
21
|
+
expect(response.headers['Cache-Control']).to eq 'max-age=31557600, private'
|
21
22
|
end
|
22
23
|
|
23
24
|
context 'with an unauthorized image' do
|
@@ -115,6 +116,7 @@ describe Riiif::ImagesController do
|
|
115
116
|
expect(response.headers['Link']).to eq '<http://iiif.io/api/image/2/level1.json>;rel="profile"'
|
116
117
|
expect(response.headers['Content-Type']).to eq 'application/ld+json; charset=utf-8'
|
117
118
|
expect(response.headers['Access-Control-Allow-Origin']).to eq '*'
|
119
|
+
expect(response.headers['Cache-Control']).to eq 'max-age=31557600, private'
|
118
120
|
end
|
119
121
|
|
120
122
|
context 'with an unauthorized image' 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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
202
|
version: '0'
|
203
203
|
requirements: []
|
204
204
|
rubyforge_project:
|
205
|
-
rubygems_version: 2.6.
|
205
|
+
rubygems_version: 2.6.10
|
206
206
|
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: A rails engine that support IIIF requests
|