From 32ec4a4d01302f2437ade631b837308de99bb4d5 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Wed, 16 Oct 2024 10:39:40 -0700 Subject: [PATCH 1/4] wip --- app/helpers/iiif_print/iiif_helper_decorator.rb | 3 +++ app/views/catalog/_index_header_list_default.html.erb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/helpers/iiif_print/iiif_helper_decorator.rb b/app/helpers/iiif_print/iiif_helper_decorator.rb index 74100ae5..68dca1cb 100644 --- a/app/helpers/iiif_print/iiif_helper_decorator.rb +++ b/app/helpers/iiif_print/iiif_helper_decorator.rb @@ -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) diff --git a/app/views/catalog/_index_header_list_default.html.erb b/app/views/catalog/_index_header_list_default.html.erb index f4ef3e66..1e92d73c 100644 --- a/app/views/catalog/_index_header_list_default.html.erb +++ b/app/views/catalog/_index_header_list_default.html.erb @@ -3,9 +3,9 @@

<% if params['q'].present? && document.any_highlighting? %> - <%= link_to document.title_or_label, [document, { parent_query: params['q'] }] %>

+ <%= link_to document.title_or_label, [document, { parent_query: params['q'], highlight: document.any_highlighting? }] %> <% elsif params['q'].present? %> - <%= link_to document.title_or_label, [document, { query: params['q'] }] %> + <%= link_to document.title_or_label, [document, { query: params['q'] }] %> <% else %> <%= link_to document.title_or_label, document %> <% end %> From 7d04b0843941daa03e683b8c99b04fc30dfd5d58 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Wed, 16 Oct 2024 11:01:06 -0700 Subject: [PATCH 2/4] Update _index_header_list_default.html.erb --- app/views/catalog/_index_header_list_default.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/catalog/_index_header_list_default.html.erb b/app/views/catalog/_index_header_list_default.html.erb index 1e92d73c..ace16eb5 100644 --- a/app/views/catalog/_index_header_list_default.html.erb +++ b/app/views/catalog/_index_header_list_default.html.erb @@ -3,7 +3,7 @@

<% if params['q'].present? && document.any_highlighting? %> - <%= link_to document.title_or_label, [document, { parent_query: params['q'], highlight: document.any_highlighting? }] %>

+ <%= link_to document.title_or_label, [document, { parent_query: params['q'], highlight: 'true' }] %> <% elsif params['q'].present? %> <%= link_to document.title_or_label, [document, { query: params['q'] }] %> <% else %> From 1e12809656ffce1c1d91c61f52135c8b2ced3406 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Mon, 21 Oct 2024 14:13:20 -0700 Subject: [PATCH 3/4] Update solr_document_decorator.rb --- app/models/concerns/iiif_print/solr_document_decorator.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/concerns/iiif_print/solr_document_decorator.rb b/app/models/concerns/iiif_print/solr_document_decorator.rb index d218e9e1..57ab924d 100644 --- a/app/models/concerns/iiif_print/solr_document_decorator.rb +++ b/app/models/concerns/iiif_print/solr_document_decorator.rb @@ -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| + highlights = response&.dig('highlighting', id, field) + highlights&.any? { |text| text.include?("") } + end + end + def solr_document self end From 6e2d7e93f00974be479b815b90d16db9b7ee7f60 Mon Sep 17 00:00:00 2001 From: Shana Moore Date: Tue, 22 Oct 2024 09:09:26 -0700 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=A7=B9=20use=20dynamic=20full=5Ftext?= =?UTF-8?q?=5Ffield?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/concerns/iiif_print/solr_document_decorator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/concerns/iiif_print/solr_document_decorator.rb b/app/models/concerns/iiif_print/solr_document_decorator.rb index 57ab924d..f6ec1d95 100644 --- a/app/models/concerns/iiif_print/solr_document_decorator.rb +++ b/app/models/concerns/iiif_print/solr_document_decorator.rb @@ -25,7 +25,7 @@ def any_highlighting? end def any_highlighting_in_all_text_fields? - ['all_text_timv', 'all_text_tsimv'].any? do |field| + [CatalogController.blacklight_config.iiif_search[:full_text_field]].any? do |field| highlights = response&.dig('highlighting', id, field) highlights&.any? { |text| text.include?("") } end