Skip to content

Commit

Permalink
feat: refine display and formatting of notes
Browse files Browse the repository at this point in the history
  • Loading branch information
yetti committed Jun 10, 2024
1 parent e3df011 commit 07cac10
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 95 deletions.
76 changes: 21 additions & 55 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,7 @@ class CatalogController < ApplicationController
values: ->(__field_config, document, _context) { document.extract_notes_by_header("sens_adv_notice") }

# Collection Show Page - Background Section
config.add_background_field "scope_content",
label: I18n.t("ead_notes.scope_content"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.scope_contents }
config.add_background_field "scopecontent", field: "scopecontent_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,
Expand Down Expand Up @@ -348,22 +345,15 @@ class CatalogController < ApplicationController
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 "access_restrict",
label: I18n.t("ead_notes.access_restrict"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("access_restrict") }
config.add_background_field "access_strict",
label: I18n.t("ead_notes.access_strict"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("access_strict") }
config.add_background_field "accruals",
label: I18n.t("ead_notes.accruals"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("accruals") }
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,
Expand All @@ -372,44 +362,17 @@ class CatalogController < ApplicationController
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 "custod_hist",
label: I18n.t("ead_notes.custod_hist"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("custod_hist") }
config.add_background_field "dimensions",
label: I18n.t("ead_notes.dimensions"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("dimensions") }
config.add_background_field "material_spec",
label: I18n.t("ead_notes.material_spec"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("material_spec") }
config.add_background_field "phys_desc",
label: I18n.t("ead_notes.phys_desc"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("phys_desc") }
config.add_background_field "custodhist", field: "custodhist_html_tesm", 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 "related_material",
label: I18n.t("ead_notes.related_material"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("related_material") }
config.add_related_field "separated_material",
label: I18n.t("ead_notes.separated_material"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("separated_material") }
config.add_related_field "other_find_aid",
label: I18n.t("ead_notes.other_find_aid"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("other_find_aid") }
config.add_related_field "alt_form_avail",
label: I18n.t("ead_notes.alt_form_avail"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("alt_form_avail") }
config.add_related_field "origs_loc",
label: I18n.t("ead_notes.origs_loc"),
helper_method: :render_html_tags,
values: ->(__field_config, document, _context) { document.extract_notes_by_header("origs_loc") }
config.add_related_field "relatedmaterial", field: "relatedmaterial_html_tesm", helper_method: :render_html_tags
config.add_related_field "separatedmaterial", field: "separatedmaterial_html_tesm", helper_method: :render_html_tags
config.add_related_field "otherfindaid", field: "otherfindaid_html_tesm", helper_method: :render_html_tags
config.add_related_field "altformavail", field: "altformavail_html_tesm", helper_method: :render_html_tags
config.add_related_field "originalsloc", field: "originalsloc_html_tesm", helper_method: :render_html_tags

# Collection Show Page - Indexed Terms Section
config.add_indexed_terms_field "access_subjects", field: "access_subjects_ssim", link_to_facet: true, separator_options: {
Expand Down Expand Up @@ -442,19 +405,22 @@ class CatalogController < ApplicationController
}, if: lambda { |_context, _field_config, document|
document.containers.present?
}
config.add_component_field "collectionidentifier", accessor: :collection_identifier, helper_method: :render_html_tags
config.add_component_field "collectionidentifier", field: "collection_identifier", accessor: :collection_identifier, helper_method: :render_html_tags
config.add_component_field "abstract", field: "abstract_html_tesm", helper_method: :render_html_tags
config.add_component_field "extent", field: "extent_ssm"
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", accessor: :extents_information, 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
9 changes: 3 additions & 6 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,13 @@ def extents_information
end
end

def scope_contents
notes.select { |note| JSON.parse(note)["head"] == "Scope and Contents" }
.map { |note| JSON.parse(note)["p"] }
.flatten
end

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
10 changes: 1 addition & 9 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,11 @@ en:
coll_retrieval_adv: "Collection Retrieval Advice"
reading_room_access: "Reading Room Access Note"
imm_source_acq: "Immediate Source of Acquisition"
references: "References"
provenance: "Provenance"
access_restrict: "Conditions Governing Access"
access_strict: "Conditions Governing Use"
accruals: "Accruals"
arrangement: "Arrangement"
listing_rehousing: "Listing and Rehousing Note"
custod_hist: "Custodial History"
dimensions: "Dimensions"
alt_form_avail: "Existence and Location of Copies"
origs_loc: "Existence and Location of Originals"
material_spec: "Materials Specific Details"
other_find_aid: "Other Finding Aids"
phys_desc: "Physical Description"
related_material: "Related Materials"
separated_material: "Separated Materials"

16 changes: 3 additions & 13 deletions spec/models/solr_document_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,13 @@
)
end

context "when notes contains 'Scope and Contents'" do
subject(:notes_value) do
document.scope_contents
end

it "returns the notes with the matching header" do
expect(notes_value).to eq ["Includes merchants' promissory notes, Fijian treasury notes and money issued in \"New Australia\", Paraguay."]
end
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("access_strict")
document.extract_notes_by_header("imm_source_acq")
end

it "returns the notes with the matching header" do
expect(notes_value.join).to include "Copying and publishing of unpublished manuscript material is subject to copyright restrictions."
expect(notes_value.join).to include "Acquired from Tyrrell's Antiquarian Bookshop, Sydney, in 1953."
end
end

Expand All @@ -165,7 +155,7 @@
end

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

0 comments on commit 07cac10

Please sign in to comment.