Skip to content

Commit

Permalink
Merge pull request #5617 from avalonmediasystem/playlist_item_comment
Browse files Browse the repository at this point in the history
Display playlist item comment on playlist page under title
  • Loading branch information
cjcolvar authored Feb 2, 2024
2 parents 18c9ece + 757f942 commit 5b5c55b
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ GIT

GIT
remote: https://github.com/samvera-labs/iiif_manifest.git
revision: 6a027ff84d2b1ca65765dea0c83c820643cebe01
revision: 1ede49aec4fc01582df8132e000121edbdcfac4a
branch: main
specs:
iiif_manifest (1.3.1)
Expand Down Expand Up @@ -331,7 +331,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.2.2)
concurrent-ruby (1.2.3)
config (4.2.1)
deep_merge (~> 1.2, >= 1.2.1)
dry-validation (~> 1.0, >= 1.0.0)
Expand Down Expand Up @@ -586,7 +586,7 @@ GEM
mini_mime (1.1.2)
mini_portile2 (2.8.4)
minitar (0.9)
minitest (5.20.0)
minitest (5.21.2)
msgpack (1.6.0)
multi_json (1.15.0)
multi_xml (0.6.0)
Expand Down
5 changes: 4 additions & 1 deletion app/javascript/components/PlaylistRamp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ const Ramp = ({
}) => {
const [manifestUrl, setManifestUrl] = React.useState('');
const [activeItemTitle, setActiveItemTitle] = React.useState();
const [activeItemSummary, setActiveItemSummary] = React.useState();

let interval;

Expand All @@ -70,7 +71,8 @@ const Ramp = ({
playerInst.ready(() => {
let activeElement = document.getElementsByClassName('ramp--structured-nav__list-item active');
if (activeElement != undefined && activeElement?.length > 0) {
setActiveItemTitle(activeElement[0].textContent);
setActiveItemTitle(activeElement[0].dataset.label);
setActiveItemSummary(activeElement[0].dataset.summary);
}
});
}
Expand All @@ -84,6 +86,7 @@ const Ramp = ({
<Card className="ramp--playlist-accordion">
<Card.Header>
<h4>{activeItemTitle}</h4>
{ activeItemSummary && <div>{activeItemSummary}</div> }
</Card.Header>
<Card.Body>
<Accordion>
Expand Down
11 changes: 10 additions & 1 deletion app/models/iiif_playlist_canvas_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def part_of
def item_metadata
return if master_file.nil?
[
metadata_field('Title', master_file.media_object.title),
metadata_field('Title', playlist_source_link),
metadata_field('Date', master_file.media_object.date_issued),
metadata_field('Main Contributor', master_file.media_object.creator)
].compact
Expand Down Expand Up @@ -93,8 +93,17 @@ def placeholder_content
end
end

def description
playlist_item.comment
end

private

def playlist_source_link
link_target = master_file.media_object.permalink.presence || Rails.application.routes.url_helpers.media_object_url(master_file.media_object_id)
"<a href='#{link_target}'>#{master_file.media_object.title}</a>"
end

# Following methods adapted from ApplicationHelper and MediaObjectHelper
def metadata_field(label, value, default = nil)
sanitized_values = Array(value).delete_if(&:empty?)
Expand Down
10 changes: 9 additions & 1 deletion spec/models/iiif_playlist_canvas_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,19 @@

it 'returns the title, date, and main contributor of the parent item' do
expect(subject.first['label']).to eq({ 'en' => ['Title'] })
expect(subject.first['value']).to eq({ 'en' => [media_object.title] })
expect(subject.first['value']).to eq({ 'en' => ["<a href='#{Rails.application.routes.url_helpers.media_object_url(media_object)}'>#{media_object.title}</a>"] })
expect(subject.second['label']).to eq({ 'en' => ['Date'] })
expect(subject.second['value']).to eq({ 'en' => [media_object.date_issued] })
expect(subject.last['label']).to eq({ 'en' => ['Main Contributor'] })
expect(subject.last['value']).to eq({ 'en' => media_object.creator })
end
end

describe "#description" do
subject { presenter.description }

it 'returns the description of the playlist item' do
expect(subject).to eq playlist_item.comment
end
end
end
18 changes: 15 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1035,13 +1035,20 @@
dependencies:
regenerator-runtime "^0.14.0"

"@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5":
"@babel/runtime@^7.11.2":
version "7.22.6"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.22.6.tgz#57d64b9ae3cff1d67eb067ae117dac087f5bd438"
integrity sha512-wDb5pWm4WDdF6LFUde3Jl8WzPA+3ZbxYqkC6xAXuD3irdEHN1k0NfTRrJD8ZD378SJ61miMLCqIOXYhd8x+AJQ==
dependencies:
regenerator-runtime "^0.13.11"

"@babel/runtime@^7.12.5":
version "7.23.9"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.23.9.tgz#47791a15e4603bb5f905bc0753801cf21d6345f7"
integrity sha512-0CX6F+BI2s9dkUqr08KFrAIZgNFj75rdBU/DjCyYLIaV/quFjkk6T+EJ2LkZHyZTbEV4L5p97mNkUsHl2wLFAw==
dependencies:
regenerator-runtime "^0.14.0"

"@babel/runtime@^7.13.8", "@babel/runtime@^7.14.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.3", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7":
version "7.15.4"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.15.4.tgz#fd17d16bfdf878e6dd02d19753a39fa8a8d9c84a"
Expand Down Expand Up @@ -1339,7 +1346,7 @@

"@samvera/ramp@https://github.com/samvera-labs/ramp.git":
version "2.0.0"
resolved "https://github.com/samvera-labs/ramp.git#4d0a9790b2f13b0b987aed25e6f56cccc12b45d7"
resolved "https://github.com/samvera-labs/ramp.git#10fc908009538f2a4df1ee694adc517d1cf7d237"
dependencies:
"@rollup/plugin-json" "^6.0.1"
"@silvermine/videojs-quality-selector" "^1.2.4"
Expand Down Expand Up @@ -1413,11 +1420,16 @@
"@types/estree" "*"
"@types/json-schema" "*"

"@types/estree@*", "@types/estree@^1.0.0":
"@types/estree@*":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.1.tgz#aa22750962f3bf0e79d753d3cc067f010c95f194"
integrity sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==

"@types/estree@^1.0.0":
version "1.0.5"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4"
integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==

"@types/express-serve-static-core@*", "@types/express-serve-static-core@^4.17.18":
version "4.17.28"
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.28.tgz#c47def9f34ec81dc6328d0b1b5303d1ec98d86b8"
Expand Down

0 comments on commit 5b5c55b

Please sign in to comment.