Skip to content

Commit

Permalink
Merge pull request #372 from scientist-softserv/i769-snippets-rework
Browse files Browse the repository at this point in the history
I769 snippets rework
  • Loading branch information
laritakr authored Oct 24, 2024
2 parents 02f68fc + 6e2d7e9 commit 7f35ea9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions app/helpers/iiif_print/iiif_helper_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ def uv_search_param
search_params = current_search_session.try(:query_params) || {}
q = search_params['q'].presence || ''

return unless search_params[:highlight] || params[:highlight]

"&q=#{url_encode(q)}" if q.present?
end
end
end

Hyrax::IiifHelper.prepend(IiifPrint::IiifHelperDecorator)
7 changes: 7 additions & 0 deletions app/models/concerns/iiif_print/solr_document_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ def any_highlighting?
response&.[]('highlighting')&.[](id)&.present?
end

def any_highlighting_in_all_text_fields?
[CatalogController.blacklight_config.iiif_search[:full_text_field]].any? do |field|
highlights = response&.dig('highlighting', id, field)
highlights&.any? { |text| text.include?("<span class='highlight'>") }
end
end

def solr_document
self
end
Expand Down
4 changes: 2 additions & 2 deletions app/views/catalog/_index_header_list_default.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<div class="search-results-title-row">
<h3 class="search-result-title">
<% if params['q'].present? && document.any_highlighting? %>
<%= link_to document.title_or_label, [document, { parent_query: params['q'] }] %></h3>
<%= link_to document.title_or_label, [document, { parent_query: params['q'], highlight: 'true' }] %></h3>
<% elsif params['q'].present? %>
<%= link_to document.title_or_label, [document, { query: params['q'] }] %></h3>
<%= link_to document.title_or_label, [document, { query: params['q'] }] %>
<% else %>
<%= link_to document.title_or_label, document %></h3>
<% end %>
Expand Down

0 comments on commit 7f35ea9

Please sign in to comment.