Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move PDF and m3 components out of Embed namespace #2330

Merged
merged 1 commit into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions app/components/embed/login_component.rb

This file was deleted.

11 changes: 0 additions & 11 deletions app/components/embed/m3_component.rb

This file was deleted.

18 changes: 0 additions & 18 deletions app/components/embed/pdf_component.rb

This file was deleted.

5 changes: 5 additions & 0 deletions app/components/login_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

# This is only used by the PdfComponent
class LoginComponent < ViewComponent::Base
end
9 changes: 9 additions & 0 deletions app/components/m3_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class M3Component < ViewComponent::Base
def initialize(viewer:)
@viewer = viewer
end

attr_reader :viewer
end
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<% component.with_body do %>
<div class="sul-embed-body" style="width: 100%">
<% if viewer.available? %>
<%= render Embed::LoginComponent.new %>
<%= render LoginComponent.new %>
<div class="sul-embed-pdf" style="height: 100%"
data-controller="pdf"
data-fullscreen-target="area"
Expand Down
16 changes: 16 additions & 0 deletions app/components/pdf_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

class PdfComponent < ViewComponent::Base
def initialize(viewer:)
@viewer = viewer
end

attr_reader :viewer

delegate :purl_object, to: :viewer
delegate :druid, to: :purl_object

def iiif_v3_manifest_url
"#{Settings.purl_url}/#{druid}/iiif3/manifest"
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'rails_helper'

RSpec.describe Embed::M3Component, type: :component do
RSpec.describe M3Component, type: :component do
let(:request) { Embed::Request.new(url: 'http://purl.stanford.edu/abc123', canvas_index: 3, search: 'xyz', suggested_search: 'abc') }
let(:viewer) { Embed::Viewer::M3Viewer.new(request) }
let(:purl) { build(:purl) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'rails_helper'

RSpec.describe Embed::PdfComponent, type: :component do
RSpec.describe PdfComponent, type: :component do
include PurlFixtures

let(:url) { 'https://purl.stanford.edu/sq929fn8035' }
Expand Down