Skip to content

Commit

Permalink
Merge pull request #1437 from projectblacklight/template
Browse files Browse the repository at this point in the history
Fix template with generator
  • Loading branch information
randalldfloyd authored and marlo-longley committed Dec 8, 2023
2 parents 7c1cc18 + d7bbeb6 commit bf2dc18
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 29 deletions.
4 changes: 3 additions & 1 deletion app/components/arclight/group_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
</div>
<% end %>
<h3><%= helpers.link_to_document document %></h3>
<%= 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 }) %>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<header class="documentHeader row" data-document-id="<%= @document.id %>">
<h3 class="index_title document-title-heading col">
<%= 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? %>
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/arclight/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
17 changes: 15 additions & 2 deletions lib/arclight/traject/ead2_component_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
18 changes: 16 additions & 2 deletions lib/arclight/traject/ead2_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion lib/generators/arclight/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions spec/features/grouped_results_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions spec/features/traject/ead2_indexing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
5 changes: 4 additions & 1 deletion spec/fixtures/ead/nlm/alphaomegaalpha.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@
<corpname source="ingest">Alpha Omega Alpha</corpname>
</origination>
<unitid>MS C 271</unitid>
<physdesc altrender="whole">
<physdesc altrender="part">
<extent altrender="materialtype spaceoccupied">15.0 linear feet (36 boxes + oversize
folder)</extent>
</physdesc>
<physdesc altrender="part">
<extent altrender="materialtype spaceoccupied">3 CDs</extent>
</physdesc>
<unitdate normal="1894/1992" type="inclusive">1894-1992</unitdate>
<langmaterial id="aspace_1cf405d4520ad390ab7b5532eab3ea00">Collection materials primarily in
<language langcode="eng">English.</language></langmaterial>
Expand Down
12 changes: 8 additions & 4 deletions spec/fixtures/ead/sul-spec/a0011.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,16 @@
</corpname>
</origination>
<unitid>A0011</unitid>
<physdesc altrender="whole">
<extent altrender="materialtype spaceoccupied">1.25 Linear
Feet
</extent>
<physdesc altrender="part">
<extent altrender="materialtype spaceoccupied">1.25 Linear Feet</extent>
<extent altrender="carrier">(1 volume)</extent>
</physdesc>
<physdesc altrender="part">
<extent altrender="materialtype spaceoccupied">1 document case</extent>
</physdesc>
<physdesc altrender="part">
<extent altrender="materialtype spaceoccupied">16 DVDRs</extent>
</physdesc>
<unitdate normal="1900/1906" type="inclusive">circa 1900-1906
</unitdate>
</did>
Expand Down
7 changes: 5 additions & 2 deletions spec/models/arclight/document_downloads_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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..
)
Expand Down Expand Up @@ -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'
}
}
Expand Down
10 changes: 5 additions & 5 deletions template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bf2dc18

Please sign in to comment.