Skip to content

Commit

Permalink
Merge branch 'main' into i233-rework_relationships_job
Browse files Browse the repository at this point in the history
  • Loading branch information
laritakr committed May 17, 2023
2 parents a88af47 + 124cc4d commit 2baac73
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/services/iiif_print/pluggable_derivative_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def plugins_for(file_set)
return Array(default_plugins) if parent.nil?
return Array(default_plugins) unless parent.respond_to?(:iiif_print_config)

(file_set.parent.iiif_print_config.derivative_service_plugins + Array(default_plugins)).flatten.compact.uniq
(parent.iiif_print_config.derivative_service_plugins + Array(default_plugins)).flatten.compact.uniq
end

def parent_for(file_set)
Expand Down
13 changes: 7 additions & 6 deletions lib/iiif_print/blacklight_iiif_search/annotation_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def coordinates
return default_coords if query.blank?
coords_json = fetch_and_parse_coords
return default_coords unless coords_json && coords_json['coords']
query.gsub!(additional_query_terms, '')
query_terms = query.split(' ').map(&:downcase)
sanitized_query = query.match(additional_query_terms_regex)[1].strip
query_terms = sanitized_query.split(' ').map(&:downcase)
matches = coords_json['coords'].select do |k, _v|
k.downcase =~ /(#{query_terms.join('|')})/
end
Expand Down Expand Up @@ -88,10 +88,11 @@ def file_set_id
# query. This resulted in the query split here returning more than the actual query term.
#
# @see IiifPrint::IiifSearchDecorator#solr_params
# @return [String] Returns a string containing additional query terms based on the parent document's id.
def additional_query_terms
parent_id = document['is_page_of_ssim'].first
" AND (is_page_of_ssim:\"#{parent_id}\" OR id:\"#{parent_id}\")"
# @return [Regexp] A regular expression to find the last AND and everything after it
# @example
# 'foo AND (is_page_of_ssim:\"123123\" OR id:\"123123\")' #=> 'foo'
def additional_query_terms_regex
/(.*)(?= AND (\(.+\)|\w+)$)/
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
SolrDocument.new('id' => parent_id,
'has_model_ssim' => ['NewspaperIssue'])
end
let(:query) { "software AND (is_page_of_ssim:#{parent_id} OR id:#{parent_id})" }
let(:iiif_search_annotation) do
BlacklightIiifSearch::IiifSearchAnnotation.new(page_document, 'software',
BlacklightIiifSearch::IiifSearchAnnotation.new(page_document, query,
0, nil, controller,
parent_document)
end
Expand Down

0 comments on commit 2baac73

Please sign in to comment.