- 
                Notifications
    You must be signed in to change notification settings 
- Fork 29
Digital Object Viewers
Arclight provides the ability for a downstream application to configure their own digital object viewer to be displayed on record pages.
The default/reference implementation is a simple oEmbed based viewer.  This viewer works by checking for link[rel="alternate"] tags in the document with a type of type of application/json+oembed [1].  The url referenced in that link will then be requested, and the html described in the oEmbed rich-type response will be injected into the document page. The oEmbed implementation that ships with Arclight can be configured to exclude certain url patterns that will be known to not contain oEmbed responses (e.g. PDF or PowerPoint) [2].
A downstream application can configure their own class to handle a local viewer implementation. This can be accomplished by changing the Arclight::Engine.config.viewer_class in an initializer.
# config/initializers/configure_arclight_viewer.rb
Arclight::Engine.config.viewer_class = MyApplicationViewerThis class will be initialized with the SolrDocument and must implement to_partial_path that references the path to a partial to render for that object.
class MyApplicationViewer
  def initialize(document)
    @document = document
  end
  def to_partial_path
    'viewers/_my_viewer'
  end
endThis is where you can add logic about how to get at the necessary data from your document to render a viewer. A very simple example would be if you parsed out an image url that was defined in the EAD into a solr field in your indexing logic [3]. You could add a method to your viewer like:
class MyApplicationViewer
  ...
  def images
    @document.fetch(:image_urls_ssim, [])
  end
  ...
endThe partial will receive an instance of viewer class as a local so any accessors/methods you add to your viewer class will available to your view.
<% # app/views/viewers/_my_viewer.html.erb %>
<% viewer.images.each do |image| %>
  <%= image_tag(image) %>
<% end %>- This requires that the resource has CORS enabled.
- All resources that are not CORS enabled will fail the pre-flight check, and won't have the full contents requested either.
- Arclight provides a digital_objectsmethod on the SolrDocument model that already gathers thedaodata for you that will most likely be used in place of fetching fields directly out of the index as is in this example.