Class: Spotlight::IiifManifestPresenter
- Inherits:
-
Object
- Object
- Spotlight::IiifManifestPresenter
- 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
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#resource ⇒ Object
Returns the value of attribute resource.
Instance Method Summary collapse
-
#description ⇒ Object
a description of the manifest.
-
#display_image ⇒ Object
IIIFManifest expects leaf nodes to implement #display_image, which returns an instance of IIIFManifest::DisplayImage.
-
#file_set_presenters ⇒ Object
Returns an array of leaf nodes.
- #iiif_manifest ⇒ Object
- #iiif_manifest_json ⇒ Object
-
#initialize(resource, controller) ⇒ IiifManifestPresenter
constructor
A new instance of IiifManifestPresenter.
-
#manifest_url ⇒ Object
where this manifest can be found.
-
#to_s ⇒ Object
IIIFManifest will call #to_s on each leaf node to get its respective label (not called out in README).
-
#work_presenters ⇒ Object
This is an empty array, since we’re not building manifests for works at the moment.
Constructor Details
#initialize(resource, controller) ⇒ IiifManifestPresenter
Returns a new instance of IiifManifestPresenter.
20 21 22 23 |
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 20 def initialize(resource, controller) @resource = resource @controller = controller end |
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
18 19 20 |
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 18 def controller @controller end |
#resource ⇒ Object
Returns the value of attribute resource.
18 19 20 |
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 18 def resource @resource end |
Instance Method Details
#description ⇒ Object
a description of the manifest
51 52 53 |
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 51 def description resource.first(Spotlight::Engine.config.upload_description_field) end |
#display_image ⇒ Object
IIIFManifest expects leaf nodes to implement #display_image, which returns an instance of IIIFManifest::DisplayImage.
26 27 28 29 30 31 32 |
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 26 def display_image IIIFManifest::DisplayImage.new(id, width: resource.first(:spotlight_full_image_width_ssm), height: resource.first(:spotlight_full_image_height_ssm), format: 'image/jpeg', iiif_endpoint: endpoint) end |
#file_set_presenters ⇒ Object
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.
36 37 38 |
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 36 def file_set_presenters [self] end |
#iiif_manifest ⇒ Object
60 61 62 |
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 60 def iiif_manifest IIIFManifest::ManifestFactory.new(self) end |
#iiif_manifest_json ⇒ Object
64 65 66 |
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 64 def iiif_manifest_json iiif_manifest.to_h.to_json end |
#manifest_url ⇒ Object
where this manifest can be found
46 47 48 |
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 46 def manifest_url controller.spotlight.manifest_exhibit_solr_document_url(uploaded_resource.exhibit, resource) end |
#to_s ⇒ Object
IIIFManifest will call #to_s on each leaf node to get its respective label (not called out in README).
56 57 58 |
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 56 def to_s resource.first(blacklight_config.view_config(:show).title_field) end |
#work_presenters ⇒ Object
This is an empty array, since we’re not building manifests for works at the moment.
41 42 43 |
# File 'app/presenters/spotlight/iiif_manifest_presenter.rb', line 41 def work_presenters [] end |