Class: Hyrax::ManifestHelper

Inherits:
Object
  • Object
show all
Includes:
ActionDispatch::Routing::PolymorphicRoutes
Defined in:
app/builders/hyrax/manifest_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(hostname) ⇒ ManifestHelper

Returns a new instance of ManifestHelper.


6
7
8
# File 'app/builders/hyrax/manifest_helper.rb', line 6

def initialize(hostname)
  @hostname = hostname
end

Instance Method Details

#build_rendering(file_set_id) ⇒ Hash

Build a rendering hash

Returns:

  • (Hash)

    rendering


18
19
20
21
22
23
24
25
26
27
# File 'app/builders/hyrax/manifest_helper.rb', line 18

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

#polymorphic_url(record, opts = {}) ⇒ Object


10
11
12
13
# File 'app/builders/hyrax/manifest_helper.rb', line 10

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

#query_for_rendering(file_set_id) ⇒ SolrDocument

Query for the properties to create a rendering

Returns:


32
33
34
# File 'app/builders/hyrax/manifest_helper.rb', line 32

def query_for_rendering(file_set_id)
  ::SolrDocument.find(file_set_id)
end