Class: Spotlight::IiifManifestPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/spotlight/iiif_manifest_presenter.rb

Overview

A presenter class that provides the methods that IIIFManifest expects, as well as convenience methods

that will generate a IIIFManifest object, and the actual JSON manifest from the IIIFManifest object.
Instances of this class represent IIIF leaf nodes.  We do not currently generate manifests with interstitial
nodes.

IIIFManifest expects the following methods: #file_set_presenters, #work_presenters, #manifest_url, #description.

see: https://github.com/projecthydra-labs/iiif_manifest/blob/master/README.md

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, controller) ⇒ IiifManifestPresenter

Returns a new instance of IiifManifestPresenter.



22
23
24
25
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 22

def initialize(resource, controller)
  @resource = resource
  @controller = controller
end

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



20
21
22
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 20

def controller
  @controller
end

#resourceObject

Returns the value of attribute resource.



20
21
22
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 20

def resource
  @resource
end

Instance Method Details

#descriptionObject

a description of the manifest



53
54
55
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 53

def description
  resource.first(Spotlight::Engine.config.upload_description_field)
end

#display_imageObject

IIIFManifest expects leaf nodes to implement #display_image, which returns an instance of IIIFManifest::DisplayImage.



28
29
30
31
32
33
34
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 28

def display_image
  IIIFManifest::DisplayImage.new(id,
                                 width: resource.first(:spotlight_full_image_width_ssm)&.to_i,
                                 height: resource.first(:spotlight_full_image_height_ssm)&.to_i,
                                 format: 'image/jpeg',
                                 iiif_endpoint: endpoint)
end

#file_set_presentersObject

Returns an array of leaf nodes. Currently, this is a single element array containing this presenter instance, since we’re only building a single-image manifest for the given resource.



38
39
40
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 38

def file_set_presenters
  [self]
end

#iiif_manifestObject



62
63
64
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 62

def iiif_manifest
  IIIFManifest::ManifestFactory.new(self)
end

#iiif_manifest_jsonObject



66
67
68
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 66

def iiif_manifest_json
  iiif_manifest.to_h.to_json
end

#manifest_urlObject

where this manifest can be found



48
49
50
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 48

def manifest_url
  controller.spotlight.manifest_exhibit_solr_document_url(uploaded_resource.exhibit, resource)
end

#to_sObject

IIIFManifest will call #to_s on each leaf node to get its respective label (not called out in README).



58
59
60
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 58

def to_s
  presenter.heading
end

#work_presentersObject

This is an empty array, since we’re not building manifests for works at the moment.



43
44
45
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 43

def work_presenters
  []
end