Skip to content

Commit 611eb00

Browse files
committed
WIP
1 parent 64cec8f commit 611eb00

File tree

4 files changed

+104
-15
lines changed

4 files changed

+104
-15
lines changed

app/models/iiif/base_resource.rb

+60
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
class Iiif::BaseResource
2+
extend Forwardable
3+
def_delegator 'I18n', :t
4+
include FieldDisplayHelpers::Repository
25
attr_reader :id, :solr_document
36

47
def initialize(id:, solr_document:, **args)
@@ -14,6 +17,63 @@ def doi
1417
@doi ||= @solr_document[:ezid_doi_ssim].first&.sub(/^doi:/,'')
1518
end
1619

20+
def marcorg
21+
@marcorg ||= begin
22+
value_obj = {}
23+
if @solr_document[:lib_repo_code_ssim].present?
24+
value_obj[:value] = { none: @solr_document[:lib_repo_code_ssim] }
25+
else
26+
value_obj[:value] = { none: ['NNC'] }
27+
end
28+
if value_obj.present?
29+
normal_value = value_obj.dig(:value, :none).first.downcase.gsub('-', '')
30+
label_value = t("cul.archives.display_value.#{normal_value}", default: false)
31+
homepage_value = t("cul.archives.url.#{normal_value}", default: false)
32+
homepage_label = t("cul.archives.physical_location.#{normal_value}", default: false)
33+
if label_value
34+
value_obj[:value] = { en: [label_value] }
35+
value_obj[:label] = { en: ['Location'] }
36+
see_also = {}
37+
see_also[:id] = "https://id.loc.gov/vocabulary/organizations/#{normal_value}"
38+
see_also[:profile] = "https://id.loc.gov/vocabulary/organizations"
39+
40+
if homepage_value
41+
see_also[:homepage] = {
42+
id: homepage_value,
43+
label: "#{homepage_label} Homepage",
44+
type: "Text",
45+
format: "text/html"
46+
}
47+
end
48+
value_obj[:seeAlso] = [see_also]
49+
else
50+
value_obj.delete(:value)
51+
end
52+
end
53+
value_obj
54+
end
55+
end
56+
57+
def archival_collection
58+
@archival_collection ||= begin
59+
value_obj = {}
60+
bib_ids = @solr_document[:collection_key_ssim]&.select {|bib_val| bib_val =~ /^\d+$/ }
61+
if bib_ids.present?
62+
value_obj[:seeAlso] = bib_ids.map do |bib_id|
63+
{
64+
id: generate_finding_aid_url(bib_id, @solr_document),
65+
profile: 'https://clio.columbia.edu/archives',
66+
}
67+
end
68+
end
69+
if @solr_document[:lib_collection_ssm]&.first
70+
value_obj[:value] = { en: @solr_document[:lib_collection_ssm] }
71+
end
72+
value_obj[:label] = { en: ['Archival Collection'] } unless value_obj.blank?
73+
value_obj
74+
end
75+
end
76+
1777
def as_json(opts = {})
1878
{}
1979
end

app/models/iiif/manifest.rb

+31-9
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,28 @@ def metadata
2424
fields = []
2525
presenter = Dcv::ShowPresenter.new(@solr_document, @route_helper.view_context)
2626
presenter.fields_to_render do |name, field_config, field_presenter|
27+
field_presenter.except_operations << Blacklight::Rendering::Join
2728
fields << {
28-
label: { en: [field_config.label]},
29+
label: { en: [field_presenter.label]},
2930
value: { en: Array(field_presenter.render) }
30-
}
31+
} unless field_config.iiif == false
32+
end
33+
34+
if self.marcorg.present?
35+
fields << self.marcorg
3136
end
32-
33-
if @solr_document['lib_repo_full_ssim'].present?
37+
if self.doi
3438
fields << {
35-
label: { en: ['Location'] },
36-
value: { en: Array(@solr_document['lib_repo_full_ssim']) }
39+
profile: "http://purl.org/ontology/bibo/doi",
40+
seeAlso: [{ id: "https://doi.org/#{self.doi}" }],
41+
label: { none: ['DOI'] },
42+
value: { none: [self.doi] }
3743
}
3844
end
45+
if self.archival_collection.present?
46+
fields << self.archival_collection
47+
end
48+
3949
descriptor_values = descriptors
4050
if descriptor_values.present?
4151
fields.unshift({
@@ -47,7 +57,7 @@ def metadata
4757
more_at_url = route_helper.resolve_doi_url(registrant: registrant, doi: doi)
4858
fields.unshift({
4959
label: { en: ['More At'] },
50-
value: { en: ["<a href=\"#{more_at_url}\" target=\"_blank\" rel=\"nofollow, noindex, noreferrer\">#{I18n.t("blacklight.application_name")}</a>"] }
60+
value: { en: ["<a href=\"#{more_at_url}\" target=\"_blank\" rel=\"nofollow, noindex, noreferrer\">#{t("blacklight.application_name")}</a>"] }
5161
})
5262
elsif @solr_document.persistent_url
5363
fields.unshift({
@@ -95,11 +105,15 @@ def thumbnail
95105
end
96106

97107
def as_json(opts = {})
98-
manifest = {}
99-
manifest["@context"] = ["http://iiif.io/api/presentation/3/context.json"] if opts[:include]&.include?(:context)
108+
manifest = IIIF_TEMPLATES['manifest'].deep_dup
109+
manifest.delete("@context") unless opts[:include]&.include?(:context)
100110
manifest['id'] = @id
101111
manifest['type'] = 'Manifest'
102112
manifest['label'] = label
113+
manifest['provider'].first&.tap do |provider|
114+
provider['id'] = @id.split('/')[0..2].join('/')
115+
provider['label'] = { en: [I18n.t('blacklight.application_name')] }
116+
end
103117
if opts[:include]&.include?(:metadata)
104118
manifest['summary'] = summary
105119
manifest['metadata'] = metadata
@@ -122,6 +136,14 @@ def as_json(opts = {})
122136
"profile": "https://example.org/profiles/bibliographic"
123137
}
124138
end
139+
if self.archival_collection.present? && self.archival_collection[:seeAlso]&.first
140+
(manifest["seeAlso"] ||= []) << self.archival_collection[:seeAlso].first.merge({
141+
"type": "Text",
142+
"label": { "en": [ "Finding Aid" ] },
143+
"format": "text/html",
144+
"profile": self.archival_collection[:profile]
145+
})
146+
end
125147
end
126148
manifest['thumbnail'] = [thumbnail]
127149
manifest['partOf'] = Array(@part_of).map {|part| part.as_json } if @part_of.present?

config/iiif_templates.yml

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
manifest:
22
"@context": "http://iiif.io/api/presentation/3/context.json"
3-
"type": "sc:Manifest"
4-
"logo":
5-
"id": "http://cdn.cul.columbia.edu/ldpd-toolkit/img/crown-bts-24x24.png"
6-
sequences : []
3+
"type": "Manifest"
74
structures : []
5+
provider:
6+
- "type": "Agent"
7+
"logo":
8+
"id": "http://cdn.cul.columbia.edu/ldpd-toolkit/img/crown-bts-24x24.png"
9+
"partOf":
10+
"id": "https://library.columbia.edu"
11+
"type": "Agent"
12+
"label":
13+
en:
14+
- Columbia University Libraries
815
canvas :
916
"type" : "Canvas"
1017
painting_annotation :

lib/dcv/configurators/dcv_blacklight_configurator.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def self.configure_show_fields(config)
116116
config.add_show_field 'title_display_ssm', label: 'Title'
117117
config.add_show_field 'alternative_title_ssm', :label => 'Other Titles'
118118
config.add_show_field 'abstract_ssm', label: 'Abstract', helper_method: :expandable_past_400
119-
config.add_show_field 'lib_collection_ssm', label: 'Collection Name', helper_method: :display_collection_with_links
119+
config.add_show_field 'lib_collection_ssm', label: 'Collection Name', helper_method: :display_collection_with_links, iiif: false
120120
config.add_show_field 'archival_context_json_ss', label: 'Archival Context', helper_method: :display_archival_context, if: :has_archival_context?
121121
config.add_show_field 'location_shelf_locator_ssm', label: 'Shelf Location', unless: :has_archival_context?, archival_context_field: 'archival_context_json_ss'
122122
config.add_show_field 'accession_number_ssm', label: 'Accession Number'
@@ -132,7 +132,7 @@ def self.configure_show_fields(config)
132132
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
133133
config.add_show_field 'language_language_term_text_ssim', :label => 'Language', :link_to_search => 'language_language_term_text_ssim'
134134
config.add_show_field 'table_of_contents_ssm', :label => 'Contents'
135-
config.add_show_field 'lib_repo_short_ssim', label: 'Library Location', helper_method: :show_field_repository_to_facet_link, link_to_search: true
135+
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
136136
config.add_show_field 'location_sublocation_ssm', :label => 'Department'
137137
config.add_show_field 'clio_ssim', label: 'Catalog Record', helper_method: :render_link_to_clio, join: false
138138
config.add_show_field 'lib_part_ssm', :label => 'Part'

0 commit comments

Comments
 (0)