From 62f0640fb603dc854b2d50b5363a4db63db95aad Mon Sep 17 00:00:00 2001 From: Randall Floyd Date: Tue, 19 Dec 2023 11:37:15 -0500 Subject: [PATCH] Adding bibliography/bibref elements to indexers and catalog views --- lib/arclight/traject/ead2_component_config.rb | 3 +++ lib/arclight/traject/ead2_config.rb | 4 ++++ .../arclight/templates/catalog_controller.rb | 2 ++ .../templates/config/locales/arclight.en.yml | 1 + spec/features/collection_page_spec.rb | 3 +++ spec/features/component_page_spec.rb | 2 ++ spec/features/traject/ead2_indexing_spec.rb | 19 +++++++++++++++++++ spec/fixtures/ead/nlm/alphaomegaalpha.xml | 18 ++++++++++++++++++ spec/fixtures/ead/sul-spec/a0011.xml | 15 +++++++++++++++ 9 files changed, 67 insertions(+) diff --git a/lib/arclight/traject/ead2_component_config.rb b/lib/arclight/traject/ead2_component_config.rb index 7c7d069ec..9470a81d6 100644 --- a/lib/arclight/traject/ead2_component_config.rb +++ b/lib/arclight/traject/ead2_component_config.rb @@ -297,6 +297,9 @@ end end +# Skip over elaborate bibliography text and only index list of child bibref elements +to_field 'bibref_html_tesm', extract_xpath('.//bibliography//bibref', to_text: false) + SEARCHABLE_NOTES_FIELDS.map do |selector| to_field "#{selector}_html_tesm", extract_xpath("./#{selector}/*[local-name()!='head']", to_text: false) to_field "#{selector}_heading_ssm", extract_xpath("./#{selector}/head") diff --git a/lib/arclight/traject/ead2_config.rb b/lib/arclight/traject/ead2_config.rb index 5a6958881..50f11f390 100644 --- a/lib/arclight/traject/ead2_config.rb +++ b/lib/arclight/traject/ead2_config.rb @@ -230,6 +230,10 @@ to_field 'indexes_html_tesm', extract_xpath('/ead/archdesc/index', to_text: false) to_field 'indexes_tesim', extract_xpath('/ead/archdesc/index') +# Skip over elaborate bibliography text and only index list of child bibref elements. +# The bibref elements can be in many places for collection level; ignore if in subordinate components. +to_field 'bibref_html_tesm', extract_xpath('/ead//bibliography//bibref[not(ancestor::dsc)]', to_text: false) + SEARCHABLE_NOTES_FIELDS.map do |selector| to_field "#{selector}_html_tesm", extract_xpath("/ead/archdesc/#{selector}/*[local-name()!='head']", to_text: false) do |_record, accumulator| accumulator.map!(&:to_html) diff --git a/lib/generators/arclight/templates/catalog_controller.rb b/lib/generators/arclight/templates/catalog_controller.rb index fdccba164..b6611df1d 100644 --- a/lib/generators/arclight/templates/catalog_controller.rb +++ b/lib/generators/arclight/templates/catalog_controller.rb @@ -300,6 +300,7 @@ class CatalogController < ApplicationController config.add_background_field 'fileplan', field: 'fileplan_html_tesm', helper_method: :render_html_tags config.add_background_field 'descrules', field: 'descrules_ssm', helper_method: :render_html_tags config.add_background_field 'note', field: 'note_html_tesm', helper_method: :render_html_tags + config.add_background_field 'bibref', field: 'bibref_html_tesm', helper_method: :render_html_tags # Collection Show Page - Related Section config.add_related_field 'relatedmaterial', field: 'relatedmaterial_html_tesm', helper_method: :render_html_tags @@ -369,6 +370,7 @@ class CatalogController < ApplicationController config.add_component_field 'separatedmaterial', field: 'separatedmaterial_html_tesm', helper_method: :render_html_tags config.add_component_field 'originalsloc', field: 'originalsloc_html_tesm', helper_method: :render_html_tags config.add_component_field 'note', field: 'note_html_tesm', helper_method: :render_html_tags + config.add_component_field 'bibref', field: 'bibref_html_tesm', helper_method: :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: { diff --git a/lib/generators/arclight/templates/config/locales/arclight.en.yml b/lib/generators/arclight/templates/config/locales/arclight.en.yml index 99da7c50d..534bfd1ff 100644 --- a/lib/generators/arclight/templates/config/locales/arclight.en.yml +++ b/lib/generators/arclight/templates/config/locales/arclight.en.yml @@ -23,6 +23,7 @@ en: dimensions: Dimensions indexes: Indexes descrules: Rules or conventions + bibref: Bibliography relatedmaterial: Related material separatedmaterial: Separated material diff --git a/spec/features/collection_page_spec.rb b/spec/features/collection_page_spec.rb index 6fd80f576..729c60f31 100644 --- a/spec/features/collection_page_spec.rb +++ b/spec/features/collection_page_spec.rb @@ -110,6 +110,9 @@ expect(page).to have_css('dt', text: 'Rules or conventions') expect(page).to have_css('dd', text: /^Finding aid prepared using Rules for Archival Description/) + + expect(page).to have_css('dt', text: 'Bibliography') + expect(page).to have_css('dd', text: /Medical society annual. 2008/) end end diff --git a/spec/features/component_page_spec.rb b/spec/features/component_page_spec.rb index 46dd8d4b0..f928b2136 100644 --- a/spec/features/component_page_spec.rb +++ b/spec/features/component_page_spec.rb @@ -96,6 +96,8 @@ expect(page).to have_css('dd', text: /^Boxes and folders/) expect(page).to have_css('dt', text: 'Scope and content') expect(page).to have_css('table thead tr th', text: 'GHI') + expect(page).to have_css('dt', text: 'Bibliography') + expect(page).to have_css('dd', text: /^Campus regulations. 2008/) end it 'multivalued notes are rendered as paragaphs' do diff --git a/spec/features/traject/ead2_indexing_spec.rb b/spec/features/traject/ead2_indexing_spec.rb index e97407d01..1fcc0f513 100644 --- a/spec/features/traject/ead2_indexing_spec.rb +++ b/spec/features/traject/ead2_indexing_spec.rb @@ -138,6 +138,13 @@ def components(result) end end + describe 'bibliography' do + # We skip bibliography text so only test for list of child bibref elements + it 'bibref' do + expect(result['bibref_html_tesm'].first).to match(/Campus annual/) + end + end + it 'has_online_content' do expect(result['has_online_content_ssim']).to eq [true] end @@ -568,6 +575,18 @@ def components(result) end end + describe 'bibliography' do + let(:fixture_path) do + Arclight::Engine.root.join('spec', 'fixtures', 'ead', 'nlm', 'alphaomegaalpha.xml') + end + + # We skip bibliography text so only test for list of child bibref elements + it 'bibref' do + component = all_components.find { |c| c['ref_ssi'] == ['aspace_dc2aaf83625280ae2e193beb3f4aea78'] } + expect(component['bibref_html_tesm'].first).to match(/Campus regulations/) + end + end + describe 'geognames' do let(:fixture_path) do Arclight::Engine.root.join('spec', 'fixtures', 'ead', 'nlm', 'alphaomegaalpha.xml') diff --git a/spec/fixtures/ead/nlm/alphaomegaalpha.xml b/spec/fixtures/ead/nlm/alphaomegaalpha.xml index 6c6f413d9..bb852520b 100644 --- a/spec/fixtures/ead/nlm/alphaomegaalpha.xml +++ b/spec/fixtures/ead/nlm/alphaomegaalpha.xml @@ -29,6 +29,15 @@ + + Selected Bibliography + + Medical society annual. 2008 + + + Medical society annual. 2009 + + English @@ -487,6 +496,15 @@ + + Selected Bibliography + + Campus regulations. 2008 + + + Campus regulations. 2009 + + Constitution and by-laws - drafts, 1902-1904 diff --git a/spec/fixtures/ead/sul-spec/a0011.xml b/spec/fixtures/ead/sul-spec/a0011.xml index 09f77cb89..ed4385482 100644 --- a/spec/fixtures/ead/sul-spec/a0011.xml +++ b/spec/fixtures/ead/sul-spec/a0011.xml @@ -60,6 +60,15 @@ + + Selected Bibliography + + Campus annual. 2008 + + + Campus annual. 2009 + + English @@ -165,6 +174,12 @@ + + Selected Bibliography + + Campus annual.2010 + + Photograph Album