Sha256: 79b30b7710ffdb23e0cd38b6eee1a330d23e8abb9a8a053473543c510acbdb17

Contents?: true

Size: 1.48 KB

Versions: 5

Compression:

Stored size: 1.48 KB

Contents

# mixin to provide URL for IIIF Content Search service
module IiifPrint
  module IiifManifestPresenterDecorator
    extend ActiveSupport::Concern

    # Extending the presenter to the base url which includes the protocol.
    # We need the base url to render the facet links and normalize the interface.
    attr_accessor :base_url

    def manifest_metadata
      # ensure we are using a SolrDocument
      @manifest_metadata ||= IiifPrint.manifest_metadata_from(work: model.solr_document, presenter: self)
    end

    def search_service
      Rails.application.routes.url_helpers.solr_document_iiif_search_url(id, host: hostname)
    end

    # OVERRIDE: Hyrax 3x, avoid nil returning to IIIF Manifest gem
    # @see https://github.com/samvera/iiif_manifest/blob/c408f90eba11bef908796c7236ba6bcf8d687acc/lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb#L28
    ##
    # @return [Array<Hash{String => String}>]
    def sequence_rendering
      Array(try(:rendering_ids)).map do |file_set_id|
        rendering = file_set_presenters.find { |p| p.id == file_set_id }
        return [] unless rendering

        { '@id' => Hyrax::Engine.routes.url_helpers.download_url(rendering.id, host: hostname),
          'format' => rendering.mime_type.presence || I18n.t("hyrax.manifest.unknown_mime_text"),
          'label' => I18n.t("hyrax.manifest.download_text") + (rendering.label || '') }
      end.flatten
    end
  end
end
Hyrax::IiifManifestPresenter.prepend(IiifPrint::IiifManifestPresenterDecorator)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
iiif_print-3.0.4 app/presenters/iiif_print/iiif_manifest_presenter_decorator.rb
iiif_print-3.0.3 app/presenters/iiif_print/iiif_manifest_presenter_decorator.rb
iiif_print-3.0.2 app/presenters/iiif_print/iiif_manifest_presenter_decorator.rb
iiif_print-3.0.1 app/presenters/iiif_print/iiif_manifest_presenter_decorator.rb
iiif_print-3.0.0 app/presenters/iiif_print/iiif_manifest_presenter_decorator.rb