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.



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

def initialize(hostname)
  @hostname = hostname
end

Instance Method Details

#build_rendering(file_set_id) ⇒ Hash

Build a rendering hash

Returns:

  • (Hash)

    rendering



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

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.presence || 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



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

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:



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

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