Skip to content

Commit

Permalink
Add language to iiif3 metadata writer
Browse files Browse the repository at this point in the history
Fixes #1222
  • Loading branch information
jcoyne committed Feb 28, 2025
1 parent 04df421 commit 51e68ef
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
9 changes: 7 additions & 2 deletions app/models/iiif3_metadata_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def initialize(cocina_descriptive:, collection_title:, published_date:, doi:)

# @return [Array<Hash>] the IIIF v3 metadata structure
def write # rubocop:disable Metrics/AbcSize
available_online + titles + contributors + contacts + types + format + notes +
subjects + coverage + dates + identifiers + collection + publication
available_online + titles + contributors + contacts + types + format + language +
notes + subjects + coverage + dates + identifiers + collection + publication
end

private
Expand Down Expand Up @@ -79,6 +79,11 @@ def format
vals.present? ? [iiif_key_value('Format', vals)] : []
end

def language
vals = Array(cocina_descriptive['language']).map { it['value'] || it['code'] }
vals.present? ? [iiif_key_value('Language', vals)] : []
end

def genre
filtered_form('genre').map do
it['value']
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/purl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
visit '/bc854fy5899/iiif3/manifest'
json_body = JSON.parse(page.body)
expect(json_body['label']['en'].first).to eq('John Wyclif and his followers, Tracts in Middle English')
expect(json_body['metadata'].length).to eq 11
expect(json_body['metadata'].length).to eq 12
end
end

Expand Down
12 changes: 12 additions & 0 deletions spec/model/iiif3_metadata_writer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,5 +303,17 @@
end['value'][:en]).to eq ['51.5 x 59.8 cm., including title along top and border, with 10 diagrams/maps and 6 columns of titled text.']
end
end

context 'with language' do
let(:cocina_descriptive) do
PurlResource.find('zf119tw4418').version(:head).cocina['description']
end

it 'extracts the metadata' do
expect(metadata.find do
it['label'][:en] == ['Language']
end['value'][:en]).to eq ['eng']
end
end
end
end
4 changes: 2 additions & 2 deletions spec/requests/iiif3_manifest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
get '/zf119tw4418/iiif3/manifest'

expect(json['items'].length).to eq 58
expect(json['metadata'].length).to eq 12
expect(json['metadata'].length).to eq 13
end

context 'when pages do not have OCR content' do
Expand Down Expand Up @@ -363,7 +363,7 @@
get "/#{druid}/iiif3/manifest"
expect(response).to have_http_status(:ok)
expect(json['label']['en'].first).to eq '10 Meter Contours: Russian River Basin, California'
expect(json['metadata'].size).to eq 11
expect(json['metadata'].size).to eq 12
end
end

Expand Down

0 comments on commit 51e68ef

Please sign in to comment.