Skip to content

Commit

Permalink
Merge pull request #3996 from pulibrary/3952-deprecated-firestone-loc…
Browse files Browse the repository at this point in the history
…ator

Removed firestone locator
  • Loading branch information
sandbergja committed Apr 5, 2024
2 parents b71fa2a + 0743199 commit 4a51363
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 186 deletions.
9 changes: 0 additions & 9 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,11 @@ def locate_link_with_glyph(location, document, call_number, library, location_na
link = locate_url(location, document, call_number, library)
if link.nil? || (find_it_location?(location) == false)
''
elsif Flipflop.firestone_locator?
stackmap_url_markup(location, library, location_name, document['id'], call_number)
else
stackmap_span_markup(location, library, location_name)
end
end

def stackmap_url_markup(location, library, location_name, doc_id, call_number)
stackmap_url = "/catalog/#{doc_id}/stackmap?loc=#{location}"
stackmap_url << "&cn=#{call_number}" if call_number

' ' + link_to('<span class="fa fa-map-marker" aria-hidden="true"></span>'.html_safe, stackmap_url, title: t('blacklight.holdings.stackmap'), class: 'find-it', data: { 'map-location': location.to_s, 'blacklight-modal': 'trigger', 'location-library': library, 'location-name': location_name }, 'aria-label' => 'Where to find it')
end

def stackmap_span_markup(location, library, location_name)
' ' + content_tag(
:span, '',
Expand Down
30 changes: 1 addition & 29 deletions app/services/physical_holdings_markup_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,38 +316,10 @@ def locate_link(location, call_number, library, holding)
return '' if locator.exclude?(call_number:, library:)

markup = ''
markup = stackmap_markup(location, library, holding, call_number) if find_it_location?(location)
markup = stackmap_span_markup(location, library, holding) if find_it_location?(location)
' ' + markup
end

def stackmap_markup(location, library, holding, call_number)
if Flipflop.firestone_locator?
stackmap_url_markup(location, library, holding, call_number)
else
stackmap_span_markup(location, library, holding)
end
end

def stackmap_url_markup(location, library, holding, call_number)
doc_id = doc_id(holding)

stackmap_url = "/catalog/#{doc_id}/stackmap?loc=#{location}"
stackmap_url << "&cn=#{call_number}" if call_number

child = %(<span class="link-text">#{I18n.t('blacklight.holdings.stackmap')}</span>\
<span class="fa fa-map-marker" aria-hidden="true"></span>)
link_to(child.html_safe, stackmap_url,
class: 'find-it',
data: {
'map-location' => location.to_s,
'location-library' => library,
'location-name' => holding['location'],
'blacklight-modal' => 'trigger',
'call-number' => call_number,
'library' => library
})
end

def stackmap_span_markup(location, library, holding)
content_tag(:span, '',
data: {
Expand Down
15 changes: 3 additions & 12 deletions app/services/stackmap_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def url
elsif stackmap_libs.include? lib
stackmap_url
else
locator_url
fallback_url
end
else
fallback_url
Expand Down Expand Up @@ -53,11 +53,6 @@ def self.missing_stackmap_reserves

private

def locator_url
base_url = Orangelight.config['firestone_locator_base_url'] || 'https://locator-prod.princeton.edu'
"#{base_url}/index.php?loc=#{@loc}&id=#{bibid}&embed=true"
end

def stackmap_url
stackmap_url = 'https://princeton.stackmap.com/view/'
stackmap_params = {
Expand All @@ -84,11 +79,7 @@ def callno
end

def stackmap_libs
if Flipflop.firestone_locator?
%w[arch eastasian engineer lewis mendel plasma stokes]
else
%w[arch eastasian engineer lewis mendel plasma stokes firestone]
end
%w[arch eastasian engineer lewis mendel plasma stokes firestone]
end

def by_title_locations
Expand All @@ -104,7 +95,7 @@ def lib
end

def valid?
!holding_location.nil? && !@document.nil?
!holding_location.nil? && !@document.nil? && !callno.nil?
end
end
end
10 changes: 3 additions & 7 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@
<link rel="stylesheet" href="https://use.typekit.net/yhr7zwc.css">
<%= stylesheet_link_tag "application", media: "screen" %>
<%= stylesheet_link_tag "print", media: "print" %>
<% if !Flipflop.firestone_locator? %>
<!-- STACKMAP CHANGES BEGIN HERE -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
<script src="https://www.stackmapintegration.com/princeton-blacklight/StackMap.min.js" type="text/javascript"></script>
<link rel="stylesheet" media="all" type="text/css" href="https://www.stackmapintegration.com/princeton-blacklight/StackMap.min.css" />
<!-- STACKMAP CHANGES END HERE -->
<% end %>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
<script src="https://www.stackmapintegration.com/princeton-blacklight/StackMap.min.js" type="text/javascript"></script>
<link rel="stylesheet" media="all" type="text/css" href="https://www.stackmapintegration.com/princeton-blacklight/StackMap.min.css" />
<% unless controller.controller_name == "request" %>
<%= javascript_include_tag "application" %>
<% else %>
Expand Down
4 changes: 0 additions & 4 deletions config/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
# default: false,
# description: "Display a test header to show if flipflop is working."

feature :firestone_locator,
default: true,
description: "When on / true, uses the old locator service for Firestone. When off / false uses the new Stackmap service for Firestone."

feature :message_display,
default: false,
description: "When on / true, displays the message set by the announcement rake task."
Expand Down
2 changes: 0 additions & 2 deletions config/orangelight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ defaults: &defaults
to: <%= ENV['OL_HARMFUL_CONTENT_TO'] %>
report_biased_results_form:
to: <%= ENV['OL_BIASED_RESULTS_TO'] %>
firestone_locator_base_url: https://locator-prod.princeton.edu
redis:
host: 'localhost'
port: '6379'
Expand Down Expand Up @@ -75,7 +74,6 @@ staging:
events:
server: <%= ENV['OL_RABBIT_SERVER'] || 'amqp://localhost:5672' %>
exchange: 'orangelight_events'
firestone_locator_base_url: https://locator-staging.princeton.edu

qa:
<<: *defaults
Expand Down
19 changes: 1 addition & 18 deletions spec/helpers/holding_block_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,7 @@

before { stub_holding_locations }

context 'with Firestone Locator off' do
before do
allow(Flipflop).to receive(:firestone_locator?).and_return(false)
end
context 'using the stackmap' do
let(:expected_result) do
"<ul><li class=\"holding-status\" data-availability-record=\"true\" data-record-id=\"1\" data-holding-id=\"3580281\" data-bound-with=\"false\"><span class=\"availability-icon badge badge-secondary\">Loading...</span><div class=\"library-location\" data-location=\"true\" data-record-id=\"1\" data-holding-id=\"3580281\"><span class=\"results_location\">Rare Books and Special Collections - Rare Books and Special Collections - Reference Collection in Dulles Reading Room</span> &raquo; <span class=\"call-number\">PS3539.A74Z93 2000</span></div></li><li><span class=\"badge badge-primary\" data-availability-cdl=\"true\"></span></li><li class=\"holding-status\" data-availability-record=\"true\" data-record-id=\"1\" data-holding-id=\"3595800\" data-bound-with=\"false\"><span class=\"availability-icon badge badge-secondary\">Link Missing</span><div class=\"library-location\">Online access is not currently available.</div></li><li><span class=\"badge badge-primary\" data-availability-cdl=\"true\"></span></li><span style=\"font-size: small; font-style: italic;\">View record for information on additional holdings</span></ul>"
end
Expand All @@ -409,20 +406,6 @@
end
end

context 'with Firestone Locator on' do
before do
allow(Flipflop).to receive(:firestone_locator?).and_return(true)
end

it 'includes the find it icon' do
search_result = helper.holding_block_search(SolrDocument.new(document_with_find_it_link))
expect(search_result).to include "fa-map-marker"
expect(search_result).to include "data-map-location"
expect(search_result).to include "data-location-name"
expect(search_result).to include "data-location-library"
end
end

# For certain locations a map icon is not displayed if the location is not accessible by patrons.
# The icon is displayed based on the presence of data-map-location
it 'does not include the find it icon' do
Expand Down
13 changes: 9 additions & 4 deletions spec/helpers/locations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
let(:stackmap_location) { 'mendel$stacks' }
let(:locator_location) { 'firestone$stacks' }
let(:stackmap_ineligible_location) { 'annex$noncirc' }
let(:bib) { { id: '123456' } }
let(:bib) { SolrDocument.new(properties) }
let(:properties) do
{
id: '1234567'
}
end
let(:call_number) { 'RCPXR-6136516' }
let(:locator_library) { 'Firestone Library' }
let(:stackmap_library) { 'Mendel Music Library' }
Expand All @@ -18,7 +23,7 @@
it 'Returns a Stackmap Link for a Mapping Location' do
stackmap_link = locate_url(locator_location, bib, call_number, locator_library)
expect(stackmap_link).to be_truthy
expect(stackmap_link).to include("?loc=#{locator_location}&id=#{bib[:id]}")
expect(stackmap_link).to include("&location=#{CGI.escape(locator_location)}")
end

it 'Does not return a stackmap link for an inaccessible location' do
Expand All @@ -31,9 +36,9 @@
expect(stackmap_link).to be_nil
end

it 'Returns a locator link when there is no call number for Firestone' do
it 'Returns the fallback details page when there is no call number for Firestone' do
locator_link = locate_url(locator_location, bib, nil, locator_library)
expect(locator_link).to include("?loc=#{locator_location}&id=#{bib[:id]}")
expect(locator_link).to include("catalog/#{bib[:id]}")
end
end

Expand Down
20 changes: 1 addition & 19 deletions spec/services/physical_holdings_markup_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,7 @@
describe '.holding_location' do
let(:holding_location_markup) { builder.holding_location(holding.first[1], location, holding_id, call_number) }

context 'with firestone_locator on' do
before do
allow(Flipflop).to receive(:firestone_locator?).and_return(true)
end

it 'includes a link with mapping details' do
expect(holding_location_markup).to include '<td class="library-location"'
expect(holding_location_markup).to include "href=\"/catalog/123456/stackmap?loc=firestone$stacks&amp;cn=#{call_number}\""
expect(holding_location_markup).to include 'Firestone Library'
expect(holding_location_markup).to include 'data-holding-id="3668455"'
expect(holding_location_markup).to include "data-map-location=\"#{holding.first[1]['location_code']}"
end
end

context 'with firestone_locator off' do
before do
allow(Flipflop).to receive(:firestone_locator?).and_return(false)
end

context 'with the stackmap' do
it 'includes a span with mapping details' do
expect(holding_location_markup).to include '<td class="library-location"'
expect(holding_location_markup).to include '<span class="location-text"'
Expand Down
31 changes: 5 additions & 26 deletions spec/services/stackmap_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,7 @@
let(:location) { 'firestone$stacks' }
let(:call_number) { 'Q43.2' }

context 'with firestone_locator on' do
before do
allow(Flipflop).to receive(:firestone_locator?).and_return(true)
end
it 'resolves to embeded firestone locator with loc and bibid' do
expect(url).to eq("https://locator-prod.princeton.edu/index.php?loc=#{location}&id=#{properties[:id]}&embed=true")
end

context 'when firestone_locator_base_url points to the staging locator' do
before do
allow(Orangelight.config).to receive(:[]).with('firestone_locator_base_url')
.and_return('https://locator-staging.princeton.edu')
end
it 'resolves to embeded staging firestone locator with loc and bibid' do
expect(url).to eq("https://locator-staging.princeton.edu/index.php?loc=#{location}&id=#{properties[:id]}&embed=true")
end
end
end
context 'with firestone_locator off' do
before do
allow(Flipflop).to receive(:firestone_locator?).and_return(false)
end
context 'using the stackmap' do
it 'resolves to external stackmap service' do
expect(url).to eq("https://princeton.stackmap.com/view/?callno=Q43.2&library=Firestone+Library&location=firestone%24stacks")
end
Expand All @@ -54,17 +33,17 @@
describe 'firestone, no call number provided' do
let(:location) { 'firestone$stacks' }

it 'resolves to embeded firestone locator with loc and bibid' do
expect(url).to eq("https://locator-prod.princeton.edu/index.php?loc=#{location}&id=#{properties[:id]}&embed=true")
it 'resolves to catalog details page as a fallback' do
expect(url).to eq("https://princeton.stackmap.com/view/?callno=#{CGI.escape(doc_cn[0])}&library=Firestone+Library&location=#{CGI.escape(location)}")
end
end

describe 'firestone, doc has no call number' do
let(:location) { 'firestone$stacks' }
let(:doc_cn) { nil }

it 'resolves to embeded firestone locator with loc and bibid' do
expect(url).to eq("https://locator-prod.princeton.edu/index.php?loc=#{location}&id=#{properties[:id]}&embed=true")
it 'resolves to catalog details page as a fallback' do
expect(url).to eq("/catalog/#{properties[:id]}")
end

it 'preferred_callno returns nil' do
Expand Down
18 changes: 1 addition & 17 deletions spec/system/searching_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,7 @@
end
end

context 'with firestone_locator on' do
before do
allow(Flipflop).to receive(:firestone_locator?).and_return(true)
end

it 'renders an accessible link to the stack map' do
visit '/catalog?q=&search_field=all_fields'
expect(page).to have_selector('.fa-map-marker')
expect(page).to have_selector('.fa-map-marker[aria-hidden="true"]')
end
end

context 'with firestone_locator off' do
before do
allow(Flipflop).to receive(:firestone_locator?).and_return(false)
end

context 'using the stackmap' do
it 'renders an accessible link to the stack map', js: true do
visit '/catalog?q=&search_field=all_fields'
expect(page).to have_selector('.fa-map-marker', wait: 5)
Expand Down
40 changes: 1 addition & 39 deletions spec/system/stackmap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
before do
stub_holding_locations
end
context 'with Firestone Locator off' do
before do
allow(Flipflop).to receive(:firestone_locator?).and_return(false)
end

context 'using the stackmap' do
it 'has a link to the stackmap on the record page' do
visit '/catalog/99125428126306421'
click_button('Where to find it', wait: 5)
Expand All @@ -22,38 +18,4 @@
expect(page).to have_button('Where to find it', wait: 5)
end
end

context 'with Firestone Locator on' do
before do
allow(Flipflop).to receive(:firestone_locator?).and_return(true)
end

it 'has a link to the stackmap on the search results page' do
visit '/catalog?search_field=all_fields&q='
expect(page).to have_no_button('Map it', wait: 5)
expect(page).to have_link('Where to find it')
end

context 'with Firestone item' do
it 'opens a modal with the Firestone Locator' do
visit '/catalog/99125428126306421'
expect(page).to have_link('Where to find it')
expect(page).to have_no_button('Map it', wait: 5)
click_link('Where to find it')
iframe = find('iframe')
expect(iframe['src']).to eq('https://locator-prod.princeton.edu/index.php?loc=firestone$clas&id=99125428126306421&embed=true')
end
end

context 'with non-Firestone item' do
it 'opens a modal with the Stackmap locator' do
visit '/catalog/99116547863506421'
expect(page).to have_link('Where to find it')
expect(page).to have_no_button('Map it', wait: 5)
click_link('Where to find it')
iframe = find('iframe')
expect(iframe['src']).to eq('https://princeton.stackmap.com/view/?callno=J3306%2F5047.4+pt.31&library=East+Asian+Library&location=eastasian%24hy')
end
end
end
end

0 comments on commit 4a51363

Please sign in to comment.