diff --git a/app/models/solr_document.rb b/app/models/solr_document.rb index a916e2e3..e7faaa13 100644 --- a/app/models/solr_document.rb +++ b/app/models/solr_document.rb @@ -401,7 +401,7 @@ def pulfalight_attributes end def content_warning - field_with_headings("scopecontent_ssim")["Content Warning"] + fetch("direct_content_warning_ssm", []) end def arclight_attributes diff --git a/lib/pulfalight/traject/ead2_component_config.rb b/lib/pulfalight/traject/ead2_component_config.rb index c6cdb291..50d0eaad 100644 --- a/lib/pulfalight/traject/ead2_component_config.rb +++ b/lib/pulfalight/traject/ead2_component_config.rb @@ -564,6 +564,7 @@ # For scope & contents, inherit ONLY content warning. if selector == "scopecontent" + context.output_hash["direct_content_warning_ssm"] = content["Content Warning"] parent = settings[:parent] || settings[:root] parent_values = Array.wrap(parent.output_hash["#{selector}_combined_tsm"].clone) # parent values is an array containing one stringified JSON hash @@ -573,10 +574,10 @@ ::JSON.parse(parent_value).slice("Content Warning") end.reduce({}, :merge) - content.reverse_merge!(parent_warning) - if content.present? - accumulator.append(::JSON.dump(content)) - scope_values = content.values.flatten + new_content = content.reverse_merge(parent_warning) + if new_content.present? + accumulator.append(::JSON.dump(new_content)) + scope_values = new_content.values.flatten context.output_hash["scopecontent_ssm"] = scope_values end diff --git a/lib/pulfalight/traject/ead2_config.rb b/lib/pulfalight/traject/ead2_config.rb index 96bcad45..31e1ad76 100644 --- a/lib/pulfalight/traject/ead2_config.rb +++ b/lib/pulfalight/traject/ead2_config.rb @@ -306,7 +306,7 @@ end to_field "#{selector}_heading_ssm", extract_xpath("/ead/archdesc/#{selector}/head") to_field "#{selector}_teim", extract_xpath("/ead/archdesc/#{selector}/*[local-name()!='head']") - to_field "#{selector}_combined_tsm", extract_xpath("/ead/archdesc/#{selector}", to_text: false) do |_record, accumulator| + to_field "#{selector}_combined_tsm", extract_xpath("/ead/archdesc/#{selector}", to_text: false) do |_record, accumulator, context| content = accumulator.each_with_object({}) do |element, hsh| header = element.xpath("./head")[0].text || "Unknown" values = element.xpath("./p").map do |el| @@ -316,6 +316,7 @@ hsh[header].concat values end accumulator.clear + context.output_hash["direct_content_warning_ssm"] = content["Content Warning"] if selector == "scopecontent" accumulator << ::JSON.dump(content) end end diff --git a/spec/features/traject/ead2_indexing_spec.rb b/spec/features/traject/ead2_indexing_spec.rb index c5fca4a2..79abcf0c 100644 --- a/spec/features/traject/ead2_indexing_spec.rb +++ b/spec/features/traject/ead2_indexing_spec.rb @@ -475,6 +475,7 @@ def all_components(result) # Ensure it's inheriting from its parent. expect(component["scopecontent_combined_tsm"][0]).not_to eq "{}" expect(component["scopecontent_ssm"][0]).to include "Many of the photographs" + expect(component["direct_content_warning_ssm"]).to be_blank json = JSON.parse(component["scopecontent_combined_tsm"][0]) expect(json["Content Warning"]).not_to be_blank # Never inherit Scope & Contents @@ -482,6 +483,17 @@ def all_components(result) end end + context "and its component does" do + let(:fixture_path) do + Rails.root.join("spec", "fixtures", "aspace", "generated", "mss", "C1372.processed.EAD.xml") + end + it "indexes a direct_content_warning" do + component = find_component(result, "C1372_c47202-68234") + + expect(component["direct_content_warning_ssm"]).not_to be_blank + end + end + context "when child had a non-warning scopecontent note" do let(:fixture_path) do Rails.root.join("spec", "fixtures", "aspace", "generated", "mss", "WC064.processed.EAD.xml") @@ -492,6 +504,8 @@ def all_components(result) # Ensure it's inheriting from its parent. expect(component["scopecontent_combined_tsm"][0]).not_to eq "{}" expect(component["scopecontent_ssm"][0]).to include "harmful descriptions" + expect(component["direct_content_warning_ssm"]).to be_blank + expect(result["direct_content_warning_ssm"]).not_to be_blank json = JSON.parse(component["scopecontent_combined_tsm"][0]) expect(json["Content Warning"]).not_to be_blank end diff --git a/spec/fixtures/aspace/generated/mss/TC040.processed.EAD.xml b/spec/fixtures/aspace/generated/mss/TC040.processed.EAD.xml index 01eadece..9fc70215 100644 --- a/spec/fixtures/aspace/generated/mss/TC040.processed.EAD.xml +++ b/spec/fixtures/aspace/generated/mss/TC040.processed.EAD.xml @@ -214,6 +214,6 @@ In 2022, restrictions on glass-plate negatives were lifted as part of a restrict Scrapbooks. Barnum and Bailey - Series 1: Photographs/repositories/5/archival_objects/79465316 boxes8 items1854-1903Scope and Contents

Consists of photographs of exotica, performers, animal acts, "freaks," and equipment used by the circus.

Arrangement

Arranged by subject of photograph.

Content Warning

Many of the photographs in this series contain dehumanizing and harmful descriptions using racist, colonialist, and ableist language. In the majority of cases, the descriptions of people have been transcribed from the photographs themselves. Some of the photographs have been stamped with titles (likely by the original photographic studio); other titles are handwritten. In cases where photographs have no title, descriptions derive from a typewritten inventory of the collection that may have been provided by the donor, or may have been created by an archivist.

Exotica/repositories/5/archival_objects/7946564 boxes1878-1900 November
+ Series 1: Photographs/repositories/5/archival_objects/79465316 boxes8 items1854-1903Scope and Contents

Consists of photographs of exotica, performers, animal acts, "freaks," and equipment used by the circus.

Arrangement

Arranged by subject of photograph.

Content Warning

Many of the photographs in this series contain dehumanizing and harmful descriptions using racist, colonialist, and ableist language. In the majority of cases, the descriptions of people have been transcribed from the photographs themselves. Some of the photographs have been stamped with titles (likely by the original photographic studio); other titles are handwritten. In cases where photographs have no title, descriptions derive from a typewritten inventory of the collection that may have been provided by the donor, or may have been created by an archivist.

Exotica/repositories/5/archival_objects/7946564 boxes1878-1900 NovemberElephant, with native rider, lifting wood beam/repositories/5/archival_objects/7947491 itemdates not examined144

View digital content

diff --git a/spec/requests/catalog_controller_spec.rb b/spec/requests/catalog_controller_spec.rb index 2caa5515..a2adf9ef 100644 --- a/spec/requests/catalog_controller_spec.rb +++ b/spec/requests/catalog_controller_spec.rb @@ -140,6 +140,12 @@ json_body = JSON.parse(response.body) expect(json_body["content_warning"]).to eq ['The "Revolution in China" album contains photographs of dead bodies.'] end + it "doesn't render it for content warnings inherited from the series" do + get "/catalog/TC040_c00034.json" + json_body = JSON.parse(response.body) + + expect(json_body["content_warning"]).to be_blank + end end context "for a collection" do it "renders sufficient JSON for Figgy to use" do