-
Notifications
You must be signed in to change notification settings - Fork 6
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 #2329 from sul-dlss/media
Move the Media components out of the Embed namespace
- Loading branch information
Showing
22 changed files
with
267 additions
and
279 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module Media | ||
class EmbedThisFormComponent < ViewComponent::Base | ||
def initialize(viewer:) | ||
@viewer = viewer | ||
end | ||
|
||
delegate :embed_request, :purl_object, to: :viewer | ||
delegate :title, to: :purl_object, prefix: true | ||
delegate :purl_url, to: :purl_object | ||
|
||
attr_reader :viewer | ||
end | ||
end |
File renamed without changes.
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 @@ | ||
# frozen_string_literal: true | ||
|
||
module Media | ||
class MetadataComponent < ViewComponent::Base | ||
def initialize(viewer:) | ||
@viewer = viewer | ||
end | ||
|
||
attr_reader :viewer | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# frozen_string_literal: true | ||
|
||
module Media | ||
# Displays an image (e.g. photo of the media) for a media resource | ||
class PreviewImageComponent < ViewComponent::Base | ||
include Embed::StacksImage | ||
|
||
# @param [String] druid the object identifier | ||
# @param [ResourceFile] file the file to display | ||
# @param [Integer] resource_index the offset of this resource in the purl | ||
# @param [String] type the type of resource (either audio or video), used to determine which icon to show | ||
def initialize(druid:, file:, resource_index:, type:) | ||
@druid = druid | ||
@file = file | ||
@resource_index = resource_index | ||
@type = type | ||
end | ||
|
||
attr_reader :resource_index, :druid, :file, :type | ||
|
||
def call | ||
# the 74,73 size accounts for the additional pixel size returned by the image server | ||
thumb_url = stacks_square_url(druid, file.title, size: '74,73') | ||
render WrapperComponent.new(thumbnail: thumb_url, file:, type:, resource_index:) do | ||
tag.div(class: 'osd', id: "openseadragon-#{resource_index}", | ||
data: { controller: 'osd', osd_url_value:, osd_nav_images_value: }) | ||
end | ||
end | ||
|
||
def osd_url_value | ||
"#{stacks_image_url(druid, file.filename)}/info.json" | ||
end | ||
|
||
def osd_nav_images_value # rubocop:disable Metrics/MethodLength | ||
{ | ||
zoomIn: { | ||
REST: asset_path('zoomin_rest.png'), | ||
GROUP: asset_path('zoomin_grouphover.png'), | ||
HOVER: asset_path('zoomin_hover.png'), | ||
DOWN: asset_path('zoomin_pressed.png') | ||
}, | ||
zoomOut: { | ||
REST: asset_path('zoomout_rest.png'), | ||
GROUP: asset_path('zoomout_grouphover.png'), | ||
HOVER: asset_path('zoomout_hover.png'), | ||
DOWN: asset_path('zoomout_pressed.png') | ||
}, | ||
home: { | ||
REST: asset_path('home_rest.png'), | ||
GROUP: asset_path('home_grouphover.png'), | ||
HOVER: asset_path('home_hover.png'), | ||
DOWN: asset_path('home_pressed.png') | ||
}, | ||
fullpage: { | ||
REST: asset_path('fullpage_rest.png'), | ||
GROUP: asset_path('fullpage_grouphover.png'), | ||
HOVER: asset_path('fullpage_hover.png'), | ||
DOWN: asset_path('fullpage_pressed.png') | ||
} | ||
} | ||
end | ||
end | ||
end |
Oops, something went wrong.