-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add access point and masthead for bookplates.
- Loading branch information
Showing
8 changed files
with
231 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
### | ||
# Helper module for contents rendered in mastheads | ||
### | ||
module MastheadHelper | ||
def render_masthead_partial | ||
if page_location.access_point? | ||
begin | ||
render "catalog/mastheads/#{page_location.access_point}" | ||
rescue ActionView::MissingTemplate | ||
end | ||
return '' unless page_location.access_point? | ||
begin | ||
render "catalog/mastheads/#{page_location.access_point}" | ||
rescue ActionView::MissingTemplate | ||
return '' | ||
end | ||
end | ||
|
||
def facets_prefix_options | ||
["0-9", ("A".."Z").to_a].flatten | ||
['0-9', ('A'..'Z').to_a].flatten | ||
end | ||
def digital_collections_params_for(format=nil) | ||
facet_params = {f: {building_facet: ["Stanford Digital Repository"]}} | ||
|
||
def digital_collections_params_for(format = nil) | ||
facet_params = { f: { building_facet: ['Stanford Digital Repository'] } } | ||
facet_params[:f][:format_main_ssim] = [format] if format | ||
catalog_index_path(facet_params) | ||
end | ||
|
||
def bookplate_from_document_list(response = @response) | ||
return unless params[:f] && params[:f][:fund_facet].present? && response.docs.present? | ||
SolrDocument.new(response.docs.first).bookplates.find do |bookplate| | ||
bookplate.linking_value == params[:f][:fund_facet].first | ||
end | ||
end | ||
|
||
def bookplate_breadcrumb_value(druid, response = @response) | ||
return druid unless response.docs.present? | ||
bookplate_from_document_list.try(:text) || druid | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<% bookplate = bookplate_from_document_list %> | ||
<% if bookplate.present? %> | ||
<div id="masthead-container"> | ||
<div id="masthead" class="bookplate-fund-masthead row"> | ||
<div class='col-md-2 col-sm-3'> | ||
<%= image_tag(bookplate.thumbnail_url, alt: bookplate.text) %> | ||
</div> | ||
<div class='col-md-10 col-sm-9'> | ||
<h1><%= bookplate.text %></h1> | ||
<p> | ||
Bookplates honor donors who have created and sustained acquisition | ||
funds, often over many years and sometimes several generations, as | ||
well as those who have given the Libraries extraordinary collections. | ||
</p> | ||
<% if Settings.BOOKPLATES_EXHIBIT_URL.present? %> | ||
<p> | ||
Find out more at the <%= link_to('Digital Bookplates Exhibit', Settings.BOOKPLATES_EXHIBIT_URL) %> | ||
<i class='external-link-icon'></i> | ||
</p> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
require 'spec_helper' | ||
|
||
describe 'Bookplates' do | ||
describe 'on the record view' do | ||
it 'displays bookplate data when present' do | ||
visit catalog_path('45') | ||
|
||
expect(page).to have_css('h2', text: 'Bookplate') | ||
expect(page).to have_css('.bookplate', count: 2) | ||
|
||
within(first('.bookplate')) do | ||
expect(page).to have_css('.media-left img') | ||
expect(page).to have_css('.media-body a', text: 'Susan and Ruth Sharp Fund') | ||
end | ||
|
||
within(all('.bookplate').last) do | ||
expect(page).to have_css('.media-left img') | ||
expect(page).to have_css('.media-body a', text: 'The Edgar Amos Boyles Centennial Book Fund') | ||
end | ||
end | ||
|
||
it 'does not include the section when there is no bookplate data' do | ||
visit catalog_path('44') | ||
|
||
expect(page).not_to have_css('h2', text: 'Bookplate') | ||
expect(page).not_to have_css('.bookplate') | ||
end | ||
end | ||
|
||
describe 'search results' do | ||
let(:masthead_text) { 'Bookplates honor donors who have created and sustained acquisition funds' } | ||
it 'displays a masthead with the bookplate data for each individual fund (with correct breadcrumb)' do | ||
visit catalog_path('45') | ||
|
||
click_link 'Susan and Ruth Sharp Fund' | ||
|
||
within('.bookplate-fund-masthead') do | ||
expect(page).to have_css('img') | ||
expect(page).to have_css('h1', text: 'Susan and Ruth Sharp Fund') | ||
expect(page).to have_content masthead_text | ||
end | ||
|
||
within('.constraint') do | ||
expect(page).to have_css('.filterName', text: 'Bookplate') | ||
expect(page).to have_css('.filterValue', text: 'Susan and Ruth Sharp Fund') | ||
end | ||
|
||
expect(page).to have_css('h2', text: '1 result') | ||
|
||
visit catalog_path('45') | ||
|
||
click_link 'The Edgar Amos Boyles Centennial Book Fund' | ||
|
||
within('.bookplate-fund-masthead') do | ||
expect(page).to have_css('img') | ||
expect(page).to have_css('h1', text: 'The Edgar Amos Boyles Centennial Book Fund') | ||
expect(page).to have_content masthead_text | ||
end | ||
|
||
within('.constraint') do | ||
expect(page).to have_css('.filterName', text: 'Bookplate') | ||
expect(page).to have_css('.filterValue', text: 'The Edgar Amos Boyles Centennial Book Fund') | ||
end | ||
|
||
expect(page).to have_css('h2', text: '1 result') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters