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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be59d18f6377129fef45f1bedfd5a97e0c49838b
4
- data.tar.gz: b7bdecc0a5ad3354ba72864d7550fb9b36e59fc3
3
+ metadata.gz: 8772e4a904c4e4a561352a0e1a449da790347522
4
+ data.tar.gz: adffd5861fe1daa395c5d012936208a623b2829c
5
5
  SHA512:
6
- metadata.gz: b5e12cb928aa79bd9888a881fb9331851506c0b5c61504e13956535405969701ef1c30477b1bd9b103c61d463a135747330491562e241dd9aa75693b47a89cf0
7
- data.tar.gz: 4c13a191e50ea352bb1ef056f0467b2ea56fc767358b748e19f01af8349fbee8d8670fa07e34986ee0e959b4085ef3cba3a9dc76a116b07ce064c8b667766575
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
@@ -1,3 +1,3 @@
1
1
  module Riiif
2
- VERSION = '1.1.3'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
@@ -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.1.3
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-03-16 00:00:00.000000000 Z
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.8
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