Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
barmintor committed Apr 23, 2024
1 parent 64cec8f commit beedb08
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 19 deletions.
60 changes: 60 additions & 0 deletions app/models/iiif/base_resource.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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
Expand Down
13 changes: 11 additions & 2 deletions app/models/iiif/canvas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def as_json(opts = {})
end
canvas['items'] = [annotation_page.to_h]
canvas['rendering'] = rendering
canvas['seeAlso'] = seeAlso
canvas.compact
end

Expand Down Expand Up @@ -68,19 +69,27 @@ def annotation_page
end

def rendering
[]
end

def seeAlso
values = []
if has_datastream?('synchronized_transcript', @solr_document)
st_id = route_helper.url_for({controller: '/catalog', action: 'synchronizer', id: @solr_document.id, mode: 'synchronized_transcript'})
values << {
id: st_id,
label: { en: ['View with Synchronized Transcript'] }
format: "text/html",
label: { en: ['View with Synchronized Transcript'] },
type: "Text"
}
end
if has_datastream?('chapters', @solr_document)
st_id = route_helper.url_for({controller: '/catalog', action: 'synchronizer', id: @solr_document.id, mode: 'chapters'})
values << {
id: st_id,
label: { en: ['View with Synchronized Index'] }
format: "text/html",
label: { en: ['View with Synchronized Index'] },
type: "Text"
}
end
values if values.present?
Expand Down
40 changes: 31 additions & 9 deletions app/models/iiif/manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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: ["<a href=\"#{more_at_url}\" target=\"_blank\" rel=\"nofollow, noindex, noreferrer\">#{I18n.t("blacklight.application_name")}</a>"] }
value: { en: ["<a href=\"#{more_at_url}\" target=\"_blank\" rel=\"nofollow, noindex, noreferrer\">#{t("blacklight.application_name")}</a>"] }
})
elsif @solr_document.persistent_url
fields.unshift({
Expand Down Expand Up @@ -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
Expand All @@ -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?
Expand Down
19 changes: 14 additions & 5 deletions config/iiif_templates.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
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 : []
"@context":
- "https://dlc.library.columbia.edu/schema/iiif/3/context.json"
- "http://iiif.io/api/presentation/3/context.json"
"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 :
Expand Down
6 changes: 3 additions & 3 deletions lib/dcv/configurators/dcv_blacklight_configurator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def self.configure_show_fields(config)
config.add_show_field 'lib_name_ssm', label: 'Name', link_to_search: 'lib_name_sim', helper_method: :display_non_copyright_names_with_roles, if: :has_non_copyright_names?
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 'abstract_ssm', label: 'Abstract', helper_method: :expandable_past_400, iiif: false
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'
Expand All @@ -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'
Expand Down

0 comments on commit beedb08

Please sign in to comment.