Skip to content

Commit

Permalink
Merge pull request #226 from cul/dlc-1141
Browse files Browse the repository at this point in the history
index relatedItem[@otherType='project']/title into a facetable field …
  • Loading branch information
barmintor authored Jul 24, 2024
2 parents d9570f7 + 26bfa6c commit 8a0b364
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 8 deletions.
2 changes: 0 additions & 2 deletions app/assets/stylesheets/stylesheets/gallery/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
width: 100%;
padding: 2px 0 0;
text-align: center;
font-family: $font_0, $font_1, $font_4, $font_2;
a {
color: $info;
&:hover {
Expand All @@ -28,7 +27,6 @@
padding: 2px 0 0;
margin-bottom: .5em;
text-align: center;
font-family: $font_0, $font_1, $font_4, $font_2;
font-size: 180%;
a {
color: $info;
Expand Down
1 change: 0 additions & 1 deletion app/assets/stylesheets/stylesheets/portrait/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
width:100%;
padding: 0;
margin: 0;
//@extend %extend_brand_font;
color: color-shade(map-get($theme-text-colors, 'brand'));
font-size: 90%;
font-weight: 200;
Expand Down
1 change: 0 additions & 1 deletion app/assets/stylesheets/stylesheets/signature/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ header[role='banner'] {
color: color-shade(map-get($theme-text-colors, 'brand'));
}
#site-title {
font-family: $font_0, $font_3, $font_1, $font_2;
white-space: normal;
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/views/signature/home.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<div class="panel-group">
<div class="card panel-ui">
<div class="card-header">
<h3 class="card-title"><%= link_to_site_browse("BROWSE THE COLLECTION", "VISIT SITE") %></h3>
<h3 class="card-title"><%= link_to_site_browse("BROWSE THE COLLECTION", "VISIT SITE", class: ['btn', 'btn-outline-light']) %></h3>
</div>
</div>
<div class="card panel-ui">
<%- if (about_link = @subsite.about_link) -%>
<div class="card-header">
<h3 class="card-title"><%= link_to("ABOUT THE COLLECTION", site_page_path(site_slug: @subsite.slug, slug: about_link.link)) %></h3>
<h3 class="card-title"><%= link_to("ABOUT THE COLLECTION", site_page_path(site_slug: @subsite.slug, slug: about_link.link), class: ['btn', 'btn-outline-light']) %></h3>
</div>
<%- end -%>
</div>
Expand Down
5 changes: 3 additions & 2 deletions lib/dcv/configurators/dcv_blacklight_configurator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ def self.configure_sort_fields(config)
# solr fields to be displayed in the index (search results) view
# The ordering of the field names is the order of the display
def self.configure_index_fields(config)
#config.add_index_field 'title_display_ssm', :label => 'Title'
config.add_index_field 'lib_repo_long_ssim', :label => 'Library Location'
config.add_index_field 'primary_name_ssm', label: 'Name', helper_method: :display_non_copyright_names_with_roles, if: :has_non_copyright_names?
config.add_index_field 'rel_other_project_ssim', :label => 'Project'
config.add_index_field 'lib_repo_long_ssim', :label => 'Library Location'
config.add_index_field 'location_sublocation_ssm', :label => 'Department'
config.add_index_field 'lib_collection_ssm', label: 'Collection Name', helper_method: :display_composite_archival_context
config.add_index_field 'lib_date_textual_ssm', :label => 'Date'
Expand All @@ -113,6 +113,7 @@ def self.configure_index_fields(config)
def self.configure_show_fields(config)
configure_file_show_fields(config)
config.add_show_field 'lib_name_ssm', label: 'Name', link_to_search: 'lib_name_sim', helper_method: :display_non_copyright_names_with_roles, if: :has_non_copyright_names?
config.add_show_field 'rel_other_project_ssim', :label => 'Project'
config.add_show_field 'title_display_ssm', label: 'Title'
config.add_show_field 'alternative_title_ssm', :label => 'Other Titles'
config.add_show_field 'abstract_ssm', label: 'Abstract', helper_method: :expandable_past_400, iiif: false
Expand Down
16 changes: 16 additions & 0 deletions lib/dcv/solr/document_adapter/mods_xml/fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,9 @@ def to_solr(solr_doc={})
solr_doc['reading_room_ssim'] = reading_room_locations

solr_doc.merge!(iiif_properties(mods))
othertype_fields = othertype_relations(mods)
solr_doc.merge!(othertype_fields)
solr_doc["all_text_teim"] += othertype_fields.values.flatten
solr_doc
end

Expand Down Expand Up @@ -730,5 +733,18 @@ def key_date_year_bounds(start_date, end_date)
return KEY_DATE_EMPTY_BOUNDS if (end_year && start_year) && end_year.to_i < start_year.to_i
[start_year, end_year]
end

# Create a map of field names to value arrays for relatedItem[@otherType]
# @param node [Nokogiri::XML::Node] search context
# @return [Hash<String, Array<String>] map of field name strings to value string arrays
def othertype_relations(node)
field_values = {}
mods.xpath("./mods:relatedItem[@otherType]/mods:titleInfo", MODS_NS).each do |title|
field_name = title.parent['otherType'].downcase.split(/[^a-z]+/).compact.join('_')
field_name = "rel_other_#{field_name}_ssim"
(field_values[field_name] ||= []) << title.text.strip
end
field_values
end
end
end
5 changes: 5 additions & 0 deletions spec/fixtures/mods/mods-relateditem-project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@
</titleInfo>
<identifier type="uri">info:hyacinth.library.columbia.edu/projects/customer_orders</identifier>
</relatedItem>
<relatedItem otherType="project" otherTypeAuth="local" otherTypeURI="http://id.library.columbia.edu/term/6e2483cf-b669-4630-a033-3ec05e78c2cd">
<titleInfo>
<title>Project 2508: Edna Gladney house (Fort Worth, Texas). Scheme 2, Unbuilt Project</mods:title>
</titleInfo>
</relatedItem>
</mods>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'rails_helper'

describe Dcv::Solr::DocumentAdapter::ModsXml, type: :unit do
let(:xml_src) { fixture(File.join("mods", "mods-all.xml")) }
let(:ng_xml) { Nokogiri::XML(xml_src.read) }
let(:adapter) { described_class.new(ng_xml) }
let(:solr_doc) { adapter.to_solr }
let(:all_text) { solr_doc['all_text_teim'] }
let(:all_text_joined) { all_text.join(' ') }

describe ".to_solr" do
subject {
solr_doc
}
context "has otherType project cataloged" do
let(:xml_src) { fixture( File.join("mods", "mods-relateditem-project.xml") ) }
let(:project_label) { 'Project 2508: Edna Gladney house (Fort Worth, Texas). Scheme 2, Unbuilt Project' }
it "should extract project labels" do
expect(subject["rel_other_project_ssim"]).to eq([project_label])
end
end
end
end

0 comments on commit 8a0b364

Please sign in to comment.