Skip to content

Commit

Permalink
Resolves #379 by ensuring that Collections are built using the Licens…
Browse files Browse the repository at this point in the history
…eBuilder and porting the RenderingBuilder
  • Loading branch information
jrgriffiniii committed Oct 20, 2017
1 parent c066ba4 commit ec8c48e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/services/manifest_builder/faster_iiif_manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def license=(license)
inner_hash["license"] = license
end

def rendering=(rendering)
inner_hash["rendering"] = rendering
end

def initial_attributes
{
"@context" => "http://iiif.io/api/presentation/2/context.json",
Expand Down
4 changes: 4 additions & 0 deletions app/services/manifest_builder/manifest_service_locator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def child_collection_builder
record_property_builder,
metadata_manifest_builder,
see_also_builder,
license_builder,
rendering_builder,
composite_builder: composite_builder
),
top_record_factory: iiif_collection_factory
Expand All @@ -78,6 +80,8 @@ def collection_manifest_builders
child_manifest_builder_factory,
metadata_manifest_builder,
see_also_builder,
license_builder,
rendering_builder,
composite_builder: composite_builder
)
end
Expand Down
11 changes: 9 additions & 2 deletions app/services/manifest_builder/rendering_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@ def initialize(resource)
# @param [IIIF::Presentation::Manifest] manifest the IIIF manifest being
# @return [IIIF::Presentation::Manifest]
def apply(manifest)
manifest.rendering = rendering_hash if identifier?
# This is currently here to work around https:/iiif-prezi/osullivan/issues/56
if identifier?
if manifest.is_a? FasterIIIFManifest
manifest.rendering = rendering_hash
else
manifest.insert(-1, 'rendering', rendering_hash)
end
end
manifest
end

private

def identifier?
resource.decorate.identifier.present?
resource.decorate.try(:identifier)
end

def identifier
Expand Down
8 changes: 5 additions & 3 deletions spec/services/manifest_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
call_number: 'test value2',
edition: 'test edition',
nav_date: 'test date',
identifier: 'ark:/88435/abc1234de',
imported_metadata: [{
description: "Test Description"
}])
Expand Down Expand Up @@ -64,6 +65,7 @@ def logical_structure(file_set_id)
expect(output).to be_kind_of Hash
expect(output["description"]).to eq "Test Description"
expect(output["viewingHint"]).to eq "individuals"
expect(output["rendering"]).to include "@id" => "http://arks.princeton.edu/ark:/88435/abc1234de", "format" => "text/html"
expect(output["sequences"].length).to eq 1
canvas_id = output["sequences"][0]["canvases"][0]["@id"]
expect(output["structures"].length).to eq 3
Expand Down Expand Up @@ -102,7 +104,7 @@ def logical_structure(file_set_id)
expect(output).to include 'metadata'
metadata = output["metadata"]
expect(metadata).to be_kind_of Array
expect(metadata.length).to eq(10)
expect(metadata.length).to eq(11)

metadata_object = metadata.shift
expect(metadata_object).to be_kind_of Hash
Expand Down Expand Up @@ -132,7 +134,7 @@ def logical_structure(file_set_id)
end
end
context "when given a nested child" do
let(:scanned_resource) { FactoryGirl.create_for_repository(:scanned_resource, member_ids: child.id, identifier: '5m60qr98h') }
let(:scanned_resource) { FactoryGirl.create_for_repository(:scanned_resource, member_ids: child.id, identifier: 'ark:/88435/5m60qr98h') }
let(:child) { FactoryGirl.create_for_repository(:scanned_resource, files: [file]) }
it "builds a IIIF collection" do
output = manifest_builder.build
Expand All @@ -143,7 +145,7 @@ def logical_structure(file_set_id)
expect(output["manifests"][0]["@id"]).to eq "http://www.example.com/concern/scanned_resources/#{child.id}/manifest"
expect(output["manifests"][0]["viewingHint"]).to be_nil
expect(output["seeAlso"]).to include "@id" => "http://www.example.com/catalog/#{scanned_resource.id}.jsonld", "format" => "application/ld+json"
expect(output["rendering"]).to eq "http://arks.princeton.edu/ark:/88435/5m60qr98h"
expect(output["rendering"]).to include "@id" => "http://arks.princeton.edu/ark:/88435/5m60qr98h", "format" => "text/html"
expect(output["license"]).to eq "http://rightsstatements.org/vocab/NKC/1.0/"
end
end
Expand Down

0 comments on commit ec8c48e

Please sign in to comment.