Sha256: 90cb19473c4192c0d69aeefae77f71a9a148078bae554cb0c44595800a050dce
Contents?: true
Size: 981 Bytes
Versions: 29
Compression:
Stored size: 981 Bytes
Contents
# frozen_string_literal: true require 'iiif/presentation' module Spotlight module Resources # harvest Images from IIIF Manifest and turn them into a Spotlight::Resource # Note: IIIF API : http://iiif.io/api/presentation/2.0 class IiifHarvester < Spotlight::Resource self.document_builder_class = Spotlight::Resources::IiifBuilder self.weight = -5000 validate :valid_url? def iiif_manifests @iiif_manifests ||= IiifService.parse(url) end private def valid_url? errors.add(:url, 'Invalid IIIF URL') unless url_is_iiif?(url) end def url_is_iiif?(url) valid_content_types = ['application/json', 'application/ld+json'] req = Faraday.head(url) req = Faraday.get(url) if req.status == 405 return unless req.success? valid_content_types.any? do |valid_type| req.headers['content-type'].include?(valid_type) end end end end end
Version data entries
29 entries across 29 versions & 1 rubygems