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

I769 snippets rework #372

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
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?
['all_text_timv', 'all_text_tsimv'].any? do |field|
ShanaLMoore marked this conversation as resolved.
Show resolved Hide resolved
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
Loading