Module: IiifPrint::IiifSearchResponseDecorator
- Defined in:
- app/models/iiif_print/iiif_search_response_decorator.rb
Instance Method Summary collapse
- #add_metadata_match(json_results) ⇒ Object
-
#annotation_list ⇒ Object
Enable the user to search for child metadata in the parent’s UV.
- #remove_invalid_hit(json_results) ⇒ Object
Instance Method Details
#add_metadata_match(json_results) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/models/iiif_print/iiif_search_response_decorator.rb', line 28 def (json_results) json_results['resources'].each do |result_hit| next if result_hit['resource'].present? # Add resource details if not present result_hit['resource'] = { "@type": "cnt:ContentAsText", "chars": "Metadata match, see sidebar for details" } end end |
#annotation_list ⇒ Object
Enable the user to search for child metadata in the parent’s UV
5 6 7 8 9 10 11 12 13 14 15 |
# File 'app/models/iiif_print/iiif_search_response_decorator.rb', line 5 def annotation_list json_results = super # Check and process invalid hit if json_results&.[]('resources') remove_invalid_hit(json_results) (json_results) end json_results end |
#remove_invalid_hit(json_results) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'app/models/iiif_print/iiif_search_response_decorator.rb', line 17 def remove_invalid_hit(json_results) resources = json_results['resources'] invalid_hit = resources.detect { |resource| resource["on"].include?(IiifPrint::BlacklightIiifSearch::AnnotationDecorator::INVALID_MATCH_TEXT) } return unless invalid_hit # Delete invalid hit from resources, remove first hit (which is from the invalid hit), decrement total within resources.delete(invalid_hit) json_results['hits'].shift json_results['within']['total'] -= 1 end |