Sha256: bbea2cbba54b84083c18d892005728f31bc82963f9c50aa6a4c5e37483b7548c

Contents?: true

Size: 1.08 KB

Versions: 36

Compression:

Stored size: 1.08 KB

Contents

module Hyrax
  class ManifestHelper
    include Rails.application.routes.url_helpers
    include ActionDispatch::Routing::PolymorphicRoutes

    def initialize(hostname)
      @hostname = hostname
    end

    def polymorphic_url(record, opts = {})
      opts[:host] ||= @hostname
      super(record, opts)
    end

    # Build a rendering hash
    #
    # @return [Hash] rendering
    def build_rendering(file_set_id)
      file_set_document = query_for_rendering(file_set_id)
      label = file_set_document.label.present? ? ": #{file_set_document.label}" : ''
      mime = file_set_document.mime_type.present? ? file_set_document.mime_type : I18n.t("hyrax.manifest.unknown_mime_text")
      {
        '@id' => Hyrax::Engine.routes.url_helpers.download_url(file_set_document.id, host: @hostname),
        'format' => mime,
        'label' => I18n.t("hyrax.manifest.download_text") + label
      }
    end

    # Query for the properties to create a rendering
    #
    # @return [SolrDocument] query result
    def query_for_rendering(file_set_id)
      ::SolrDocument.find(file_set_id)
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
hyrax-2.9.6 app/builders/hyrax/manifest_helper.rb
hyrax-2.9.5 app/builders/hyrax/manifest_helper.rb
hyrax-2.9.4 app/builders/hyrax/manifest_helper.rb
hyrax-2.9.3 app/builders/hyrax/manifest_helper.rb
hyrax-2.9.2 app/builders/hyrax/manifest_helper.rb
hyrax-2.9.1 app/builders/hyrax/manifest_helper.rb
hyrax-2.9.0 app/builders/hyrax/manifest_helper.rb
hyrax-2.8.0 app/builders/hyrax/manifest_helper.rb
hyrax-2.7.2 app/builders/hyrax/manifest_helper.rb
hyrax-2.7.1 app/builders/hyrax/manifest_helper.rb
hyrax-2.7.0 app/builders/hyrax/manifest_helper.rb
hyrax-2.6.0 app/builders/hyrax/manifest_helper.rb
hyrax-3.0.0.pre.rc1 app/builders/hyrax/manifest_helper.rb
hyrax-3.0.0.pre.beta3 app/builders/hyrax/manifest_helper.rb
hyrax-2.5.1 app/builders/hyrax/manifest_helper.rb
hyrax-2.5.0 app/builders/hyrax/manifest_helper.rb
hyrax-3.0.0.pre.beta2 app/builders/hyrax/manifest_helper.rb
hyrax-2.4.1 app/builders/hyrax/manifest_helper.rb
hyrax-3.0.0.pre.beta1 app/builders/hyrax/manifest_helper.rb
hyrax-2.4.0 app/builders/hyrax/manifest_helper.rb