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 +4 -4
- data/.circleci/config.yml +0 -12
- data/README.md +5 -13
- data/lib/iiif_manifest/manifest_builder/canvas_builder.rb +15 -0
- data/lib/iiif_manifest/manifest_range.rb +11 -0
- data/lib/iiif_manifest/v3/display_content.rb +2 -1
- data/lib/iiif_manifest/v3/manifest_builder/body_builder.rb +7 -3
- data/lib/iiif_manifest/v3/manifest_builder/canvas_builder.rb +1 -1
- data/lib/iiif_manifest/v3/manifest_builder/iiif_service.rb +1 -2
- data/lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb +15 -0
- data/lib/iiif_manifest/version.rb +1 -1
- data/lib/iiif_manifest.rb +1 -0
- metadata +4 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 236503bcbcb70254e25c524e682f169846b84eabeb745db6a00593a15f089e43
|
|
4
|
+
data.tar.gz: e6da2480b7a053c401a5341f8cb2593650ed823d2d6ef62c87ac0dfa32311952
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
@@ -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
|
|
@@ -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
|
data/lib/iiif_manifest.rb
CHANGED
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.
|
|
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:
|
|
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.
|
|
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: []
|