Skip to content

Commit

Permalink
Link to collection without requiring a second lookup
Browse files Browse the repository at this point in the history
Fixes #2154

The link is only used for analytics, so it shouldn't matter if the collection is dark or not
  • Loading branch information
jcoyne committed May 29, 2024
1 parent b971206 commit 8d46846
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
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 %>
</head>
<body>
<%= render @embed_response.viewer.component.new(viewer: @embed_response.viewer) %>
Expand Down

0 comments on commit 8d46846

Please sign in to comment.