diff --git a/app/components/arclight/group_component.html.erb b/app/components/arclight/group_component.html.erb index 8d96e6d04..6fecd240d 100644 --- a/app/components/arclight/group_component.html.erb +++ b/app/components/arclight/group_component.html.erb @@ -7,7 +7,9 @@ <% end %>

<%= helpers.link_to_document document %>

- <%= tag.span(document.extent, class: 'al-document-extent badge') if document.extent %> + <% document.extent.each do |extent| %> + <%= tag.span extent, class: 'al-document-extent badge' %> + <% end %> <%= render Arclight::IndexMetadataFieldComponent.with_collection(presenter.field_presenters.select { |field| !compact? || field.field_config.compact }) %> diff --git a/app/components/arclight/search_result_title_component.html.erb b/app/components/arclight/search_result_title_component.html.erb index 79e67b422..b622fa806 100644 --- a/app/components/arclight/search_result_title_component.html.erb +++ b/app/components/arclight/search_result_title_component.html.erb @@ -1,7 +1,9 @@

<%= helpers.link_to_document @document, counter: @counter %> - <%= tag.span @document.extent, class: 'al-document-extent badge' if @document.extent && !compact? %> + <% @document.extent.each do |extent| %> + <%= tag.span extent, class: 'al-document-extent badge' unless compact? %> + <% end %> <%= tag.span class: 'al-document-container text-muted ml-auto' do %> <%= @document.containers.join(', ') %> <% end if @document.containers.present? %> diff --git a/app/models/concerns/arclight/solr_document.rb b/app/models/concerns/arclight/solr_document.rb index 41f182b21..3e2148cf0 100644 --- a/app/models/concerns/arclight/solr_document.rb +++ b/app/models/concerns/arclight/solr_document.rb @@ -11,7 +11,7 @@ module SolrDocument attribute :parent_labels, :array, 'parent_unittitles_ssm' attribute :parent_levels, :array, 'parent_levels_ssm' attribute :unitid, :string, 'unitid_ssm' - attribute :extent, :string, 'extent_ssm' + attribute :extent, :array, 'extent_ssm' attribute :abstract, :string, 'abstract_html_tesm' attribute :scope, :string, 'scopecontent_html_tesm' attribute :creator, :string, 'creator_ssm' diff --git a/lib/arclight/traject/ead2_component_config.rb b/lib/arclight/traject/ead2_component_config.rb index 61a9c54ce..ea8615c6c 100644 --- a/lib/arclight/traject/ead2_component_config.rb +++ b/lib/arclight/traject/ead2_component_config.rb @@ -155,8 +155,21 @@ accumulator.concat settings[:root].output_hash['normalized_title_ssm'] end -to_field 'extent_ssm', extract_xpath('./did/physdesc/extent') -to_field 'extent_tesim', extract_xpath('./did/physdesc/extent') +to_field 'extent_ssm' do |record, accumulator| + physdescs = record.xpath('./did/physdesc') + extents_per_physdesc = physdescs.map do |physdesc| + extents = physdesc.xpath('./extent').map { |e| e.text.strip } + # Join extents within the same physdesc with an empty string + extents.join(' ') + end + + # Add each physdesc separately to the accumulator + accumulator.concat(extents_per_physdesc) +end + +to_field 'extent_tesim' do |_record, accumulator, context| + accumulator.concat context.output_hash['extent_ssm'] || [] +end to_field 'creator_ssm', extract_xpath('./did/origination') to_field 'creator_ssim', extract_xpath('./did/origination') diff --git a/lib/arclight/traject/ead2_config.rb b/lib/arclight/traject/ead2_config.rb index 7bbe178ab..f86fd5113 100644 --- a/lib/arclight/traject/ead2_config.rb +++ b/lib/arclight/traject/ead2_config.rb @@ -185,8 +185,22 @@ end end -to_field 'extent_ssm', extract_xpath('/ead/archdesc/did/physdesc/extent') -to_field 'extent_tesim', extract_xpath('/ead/archdesc/did/physdesc/extent') +to_field 'extent_ssm' do |record, accumulator| + physdescs = record.xpath('/ead/archdesc/did/physdesc') + extents_per_physdesc = physdescs.map do |physdesc| + extents = physdesc.xpath('./extent').map { |e| e.text.strip } + # Join extents within the same physdesc with an empty string + extents.join(' ') + end + + # Add each physdesc separately to the accumulator + accumulator.concat(extents_per_physdesc) +end + +to_field 'extent_tesim' do |_record, accumulator, context| + accumulator.concat context.output_hash['extent_ssm'] || [] +end + to_field 'genreform_ssim', extract_xpath('/ead/archdesc/controlaccess/genreform') to_field 'date_range_ssim', extract_xpath('/ead/archdesc/did/unitdate/@normal', to_text: false) do |_record, accumulator| diff --git a/lib/generators/arclight/install_generator.rb b/lib/generators/arclight/install_generator.rb index aa7b4dfce..3bacb7171 100644 --- a/lib/generators/arclight/install_generator.rb +++ b/lib/generators/arclight/install_generator.rb @@ -22,7 +22,7 @@ def include_arclight_solrdocument def install_blacklight_locale_picker gem 'blacklight-locale_picker' - Bundler.with_clean_env do + Bundler.with_unbundled_env do run 'bundle install' end diff --git a/spec/features/grouped_results_spec.rb b/spec/features/grouped_results_spec.rb index 2bb92cf0f..c4038e2cd 100644 --- a/spec/features/grouped_results_spec.rb +++ b/spec/features/grouped_results_spec.rb @@ -4,14 +4,14 @@ RSpec.describe 'Grouped search results' do it 'displays collection group information' do - visit search_catalog_path q: 'alpha omega', group: 'true' + visit search_catalog_path q: 'student life', group: 'true' within '.al-grouped-title-bar' do - expect(page).to have_css 'h3 a', text: /Alpha/ - expect(page).to have_css '.al-document-abstract-or-scope', text: /founded in 1902/ - expect(page).to have_css '.badge', text: '15.0 linear feet (36 boxes + oversize folder)' + expect(page).to have_css 'h3 a', text: /photograph album/ + expect(page).to have_css '.al-document-abstract-or-scope', text: /track meets/ + expect(page).to have_css('.al-document-extent.badge', count: 3) end within '.grouped-documents' do - expect(page).to have_css 'article', count: 3 + expect(page).to have_css 'article', count: 1 end end @@ -52,7 +52,7 @@ within '.al-grouped-title-bar' do expect(page).to have_css 'h3 a', text: /Alpha/ expect(page).not_to have_css '.al-document-abstract-or-scope', text: /founded in 1902/ - expect(page).to have_css '.badge', text: '15.0 linear feet (36 boxes + oversize folder)' + expect(page).not_to have_css('.badge') end end end diff --git a/spec/features/traject/ead2_indexing_spec.rb b/spec/features/traject/ead2_indexing_spec.rb index 6a23ccb6b..a7b94fd09 100644 --- a/spec/features/traject/ead2_indexing_spec.rb +++ b/spec/features/traject/ead2_indexing_spec.rb @@ -120,6 +120,10 @@ def components(result) expect(result['places_ssim']).to equal_array_ignoring_whitespace ['Yosemite National Park (Calif.)'] end + it 'physdesc' do + expect(result['extent_ssm']).to equal_array_ignoring_whitespace ['1.25 Linear Feet (1 volume)', '1 document case', '16 DVDRs'] + end + it 'has_online_content' do expect(result['has_online_content_ssim']).to eq [true] end @@ -293,9 +297,7 @@ def components(result) it 'extent at the collection level' do %w[extent_ssm extent_tesim].each do |field| - expect(result[field]).to equal_array_ignoring_whitespace( - ['15.0 linear feet (36 boxes + oversize folder)'] - ) + expect(result[field]).to equal_array_ignoring_whitespace(['15.0 linear feet (36 boxes + oversize folder)', '3 CDs']) end end diff --git a/spec/fixtures/ead/nlm/alphaomegaalpha.xml b/spec/fixtures/ead/nlm/alphaomegaalpha.xml index 0f3184e09..2fd8eebc9 100644 --- a/spec/fixtures/ead/nlm/alphaomegaalpha.xml +++ b/spec/fixtures/ead/nlm/alphaomegaalpha.xml @@ -41,10 +41,13 @@ Alpha Omega Alpha MS C 271 - + 15.0 linear feet (36 boxes + oversize folder) + + 3 CDs + 1894-1992 Collection materials primarily in English. diff --git a/spec/fixtures/ead/sul-spec/a0011.xml b/spec/fixtures/ead/sul-spec/a0011.xml index 3bf53718c..8563271fa 100644 --- a/spec/fixtures/ead/sul-spec/a0011.xml +++ b/spec/fixtures/ead/sul-spec/a0011.xml @@ -77,12 +77,16 @@ A0011 - - 1.25 Linear - Feet - + + 1.25 Linear Feet (1 volume) + + 1 document case + + + 16 DVDRs + circa 1900-1906 diff --git a/spec/models/arclight/document_downloads_spec.rb b/spec/models/arclight/document_downloads_spec.rb index 71ed380d6..f0f0f784c 100644 --- a/spec/models/arclight/document_downloads_spec.rb +++ b/spec/models/arclight/document_downloads_spec.rb @@ -10,7 +10,6 @@ id: 'abc123', unitid_ssm: ['sample_unitid'], userestrict_html_tesm: ['The Terms of the Collection'], - extent_ssm: ['42GB'], # This field does not typically hold file size, but for test purposes.. level_ssm: ['collection'], ref_ssm: ['http://example.com/finding-aid.pdf'] # This field does not typically hold URLs, but for test purposes.. ) @@ -55,10 +54,14 @@ end context 'when a size_accessor is provided for the size' do + before do + allow(document).to receive(:finding_aid_size).and_return('42GB') + end + let(:file_params) do { data: { - 'size_accessor' => 'extent', + 'size_accessor' => 'finding_aid_size', 'href' => 'http://example.com/finding-aid.pdf' } } diff --git a/template.rb b/template.rb index f9d5a92cf..d5aa2668a 100644 --- a/template.rb +++ b/template.rb @@ -2,9 +2,9 @@ gem 'arclight' -run 'bundle install' +after_bundle do + generate 'blacklight:install', '--devise' + generate 'arclight:install', '-f' -generate 'blacklight:install', '--devise' -generate 'arclight:install', '-f' - -rake 'db:migrate' + rake 'db:migrate' +end