diff --git a/app/helpers/record_helper.rb b/app/helpers/record_helper.rb index 3c36d315f..d71affca6 100644 --- a/app/helpers/record_helper.rb +++ b/app/helpers/record_helper.rb @@ -62,7 +62,8 @@ def link_to_mods_name(name) link_to(name, search_catalog_path(q: "\"#{name}\"", search_field: 'search_author')) end - # We need this to remove the ending ":" from the role labels + # We need this to remove the ending ":" from the role labels only in data from + # mods_display def sanitize_mods_name_label(label) label.sub(/:$/, '') end diff --git a/app/models/concerns/mods_data.rb b/app/models/concerns/mods_data.rb index cdad410ff..96dd034e0 100644 --- a/app/models/concerns/mods_data.rb +++ b/app/models/concerns/mods_data.rb @@ -17,4 +17,18 @@ def prettified_mods return nil unless self["modsxml"] @prettified_mods ||= CodeRay::Duo[:xml, :div].highlight(self["modsxml"]).html_safe end + + ## + # Convenience accessors and parsers for mods_display content already indexed + + ## + # A ModsDisplay::Values object dumped while indexing. The object is needed + # as there is there is some necessary display logic. + def mods_display_name + fetch(:author_struct, []) + end + + def mods_abstract + fetch(:summary_display, []) + end end diff --git a/app/views/catalog/_mods_search_results_document_fields.html.erb b/app/views/catalog/_mods_search_results_document_fields.html.erb index f5648f130..fa3167e6e 100644 --- a/app/views/catalog/_mods_search_results_document_fields.html.erb +++ b/app/views/catalog/_mods_search_results_document_fields.html.erb @@ -3,8 +3,13 @@ <% if document[:vern_title_display].present? %>
  • <%= document[:vern_title_display].html_safe %>
  • <% end %> - - <% if document.mods.name.present? && document.mods.name.first.values.present? %> + <% if document.mods_display_name.present? %> +
  • + <% name = document.mods_display_name.first %> + <%= link_to_mods_name(name['link']) %> <%= name['post_text'] %> +
  • + <%# TODO: Remove this elsif block after new mods index is in place %> + <% elsif document.mods.name.present? && document.mods.name.first.values.present? %>
  • <% name = document.mods.name.first %> <%= link_to_mods_name(name.values.first) %> (<%= sanitize_mods_name_label(name.label) %>) diff --git a/app/views/catalog/_summary_data.html.erb b/app/views/catalog/_summary_data.html.erb index 5cdabcd67..c807bc4d9 100644 --- a/app/views/catalog/_summary_data.html.erb +++ b/app/views/catalog/_summary_data.html.erb @@ -44,13 +44,16 @@ <% end %> <% end %> -<% elsif document.respond_to?(:mods) && document.mods.present? %> - <% if document.mods.abstract.present? %> - <%= document.mods.abstract.map(&:values).join('
    ').html_safe %> - <% end %> +<% elsif document.mods_abstract.present? %> + <%= document.mods_abstract.join('
    ').html_safe %> <% elsif document[:summary_display].present? %>
    <%= document[:summary_display].join('
    ').html_safe %>
    +<%# TODO: Remove this elsif block after new mods index is in place %> +<% elsif document.respond_to?(:mods) && document.mods.present? %> + <% if document.mods.abstract.present? %> + <%= document.mods.abstract.map(&:values).join('
    ').html_safe %> + <% end %> <% end %> diff --git a/config/solr_configs/solrconfig.xml b/config/solr_configs/solrconfig.xml index 89d283459..4a1db7c8d 100644 --- a/config/solr_configs/solrconfig.xml +++ b/config/solr_configs/solrconfig.xml @@ -869,6 +869,7 @@ author_meeting_display, vern_author_meeting_display, author_person_display, vern_author_person_display, author_person_full_display, vern_author_person_full_display, + author_struct:[json], bookplates_display, collection, collection_type, diff --git a/spec/fixtures/solr_documents/31.yml b/spec/fixtures/solr_documents/31.yml index 9d8d44aa9..f43e3df97 100644 --- a/spec/fixtures/solr_documents/31.yml +++ b/spec/fixtures/solr_documents/31.yml @@ -11,3 +11,5 @@ :pub_date: 2010 :beginning_year_isi: 2010 :imprint_display: 2010 +:summary_display: + - Nunc venenatis et odio ac elementum. Nulla ornare faucibus laoreet diff --git a/spec/fixtures/solr_documents/47.yml b/spec/fixtures/solr_documents/47.yml index d4fa0f3d6..090a396b2 100644 --- a/spec/fixtures/solr_documents/47.yml +++ b/spec/fixtures/solr_documents/47.yml @@ -3,3 +3,8 @@ :format_main_ssim: "Archive/Manuscript" :modsxml: <%= mods_everything %> :collection_type: Digital Collection +:author_struct: + - '{"link":"J. Smith","search":"\"J. Smith\"","post_text":"(Author)"}' + - '{"link":"B. Smith","search":"\"B. Smith\"","post_text":"(Producer)"}' +:summary_display: + - This collection of Virtual Objects is really important. diff --git a/spec/views/catalog/_index_mods.html.erb_spec.rb b/spec/views/catalog/_index_mods.html.erb_spec.rb index 5517cdcb8..4eb00f745 100644 --- a/spec/views/catalog/_index_mods.html.erb_spec.rb +++ b/spec/views/catalog/_index_mods.html.erb_spec.rb @@ -10,7 +10,11 @@ collection_with_title: ['12345 -|- Collection Title'], modsxml: mods_everything, physical: ["The Physical Extent"], - imprint_display: ["Imprint Statement"] + imprint_display: ["Imprint Statement"], + author_struct: [ + { 'link' => 'J. Smith', 'search' => '"J. Smith"', 'post_text' => '(Author)' }, + { 'link' => 'B. Smith', 'search' => '"B. Smith"', 'post_text' => '(Producer)' }, + ] ) ) expect(view).to receive(:show_presenter).and_return(presenter) diff --git a/spec/views/catalog/_index_mods_collection.html.erb_spec.rb b/spec/views/catalog/_index_mods_collection.html.erb_spec.rb index d434fa080..a4f29c65e 100644 --- a/spec/views/catalog/_index_mods_collection.html.erb_spec.rb +++ b/spec/views/catalog/_index_mods_collection.html.erb_spec.rb @@ -7,7 +7,11 @@ SolrDocument.new( id: 'abc123', modsxml: mods_everything, - physical: ["The Physical Extent"] + physical: ["The Physical Extent"], + author_struct: [ + { 'link' => 'J. Smith', 'search' => '"J. Smith"', 'post_text' => '(Author)' }, + { 'link' => 'B. Smith', 'search' => '"B. Smith"', 'post_text' => '(Producer)' }, + ] ) ) render diff --git a/spec/views/preview/_show_mods.html.erb_spec.rb b/spec/views/preview/_show_mods.html.erb_spec.rb index 4b657e6ec..492b595be 100644 --- a/spec/views/preview/_show_mods.html.erb_spec.rb +++ b/spec/views/preview/_show_mods.html.erb_spec.rb @@ -12,7 +12,12 @@ display_type: ["image"], item_display: [ "123 -|- GREEN -|- STACKS -|- -|- -|- -|- -|- -|- ABC 123" ], isbn_display: [ 123 ], - imprint_display: ["Imprint Statement"] + imprint_display: ["Imprint Statement"], + author_struct: [ + { 'link' => 'J. Smith', 'search' => '"J. Smith"', 'post_text' => '(Author)' }, + { 'link' => 'B. Smith', 'search' => '"B. Smith"', 'post_text' => '(Producer)' }, + ], + summary_display: ['Nunc venenatis et odio ac elementum. Nulla ornare faucibus laoreet'] ) } before do