-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2831 from sul-dlss/mirador-component
Extract a component for embedded mirador
- Loading branch information
Showing
6 changed files
with
75 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<%= content_tag :iframe, '', | ||
src: iframe_src, | ||
allowfullscreen: true, | ||
class: 'mirador-embed-wrapper', | ||
frameborder: 0, | ||
marginwidth: 0, | ||
marginheight: 0, | ||
scrolling: 'no', | ||
width: '100%' | ||
%> | ||
<%= iiif_drag_n_drop(manifest_url, document:) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
# Display the embed iframe | ||
class EmbeddedMiradorComponent < ViewComponent::Base | ||
def initialize(document:) | ||
@document = document | ||
super | ||
end | ||
|
||
attr_reader :document | ||
|
||
delegate :iiif_drag_n_drop, to: :helpers | ||
|
||
def render? | ||
document.manifest_url.present? | ||
end | ||
|
||
def manifest_url | ||
@manifest_url ||= doc_manifest.starts_with?('/') ? root_url + doc_manifest.slice(1..-1) : doc_manifest | ||
end | ||
|
||
def iframe_src | ||
"#{Settings.iiif_embed.url}?#{{ url: manifest_url }.to_query}" | ||
end | ||
|
||
def doc_manifest | ||
document.manifest_url | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe CustomViewerComponent, type: :component do | ||
let(:component) { described_class.new(document:, presenter:) } | ||
let(:presenter) { double } | ||
let(:exhibit) { create(:exhibit) } | ||
let(:manifest_url) { 'http://example.com/iiif/manifest' } | ||
|
||
before do | ||
exhibit.required_viewer.viewer_type = 'mirador3' | ||
exhibit.required_viewer.save | ||
with_request_url "/#{exhibit.slug}/catalog/cf101bh9631" do | ||
render_inline(component) | ||
end | ||
end | ||
|
||
context 'with external_iiif resource' do | ||
let(:document) do | ||
SolrDocument.new(id: 'abc', iiif_manifest_url_ssi: manifest_url, | ||
spotlight_resource_type_ssim: ['spotlight/resources/iiif_harvesters']) | ||
end | ||
|
||
it 'renders the component' do | ||
expect(page).to have_css "iframe[src='https://embed.stanford.edu/iiif?#{{ url: manifest_url }.to_query}']" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters