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

Adjust rendering property #73

Merged
merged 6 commits into from
Oct 3, 2022
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
23 changes: 10 additions & 13 deletions lib/iiif_manifest/v3/manifest_builder/record_property_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@ def apply(manifest)
end

def populate_rendering
if record.respond_to?(:sequence_rendering)
record.sequence_rendering.collect do |rendering|
sequence_rendering = rendering.to_h.except('@id', 'label')
sequence_rendering['id'] = rendering['@id']
if rendering['label'].present?
sequence_rendering['label'] = ManifestBuilder.language_map(rendering['label'])
end
sequence_rendering
return unless record.respond_to?(:sequence_rendering)
record.sequence_rendering.collect do |rendering|
sequence_rendering = rendering.to_h.except('@id', 'label')
sequence_rendering['id'] = rendering['@id']
if rendering['label'].present?
sequence_rendering['label'] = ManifestBuilder.language_map(rendering['label'])
end
else
[]
sequence_rendering
end
end

Expand All @@ -41,7 +38,7 @@ def canvas_builder
canvas_builder_factory.from(record)
end

# rubocop:disable Metrics/CyclomaticComplexity
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
def setup_manifest_from_record(manifest, record)
manifest['id'] = record.manifest_url.to_s
manifest.label = ManifestBuilder.language_map(record.to_s) if record.to_s.present?
Expand All @@ -50,10 +47,10 @@ def setup_manifest_from_record(manifest, record)
manifest.metadata = metadata_from_record(record)
manifest.viewing_direction = viewing_direction if viewing_direction.present?
manifest.service = services if search_service.present?
manifest.rendering = populate_rendering
manifest.rendering = populate_rendering if populate_rendering.present?
manifest.homepage = record.homepage if record.try(:homepage).present?
end
# rubocop:enable Metrics/CyclomaticComplexity
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity

def metadata_from_record(record)
if valid_v3_metadata?
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/iiif_manifest/v3/manifest_factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def display_content

it 'does not have a rendering on the sequence' do
allow(book_presenter).to receive(:file_set_presenters).and_return([file_presenter])
expect(result['rendering']).to eq []
expect(result.key?('rendering')).to be false
end
end

Expand Down