Sha256: 229ec6b858197417ee20e435e4e1ee465622ffaf14a2e9f4efe60199ce594c15
Contents?: true
Size: 1.6 KB
Versions: 2
Compression:
Stored size: 1.6 KB
Contents
# frozen_string_literal: true module Spotlight # Creates solr documents for the uploaded documents in a resource class UploadSolrDocumentBuilder < SolrDocumentBuilder delegate :compound_id, to: :resource def to_solr super.tap do |solr_hash| add_default_solr_fields solr_hash add_sidecar_fields solr_hash if attached_file? add_image_dimensions solr_hash add_file_versions solr_hash add_manifest_path solr_hash end end end private def add_default_solr_fields(solr_hash) solr_hash[exhibit.blacklight_config.document_model.unique_key.to_sym] = compound_id end def add_image_dimensions(solr_hash) dimensions = Riiif::Image.new(resource.upload_id).info solr_hash[:spotlight_full_image_width_ssm] = dimensions.width solr_hash[:spotlight_full_image_height_ssm] = dimensions.height end def add_file_versions(solr_hash) solr_hash[Spotlight::Engine.config.thumbnail_field] = Spotlight::Engine.config.iiif_url_helpers.image_path(resource.upload_id, size: '!400,400') end def add_sidecar_fields(solr_hash) solr_hash.merge! resource.sidecar.to_solr end def add_manifest_path(solr_hash) solr_hash[Spotlight::Engine.config.iiif_manifest_field] = spotlight_routes.manifest_exhibit_solr_document_path(exhibit, resource.compound_id) end def spotlight_routes Spotlight::Engine.routes.url_helpers end def riiif Spotlight::Engine.config.iiif_url_helpers end def attached_file? resource.upload&.file_present? end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
blacklight-spotlight-2.11.0 | app/services/spotlight/upload_solr_document_builder.rb |
blacklight-spotlight-2.10.0 | app/services/spotlight/upload_solr_document_builder.rb |