Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add language to iiif3 metadata writer #1223

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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