iiif_manifest 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +10 -22
- data/.github_changelog_generator +2 -0
- data/.rubocop.yml +14 -7
- data/.rubocop_todo.yml +38 -83
- data/CHANGELOG.md +118 -0
- data/README.md +40 -29
- data/iiif_manifest.gemspec +2 -4
- data/lib/iiif_manifest/manifest_builder.rb +6 -6
- data/lib/iiif_manifest/manifest_builder/canvas_builder.rb +12 -12
- data/lib/iiif_manifest/manifest_builder/canvas_builder_factory.rb +3 -3
- data/lib/iiif_manifest/manifest_builder/deep_canvas_builder_factory.rb +9 -9
- data/lib/iiif_manifest/manifest_builder/image_builder.rb +9 -9
- data/lib/iiif_manifest/manifest_builder/image_service_builder.rb +3 -3
- data/lib/iiif_manifest/manifest_builder/record_property_builder.rb +35 -35
- data/lib/iiif_manifest/manifest_builder/resource_builder.rb +9 -9
- data/lib/iiif_manifest/manifest_builder/sequence_builder.rb +19 -19
- data/lib/iiif_manifest/manifest_factory.rb +3 -3
- data/lib/iiif_manifest/manifest_service_locator.rb +2 -2
- data/lib/iiif_manifest/v3/manifest_builder.rb +7 -7
- data/lib/iiif_manifest/v3/manifest_builder/body_builder.rb +37 -37
- data/lib/iiif_manifest/v3/manifest_builder/canvas_builder.rb +24 -24
- data/lib/iiif_manifest/v3/manifest_builder/choice_builder.rb +14 -14
- data/lib/iiif_manifest/v3/manifest_builder/content_builder.rb +9 -9
- data/lib/iiif_manifest/v3/manifest_builder/image_service_builder.rb +10 -10
- data/lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb +40 -40
- data/lib/iiif_manifest/v3/manifest_factory.rb +3 -3
- data/lib/iiif_manifest/version.rb +1 -1
- metadata +14 -40
@@ -41,36 +41,36 @@ module IIIFManifest
|
|
41
41
|
|
42
42
|
private
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
def display_image
|
45
|
+
record.display_image if record.respond_to?(:display_image)
|
46
|
+
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
def display_content
|
49
|
+
Array.wrap(record.display_content) if record.respond_to?(:display_content) && record.display_content.present?
|
50
|
+
end
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
def apply_record_properties
|
53
|
+
canvas['id'] = path
|
54
|
+
canvas.label = ManifestBuilder.language_map(record.to_s) if record.to_s.present?
|
55
|
+
annotation_page['id'] = "#{path}/annotation_page/#{annotation_page.index}"
|
56
|
+
canvas.items = [annotation_page]
|
57
|
+
end
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
def annotation_page
|
60
|
+
@annotation_page ||= iiif_annotation_page_factory.new
|
61
|
+
end
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
def attach_image
|
64
|
+
content_builder.new(display_image).apply(canvas)
|
65
|
+
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
end
|
67
|
+
def attach_content
|
68
|
+
if display_content.size == 1
|
69
|
+
content_builder.new(display_content.first).apply(canvas)
|
70
|
+
else
|
71
|
+
choice_builder.new(display_content).apply(canvas)
|
73
72
|
end
|
73
|
+
end
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -23,24 +23,24 @@ module IIIFManifest
|
|
23
23
|
|
24
24
|
private
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
26
|
+
def build_choice
|
27
|
+
display_content.each do |content|
|
28
|
+
content_body = body_builder(content).apply(iiif_annotation_factory.new)
|
29
|
+
choice.items += [content_body]
|
31
30
|
end
|
31
|
+
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
def body_builder(content)
|
34
|
+
body_builder_factory.new(content)
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
def annotation
|
38
|
+
@annotation ||= iiif_annotation_factory.new
|
39
|
+
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
def choice
|
42
|
+
@choice ||= iiif_choice_factory.new
|
43
|
+
end
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -21,17 +21,17 @@ module IIIFManifest
|
|
21
21
|
|
22
22
|
private
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
def build_resource
|
25
|
+
body_builder.apply(annotation)
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
def body_builder
|
29
|
+
body_builder_factory.new(display_content)
|
30
|
+
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
def annotation
|
33
|
+
@annotation ||= iiif_annotation_factory.new
|
34
|
+
end
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
@@ -17,18 +17,18 @@ module IIIFManifest
|
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
20
|
+
def determine_type(context)
|
21
|
+
case context
|
22
|
+
when 'http://iiif.io/api/image/1/context.json'
|
23
|
+
'ImageService1'
|
24
|
+
when 'http://iiif.io/api/image/2/context.json'
|
25
|
+
'ImageService2'
|
27
26
|
end
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
29
|
+
def service
|
30
|
+
@service ||= iiif_service_factory.new
|
31
|
+
end
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -37,63 +37,63 @@ module IIIFManifest
|
|
37
37
|
|
38
38
|
private
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
def canvas_builder
|
41
|
+
canvas_builder_factory.from(record)
|
42
|
+
end
|
43
43
|
|
44
44
|
# rubocop:disable Metrics/CyclomaticComplexity
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
45
|
+
def setup_manifest_from_record(manifest, record)
|
46
|
+
manifest['id'] = record.manifest_url.to_s
|
47
|
+
manifest.label = ManifestBuilder.language_map(record.to_s) if record.to_s.present?
|
48
|
+
manifest.summary = ManifestBuilder.language_map(record.description) if record.try(:description).present?
|
49
|
+
manifest.behavior = viewing_hint if viewing_hint.present?
|
50
|
+
manifest.metadata = metadata_from_record(record)
|
51
|
+
manifest.viewing_direction = viewing_direction if viewing_direction.present?
|
52
|
+
manifest.service = services if search_service.present?
|
53
|
+
manifest.rendering = populate_rendering
|
54
|
+
manifest.homepage = record.homepage if record.try(:homepage).present?
|
55
|
+
end
|
56
56
|
# rubocop:enable Metrics/CyclomaticComplexity
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
58
|
+
def metadata_from_record(record)
|
59
|
+
if valid_v3_metadata?
|
60
|
+
record.manifest_metadata
|
61
|
+
elsif valid_metadata?
|
62
|
+
transform_metadata(record.manifest_metadata)
|
64
63
|
end
|
64
|
+
end
|
65
65
|
|
66
66
|
# Validate manifest_metadata against the IIIF spec format for metadata
|
67
67
|
#
|
68
68
|
# @return [Boolean]
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
def valid_v3_metadata?
|
70
|
+
return false unless record.respond_to?(:manifest_metadata)
|
71
|
+
metadata = record.manifest_metadata
|
72
|
+
valid_v3_metadata_fields?(metadata)
|
73
|
+
end
|
74
74
|
|
75
75
|
# Manifest metadata must be an array containing hashes
|
76
76
|
#
|
77
77
|
# @param metadata [Array<Hash>] a list of metadata with label and value as required keys for each entry
|
78
78
|
# @return [Boolean]
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
79
|
+
def valid_v3_metadata_fields?(metadata)
|
80
|
+
metadata.is_a?(Array) && metadata.all? do |metadata_field|
|
81
|
+
metadata_field.is_a?(Hash) &&
|
82
|
+
ManifestBuilder.valid_language_map?(metadata_field['label']) &&
|
83
|
+
ManifestBuilder.valid_language_map?(metadata_field['value'])
|
85
84
|
end
|
85
|
+
end
|
86
86
|
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
def transform_metadata(metadata)
|
88
|
+
metadata.collect { |field| transform_field(field) }
|
89
|
+
end
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
91
|
+
def transform_field(field)
|
92
|
+
metadata_field = {}
|
93
|
+
metadata_field['label'] = ManifestBuilder.language_map(field['label'])
|
94
|
+
metadata_field['value'] = ManifestBuilder.language_map(field['value'])
|
95
|
+
metadata_field
|
96
|
+
end
|
97
97
|
end
|
98
98
|
end
|
99
99
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iiif_manifest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
- Trey Pendragon
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -31,14 +31,14 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '3.0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '3.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: coveralls
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,16 +71,16 @@ dependencies:
|
|
71
71
|
name: rake
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- - "
|
74
|
+
- - ">="
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 12.3.3
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - "
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
83
|
+
version: 12.3.3
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: rspec
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,34 +109,6 @@ dependencies:
|
|
109
109
|
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
|
-
- !ruby/object:Gem::Dependency
|
113
|
-
name: rubocop
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
115
|
-
requirements:
|
116
|
-
- - ">="
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
version: '0'
|
119
|
-
type: :development
|
120
|
-
prerelease: false
|
121
|
-
version_requirements: !ruby/object:Gem::Requirement
|
122
|
-
requirements:
|
123
|
-
- - ">="
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: rubocop-rspec
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
requirements:
|
130
|
-
- - ">="
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
version: '0'
|
133
|
-
type: :development
|
134
|
-
prerelease: false
|
135
|
-
version_requirements: !ruby/object:Gem::Requirement
|
136
|
-
requirements:
|
137
|
-
- - ">="
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
version: '0'
|
140
112
|
description: IIIF http://iiif.io/ defines an API for presenting related images in
|
141
113
|
a viewer. This transforms Hydra::Works objects into that format usable by players
|
142
114
|
such as http://universalviewer.io/
|
@@ -148,10 +120,12 @@ extra_rdoc_files: []
|
|
148
120
|
files:
|
149
121
|
- ".circleci/config.yml"
|
150
122
|
- ".coveralls.yml"
|
123
|
+
- ".github_changelog_generator"
|
151
124
|
- ".gitignore"
|
152
125
|
- ".rspec"
|
153
126
|
- ".rubocop.yml"
|
154
127
|
- ".rubocop_todo.yml"
|
128
|
+
- CHANGELOG.md
|
155
129
|
- CODE_OF_CONDUCT.md
|
156
130
|
- CODE_OF_CONDUCT.old.md
|
157
131
|
- CONTRIBUTING.md
|
@@ -200,7 +174,7 @@ files:
|
|
200
174
|
homepage: https://github.com/samvera/iiif_manifest
|
201
175
|
licenses: []
|
202
176
|
metadata: {}
|
203
|
-
post_install_message:
|
177
|
+
post_install_message:
|
204
178
|
rdoc_options: []
|
205
179
|
require_paths:
|
206
180
|
- lib
|
@@ -215,8 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
189
|
- !ruby/object:Gem::Version
|
216
190
|
version: '0'
|
217
191
|
requirements: []
|
218
|
-
rubygems_version: 3.
|
219
|
-
signing_key:
|
192
|
+
rubygems_version: 3.2.3
|
193
|
+
signing_key:
|
220
194
|
specification_version: 4
|
221
195
|
summary: Generate IIIF presentation manifests for Hydra::Works
|
222
196
|
test_files: []
|