Skip to content

Commit 0c11eaa

Browse files
committed
Add 'Full text options' fulfillment link.
Why these changes are being introduced: UXWS has requested for journal records with Browzine links should also include a 'Full-text options' button that links to the full record. Relevant ticket(s): - [USE-614](https://mitlibraries.atlassian.net/browse/USE-614) How this addresses that need: This adds the 'Full-text options' link. Side effects of this change: None.
1 parent 5c6ed91 commit 0c11eaa

6 files changed

Lines changed: 19 additions & 6 deletions

File tree

app/controllers/thirdiron_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ def browzine
1414
return unless ThirdIron.enabled? && params[:issn].present?
1515

1616
@browzine = Browzine.lookup(issn: params[:issn])
17+
@full_record_url = params[:full_record_url]
1718
end
1819

1920
private

app/views/search/_result_primo.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@
122122
<%# Trigger BrowZine lookup (render inside result-get so injected HTML
123123
is part of the flex `.result-get` area and receives expected styles) %>
124124
<% if ThirdIron.enabled? && result[:format].downcase == 'journal' && result[:issn].present? %>
125-
<%= render(partial: 'trigger_browzine', locals: { issn: result[:issn] }) %>
125+
<% full_record_url = result[:links]&.find { |link| link['kind'] == 'full record' }&.dig('url') %>
126+
<%= render(partial: 'trigger_browzine', locals: { issn: result[:issn], full_record_url: full_record_url }) %>
126127
<% end %>
127128
</div>
128129
<% end %>

app/views/search/_trigger_browzine.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<% return unless ThirdIron.enabled? %>
22

3-
<% data_url = "/browzine?issn=#{issn}" %>
3+
<% data_url = "/browzine?issn=#{issn}&full_record_url=#{ERB::Util.url_encode(full_record_url)}" %>
44

55
<span class="libkey-container"
66
data-controller="content-loader"
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<% if ThirdIron.enabled? && @browzine.present? %>
2+
<%= link_to 'Full-text options', @full_record_url, class: 'button libkey-link', data: { matomo_seen: "Results, Full-text Options Link Seen, Tab: {{getActiveTabName}}", matomo_click: "Results, Full-text Options Link Engaged, Link: {{getElementText}}", content_piece: 'Full-text options' } %>
3+
24
<% if @browzine[:browzine_link].present? %>
35
<div class="libkey-actions">
4-
<%= link_to @browzine[:browzine_link][:text], @browzine[:browzine_link][:link], class: 'button libkey-link', data: { matomo_seen: "Results, Browzine Link Seen, Tab: {{getActiveTabName}}", matomo_click: "Results, Browzine Link Engaged, Link: {{getElementText}}", content_piece: @browzine[:browzine_link][:text] } %>
6+
<%= link_to @browzine[:browzine_link][:text], @browzine[:browzine_link][:link], class: 'libkey-link', data: { matomo_seen: "Results, Browzine Link Seen, Tab: {{getActiveTabName}}", matomo_click: "Results, Browzine Link Engaged, Link: {{getElementText}}", content_piece: @browzine[:browzine_link][:text] } %>
57
</div>
68
<% end %>
79
<% end %>

app/views/thirdiron/libkey.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<%# Display browzine link if available. This should always display if we have it regardless of other links. %>
1717
<% if @libkey[:browzine_link].present? %>
1818
<div class="libkey-actions">
19-
<%= link_to @libkey[:browzine_link][:text], @libkey[:browzine_link][:link], class: 'button libkey-link', data: { matomo_seen: "Results, Browzine Link Seen, Tab: {{getActiveTabName}}", matomo_click: "Results, Browzine Link Engaged, Link: {{getElementText}}", content_piece: @libkey[:browzine_link][:text] } %>
19+
<%= link_to @libkey[:browzine_link][:text], @libkey[:browzine_link][:link], class: 'libkey-link', data: { matomo_seen: "Results, Browzine Link Seen, Tab: {{getActiveTabName}}", matomo_click: "Results, Browzine Link Engaged, Link: {{getElementText}}", content_piece: @libkey[:browzine_link][:text] } %>
2020
</div>
2121
<% end %>
2222

test/controllers/thirdiron_controller_test.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ class ThirdironControllerTest < ActionDispatch::IntegrationTest
2727
get '/libkey?type=doi&identifier=10.1038/s41567-023-02305-y'
2828

2929
assert_response :success
30-
assert_select 'a.button', { count: 3 }
30+
assert_select 'a.libkey-link', { count: 3 }
3131
end
3232

3333
VCR.use_cassette('libkey pmid') do
3434
get '/libkey?type=pmid&identifier=22110403'
3535

3636
assert_response :success
37-
assert_select 'a.button', { count: 3 }
37+
assert_select 'a.libkey-link', { count: 3 }
3838
end
3939
end
4040

@@ -115,6 +115,15 @@ class ThirdironControllerTest < ActionDispatch::IntegrationTest
115115
end
116116
end
117117

118+
test 'browzine route with full_record_url returns both links' do
119+
VCR.use_cassette('browzine issn') do
120+
get '/browzine?issn=1546170X&full_record_url=https://example.com/full-record'
121+
122+
assert_response :success
123+
assert_select 'a.libkey-link', { count: 2 }
124+
end
125+
end
126+
118127
test 'browzine route for non-existent issn returns blank' do
119128
# Browzine responds here, so we have a cassette - but the response is empty
120129
VCR.use_cassette('browzine nonexistent') do

0 commit comments

Comments
 (0)