Skip to content

Commit

Permalink
Merge pull request #446 from nla/feat/blac-695_notes
Browse files Browse the repository at this point in the history
feat: display notes with alternative headings in metadata
  • Loading branch information
yetti authored Jun 10, 2024
2 parents bfda842 + 07cac10 commit e4cfc66
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 44 deletions.
74 changes: 64 additions & 10 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,19 +302,70 @@ class CatalogController < ApplicationController
config.add_summary_field "extent", field: "extent_ssm"
config.add_summary_field "language", field: "language_ssim"
config.add_summary_field "prefercite", field: "prefercite_html_tesm", helper_method: :render_html_tags
config.add_summary_field "cult_sens_adv_notice",
label: I18n.t("ead_notes.cultural_sens_adv_notice"),
helper_method: :render_html_tags,
values: ->(_field_config, document, _context) { document.extract_notes_by_header("cultural_sens_adv_notice") }
config.add_summary_field "icip_notice",
label: I18n.t("ead_notes.icip_notice"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("icip_notice") }
config.add_summary_field "sens_adv_notice",
label: I18n.t("ead_notes.sens_adv_notice"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("sens_adv_notice") }

# Collection Show Page - Background Section
config.add_background_field "scopecontent", field: "scopecontent_html_tesm", helper_method: :render_html_tags
config.add_background_field "bioghist", field: "bioghist_html_tesm", helper_method: :render_html_tags
config.add_background_field "acqinfo", field: "acqinfo_ssim", helper_method: :render_html_tags
config.add_background_field "appraisal", field: "appraisal_html_tesm", helper_method: :render_html_tags
config.add_background_field "biog_hist",
label: I18n.t("ead_notes.biog_hist"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("biog_hist") }
config.add_background_field "biog",
label: I18n.t("ead_notes.biog"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("biog") }
config.add_background_field "org_hist",
label: I18n.t("ead_notes.org_hist"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("org_hist") }
config.add_background_field "general",
label: I18n.t("ead_notes.general"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("general") }
config.add_background_field "coll_retrieval_adv",
label: I18n.t("ead_notes.coll_retrieval_adv"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("coll_retrieval_adv") }
config.add_background_field "reading_room_access",
label: I18n.t("ead_notes.reading_room_access"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("reading_room_access") }
config.add_background_field "imm_source_acq",
label: I18n.t("ead_notes.imm_source_acq"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("imm_source_acq") }
config.add_background_field "references",
label: I18n.t("ead_notes.references"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("references") }
config.add_background_field "provenance",
label: I18n.t("ead_notes.provenance"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("provenance") }
config.add_background_field "accruals", field: "accruals_html_tesm", label: I18n.t("ead_notes.accruals"), helper_method: :render_html_tags
config.add_background_field "arrangement",
label: I18n.t("ead_notes.arrangement"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("arrangement") }
config.add_background_field "listing_rehousing",
label: I18n.t("ead_notes.listing_rehousing"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("listing_rehousing") }
config.add_background_field "custodhist", field: "custodhist_html_tesm", helper_method: :render_html_tags
config.add_background_field "processinfo", field: "processinfo_html_tesm", helper_method: :render_html_tags
config.add_background_field "arrangement", field: "arrangement_html_tesm", helper_method: :render_html_tags
config.add_background_field "accruals", field: "accruals_html_tesm", helper_method: :render_html_tags
config.add_background_field "phystech", field: "phystech_html_tesm", helper_method: :render_html_tags
config.add_background_field "physloc", field: "physloc_html_tesm", helper_method: :render_html_tags
config.add_background_field "descrules", field: "descrules_ssm", helper_method: :render_html_tags
config.add_background_field "physdesc_dimensions", field: "physdesc_dimensions_ssi", label: I18n.t("ead_notes.dimensions"), helper: :render_html_tags
config.add_background_field "materialspec", field: "meterialspec_tesim", label: I18n.t("ead_notes.material_spec"), helper: :render_html_tags
config.add_background_field "physdesc", field: "physdesc_facet_ssi", label: I18n.t("ead_notes.phys_desc"), helper: :render_html_tags

# Collection Show Page - Related Section
config.add_related_field "relatedmaterial", field: "relatedmaterial_html_tesm", helper_method: :render_html_tags
Expand Down Expand Up @@ -360,13 +411,16 @@ class CatalogController < ApplicationController
config.add_component_field "scopecontent", field: "scopecontent_html_tesm", helper_method: :render_html_tags
config.add_component_field "acqinfo", field: "acqinfo_ssim", helper_method: :render_html_tags
config.add_component_field "appraisal", field: "appraisal_html_tesm", helper_method: :render_html_tags
config.add_component_field "custodhist", field: "custodhist_html_tesm", helper_method: :render_html_tags
config.add_component_field "custodhist", field: "custodhist_html_tesm", label: I18n.t("ead_notes.custod_hist"), helper_method: :render_html_tags
config.add_component_field "processinfo", field: "processinfo_html_tesm", helper_method: :render_html_tags
config.add_component_field "arrangement", field: "arrangement_html_tesm", helper_method: :render_html_tags
config.add_component_field "accruals", field: "accruals_html_tesm", helper_method: :render_html_tags
config.add_component_field "phystech", field: "phystech_html_tesm", helper_method: :render_html_tags
config.add_component_field "physloc", field: "physloc_html_tesm", helper_method: :render_html_tags
config.add_component_field "extentsinfo", field: "extents_information", accessor: :extents_information, helper_method: :render_html_tags
config.add_component_field "physdesc_dimensions", field: "physdesc_dimensions_ssi", label: I18n.t("ead_notes.dimensions"), helper: :render_html_tags
config.add_component_field "materialspec", field: "meterialspec_tesim", label: I18n.t("ead_notes.material_spec"), helper: :render_html_tags
config.add_component_field "physdesc", field: "physdesc_facet_ssi", label: I18n.t("ead_notes.phys_desc"), helper: :render_html_tags

# Component Show Page - Indexed Terms Section
config.add_component_indexed_terms_field "access_subjects", field: "access_subjects_ssim", link_to_facet: true, separator_options: {
Expand Down
45 changes: 33 additions & 12 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,40 @@ class SolrDocument

# alias this field for the request link
attribute :bibid, :string, "bibid_ssi"
attribute :physdesc_quantity, :string, "physdesc_quantity_ssi"
attribute :physdesc_unittype, :string, "physdesc_unittype_ssi"
attribute :physdesc_dimensions, :string, "physdesc_dimensions_ssi"
attribute :physdesc_facet, :string, "physdesc_facet_ssi"
attribute :notes, :array, "note_json_ssm"

# **** BEWARE! ****
# Arclight aliases "level_ssm" and "unitid_ssm" fields to String type attributes in the
# Arclight::SolrDocument concern. This means, if there are multiple values for these fields,
# calling the attribute alias will only return the first value.
# MAKE SURE YOU'RE NOT LOSING DATA BY CALLING THE ALIAS INSTEAD OF DIRECTLY ACCESSING THE FIELD!

# self.unique_key = 'id'

# DublinCore uses the semantic field mappings below to assemble an OAI-compliant Dublin Core document
# Semantic mappings of solr stored fields. Fields may be multi or
# single valued. See Blacklight::Document::SemanticFields#field_semantics
# and Blacklight::Document::SemanticFields#to_semantic_values
# Recommendation: Use field names from Dublin Core
use_extension(Blacklight::Document::DublinCore)

def collection_identifier
[self["level_ssm"]&.join(" "), self["unitid_ssm"]&.join(" ")].compact.join(" ")
end

def extents_information
quantity_unittype = [
self["physdesc_quantity_ssi"],
self["physdesc_unittype_ssi"]
physdesc_quantity,
physdesc_unittype
].compact.join(" ")

dimensions_facet = [
self["physdesc_dimensions_ssi"],
self["physdesc_facet_ssi"]
physdesc_dimensions,
physdesc_facet
].compact.join(", ")

if quantity_unittype.blank?
Expand All @@ -30,12 +50,13 @@ def extents_information
end
end

# self.unique_key = 'id'

# DublinCore uses the semantic field mappings below to assemble an OAI-compliant Dublin Core document
# Semantic mappings of solr stored fields. Fields may be multi or
# single valued. See Blacklight::Document::SemanticFields#field_semantics
# and Blacklight::Document::SemanticFields#to_semantic_values
# Recommendation: Use field names from Dublin Core
use_extension(Blacklight::Document::DublinCore)
def extract_notes_by_header(header)
# compares against the parameterized value of the header to ignore case and punctuation
# rubocop:disable Rails/OutputSafety
notes.select { |note| JSON.parse(note)["head"].parameterize == I18n.t("ead_notes.#{header}").parameterize }
.map { |note| JSON.parse(note)["p"] }
.flatten
.map { |para| "<p>#{para}</p>".html_safe }
# rubocop:enable Rails/OutputSafety
end
end
24 changes: 12 additions & 12 deletions config/locales/arclight.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ en:


collectionidentifier: Component identifier
scopecontent: Scope and content
bioghist: Biographical / historical
scopecontent: Content Summary
bioghist: Biographical / Historical
acqinfo: Immediate source of acquisition
appraisal: Appraisal information
custodhist: Custodial history
custodhist: Custodial History
processinfo: Processing information
arrangement: Arrangement
accruals: Accruals
Expand All @@ -24,11 +24,11 @@ en:
descrules: Rules or conventions
extentsinfo: Extent information

relatedmaterial: Related material
separatedmaterial: Separated material
otherfindaid: Other finding aids
altformavail: Existence and location of copies
originalsloc: Existence and location of originals
relatedmaterial: Related Material
separatedmaterial: Separated Material
otherfindaid: Other Finding Aids
altformavail: Existence and Location of Copies
originalsloc: Existence and Location of Originals

access_subjects: Subjects
names_coll: Names
Expand All @@ -37,10 +37,10 @@ en:
containers: Containers
names: Names

restrictions: Conditions governing access
terms: Conditions governing use
parent_restrictions: Parent restrictions
parent_terms: Parent terms of access
restrictions: Conditions Governing Access
terms: Conditions Governing Use
parent_restrictions: Parent Restrictions
parent_terms: Parent Terms of Access
repository_location: Location of this collection
before_you_visit: Before you visit
repository_contact: Contact
Expand Down
22 changes: 21 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,24 @@
en:
request_this: "Request this via the Catalogue"
hello: "Hello world"
collection_prefix: "Guide to the "
collection_prefix: "Guide to the "
ead_notes:
cultural_sens_adv_notice: "Cultural Sensitivity Advisory Notice"
icip_notice: "Indigenous Cultural and Intellectual Property (ICIP) Notice"
sens_adv_notice: "Sensitivity Advisory Notice"
scope_contents: "Content Summary"
biog_hist: "Biographical / Historical"
biog: "Biographical Note"
org_hist: "Organisational History Note"
general: "General"
coll_retrieval_adv: "Collection Retrieval Advice"
reading_room_access: "Reading Room Access Note"
imm_source_acq: "Immediate Source of Acquisition"
references: "References"
provenance: "Provenance"
arrangement: "Arrangement"
listing_rehousing: "Listing and Rehousing Note"
dimensions: "Dimensions"
material_spec: "Materials Specific Details"
phys_desc: "Physical Description"

18 changes: 9 additions & 9 deletions spec/components/arclight/breadcrumbs_hierarchy_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
let(:document) do
SolrDocument.new(
ead_ssi: "abc123",
repository_ssm: "National Library of Australia",
repository_ssm: ["National Library of Australia"],
_root_: "abc123",
normalized_title_ssm: "ABC123",
level_ssm: "collection"
normalized_title_ssm: ["ABC123"],
level_ssm: ["collection"]
)
end
let(:view_context) { ActionView::Base.new(nil, {}, nil) }
Expand All @@ -33,10 +33,10 @@
parent_unittitles_ssm: %w[ABC123 DEF],
parent_levels_ssm: %w[collection Series],
ead_ssi: "abc123",
repository_ssm: "National Library of Australia",
repository_ssm: ["National Library of Australia"],
_root_: "abc123",
normalized_title_ssm: "GHI",
level_ssm: "Subseries"
normalized_title_ssm: ["GHI"],
level_ssm: ["Subseries"]
)
end

Expand All @@ -62,10 +62,10 @@
parent_unittitles_ssm: %w[ABC123 DEF GHI],
parent_levels_ssm: %w[collection Series Subseries],
ead_ssi: "abc123",
repository_ssm: "National Library of Australia",
repository_ssm: ["National Library of Australia"],
_root_: "abc123",
normalized_title_ssm: "JKL",
level_ssm: "file"
normalized_title_ssm: ["JKL"],
level_ssm: ["file"]
)
end

Expand Down
46 changes: 46 additions & 0 deletions spec/models/solr_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,50 @@
end
end
end

describe "#extract_notes_by_header" do
let(:document) do
described_class.new(
note_json_ssm: ["{\"head\":\"Conditions Governing Access\",\"p\":\"Please refer to the collection's catalogue record for the access conditions (<a href=\\\"http://nla.gov.au/nla.cat-vn1132324\\\">http://nla.gov.au/nla.cat-vn1132324</a>).\",\"audience\":\"internal\"}",
"{\"head\":\"References\",\"p\":[\"References used in the creation of this finding aid include:\",\"<a href=\\\"http://nla.gov.au/nla.cat-vn5977580\\\">Australian colonial currency and promissory notes</a> by Michael P. Vort-Ronald, second edition, 2012 and <a href=\\\"http://nla.gov.au/nla.cat-vn2073970\\\">Standard catalogue of world paper money</a> by Albert Pick, vol 2, c1990.\"],\"audience\":\"internal\"}",
"{\"head\":\"Scope and Contents\",\"p\":\"Includes merchants' promissory notes, Fijian treasury notes and money issued in \\\"New Australia\\\", Paraguay.\",\"audience\":\"internal\"}",
"{\"head\":\"Conditions Governing Use\",\"p\":\"Copying and publishing of unpublished manuscript material is subject to copyright restrictions. For such material, written permission to publish must be obtained from the copyright holder(s). Copying of unpublished material for research purposes is permissible 50 years after the death of the creator of the material.\",\"audience\":\"internal\"}",
"{\"head\":\"Immediate Source of Acquisition\",\"p\":\"Acquired from Tyrrell's Antiquarian Bookshop, Sydney, in 1953.\",\"audience\":\"internal\"}"]
)
end

context "when notes contains a note with a header matching a localised string literal" do
subject(:notes_value) do
document.extract_notes_by_header("imm_source_acq")
end

it "returns the notes with the matching header" do
expect(notes_value.join).to include "Acquired from Tyrrell's Antiquarian Bookshop, Sydney, in 1953."
end
end

context "when notes does not contain a note with a header matching a localised string literal" do
subject(:notes_value) do
document.extract_notes_by_header("coll_retrieval_adv")
end

it "returns an empty array" do
expect(notes_value).to eq []
end
end

context "when header literal contains punctuation" do
subject(:notes_value) do
document = described_class.new(
note_json_ssm: ["{\"head\":\"Biographical / Historical\",\"p\":\"Testing\",\"audience\":\"internal\"}"]
)

document.extract_notes_by_header("biog_hist")
end

it "returns the notes with the matching header" do
expect(notes_value).to eq ["<p>Testing</p>"]
end
end
end
end

0 comments on commit e4cfc66

Please sign in to comment.