Sha256: d535fc9e825742f738949e456c19dc0af577118a919579818276c6be51420021

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require 'rails/generators'


module BlacklightUnapi
  class Install < Rails::Generators::Base
    include Rails::Generators::Migration
    source_root File.expand_path('../templates', __FILE__)
    

    argument :controller_name, :type => :string, :default => "CatalogController"

    def inject_catalog_controller_extension
      file_path = "app/controllers/#{controller_name.underscore}.rb"
      if File.exists? file_path
        inject_into_file file_path, :after => "include Blacklight::Catalog" do
          "\n  include BlacklightUnapi::ControllerExtension\n"
        end
      end
    end

    def inject_unapi_configuration
      insert_into_file 'app/controllers/catalog_controller.rb', :after => "config.spell_max = 5\n" do <<-EOF

    # Add documents to the list of object formats that are supported for all objects.
    # This parameter is a hash, identical to the Blacklight::Solr::Document#export_formats 
    # output; keys are format short-names that can be exported. Hash includes:
    #    :content-type => mime-content-type
      
    config.unapi = {
      'oai_dc_xml' => { :content_type => 'text/xml' } 
    }
    config.index.partials << 'microformat'
    config.show.partials << 'microformat'
EOF
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blacklight_unapi-0.1.0 lib/generators/blacklight_unapi/install_generator.rb