iiif_manifest 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7ea1cecc789123d7b703170f21175f9c1ba0bffb42b304b6f2a6aa60915fa87
4
- data.tar.gz: ebfd7b8387200042de0803680797421573e00b6fba6d48c8d30e57ad34b43ca7
3
+ metadata.gz: 236503bcbcb70254e25c524e682f169846b84eabeb745db6a00593a15f089e43
4
+ data.tar.gz: e6da2480b7a053c401a5341f8cb2593650ed823d2d6ef62c87ac0dfa32311952
5
5
  SHA512:
6
- metadata.gz: 3fc57f1933acddeed084c7b70931e425c815f0268fb83b23a38a921b248ca38e6a2f614c02251a9207da1a7ecbbaa8f50febe66c8994718798ad227ced072ba0
7
- data.tar.gz: c7068077352a0ee38a3b43aef1d3317e118cb57796c01953e143d1f8395d890847cf830804f292ff7daef1aa5ffcdb969d0c318f4d6dc5e4628a6f8c4fd04642
6
+ metadata.gz: c2b99506970dad5d2387f0e41bc19a2ce085af1bebc52ca6c253ad224f7bc04fac4768acb81f7a8eacce0bd05193a24f4a335a72c0bfc8c53b8ed4c541de5b13
7
+ data.tar.gz: 8fe3a36661279c93ded0afcfc05b29386de997aa256979441ad74606e8e0a64644c9e121f2fbccdcd40a491a0e39077862a0389e6d9886f860136c811f260028
data/.circleci/config.yml CHANGED
@@ -49,12 +49,6 @@ workflows:
49
49
  - test:
50
50
  name: "ruby2-7"
51
51
  ruby_version: "2.7.7"
52
- - test:
53
- name: "ruby2-6"
54
- ruby_version: "2.6.10"
55
- - test:
56
- name: "ruby2-5"
57
- ruby_version: "2.5.9"
58
52
 
59
53
  nightly:
60
54
  triggers:
@@ -80,9 +74,3 @@ workflows:
80
74
  - test:
81
75
  name: "ruby2-7"
82
76
  ruby_version: "2.7.7"
83
- - test:
84
- name: "ruby2-6"
85
- ruby_version: "2.6.10"
86
- - test:
87
- name: "ruby2-5"
88
- ruby_version: "2.5.9"
data/README.md CHANGED
@@ -36,7 +36,7 @@ Additionally it **_may_** implement `#service` to contain an array of hashes for
36
36
 
37
37
  Additionally it **_may_** implement `#sequence_rendering` to contain an array of hashes for file downloads to be offered at sequences level. Each hash must contain "@id", "format" (mime type) and "label" (eg. `{ "@id" => "download url", "format" => "application/pdf", "label" => "user friendly label" }`).
38
38
 
39
- Finally, it **_may_** implement `ranges`, which returns an array of objects which represent a table of contents or similar structure, each of which responds to `label`, `ranges`, and `file_set_presenters`.
39
+ Finally, it **_may_** implement `ranges`, which returns an array of objects which represent a table of contents or similar structure, each of which responds to `label`, `ranges`, and `file_set_presenters`. `IIIFManifest::ManifestRange` is provided for this purpose; any object with those three methods will also work.
40
40
 
41
41
  For example:
42
42
 
@@ -94,10 +94,10 @@ For example:
94
94
 
95
95
  def ranges
96
96
  [
97
- ManifestRange.new(
97
+ IIIFManifest::ManifestRange.new(
98
98
  label: "Table of Contents",
99
99
  ranges: [
100
- ManifestRange.new(
100
+ IIIFManifest::ManifestRange.new(
101
101
  label: "Chapter 1",
102
102
  file_set_presenters: @pages
103
103
  )
@@ -106,15 +106,6 @@ For example:
106
106
  ]
107
107
  end
108
108
  end
109
-
110
- class ManifestRange
111
- attr_reader :label, :ranges, :file_set_presenters
112
- def initialize(label:, ranges: [], file_set_presenters: [])
113
- @label = label
114
- @ranges = ranges
115
- @file_set_presenters = file_set_presenters
116
- end
117
- end
118
109
  ```
119
110
 
120
111
  The class that represents the leaf nodes, must implement `#id`. It must also implement `#display_image` which returns an instance of `IIIFManifest::DisplayImage`
@@ -225,7 +216,8 @@ The presentation 3.0 support has been contained to the `V3` namespace. Version 2
225
216
  - `#part_of` is supported at leaf node level, to present an array of parent resources available at each leaf node.
226
217
  - `#homepage` is supported at leaf node level, to present an array of homepage resources available at each leaf node.
227
218
  - `#placeholder_content` which returns an instance of `IIIFManifest::V3::DisplayContent` presents a [`placeholderCanvas`](https://iiif.io/api/presentation/3.0/#placeholdercanvas) at leaf node level
228
- - DisplayContent may provide `#auth_service` which should return a hash containing a IIIF Authentication service definition (<https://iiif.io/api/auth/1.0/>) that will be included on the content resource.
219
+ - DisplayContent may provide `#auth_service` which should return a hash containing a IIIF Authentication 1.0 service definition (<https://iiif.io/api/auth/1.0/>) that will be included on the content resource.
220
+ - DisplayContent may provide `#auth2_service` which should return a hash containing a IIIF Authentication 2.0 service definition (<https://iiif.io/api/auth/2.0/>) that will be included on the content resource.
229
221
 
230
222
  ## Configuration
231
223
 
@@ -35,6 +35,21 @@ module IIIFManifest
35
35
  def apply_record_properties
36
36
  canvas['@id'] = path
37
37
  canvas.label = record.to_s
38
+ canvas['metadata'] = record.item_metadata if valid_item_metadata?
39
+ end
40
+
41
+ # Validate item_metadata is an array of hashes with label and value
42
+ # as required keys for each entry
43
+ #
44
+ # @return [Boolean]
45
+ def valid_item_metadata?
46
+ return false unless record.respond_to?(:item_metadata)
47
+ metadata = record.item_metadata
48
+ metadata.is_a?(Array) && metadata.all? do |metadata_field|
49
+ metadata_field.is_a?(Hash) &&
50
+ metadata_field['label'].present? &&
51
+ metadata_field['value'].present?
52
+ end
38
53
  end
39
54
 
40
55
  def attach_image
@@ -0,0 +1,11 @@
1
+ module IIIFManifest
2
+ class ManifestRange
3
+ attr_reader :label, :ranges, :file_set_presenters
4
+
5
+ def initialize(label:, ranges: [], file_set_presenters: [])
6
+ @label = label
7
+ @ranges = ranges
8
+ @file_set_presenters = file_set_presenters
9
+ end
10
+ end
11
+ end
@@ -2,7 +2,7 @@ module IIIFManifest
2
2
  module V3
3
3
  class DisplayContent
4
4
  attr_reader :url, :width, :height, :duration, :iiif_endpoint, :format, :type,
5
- :label, :auth_service, :thumbnail
5
+ :label, :auth_service, :auth2_service, :thumbnail
6
6
  def initialize(url, type:, **kwargs)
7
7
  @url = url
8
8
  @type = type
@@ -13,6 +13,7 @@ module IIIFManifest
13
13
  @format = kwargs[:format]
14
14
  @iiif_endpoint = kwargs[:iiif_endpoint]
15
15
  @auth_service = kwargs[:auth_service]
16
+ @auth2_service = kwargs[:auth2_service]
16
17
  @thumbnail = kwargs[:thumbnail]
17
18
  end
18
19
  end
@@ -12,7 +12,7 @@ module IIIFManifest
12
12
  def apply(annotation)
13
13
  build_body
14
14
  image_service_builder.apply(body) if iiif_endpoint
15
- apply_auth_service if auth_service
15
+ apply_auth_service if auth_service || auth2_service
16
16
  annotation.body = body
17
17
  end
18
18
 
@@ -63,11 +63,15 @@ module IIIFManifest
63
63
  content.try(:auth_service)
64
64
  end
65
65
 
66
+ def auth2_service
67
+ content.try(:auth2_service)
68
+ end
69
+
66
70
  def apply_auth_service
67
71
  body.service = if body['service'].blank?
68
- [auth_service]
72
+ [auth_service, auth2_service].compact
69
73
  else
70
- body['service'] + [auth_service]
74
+ body['service'] + [auth_service, auth2_service].compact
71
75
  end
72
76
  end
73
77
  end
@@ -100,7 +100,7 @@ module IIIFManifest
100
100
  def apply_thumbnail_to(canvas)
101
101
  if display_image
102
102
  canvas.thumbnail = Array(thumbnail_builder_factory.new(display_image).build)
103
- elsif display_content.try(:first)
103
+ elsif display_content.try(:first) && display_content.first.try(:thumbnail)
104
104
  canvas.thumbnail = Array(thumbnail_builder_factory.new(display_content.first).build)
105
105
  end
106
106
  end
@@ -222,8 +222,7 @@ module IIIFManifest
222
222
 
223
223
  def initial_attributes
224
224
  {
225
- 'type' => 'Choice',
226
- 'choiceHint' => 'user'
225
+ 'type' => 'Choice'
227
226
  }
228
227
  end
229
228
  end
@@ -19,6 +19,7 @@ module IIIFManifest
19
19
  setup_manifest_from_record(manifest, record)
20
20
  # Build the items array
21
21
  canvas_builder.apply(manifest.items)
22
+ apply_auth2_context(manifest) if auth2?(record)
22
23
  apply_thumbnail_to(manifest) unless manifest_thumbnail?
23
24
  manifest
24
25
  end
@@ -100,6 +101,14 @@ module IIIFManifest
100
101
  metadata_field
101
102
  end
102
103
 
104
+ def apply_auth2_context(manifest)
105
+ manifest["@context"] = [
106
+ 'http://www.w3.org/ns/anno.jsonld',
107
+ 'http://iiif.io/api/auth/2/context.json',
108
+ 'http://iiif.io/api/presentation/3/context.json'
109
+ ]
110
+ end
111
+
103
112
  def apply_thumbnail_to(manifest)
104
113
  if manifest.is_a? IIIFManifest::Collection
105
114
  manifest.thumbnail = manifest.items.collect(&:thumbnail).compact
@@ -111,6 +120,12 @@ module IIIFManifest
111
120
  def manifest_thumbnail?
112
121
  ::IIIFManifest.config.manifest_thumbnail == false
113
122
  end
123
+
124
+ def auth2?(record)
125
+ # DisplayContent can be an array, so need to massage things to iterate over everything in all cases
126
+ content = record.file_set_presenters.map { |pres| Array(pres.try(:display_content)).compact }.flatten
127
+ content.any? { |item| item.try(:auth2_service).present? }
128
+ end
114
129
  end
115
130
  end
116
131
  end
@@ -1,3 +1,3 @@
1
1
  module IIIFManifest
2
- VERSION = '1.6.0'.freeze
2
+ VERSION = '1.7.0'.freeze
3
3
  end
data/lib/iiif_manifest.rb CHANGED
@@ -8,6 +8,7 @@ module IIIFManifest
8
8
  autoload :Configuration
9
9
  autoload :ManifestBuilder
10
10
  autoload :ManifestFactory
11
+ autoload :ManifestRange
11
12
  autoload :ManifestServiceLocator
12
13
  autoload :DisplayImage
13
14
  autoload :IIIFCollection
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iiif_manifest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
8
8
  - Trey Pendragon
9
- autorequire:
10
9
  bindir: exe
11
10
  cert_chain: []
12
- date: 2024-07-17 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activesupport
@@ -157,6 +156,7 @@ files:
157
156
  - lib/iiif_manifest/manifest_builder/sequence_builder.rb
158
157
  - lib/iiif_manifest/manifest_builder/structure_builder.rb
159
158
  - lib/iiif_manifest/manifest_factory.rb
159
+ - lib/iiif_manifest/manifest_range.rb
160
160
  - lib/iiif_manifest/manifest_service_locator.rb
161
161
  - lib/iiif_manifest/v3.rb
162
162
  - lib/iiif_manifest/v3/annotation_content.rb
@@ -180,7 +180,6 @@ homepage: https://github.com/samvera/iiif_manifest
180
180
  licenses: []
181
181
  metadata:
182
182
  rubygems_mfa_required: 'true'
183
- post_install_message:
184
183
  rdoc_options: []
185
184
  require_paths:
186
185
  - lib
@@ -195,8 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
194
  - !ruby/object:Gem::Version
196
195
  version: '0'
197
196
  requirements: []
198
- rubygems_version: 3.4.1
199
- signing_key:
197
+ rubygems_version: 3.6.7
200
198
  specification_version: 4
201
199
  summary: Generate IIIF presentation manifests for Hydra::Works
202
200
  test_files: []