Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking change: component identifier format #1478

Merged
merged 6 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/arclight/breadcrumb_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def components
yield build_repository_link

@document.parents.each do |parent|
yield tag.li(class: 'breadcrumb-item') { link_to(parent.label, solr_document_path(parent.global_id)) }
yield tag.li(class: 'breadcrumb-item') { link_to(parent.label, solr_document_path(parent.id)) }
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<% if collection %>
<li class="breadcrumb-item breadcrumb-item-2">
<span aria-hidden="true"><%= blacklight_icon :collection, classes: 'al-collection-content-icon' %></span>
<span class="breadcrumb-text"><%= link_to collection.label, solr_document_path(collection.global_id) %></span>
<span class="breadcrumb-text"><%= link_to collection.label, solr_document_path(collection.id) %></span>

<ol class="breadcrumb">
<% parents_under_collection.each do |parent| %>
<li class="breadcrumb-item breadcrumb-item-3">
<span class="breadcrumb-text"><%= link_to parent.label, solr_document_path(parent.global_id) %></span>
<span class="breadcrumb-text"><%= link_to parent.label, solr_document_path(parent.id) %></span>
</li>
<% end %>

Expand Down
10 changes: 0 additions & 10 deletions app/models/arclight/parent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,5 @@ def initialize(id:, label:, eadid:, level:)
def collection?
level == 'collection'
end

##
# Concatenates the eadid and the id, to return an "id" in the context of
# Blacklight and Solr
# @return [String]
def global_id
return id if eadid == id

"#{eadid}#{id}"
end
end
end
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 @@ -7,7 +7,7 @@ module SolrDocument
extend ActiveSupport::Concern

included do
attribute :parent_ids, :array, 'parent_ssim'
attribute :parent_ids, :array, 'parent_ids_ssim'
attribute :parent_labels, :array, 'parent_unittitles_ssm'
attribute :parent_levels, :array, 'parent_levels_ssm'
attribute :unitid, :string, 'unitid_ssm'
Expand Down
23 changes: 18 additions & 5 deletions lib/arclight/traject/ead2_component_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
provide 'title_normalizer', 'Arclight::NormalizedTitle'
provide 'reader_class_name', 'Arclight::Traject::NokogiriNamespacelessReader'
provide 'logger', Logger.new($stderr)
provide 'component_identifier_format', '%<root_id>s_%<ref_id>s'
end

NAME_ELEMENTS = %w[corpname famname name persname].freeze
Expand Down Expand Up @@ -67,7 +68,9 @@
#
# NOTE: All fields should be stored in Solr
# ==================
to_field 'ref_ssi' do |record, accumulator, _context|
to_field 'ref_ssi' do |record, accumulator, context|
next if context.output_hash['ref_ssi']

accumulator << if record.attribute('id').blank?
strategy = Arclight::MissingIdStrategy.selected
hexdigest = strategy.new(record).to_hexdigest
Expand All @@ -90,10 +93,14 @@
end

to_field 'id' do |_record, accumulator, context|
accumulator << [
settings[:root].output_hash['id'],
context.output_hash['ref_ssi']
].join
next if context.output_hash['id']

data = {
root_id: settings[:root].output_hash['id']&.first,
ref_id: context.output_hash['ref_ssi']&.first
}

accumulator << (settings[:component_identifier_format] % data)
end

to_field 'title_filing_ssi', extract_xpath('./did/unittitle'), first_only
Expand Down Expand Up @@ -131,6 +138,11 @@
accumulator.concat settings[:parent].output_hash['ref_ssi'] || settings[:parent].output_hash['id']
end

to_field 'parent_ids_ssim' do |_record, accumulator, _context|
accumulator.concat(settings[:parent].output_hash['parent_ids_ssim'] || [])
accumulator.concat settings[:parent].output_hash['id']
end

to_field 'parent_unittitles_ssm' do |_rec, accumulator, _context|
accumulator.concat(settings[:parent].output_hash['parent_unittitles_ssm'] || [])
accumulator.concat settings[:parent].output_hash['normalized_title_ssm'] || []
Expand Down Expand Up @@ -293,6 +305,7 @@
provide :counter, context.settings[:counter]
provide :depth, context.settings[:depth].to_i + 1
provide :component_traject_config, context.settings[:component_traject_config]
provide :component_identifier_format, context.settings[:component_identifier_format]
end

i.load_config_file(context.settings[:component_traject_config])
Expand Down
18 changes: 10 additions & 8 deletions spec/components/arclight/breadcrumb_component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
RSpec.describe Arclight::BreadcrumbComponent, type: :component do
let(:document) do
SolrDocument.new(
parent_ssim: %w[def ghi],
parent_unittitles_ssm: %w[DEF GHI],
parent_ids_ssim: %w[abc123 abc123_def abc123_ghi],
parent_unittitles_ssm: %w[ABC123 DEF GHI],
ead_ssi: 'abc123',
repository_ssm: 'my repository'
)
Expand All @@ -29,8 +29,9 @@

it 'renders only that many breadcrumb links' do
expect(rendered).to have_selector 'li', text: 'my repository'
expect(rendered).to have_link 'DEF', href: '/catalog/abc123def'
expect(rendered).not_to have_link 'GHI', href: '/catalog/abc123ghi'
expect(rendered).to have_link 'ABC123', href: '/catalog/abc123'
expect(rendered).not_to have_link 'DEF', href: '/catalog/abc123_def'
expect(rendered).not_to have_link 'GHI', href: '/catalog/abc123_ghi'
end

it 'renders an ellipsis if there are more links than the count' do
Expand All @@ -43,14 +44,15 @@

it 'skips some breadcrumb links' do
expect(rendered).not_to have_selector 'li', text: 'my repository'
expect(rendered).not_to have_link 'DEF', href: '/catalog/abc123def'
expect(rendered).to have_link 'GHI', href: '/catalog/abc123ghi'
expect(rendered).not_to have_link 'ABC123', href: '/catalog/abc123'
expect(rendered).to have_link 'DEF', href: '/catalog/abc123_def'
expect(rendered).to have_link 'GHI', href: '/catalog/abc123_ghi'
end
end

it 'renders breadcrumb links' do
expect(rendered).to have_selector 'li', text: 'my repository'
expect(rendered).to have_link 'DEF', href: '/catalog/abc123def'
expect(rendered).to have_link 'GHI', href: '/catalog/abc123ghi'
expect(rendered).to have_link 'DEF', href: '/catalog/abc123_def'
expect(rendered).to have_link 'GHI', href: '/catalog/abc123_ghi'
end
end
2 changes: 1 addition & 1 deletion spec/features/aeon_web_ead_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
it 'creates a request link' do
visit solr_document_path 'm0198-xml'

within '#m0198-xmlaspace_ref11_d0s-hierarchy-item' do
within '#m0198-xml_aspace_ref11_d0s-hierarchy-item' do
click_link 'Pages 1-78'
end
expect(page).to have_css(
Expand Down
2 changes: 1 addition & 1 deletion spec/features/arclight_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

describe 'eadid with a period' do
it 'is visitable with a hyphen' do
visit solr_document_path('m0198-xmlaspace_ref11_d0s')
visit solr_document_path('m0198-xml_aspace_ref11_d0s')
expect(page).to have_css 'h1', text: 'Pages 1-78'
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/features/bookmarks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

RSpec.describe 'Bookmarks' do
it 'shows bookmarks as checkboxes', js: true do
visit solr_document_path('aoa271aspace_a951375d104030369a993ff943f61a77')
visit solr_document_path('aoa271_aspace_a951375d104030369a993ff943f61a77')
check 'Bookmark'
click_link 'Bookmarks'

visit solr_document_path('aoa271aspace_a951375d104030369a993ff943f61a77')
visit solr_document_path('aoa271_aspace_a951375d104030369a993ff943f61a77')
expect(page).to have_css('input[type="checkbox"][checked]')
uncheck 'In Bookmarks'
end
Expand Down
12 changes: 6 additions & 6 deletions spec/features/collection_context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'spec_helper'

RSpec.describe 'Collection context', js: true do
let(:doc_id) { 'aoa271aspace_6ea193f778e553ca9ea0d00a3e5a1891' }
let(:doc_id) { 'aoa271_aspace_6ea193f778e553ca9ea0d00a3e5a1891' }

before do
visit solr_document_path(id: doc_id)
Expand All @@ -15,17 +15,17 @@
end

it 'siblings are not expanded' do
expect(page).to have_css '.al-toggle-view-children.collapsed[href="#collapsible-hierarchy-aoa271aspace_b70574c7229e6f237f780579cc04595d"]'
expect(page).to have_css '.al-toggle-view-children.collapsed[href="#collapsible-hierarchy-aoa271_aspace_b70574c7229e6f237f780579cc04595d"]'
end

it 'direct ancestors are expanded' do
expect(page).to have_css '#collapsible-hierarchy-aoa271aspace_f934f1add34289f28bd0feb478e68275.show', visible: :visible
expect(page).to have_css '#collapsible-hierarchy-aoa271aspace_238a0567431f36f49acea49ef576d408.show', visible: :visible
expect(page).to have_css '#collapsible-hierarchy-aoa271aspace_563a320bb37d24a9e1e6f7bf95b52671.show', visible: :visible
expect(page).to have_css '#collapsible-hierarchy-aoa271_aspace_f934f1add34289f28bd0feb478e68275.show', visible: :visible
expect(page).to have_css '#collapsible-hierarchy-aoa271_aspace_238a0567431f36f49acea49ef576d408.show', visible: :visible
expect(page).to have_css '#collapsible-hierarchy-aoa271_aspace_563a320bb37d24a9e1e6f7bf95b52671.show', visible: :visible
end

it 'siblings above are hidden' do
expect(page).not_to have_css '#aoa271aspace_843e8f9f22bac69872d0802d6fffbb04'
expect(page).not_to have_css '#aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04'
end
end
end
6 changes: 3 additions & 3 deletions spec/features/collection_filtering_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@

context 'when on a record view' do
it 'has the a select input with the "this collection" option selected' do
visit solr_document_path('lc0100aspace_327a75c226d44aa1a769edb4d2f13c6e')
visit solr_document_path('lc0100_aspace_327a75c226d44aa1a769edb4d2f13c6e')

within 'form.search-query-form' do
expect(page).to have_select('Search', selected: 'this collection')
end
end

it 'searches within the collection context by default' do
visit solr_document_path('aoa271aspace_dba76dab6f750f31aa5fc73e5402e71d')
visit solr_document_path('aoa271_aspace_dba76dab6f750f31aa5fc73e5402e71d')

fill_in 'q', with: 'File'
click_button 'Search'
Expand All @@ -56,7 +56,7 @@
end

it 'allows the user to choose to search all collections' do
visit solr_document_path('aoa271aspace_dba76dab6f750f31aa5fc73e5402e71d')
visit solr_document_path('aoa271_aspace_dba76dab6f750f31aa5fc73e5402e71d')

select 'all collections', from: 'Search within'
fill_in 'q', with: 'File'
Expand Down
16 changes: 8 additions & 8 deletions spec/features/collection_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,20 @@

it 'sub components are viewable and expandable' do
within '#collection-context' do
within '#aoa271aspace_563a320bb37d24a9e1e6f7bf95b52671-hierarchy-item' do
within '#aoa271_aspace_563a320bb37d24a9e1e6f7bf95b52671-hierarchy-item' do
click_link 'View'
within '#aoa271aspace_dc2aaf83625280ae2e193beb3f4aea78-hierarchy-item.al-collection-context' do
within '#aoa271_aspace_dc2aaf83625280ae2e193beb3f4aea78-hierarchy-item.al-collection-context' do
expect(page).to have_link 'Constitution and by-laws'
end
click_link 'Expand'
expect(page).to have_link 'Reports'
el = find_by_id('aoa271aspace_238a0567431f36f49acea49ef576d408-hierarchy-item')
el = find_by_id('aoa271_aspace_238a0567431f36f49acea49ef576d408-hierarchy-item')
evaluate_script "window.scrollTo(0,#{el.rect.y - 100})"
sleep 1
within '#aoa271aspace_238a0567431f36f49acea49ef576d408-hierarchy-item' do
within '#aoa271_aspace_238a0567431f36f49acea49ef576d408-hierarchy-item' do
click_link 'View'
expect(page).to have_link 'Expansion Plan'
within '#aoa271aspace_f934f1add34289f28bd0feb478e68275-hierarchy-item' do
within '#aoa271_aspace_f934f1add34289f28bd0feb478e68275-hierarchy-item' do
click_link 'View'
expect(page).to have_link 'Initial Phase'
expect(page).to have_link 'Phase II: Expansion'
Expand All @@ -215,7 +215,7 @@
end

it 'includes the number of direct children of the component' do
within '#aoa271aspace_563a320bb37d24a9e1e6f7bf95b52671-hierarchy-item' do
within '#aoa271_aspace_563a320bb37d24a9e1e6f7bf95b52671-hierarchy-item' do
expect(page).to have_css(
'.al-number-of-children-badge',
text: /25/
Expand Down Expand Up @@ -243,7 +243,7 @@
end

context 'content with file downloads', js: true do
let(:doc_id) { 'a0011-xmlaspace_ref6_lx4' }
let(:doc_id) { 'a0011-xml_aspace_ref6_lx4' }

it 'renders links to the files for download' do
within '.al-show-actions-box-downloads-container' do
Expand All @@ -260,7 +260,7 @@
end

context 'with EAD documents which require Aeon requests' do
let(:doc_id) { 'm0198-xmlaspace_ref11_d0s' }
let(:doc_id) { 'm0198-xml_aspace_ref11_d0s' }

it 'renders links to the Aeon request form' do
expect(page).to have_css '.al-request'
Expand Down
22 changes: 11 additions & 11 deletions spec/features/component_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'spec_helper'

RSpec.describe 'Component Page' do
let(:doc_id) { 'aoa271aspace_843e8f9f22bac69872d0802d6fffbb04' }
let(:doc_id) { 'aoa271_aspace_843e8f9f22bac69872d0802d6fffbb04' }
let(:download_config) do
ActiveSupport::HashWithIndifferentAccess.new(
default: {
Expand Down Expand Up @@ -52,7 +52,7 @@
end

describe 'Indexed Terms subjects section' do
let(:doc_id) { 'aoa271aspace_01daa89087641f7fc9dbd7a10d3f2da9' }
let(:doc_id) { 'aoa271_aspace_01daa89087641f7fc9dbd7a10d3f2da9' }

it 'includes subjects dt subheading text' do
expect(page).to have_css('dt.blacklight-access_subjects', text: 'Subjects:')
Expand All @@ -70,7 +70,7 @@
end

describe 'metadata' do
let(:doc_id) { 'aoa271aspace_dc2aaf83625280ae2e193beb3f4aea78' }
let(:doc_id) { 'aoa271_aspace_dc2aaf83625280ae2e193beb3f4aea78' }

it 'uses our rules for displaying containers' do
expect(page).to have_css('dd', text: 'Box 1, Folder 4-5')
Expand Down Expand Up @@ -143,7 +143,7 @@
end

context 'duplicate titles' do
let(:doc_id) { 'lc0100aspace_c5ef89d4ae68bb77e7c641f3edb3f1c8' }
let(:doc_id) { 'lc0100_aspace_c5ef89d4ae68bb77e7c641f3edb3f1c8' }

it 'does not highlight duplicate titles' do
within '#collection-context .al-hierarchy-highlight' do
Expand All @@ -153,7 +153,7 @@
end

context 'when there are more than ten previous sibling documents for the current document' do
let(:doc_id) { 'lc0100aspace_ca60f0c03c4638b89e0348c3c6f7b50e' }
let(:doc_id) { 'lc0100_aspace_ca60f0c03c4638b89e0348c3c6f7b50e' }

it 'hides all but the first sibling document items' do
within '#collection-context' do
Expand All @@ -178,18 +178,18 @@
end

context 'when on a deeply nested component' do
let(:doc_id) { 'aoa271aspace_6ea193f778e553ca9ea0d00a3e5a1891' }
let(:doc_id) { 'aoa271_aspace_6ea193f778e553ca9ea0d00a3e5a1891' }

it 'enables expanding nodes outside of own ancestor tree' do
within '#collection-context' do
find('#aoa271aspace_01daa89087641f7fc9dbd7a10d3f2da9-hierarchy-item .al-toggle-view-children').click
find('#aoa271_aspace_01daa89087641f7fc9dbd7a10d3f2da9-hierarchy-item .al-toggle-view-children').click
expect(page).to have_css '.document-title-heading', text: 'Miscellaneous 1999'
end
end

it 'includes ancestor\'s preceding sibling when clicking ancestor\'s Expand button' do
within '#collection-context' do
within('#collapsible-hierarchy-aoa271aspace_563a320bb37d24a9e1e6f7bf95b52671') do
within('#collapsible-hierarchy-aoa271_aspace_563a320bb37d24a9e1e6f7bf95b52671') do
first('.btn-secondary', text: 'Expand').click
end
expect(page).to have_css '.document-title-heading', text: 'Officers and directors - lists, 1961, n.d.'
Expand All @@ -198,11 +198,11 @@
end

context 'when on a component with an eadid with . normalized to -' do
let(:doc_id) { 'pc0170-xmlaspace_ref1_z0j' }
let(:doc_id) { 'pc0170-xml_aspace_ref1_z0j' }

it 'expands child nodes when clicked' do
within '#collection-context' do
find('#pc0170-xmlaspace_ref5_edi-hierarchy-item .al-toggle-view-children').click
find('#pc0170-xml_aspace_ref5_edi-hierarchy-item .al-toggle-view-children').click
expect(page).to have_css '.document-title-heading', text: 'Restricted images, 1979-2000'
end
end
Expand Down Expand Up @@ -237,7 +237,7 @@
end

context 'content with file downloads', js: true do
let(:doc_id) { 'a0011-xmlaspace_ref6_lx4' }
let(:doc_id) { 'a0011-xml_aspace_ref6_lx4' }

it 'renders links to the files for download' do
within '.al-show-actions-box-downloads-container' do
Expand Down
2 changes: 1 addition & 1 deletion spec/features/document_tools_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
end

context 'for components' do
let(:doc_id) { 'm0198-xmlaspace_ref11_d0s' }
let(:doc_id) { 'm0198-xml_aspace_ref11_d0s' }

pending 'renders the bookmark option' do
expect(page).to have_css('.al-document-title-bar form.bookmark-toggle')
Expand Down
Loading