app/controllers/spotlight/catalog_controller.rb
def manifest
      _, @document = fetch params[:id]
      if @document.uploaded_resource?
          @resource = @document.uploaded_resource
          if @resource.file_type == "image"
            source_m = Spotlight::IiifManifestPresenter.new(@document, self).iiif_manifest_json
            source_m = IIIF::Service.parse(JSON.parse(source_m))
            canvas = source_m.sequences.first.canvases.first
            resource = canvas.images.first.resource
            results = dimensions_to_i(canvas, resource)
            canvas = results[0]
            resource = results[1]
            #resource.service["@id"] = "#{resource.service['@id']}?1234567"
            add_resource_properties(source_m)
            manifest = source_m.to_json(pretty:true)
          else # If compound object, render the saved file
            doc_ids = @resource.compound_ids
            @first_resource = ::SolrDocument.find(doc_ids.first).uploaded_resource
            # Grab title from the first item in the compound object
            first_resource_title = @first_resource.data["full_title_tesim"]
            if @resource.data["full_title_tesim"].blank?
              resource_title = first_resource_title
            else
              resource_title = @resource.data["full_title_tesim"]
            end
            # See https://iiif.io/api/presentation/2.1/#attribution
            seed = {
                '@id' => "#{request.base_url}/spotlight/test-exhibit/manifest",
                'label' => resource_title
            }
            manifest = IIIF::Presentation::Manifest.new(seed)
            add_resource_properties(manifest)
            # Create sequence headers
            sequence = IIIF::Presentation::Sequence.new(
              '@id'=> "#{request.base_url}/spotlight/test-exhibit/catalog/manifest",
              '@type' => 'sc:Sequence'
              )
            # Make canvases and add them to the sequence
            sequence.canvases = make_canvases(doc_ids)
            manifest.sequences << sequence
            manifest = manifest.to_json(pretty: true)
          end
      else # Resource is imported
        source_m = Spotlight::IiifManifestPresenter.new(@document, self).iiif_manifest_json
        manifest = IIIF::Service.parse(JSON.parse(source_m))
        #byebug
        # Add attribution and logo
        add_resource_properties(manifest)
        manifest = manifest.to_json(pretty: true)
      end
        render json: manifest
    end
# Render a manifest as a raw json file
# Order of operations: Spotlight's pre-generated manifest -> modified manifest (catalog#manifest)
# -> mirador_fullscreen -> Mirador partial (renders modified manifest).
# Catalog#show calls openseadragon_default view, which has an iframe to mirador_fullscreen.
# See http://projectmirador.org/docs/docs/getting-started.html#iframe
Render a manifest as a raw json file
Order of operations: Spotlight's pre-generated manifest -> modified manifest (catalog#manifest)
> mirador_fullscreen -> Mirador partial (renders modified manifest).
Catalog#show calls openseadragon_default view, which has an iframe to mirador_fullscreen.
Render a manifest as a raw json file Order of operations : Spotlight ' s pre - generated manifest - > modified manifest ( catalog#manifest ) > mirador_fullscreen - > Mirador partial ( renders modified manifest ) . Catalog#show calls openseadragon_default view which has an iframe to mirador_fullscreen .
def manifest
      _, @document = fetch params[:id]
      if @document.uploaded_resource?
          @resource = @document.uploaded_resource
          if @resource.file_type == "image"
            source_m = Spotlight::IiifManifestPresenter.new(@document, self).iiif_manifest_json
            source_m = IIIF::Service.parse(JSON.parse(source_m))
            canvas = source_m.sequences.first.canvases.first
            resource = canvas.images.first.resource
            results = dimensions_to_i(canvas, resource)
            canvas = results[0]
            resource = results[1]
            add_resource_properties(source_m)
            manifest = source_m.to_json(pretty:true)
          else 
            doc_ids = @resource.compound_ids
            @first_resource = ::SolrDocument.find(doc_ids.first).uploaded_resource
            first_resource_title = @first_resource.data["full_title_tesim"]
            if @resource.data["full_title_tesim"].blank?
              resource_title = first_resource_title
            else
              resource_title = @resource.data["full_title_tesim"]
            end
            seed = {
                '@id' => "#{request.base_url}/spotlight/test-exhibit/manifest",
                'label' => resource_title
            }
            manifest = IIIF::Presentation::Manifest.new(seed)
            add_resource_properties(manifest)
            sequence = IIIF::Presentation::Sequence.new(
              '@id'=> "#{request.base_url}/spotlight/test-exhibit/catalog/manifest",
              '@type' => 'sc:Sequence'
              )
            sequence.canvases = make_canvases(doc_ids)
            manifest.sequences << sequence
            manifest = manifest.to_json(pretty: true)
          end
      else 
        source_m = Spotlight::IiifManifestPresenter.new(@document, self).iiif_manifest_json
        manifest = IIIF::Service.parse(JSON.parse(source_m))
        add_resource_properties(manifest)
        manifest = manifest.to_json(pretty: true)
      end
        render json: manifest
    end
def manifest _ , @document = fetch params [ :id ] if @document . uploaded_resource? @resource = @document . uploaded_resource if @resource . file_type == "image" source_m = Spotlight :: IiifManifestPresenter . new ( @document , self ) . iiif_manifest_json source_m = IIIF :: Service . parse ( JSON . parse ( source_m ) ) canvas = source_m . sequences . first . canvases . first resource = canvas . images . first . resource results = dimensions_to_i ( canvas , resource ) canvas = results [ 0 ] resource = results [ 1 ] add_resource_properties ( source_m ) manifest = source_m . to_json ( pretty : true ) else doc_ids = @resource . compound_ids @first_resource = :: SolrDocument . find ( doc_ids . first ) . uploaded_resource first_resource_title = @first_resource . data [ "full_title_tesim" ] if @resource . data [ "full_title_tesim" ] . blank? resource_title = first_resource_title else resource_title = @resource . data [ "full_title_tesim" ] end seed = { '@id' => "#{request.base_url}/spotlight/test-exhibit/manifest" , 'label' => resource_title } manifest = IIIF :: Presentation :: Manifest . new ( seed ) add_resource_properties ( manifest ) sequence = IIIF :: Presentation :: Sequence . new ( '@id' => "#{request.base_url}/spotlight/test-exhibit/catalog/manifest" , '@type' => 'sc:Sequence' ) sequence . canvases = make_canvases ( doc_ids ) manifest . sequences << sequence manifest = manifest . to_json ( pretty : true ) end else source_m = Spotlight :: IiifManifestPresenter . new ( @document , self ) . iiif_manifest_json manifest = IIIF :: Service . parse ( JSON . parse ( source_m ) ) add_resource_properties ( manifest ) manifest = manifest . to_json ( pretty : true ) end render json : manifest end
Render a manifest as a raw json file
Order of operations: Spotlight's pre-generated manifest -> modified manifest (catalog#manifest)
> mirador_fullscreen -> Mirador partial (renders modified manifest).
Render a manifest as a raw json file Order of operations : Spotlight ' s pre - generated manifest - > modified manifest ( catalog#manifest ) > mirador_fullscreen - > Mirador partial ( renders modified manifest ) .
#resource.service["@id"] = "#{resource.service['@id']}?1234567" # If compound object, render the saved file # Grab title from the first item in the compound object # See https://iiif.io/api/presentation/2.1/#attribution # Create sequence headers # Make canvases and add them to the sequence # Resource is imported #byebug # Add attribution and logo