8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'app/jobs/blacklight/allmaps/store_sidecar_annotation.rb', line 8
def perform(document_id)
solr_document = ::SolrDocument.find(document_id)
sidecar = solr_document.sidecar_allmaps
if ApplicationController.helpers.georeferenceable?(solr_document)
sleep(rand(1..5))
response = HTTParty.get(solr_document.iiif_manifest_url, follow_redirects: true)
if response.code == 200
sidecar.iiif_manifest = response.body
sidecar.manifest_id = JSON.parse(sidecar.iiif_manifest)["@id"] || JSON.parse(sidecar.iiif_manifest)["id"]
end
annotation_url_by_iiif_uri = "https://annotations.allmaps.org/?url=#{solr_document.iiif_manifest_url}"
response = HTTParty.get(annotation_url_by_iiif_uri, follow_redirects: true)
if response.code == 200
sidecar.allmaps_annotation = response.body
sidecar.annotated = true
end
sidecar.save
end
end
|