Sha256: 735bc2394bf539f49c57ee19d2a7552e618cca973a9c5a71a72993e04777b930

Contents?: true

Size: 1.32 KB

Versions: 24

Compression:

Stored size: 1.32 KB

Contents

module Spotlight
  module SolrDocument
    ##
    # Mixin for SolrDocuments backed by exhibit-specific resources
    module UploadedResource
      extend ActiveSupport::Concern

      included do
        accepts_nested_attributes_for :uploaded_resource
      end

      def uploaded_resource
        @uploaded_resource ||= GlobalID::Locator.locate first(Spotlight::Engine.config.resource_global_id_field)
      rescue => e
        Rails.logger.info("Unable to locate uploaded resource: #{e}")
        nil
      end

      def to_openseadragon(*_args)
        self[Spotlight::Engine.config.full_image_field].each_with_index.map do |image_url, index|
          { LegacyImagePyramidTileSource.new(
            image_url,
            width: self[:spotlight_full_image_width_ssm][index],
            height: self[:spotlight_full_image_height_ssm][index]
          ) => {}
          }
        end
      end

      ##
      # Stub legacy image pyramid property generators
      class LegacyImagePyramidTileSource
        attr_reader :to_tilesource
        def initialize(url, dimensions = {})
          @to_tilesource = {
            type: 'legacy-image-pyramid',
            levels: [{
              url: url,
              width: dimensions[:width],
              height: dimensions[:height]
            }]
          }
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
blacklight-spotlight-0.17.1 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.17.0 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.16.0 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.15.0 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.14.2 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.14.1 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.14.0 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.13.0 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.12.1 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.12.0 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.11.0 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.10.3 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.10.2 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.10.1 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.10.0 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.9.2 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.9.1 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.9.0 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.8.2 app/models/concerns/spotlight/solr_document/uploaded_resource.rb
blacklight-spotlight-0.8.1 app/models/concerns/spotlight/solr_document/uploaded_resource.rb