blacklight-spotlight 0.33.1 → 0.33.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spotlight/crop.es6 +12 -3
- data/app/models/spotlight/resources/iiif_manifest.rb +17 -4
- data/app/services/spotlight/upload_solr_document_builder.rb +1 -1
- data/lib/spotlight/engine.rb +2 -0
- data/lib/spotlight/version.rb +1 -1
- data/spec/fixtures/iiif_responses.rb +14 -2
- data/spec/models/spotlight/resources/iiif_manifest_spec.rb +30 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9929af9368b873e9eb460daed4109a840efbb870
|
4
|
+
data.tar.gz: b29558c9058a0e5632aee6a296072dcca65cadcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 764a628705b402874bd623e4dbccab64d7e6115a4f654c9d733911b3e6fa55982380056661aca11340c861fafc29b237eb107129ca756d3563a389dcea5ee02c
|
7
|
+
data.tar.gz: 4c8de36275779e9702c720fdcbb57801c9e9e9a863229c3fefbcc2f805e9d08ee95613d5d9d6aa5f7c44c6e7bc73708ded9a8156a9a66fbaeaf6f35f6eb7d0f8
|
@@ -30,6 +30,12 @@ export default class Crop {
|
|
30
30
|
this.iiifImageField.val(iiifObject.imageId);
|
31
31
|
}
|
32
32
|
|
33
|
+
emptyIiifFields() {
|
34
|
+
this.iiifManifestField.val('');
|
35
|
+
this.iiifCanvasField.val('');
|
36
|
+
this.iiifImageField.val('');
|
37
|
+
}
|
38
|
+
|
33
39
|
// Set the Crop tileSource and setup the cropper
|
34
40
|
setTileSource(source) {
|
35
41
|
if (source == this.tileSource) {
|
@@ -95,7 +101,9 @@ export default class Crop {
|
|
95
101
|
crs: L.CRS.Simple,
|
96
102
|
zoom: 0
|
97
103
|
});
|
98
|
-
this.iiifLayer = L.tileLayer.iiif(this.tileSource
|
104
|
+
this.iiifLayer = L.tileLayer.iiif(this.tileSource, {
|
105
|
+
tileSize: 512
|
106
|
+
}).addTo(this.iiifCropper);
|
99
107
|
|
100
108
|
this.iiifCropBox = L.areaSelect({
|
101
109
|
width: this.cropArea.data('crop-width') / 2,
|
@@ -155,8 +163,8 @@ export default class Crop {
|
|
155
163
|
self.iiifCropper.panTo(bounds.getCenter());
|
156
164
|
|
157
165
|
self.iiifCropBox.setDimensions({
|
158
|
-
width: Math.abs(x),
|
159
|
-
height: Math.abs(y)
|
166
|
+
width: Math.round(Math.abs(x)),
|
167
|
+
height: Math.round(Math.abs(y))
|
160
168
|
});
|
161
169
|
|
162
170
|
self.existingCropBoxSet = true;
|
@@ -200,6 +208,7 @@ export default class Crop {
|
|
200
208
|
}
|
201
209
|
|
202
210
|
successHandler(data, stat, xhr) {
|
211
|
+
this.emptyIiifFields();
|
203
212
|
this.setTileSource(data.tilesource);
|
204
213
|
}
|
205
214
|
}
|
@@ -63,8 +63,11 @@ module Spotlight
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def add_label
|
66
|
-
return unless
|
67
|
-
|
66
|
+
return unless title_fields.present? && manifest.try(:label)
|
67
|
+
|
68
|
+
Array.wrap(title_fields).each do |field|
|
69
|
+
solr_hash[field] = json_ld_value(manifest.label)
|
70
|
+
end
|
68
71
|
end
|
69
72
|
|
70
73
|
def add_image_urls
|
@@ -87,6 +90,12 @@ module Spotlight
|
|
87
90
|
end
|
88
91
|
end
|
89
92
|
|
93
|
+
def json_ld_value(value)
|
94
|
+
return value['@value'] if value.is_a?(Hash)
|
95
|
+
return value.find { |v| v['@language'] == default_json_ld_language }.try(:[], '@value') if value.is_a?(Array)
|
96
|
+
value
|
97
|
+
end
|
98
|
+
|
90
99
|
def create_sidecars_for(*keys)
|
91
100
|
missing_keys(keys).each do |k|
|
92
101
|
exhibit.custom_fields.create! label: k, readonly_field: true
|
@@ -143,8 +152,12 @@ module Spotlight
|
|
143
152
|
blacklight_config.show.try(:tile_source_field)
|
144
153
|
end
|
145
154
|
|
146
|
-
def
|
147
|
-
blacklight_config.index.try(:title_field)
|
155
|
+
def title_fields
|
156
|
+
Spotlight::Engine.config.iiif_title_fields || blacklight_config.index.try(:title_field)
|
157
|
+
end
|
158
|
+
|
159
|
+
def default_json_ld_language
|
160
|
+
Spotlight::Engine.config.default_json_ld_language
|
148
161
|
end
|
149
162
|
|
150
163
|
def sidecar
|
@@ -26,7 +26,7 @@ module Spotlight
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def add_file_versions(solr_hash)
|
29
|
-
solr_hash[Spotlight::Engine.config.thumbnail_field] = riiif.image_path(resource.upload_id, size: '400,400')
|
29
|
+
solr_hash[Spotlight::Engine.config.thumbnail_field] = riiif.image_path(resource.upload_id, size: '!400,400')
|
30
30
|
end
|
31
31
|
|
32
32
|
def add_sidecar_fields(solr_hash)
|
data/lib/spotlight/engine.rb
CHANGED
@@ -136,6 +136,8 @@ module Spotlight
|
|
136
136
|
config.iiif_manifest_field = :iiif_manifest_url_ssi
|
137
137
|
config.iiif_metadata_class = -> { Spotlight::Resources::IiifManifest::Metadata }
|
138
138
|
config.iiif_collection_id_field = :collection_id_ssim
|
139
|
+
config.iiif_title_fields = nil
|
140
|
+
config.default_json_ld_language = 'en'
|
139
141
|
|
140
142
|
config.masthead_initial_crop_selection = [1200, 120]
|
141
143
|
config.thumbnail_initial_crop_selection = [120, 120]
|
data/lib/spotlight/version.rb
CHANGED
@@ -132,7 +132,10 @@ module IiifResponses
|
|
132
132
|
{
|
133
133
|
"@id": 'uri://for-manifest2',
|
134
134
|
"@type": 'sc:Manifest',
|
135
|
-
"label":
|
135
|
+
"label": {
|
136
|
+
"@value": 'Test Manifest 2',
|
137
|
+
"@language": 'en'
|
138
|
+
},
|
136
139
|
"attribution": 'Attribution Data',
|
137
140
|
"description": 'A test IIIF manifest',
|
138
141
|
"license": 'http://www.example.org/license.html',
|
@@ -186,7 +189,16 @@ module IiifResponses
|
|
186
189
|
{
|
187
190
|
"@id": 'uri://for-manifest3',
|
188
191
|
"@type": 'sc:Manifest',
|
189
|
-
"label":
|
192
|
+
"label": [
|
193
|
+
{
|
194
|
+
"@value": 'Test Manifest 3',
|
195
|
+
"@language": 'en'
|
196
|
+
},
|
197
|
+
{
|
198
|
+
"@value": "Manifeste d'essai 3",
|
199
|
+
"@language": 'fr'
|
200
|
+
}
|
201
|
+
],
|
190
202
|
"attribution": 'Attribution Data',
|
191
203
|
"description": 'A test IIIF manifest',
|
192
204
|
"license": 'http://www.example.org/license.html',
|
@@ -12,8 +12,9 @@ describe Spotlight::Resources::IiifManifest do
|
|
12
12
|
let(:url) { 'uri://to-manifest' }
|
13
13
|
subject { described_class.new(url: url, manifest: manifest, collection: collection) }
|
14
14
|
let(:collection) { double(compound_id: '1') }
|
15
|
+
let(:manifest_fixture) { test_manifest1 }
|
15
16
|
before do
|
16
|
-
stub_iiif_response_for_url(url,
|
17
|
+
stub_iiif_response_for_url(url, manifest_fixture)
|
17
18
|
subject.with_exhibit(exhibit)
|
18
19
|
end
|
19
20
|
|
@@ -31,6 +32,34 @@ describe Spotlight::Resources::IiifManifest do
|
|
31
32
|
it 'is inlcuded in the solr document when present' do
|
32
33
|
expect(subject.to_solr['full_title_tesim']).to eq 'Test Manifest 1'
|
33
34
|
end
|
35
|
+
|
36
|
+
it 'indexes to multiple fields when configured' do
|
37
|
+
allow(Spotlight::Engine.config).to receive(:iiif_title_fields).at_least(:once).and_return(%w(title_field1 title_field2))
|
38
|
+
|
39
|
+
expect(subject.to_solr['title_field1']).to eq 'Test Manifest 1'
|
40
|
+
expect(subject.to_solr['title_field2']).to eq 'Test Manifest 1'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'JSON-LD style labels' do
|
45
|
+
context 'when it is an array' do
|
46
|
+
let(:manifest_fixture) { test_manifest3 }
|
47
|
+
|
48
|
+
it 'uses the configured language to find a value' do
|
49
|
+
expect(subject.to_solr['full_title_tesim']).to eq 'Test Manifest 3'
|
50
|
+
|
51
|
+
allow(Spotlight::Engine.config).to receive(:default_json_ld_language).and_return('fr')
|
52
|
+
expect(subject.to_solr['full_title_tesim']).to eq "Manifeste d'essai 3"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when it is a hash' do
|
57
|
+
let(:manifest_fixture) { test_manifest2 }
|
58
|
+
|
59
|
+
it 'is parsed correctly' do
|
60
|
+
expect(subject.to_solr['full_title_tesim']).to eq 'Test Manifest 2'
|
61
|
+
end
|
62
|
+
end
|
34
63
|
end
|
35
64
|
|
36
65
|
describe 'collection id' do
|