Sha256: 72b745e20bf8c5067a24285c86d924c9926a5c73d5f273db1522bfc650a7e0d7

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

# adds controller-scope behavior to the implementing application
require 'rails/generators'

module IiifPrint
  class CatalogControllerGenerator < Rails::Generators::Base
    desc "
      This generator makes the following changes to your app:
      1. Adds index fields in CatalogController
      2. Adjusts Blacklight IIIF Search configuration settings in CatalogController
      "

    def add_index_fields_to_catalog_controller
      marker = 'configure_blacklight do |config|'
      inject_into_file 'app/controllers/catalog_controller.rb', after: marker do
        "\n\n    # IiifPrint index fields\n"\
        "    config.add_index_field 'all_text_tsimv', highlight: true, helper_method: :render_ocr_snippets\n"
      end
    end

    def adjust_catalog_controller_all_text_config
      gsub_file('app/controllers/catalog_controller.rb',
                " full_text_field: 'text',",
                " full_text_field: 'all_text_tsimv',")
    end

    def adjust_catalog_controller_is_page_of_config
      gsub_file('app/controllers/catalog_controller.rb',
                " object_relation_field: 'is_page_of_s',",
                " object_relation_field: 'is_page_of_ssim',")
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
iiif_print-3.0.1 lib/generators/iiif_print/catalog_controller_generator.rb
iiif_print-3.0.0 lib/generators/iiif_print/catalog_controller_generator.rb
iiif_print-2.0.1 lib/generators/iiif_print/catalog_controller_generator.rb
iiif_print-2.0.0 lib/generators/iiif_print/catalog_controller_generator.rb
iiif_print-1.1.0 lib/generators/iiif_print/catalog_controller_generator.rb
iiif_print-1.0.0 lib/generators/iiif_print/catalog_controller_generator.rb