Skip to content

Commit

Permalink
Add link to catalog from figgy
Browse files Browse the repository at this point in the history
refs #736
  • Loading branch information
hackartisan committed Apr 29, 2020
1 parent 2877262 commit f197c9a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions app/values/manifest_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,15 @@ def transform_value(value)
return language_name(value) if key == 'Language'
return value['title'] if key == 'Memberof'
return value["@id"] if value["@id"]
return link_to_catalog(value) if key == "Link to catalog"

value
end

def link_to_catalog(value)
"<a href='#{value}'>#{value}</a>"
end

def electronic_location_link(value)
return value unless value.is_a?(Hash)

Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/metadata/12345678.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"title":"East Asian Library Digital Bookshelf"
}
],
"link_to_catalog":"https://catalog.princeton.edu/12345678",
"system_created_at":"2019-01-01T00:00:00Z",
"system_updated_at":"2019-01-02T00:00:00Z"
}
7 changes: 6 additions & 1 deletion spec/models/iiif_resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
context 'with recorded http interactions' do
let(:url) { 'https://hydra-dev.princeton.edu/concern/scanned_resources/1r66j1149/manifest' }

it 'ingests a iiif manifest' do
it 'ingests a iiif manifest with metadata from jsonld' do
stub_manifest(url: url, fixture: '1r66j1149-expanded.json')
stub_metadata(id: "12345678")
exhibit = Spotlight::Exhibit.create title: 'Exhibit A'
Expand All @@ -129,7 +129,10 @@
expect(Spotlight::CustomField.last.field_type).to eq 'vocab'
expect(solr_doc["readonly_created_ssim"]).to eq ["1976-01-01T00:00:00Z"]
expect(solr_doc["readonly_description_ssim"]).to eq ["First", "Second"]
expect(solr_doc["readonly_description_ssim"]).to eq ["First", "Second"]
expect(solr_doc["readonly_link-to-catalog_ssim"]).to eq ["<a href='https://catalog.princeton.edu/12345678'>https://catalog.princeton.edu/12345678</a>"]
end

it "removes old metadata" do
stub_manifest(url: url, fixture: '1r66j1149-expanded.json')
# Stub metadata with a record which has a creator
Expand All @@ -156,6 +159,7 @@

expect(solr_doc["readonly_creator_tesim"]).to eq nil
end

it 'indexes collections' do
stub_manifest(url: url, fixture: '1r66j1149-expanded.json')
stub_metadata(id: "12345678")
Expand All @@ -168,6 +172,7 @@
resource.document_builder.to_solr { |x| solr_doc = x }
expect(solr_doc["readonly_collections_tesim"]).to eq ["East Asian Library Digital Bookshelf"]
end

context "when given a MVW" do
let(:url) { "https://hydra-dev.princeton.edu/concern/multi_volume_works/f4752g76q/manifest" }
before do
Expand Down

0 comments on commit f197c9a

Please sign in to comment.