Skip to content

Commit

Permalink
Merge pull request #732 from sul-dlss/t715-collection_member
Browse files Browse the repository at this point in the history
Display link to item's collection's item.
  • Loading branch information
jcoyne authored Oct 26, 2023
2 parents dcd6e45 + 6fc28fa commit 2a49e01
Show file tree
Hide file tree
Showing 15 changed files with 333 additions and 18 deletions.
3 changes: 2 additions & 1 deletion app/controllers/preview_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def show
@purl = @document = OpenStruct.new(
mods?: true,
mods: @mods,
title: Array.wrap(@mods.title).join(' -- ')
title: Array.wrap(@mods.title).join(' -- '),
containing_purl_collections: []
)

@purl.define_singleton_method(:released_to?) do |*args|
Expand Down
6 changes: 5 additions & 1 deletion app/models/public_xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ def content_metadata
def catalog_key
@catalog_key ||= document.root.at_xpath('identityMetadata/otherId[@name="catkey"]')&.text.presence
@catalog_key ||= begin
key = document.root.at_xpath('identityMetadata/otherId[@name="folio_instance_hrid"]')&.text.presence
key = folio_instance_hrid
key = key.delete_prefix('a') if key&.match?(/^a\d+$/)
key
end
end

def folio_instance_hrid
@folio_instance_hrid ||= document.root.at_xpath('identityMetadata/otherId[@name="folio_instance_hrid"]')&.text.presence
end

def released_to?(key)
release = document.root.at_xpath("releaseData/release[@to='#{key}']")&.text

Expand Down
17 changes: 13 additions & 4 deletions app/models/purl_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,18 @@ def public_xml
@public_xml ||= PublicXml.new(public_xml_document)
end

# @return [String] the identifier of the collection this item is a member of
def containing_collection
@containing_collection ||= public_xml.relations('isMemberOfCollection').first
# @return [Array<String>] the identifiers of the collections this item is a member of
def containing_collections
@containing_collections ||= public_xml.relations('isMemberOfCollection')
end

# @return [Array<PurlResource>] the PURL resources of the collections this item is a member of
def containing_purl_collections
@containing_purl_collections ||= containing_collections.map do |id|
PurlResource.find(id)
rescue ObjectNotReady, DruidNotValid
nil
end.compact
end

delegate :rights_metadata, to: :public_xml
Expand Down Expand Up @@ -172,7 +181,7 @@ def use_and_reproduction
rights.use_and_reproduction_statement
end

delegate :catalog_key, to: :public_xml
delegate :catalog_key, :folio_instance_hrid, to: :public_xml

delegate :released_to?, to: :public_xml

Expand Down
15 changes: 15 additions & 0 deletions app/views/purl/_collection.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<% if document.containing_purl_collections.present? %>
<div class="section">
<div class="section-heading">
<h2>Collection</h2>
</div>
<div class="section-body">
<% document.containing_purl_collections.each do |collection_document| %>
<p class="mb-2"><%= collection_document.title %></p>
<% if collection_document.folio_instance_hrid %>
<%= link_to('View other items in this collection in SearchWorks', "#{Settings.searchworks.url}/catalog?f[collection][]=#{collection_document.folio_instance_hrid}") %>
<% end %>
<% end %>
</div>
</div>
<% end %>
2 changes: 1 addition & 1 deletion app/views/purl/_find_it.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</div>
<div class="section-body">
<% if @purl.catalog_key %>
<%= link_to 'View in SearchWorks', Settings.searchworks.url + @purl.catalog_key %>
<%= link_to 'View in SearchWorks', "#{Settings.searchworks.url}/view/#{@purl.catalog_key}" %>
<% end %>

<%= releases.to_sentence.html_safe %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/purl/_mods_metadata_sections.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<%= render "mods_subjects", document: document %>
<%= render "mods_bibliographic", document: document %>
<%= render "mods_contact", document: document %>
<%= render "collection", document: document %>
<%= render "find_it", document: document %>

4 changes: 0 additions & 4 deletions app/views/purl/_mods_upper_metadata_items.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,4 @@
<% document.mods.note.select { |x| x.label =~ /Preferred citation/i }.each do |notes| %>
<%= mods_record_field(notes) %>
<% end %>

<% document.mods.collection.each do |collection| %>
<%= mods_record_field(collection) %>
<% end %>
</dl>
2 changes: 1 addition & 1 deletion app/views/purl/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<% end %>
<%= tag :link, rel: "alternate", title: "MODS XML", type: 'application/xml', href: purl_url(@purl, format: 'mods') if @purl.mods? %>
<%= tag :link, rel: "alternate", title: "IIIF Manifest", type: 'application/json', href: iiif_manifest_url(@purl) if @purl.iiif_manifest? %>
<%= tag :link, rel: "up", href: purl_url(@purl.containing_collection) if @purl.containing_collection.present? %>
<%= tag :link, rel: "up", href: purl_url(@purl.containing_collections.first) if @purl.containing_collections.present? %>
<%= tag :meta, name: 'citation_doi', content: @purl.doi_id if @purl.doi.present? %>

<% end %>
Expand Down
2 changes: 1 addition & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ releases:
url: 'https://earthworks.stanford.edu/catalog/stanford-%{druid}'

searchworks:
url: 'https://searchworks.stanford.edu/view/'
url: 'https://searchworks.stanford.edu'

landing_page_druids:
- bb112zx3193
Expand Down
4 changes: 3 additions & 1 deletion spec/features/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@
expect(page).to have_metadata_section 'Contributors'
expect(page).to have_metadata_section 'Subjects'
expect(page).to have_metadata_section 'Bibliographic information'
expect(page).to have_metadata_section 'Collection'
expect(page).to have_metadata_section 'Also listed in'
end

it 'lists the collection name' do
it 'lists the collection name and links to items in collection' do
visit '/cp088pb1682'
expect(page).to have_content 'Bay Area video arcades : photographs by Ira Nowinski, 1981-1982'
expect(page).to have_link 'View other items in this collection in SearchWorks', href: 'https://searchworks.stanford.edu/catalog?f[collection][]=a9685083'
end

it 'has a link to the searchworks record' do
Expand Down
72 changes: 72 additions & 0 deletions spec/fixtures/document_cache/sk/882/gx/0113/mods
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<mods xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xlink="http://www.w3.org/1999/xlink" version="3.7" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-7.xsd">
<titleInfo usage="primary">
<title>Bay Area video arcades : photographs by Ira Nowinski, 1981-1982</title>
</titleInfo>
<name usage="primary" type="personal">
<namePart>Nowinski, Ira</namePart>
</name>
<typeOfResource manuscript="yes" collection="yes">mixed material</typeOfResource>
<physicalDescription>
<extent>2 boxes</extent>
</physicalDescription>
<language>
<languageTerm authority="iso639-2b" type="code">eng</languageTerm>
</language>
<abstract>The Bay Area video arcade photographs were taken in 1980 and 1981 at several locations in the San Francisco Bay Area. The locations include the Santa Cruz Boardwalk, the Exploratorium (site of the 1981 Atari Asteroids competition), and other arcades in Oakland and San Francisco. Materials include black &amp; white prints and approximately 650 35mm images on contact sheets with their negatives.</abstract>
<note>Each print is identified, signed, and dated by the photographer.</note>
<note type="acquisition">Purchased, 2012 and 2016. Accessions 2012-155 and 2016-129.</note>
<subject authority="lcsh">
<name type="personal">
<namePart>Nowinski, Ira</namePart>
</name>
</subject>
<subject authority="lcsh">
<name type="conference">
<namePart>Atari Asteroids Competition (San Francisco, Calif.)</namePart>
</name>
</subject>
<subject authority="lcsh">
<topic>Photography</topic>
<temporal>1980-1990</temporal>
</subject>
<subject authority="lcsh">
<topic>Video games</topic>
<topic>History</topic>
<genre>Pictorial works</genre>
</subject>
<subject authority="lcsh">
<topic>Video games</topic>
<topic>Social aspects</topic>
<geographic>California</geographic>
<geographic>San Francisco Bay Area</geographic>
</subject>
<subject>
<geographic>Santa Cruz Beach Boardwalk</geographic>
</subject>
<originInfo>
<dateIssued encoding="marc" point="start">1981</dateIssued>
<dateIssued encoding="marc" point="end">1982</dateIssued>
<place>
<placeTerm authority="marccountry" type="code">cau</placeTerm>
</place>
<issuance>monographic</issuance>
</originInfo>
<location>
<url usage="primary display">https://purl.stanford.edu/sk882gx0113</url>
</location>
<location>
<physicalLocation>Department of Special Collections, Stanford University Libraries, Stanford, CA 94305</physicalLocation>
</location>
<recordInfo>
<recordContentSource authority="marcorg">CSt</recordContentSource>
<descriptionStandard>dacs</descriptionStandard>
<recordOrigin>Converted from MARCXML to MODS version 3.7 using
MARC21slim2MODS3-7_SDR_v2-5.xsl (SUL 3.7 version 2.5 20210421; LC Revision 1.140
20200717)</recordOrigin>
<recordCreationDate encoding="marc">120808</recordCreationDate>
<recordIdentifier source="SIRSI">a9685083</recordIdentifier>
</recordInfo>
<accessCondition type="useAndReproduction">Property rights and literary rights reside with the repository. To obtain permission to publish or reproduce, please contact the Special Collections Public Services Librarian at [email protected].</accessCondition>
<accessCondition type="copyright">Copyright (c) Stanford University. All Rights Reserved.</accessCondition>
</mods>
135 changes: 135 additions & 0 deletions spec/fixtures/document_cache/sk/882/gx/0113/public
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<publicObject id="druid:sk882gx0113" published="2023-04-18T21:48:37Z" publishVersion="cocina-models/0.90.0">
<identityMetadata>
<objectType>collection</objectType>
<objectLabel>Bay Area video arcades : photographs by Ira Nowinski, 1981-1982</objectLabel>
<otherId name="catkey">9685083</otherId>
<otherId name="folio_instance_hrid">a9685083</otherId>
</identityMetadata>
<rightsMetadata>
<access type="discover">
<machine>
<world/>
</machine>
</access>
<access type="read">
<machine>
<world/>
</machine>
</access>
<use>
<human type="useAndReproduction">Property rights and literary rights reside with the repository. To obtain permission to publish or reproduce, please contact the Special Collections Public Services Librarian at [email protected].</human>
<license/>
</use>
<copyright>
<human>Copyright (c) Stanford University. All Rights Reserved.</human>
</copyright>
</rightsMetadata>
<rdf:RDF xmlns:fedora="info:fedora/fedora-system:def/relations-external#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="info:fedora/druid:sk882gx0113">


</rdf:Description>
</rdf:RDF>
<oai_dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:srw_dc="info:srw/schema/1/dc-schema" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
<dc:title>Bay Area video arcades : photographs by Ira Nowinski, 1981-1982</dc:title>
<dc:contributor>Nowinski, Ira</dc:contributor>
<dc:type>Collection</dc:type>
<dc:format>2 boxes</dc:format>
<dc:language>eng</dc:language>
<dc:description>The Bay Area video arcade photographs were taken in 1980 and 1981 at several locations in the San Francisco Bay Area. The locations include the Santa Cruz Boardwalk, the Exploratorium (site of the 1981 Atari Asteroids competition), and other arcades in Oakland and San Francisco. Materials include black &amp; white prints and approximately 650 35mm images on contact sheets with their negatives.</dc:description>
<dc:description>Each print is identified, signed, and dated by the photographer.</dc:description>
<dc:description type="acquisition">Purchased, 2012 and 2016. Accessions 2012-155 and 2016-129.</dc:description>
<dc:subject>Nowinski, Ira</dc:subject>
<dc:subject>Atari Asteroids Competition (San Francisco, Calif.)</dc:subject>
<dc:subject>Photography</dc:subject>
<dc:coverage>1980-1990</dc:coverage>
<dc:subject>Photography--1980-1990</dc:subject>
<dc:subject>Video games--History</dc:subject>
<dc:subject>Video games--History--Pictorial works</dc:subject>
<dc:subject>Video games--Social aspects</dc:subject>
<dc:coverage>California</dc:coverage>
<dc:coverage>San Francisco Bay Area</dc:coverage>
<dc:subject>Video games--Social aspects--California--San Francisco Bay Area</dc:subject>
<dc:subject/>
<dc:coverage>Santa Cruz Beach Boardwalk</dc:coverage>
<dc:date>1981-1982</dc:date>
<dc:identifier>https://purl.stanford.edu/sk882gx0113</dc:identifier>
<dc:rights>Open for research. Material must be requested at least 36 hours in advance of intended use.</dc:rights>
</oai_dc:dc>
<mods xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xlink="http://www.w3.org/1999/xlink" version="3.7" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-7.xsd">
<titleInfo usage="primary">
<title>Bay Area video arcades : photographs by Ira Nowinski, 1981-1982</title>
</titleInfo>
<name usage="primary" type="personal">
<namePart>Nowinski, Ira</namePart>
</name>
<typeOfResource manuscript="yes" collection="yes">mixed material</typeOfResource>
<physicalDescription>
<extent>2 boxes</extent>
</physicalDescription>
<language>
<languageTerm authority="iso639-2b" type="code">eng</languageTerm>
</language>
<abstract>The Bay Area video arcade photographs were taken in 1980 and 1981 at several locations in the San Francisco Bay Area. The locations include the Santa Cruz Boardwalk, the Exploratorium (site of the 1981 Atari Asteroids competition), and other arcades in Oakland and San Francisco. Materials include black &amp; white prints and approximately 650 35mm images on contact sheets with their negatives.</abstract>
<note>Each print is identified, signed, and dated by the photographer.</note>
<note type="acquisition">Purchased, 2012 and 2016. Accessions 2012-155 and 2016-129.</note>
<subject authority="lcsh">
<name type="personal">
<namePart>Nowinski, Ira</namePart>
</name>
</subject>
<subject authority="lcsh">
<name type="conference">
<namePart>Atari Asteroids Competition (San Francisco, Calif.)</namePart>
</name>
</subject>
<subject authority="lcsh">
<topic>Photography</topic>
<temporal>1980-1990</temporal>
</subject>
<subject authority="lcsh">
<topic>Video games</topic>
<topic>History</topic>
<genre>Pictorial works</genre>
</subject>
<subject authority="lcsh">
<topic>Video games</topic>
<topic>Social aspects</topic>
<geographic>California</geographic>
<geographic>San Francisco Bay Area</geographic>
</subject>
<subject>
<geographic>Santa Cruz Beach Boardwalk</geographic>
</subject>
<originInfo>
<dateIssued encoding="marc" point="start">1981</dateIssued>
<dateIssued encoding="marc" point="end">1982</dateIssued>
<place>
<placeTerm authority="marccountry" type="code">cau</placeTerm>
</place>
<issuance>monographic</issuance>
</originInfo>
<location>
<url usage="primary display">https://purl.stanford.edu/sk882gx0113</url>
</location>
<location>
<physicalLocation>Department of Special Collections, Stanford University Libraries, Stanford, CA 94305</physicalLocation>
</location>
<recordInfo>
<recordContentSource authority="marcorg">CSt</recordContentSource>
<descriptionStandard>dacs</descriptionStandard>
<recordOrigin>Converted from MARCXML to MODS version 3.7 using
MARC21slim2MODS3-7_SDR_v2-5.xsl (SUL 3.7 version 2.5 20210421; LC Revision 1.140
20200717)</recordOrigin>
<recordCreationDate encoding="marc">120808</recordCreationDate>
<recordIdentifier source="SIRSI">a9685083</recordIdentifier>
</recordInfo>
<accessCondition type="useAndReproduction">Property rights and literary rights reside with the repository. To obtain permission to publish or reproduce, please contact the Special Collections Public Services Librarian at [email protected].</accessCondition>
<accessCondition type="copyright">Copyright (c) Stanford University. All Rights Reserved.</accessCondition>
</mods>
<releaseData>
<release to="Searchworks">true</release>
<release to="Searchworks">true</release>
</releaseData>
</publicObject>
20 changes: 20 additions & 0 deletions spec/fixtures/document_cache/yb/533/nc/1884/mods
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<mods xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xlink="http://www.w3.org/1999/xlink" version="3.7" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-7.xsd">
<titleInfo>
<title>Stanford University, Cabinet, Records</title>
</titleInfo>
<abstract>Agenda, minutes, memoranda, reports, and other records from Cabinet meetings.</abstract>
<location>
<url usage="primary display">https://purl.stanford.edu/yb533nc1884</url>
</location>
<note type="contact" displayLabel="Contact">[email protected]</note>
<relatedItem>
<titleInfo>
<title>Finding aid</title>
</titleInfo>
<location>
<url>http://www.oac.cdlib.org/findaid/ark:/13030/kt1h4nf2fr</url>
</location>
</relatedItem>
<accessCondition type="useAndReproduction">User agrees that, where applicable, content will not be used to identify or to otherwise infringe the privacy or confidentiality rights of individuals. Content distributed via the Stanford Digital Repository may be subject to additional license and use restrictions applied by the depositor.</accessCondition>
</mods>
Loading

0 comments on commit 2a49e01

Please sign in to comment.