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

Link to collection without requiring a second lookup #2155

Merged
merged 1 commit into from
May 29, 2024
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: 6 additions & 0 deletions app/models/embed/purl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def purl_url
"#{Settings.purl_url}/#{@druid}"
end

def first_collection_url
return if collections.blank?

"#{Settings.purl_url}/#{collections.first}"
end

def manifest_json_url
"#{Settings.purl_url}/#{druid}/iiif/manifest"
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/embed/iframe.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<%= javascript_importmap_tags @embed_response.viewer.importmap if @embed_response.viewer.importmap %>
<%= stylesheet_link_tag @embed_response.viewer.stylesheet %>
<%= stylesheet_link_tag 'sul_icons.css' %>
<%= tag :link, rel: "up", href: Embed::Purl.find(@embed_response.request.purl_object.collections.first).purl_url if @embed_response && @embed_response.request.purl_object.collections.any? %>
<%= tag :link, rel: "up", href: @embed_response.request.purl_object.first_collection_url if @embed_response && @embed_response.request.purl_object.first_collection_url %>
Copy link
Member

@mjgiarlo mjgiarlo May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a Purl instance has no collections, won't Purl#first_collection_url return "#{Settings.purl_url}/#{nil}" (truthy)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now handled in the model. Thank you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. :shipit:

</head>
<body>
<%= render @embed_response.viewer.component.new(viewer: @embed_response.viewer) %>
Expand Down