Skip to content

Commit

Permalink
Move PDF and m3 components out of Embed namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jan 31, 2025
1 parent 87e41e4 commit c5100b1
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 38 deletions.
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.

File renamed without changes.
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
File renamed without changes.
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

0 comments on commit c5100b1

Please sign in to comment.