Developer Cheatsheet - UVicLibrary/Spotlight2_custom GitHub Wiki

Definitions

  • resource is a Spotlight::Resource object
  • document is a SolrDocument (sometimes ::SolrDocument) object
  • blacklight_url is the link to the Spotlight Solr instance

Commands

Create a new imported resource

Mandatory attributes:

  • url = The url to an IIIF manifest
  • exhibit_id

Optional attributes:

  • file_name Note: resource.file_type won't work if this is empty
  • data = metadata for the resource. If this is pre-filled, Spotlight will use this data. If blank, it will autofill based on the source manifest.
Spotlight::Resources::IiifHarvester.create( url: url, exhibit_id: exhibit.id, file_name: "default.jpg", data: row)

See create method for imported resources | See VaultIiifManifest for what gets indexed to Solr or saved in resource, document, and sidecar

Get a resource's file type (image, compound object, etc.)

Returns one of the following: "image", "compound_object", "video/audio", "video", "audio", "pdf","model", "unknown"

resource.file_type
#=> "image"

See definition

Get the file type of a compound object

resource.made_of?
# => "image"

See definition

Check if a resource/document is imported or uploaded

resource.imported? #=> true/false
document.uploaded_resource? #=> true/false

See .imported? definition | See .uploaded_resource? definition

Check if a compound object is imported or uploaded

resource.imported_compound_object?
#=> true/false

See definition

Delete a resource, document

This is what the delete button does in Curation > Items view. First we delete the document:

solr = RSolr.connect :url => 'blacklight_url'
doc_id = resource.compound_id
solr.delete_by_id doc_id
solr.commit

Destroy the resource:

resource.destroy

See the full method defined in the destroy action.

Get URLs for Vault Resources

document["content_metadata_image_iiif_info_ssm"]