Class: BlacklightIiifSearch::ControllerGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/blacklight_iiif_search/controller_generator.rb

Instance Method Summary collapse

Instance Method Details

#inject_catalog_controller_behaviorObject

Update the blacklight catalog controller



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/generators/blacklight_iiif_search/controller_generator.rb', line 19

def inject_catalog_controller_behavior
  return if IO.read("app/controllers/#{controller_name}_controller.rb").include?('BlacklightIiifSearch')
  marker = 'configure_blacklight do |config|'
  inject_into_file "app/controllers/#{controller_name}_controller.rb", before: marker do
    "# CatalogController-scope behavior and configuration for BlacklightIiifSearch
  include BlacklightIiifSearch::Controller\n\n  "
  end
  inject_into_file "app/controllers/#{controller_name}_controller.rb", after: marker do
    "\n\n    # configuration for Blacklight IIIF Content Search
config.iiif_search = {
  full_text_field: 'all_text_timv',
  object_relation_field: 'is_page_of_ssi',
  supported_params: %w[q page],
  autocomplete_handler: 'iiif_suggest',
  suggester_name: 'iiifSuggester'
}\n"
  end
end