diff --git a/app/models/iiif/base_resource.rb b/app/models/iiif/base_resource.rb index 8c5cfab0..cd012b17 100644 --- a/app/models/iiif/base_resource.rb +++ b/app/models/iiif/base_resource.rb @@ -1,4 +1,7 @@ class Iiif::BaseResource + extend Forwardable + def_delegator 'I18n', :t + include FieldDisplayHelpers::Repository attr_reader :id, :solr_document def initialize(id:, solr_document:, **args) @@ -14,6 +17,63 @@ def doi @doi ||= @solr_document[:ezid_doi_ssim].first&.sub(/^doi:/,'') end + def marcorg + @marcorg ||= begin + value_obj = {} + if @solr_document[:lib_repo_code_ssim].present? + value_obj[:value] = { none: @solr_document[:lib_repo_code_ssim] } + else + value_obj[:value] = { none: ['NNC'] } + end + if value_obj.present? + normal_value = value_obj.dig(:value, :none).first.downcase.gsub('-', '') + label_value = t("cul.archives.display_value.#{normal_value}", default: false) + homepage_value = t("cul.archives.url.#{normal_value}", default: false) + homepage_label = t("cul.archives.physical_location.#{normal_value}", default: false) + if label_value + value_obj[:value] = { en: [label_value] } + value_obj[:label] = { en: ['Location'] } + see_also = {} + see_also[:id] = "https://id.loc.gov/vocabulary/organizations/#{normal_value}" + see_also[:profile] = "https://id.loc.gov/vocabulary/organizations" + + if homepage_value + see_also[:homepage] = { + id: homepage_value, + label: "#{homepage_label} Homepage", + type: "Text", + format: "text/html" + } + end + value_obj[:seeAlso] = [see_also] + else + value_obj.delete(:value) + end + end + value_obj + end + end + + def archival_collection + @archival_collection ||= begin + value_obj = {} + bib_ids = @solr_document[:collection_key_ssim]&.select {|bib_val| bib_val =~ /^\d+$/ } + if bib_ids.present? + value_obj[:seeAlso] = bib_ids.map do |bib_id| + { + id: generate_finding_aid_url(bib_id, @solr_document), + profile: 'https://clio.columbia.edu/archives', + } + end + end + if @solr_document[:lib_collection_ssm]&.first + value_obj[:value] = { en: @solr_document[:lib_collection_ssm] } + end + value_obj[:label] = { en: ['Archival Collection'] } unless value_obj.blank? + value_obj + end + end + def as_json(opts = {}) {} end diff --git a/app/models/iiif/manifest.rb b/app/models/iiif/manifest.rb index a6ed248e..783c75d6 100644 --- a/app/models/iiif/manifest.rb +++ b/app/models/iiif/manifest.rb @@ -24,18 +24,28 @@ def metadata fields = [] presenter = Dcv::ShowPresenter.new(@solr_document, @route_helper.view_context) presenter.fields_to_render do |name, field_config, field_presenter| + field_presenter.except_operations << Blacklight::Rendering::Join fields << { - label: { en: [field_config.label]}, + label: { en: [field_presenter.label]}, value: { en: Array(field_presenter.render) } - } + } unless field_config.iiif == false + end + + if self.marcorg.present? + fields << self.marcorg end - - if @solr_document['lib_repo_full_ssim'].present? + if self.doi fields << { - label: { en: ['Location'] }, - value: { en: Array(@solr_document['lib_repo_full_ssim']) } + profile: "http://purl.org/ontology/bibo/doi", + seeAlso: [{ id: "https://doi.org/#{self.doi}" }], + label: { none: ['DOI'] }, + value: { none: [self.doi] } } end + if self.archival_collection.present? + fields << self.archival_collection + end + descriptor_values = descriptors if descriptor_values.present? fields.unshift({ @@ -47,7 +57,7 @@ def metadata more_at_url = route_helper.resolve_doi_url(registrant: registrant, doi: doi) fields.unshift({ label: { en: ['More At'] }, - value: { en: ["#{I18n.t("blacklight.application_name")}"] } + value: { en: ["#{t("blacklight.application_name")}"] } }) elsif @solr_document.persistent_url fields.unshift({ @@ -95,11 +105,15 @@ def thumbnail end def as_json(opts = {}) - manifest = {} - manifest["@context"] = ["http://iiif.io/api/presentation/3/context.json"] if opts[:include]&.include?(:context) + manifest = IIIF_TEMPLATES['manifest'].deep_dup + manifest.delete("@context") unless opts[:include]&.include?(:context) manifest['id'] = @id manifest['type'] = 'Manifest' manifest['label'] = label + manifest['provider'].first&.tap do |provider| + provider['id'] = @id.split('/')[0..2].join('/') + provider['label'] = { en: [I18n.t('blacklight.application_name')] } + end if opts[:include]&.include?(:metadata) manifest['summary'] = summary manifest['metadata'] = metadata @@ -122,6 +136,14 @@ def as_json(opts = {}) "profile": "https://example.org/profiles/bibliographic" } end + if self.archival_collection.present? && self.archival_collection[:seeAlso]&.first + (manifest["seeAlso"] ||= []) << self.archival_collection[:seeAlso].first.merge({ + "type": "Text", + "label": { "en": [ "Finding Aid" ] }, + "format": "text/html", + "profile": self.archival_collection[:profile] + }) + end end manifest['thumbnail'] = [thumbnail] manifest['partOf'] = Array(@part_of).map {|part| part.as_json } if @part_of.present? diff --git a/config/iiif_templates.yml b/config/iiif_templates.yml index 49d0522b..91e6e0ca 100644 --- a/config/iiif_templates.yml +++ b/config/iiif_templates.yml @@ -1,10 +1,17 @@ manifest: "@context": "http://iiif.io/api/presentation/3/context.json" - "type": "sc:Manifest" - "logo": - "id": "http://cdn.cul.columbia.edu/ldpd-toolkit/img/crown-bts-24x24.png" - sequences : [] + "type": "Manifest" structures : [] + provider: + - "type": "Agent" + "logo": + "id": "http://cdn.cul.columbia.edu/ldpd-toolkit/img/crown-bts-24x24.png" + "partOf": + "id": "https://library.columbia.edu" + "type": "Agent" + "label": + en: + - Columbia University Libraries canvas : "type" : "Canvas" painting_annotation : diff --git a/lib/dcv/configurators/dcv_blacklight_configurator.rb b/lib/dcv/configurators/dcv_blacklight_configurator.rb index 1107e1bf..14d5a89d 100644 --- a/lib/dcv/configurators/dcv_blacklight_configurator.rb +++ b/lib/dcv/configurators/dcv_blacklight_configurator.rb @@ -116,7 +116,7 @@ def self.configure_show_fields(config) config.add_show_field 'title_display_ssm', label: 'Title' config.add_show_field 'alternative_title_ssm', :label => 'Other Titles' config.add_show_field 'abstract_ssm', label: 'Abstract', helper_method: :expandable_past_400 - config.add_show_field 'lib_collection_ssm', label: 'Collection Name', helper_method: :display_collection_with_links + config.add_show_field 'lib_collection_ssm', label: 'Collection Name', helper_method: :display_collection_with_links, iiif: false config.add_show_field 'archival_context_json_ss', label: 'Archival Context', helper_method: :display_archival_context, if: :has_archival_context? config.add_show_field 'location_shelf_locator_ssm', label: 'Shelf Location', unless: :has_archival_context?, archival_context_field: 'archival_context_json_ss' config.add_show_field 'accession_number_ssm', label: 'Accession Number' @@ -132,7 +132,7 @@ def self.configure_show_fields(config) config.add_show_field 'dynamic_notes', pattern: /lib_.*_notes_ssm/, label: :notes_label, helper_method: :expandable_past_250, unless: :is_excepted_dynamic_field?, except: ['lib_acknowledgment_notes_ssm'], join: false config.add_show_field 'language_language_term_text_ssim', :label => 'Language', :link_to_search => 'language_language_term_text_ssim' config.add_show_field 'table_of_contents_ssm', :label => 'Contents' - config.add_show_field 'lib_repo_short_ssim', label: 'Library Location', helper_method: :show_field_repository_to_facet_link, link_to_search: true + config.add_show_field 'lib_repo_short_ssim', label: 'Library Location', helper_method: :show_field_repository_to_facet_link, link_to_search: true, iiif: false config.add_show_field 'location_sublocation_ssm', :label => 'Department' config.add_show_field 'clio_ssim', label: 'Catalog Record', helper_method: :render_link_to_clio, join: false config.add_show_field 'lib_part_ssm', :label => 'Part'