Sha256: d0b511fd62e64a0cdd2faa4d6720b39f9c58a3eda3551605f572dfe4e70d405d

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

require 'rails/generators'

module BlacklightOembed
  class Install < Rails::Generators::Base

    source_root File.expand_path('../templates', __FILE__)

    def assets
      copy_file "blacklight_oembed.css.scss", "app/assets/stylesheets/blacklight_oembed.css.scss"
      copy_file "blacklight_oembed.js", "app/assets/javascripts/blacklight_oembed.js"
    end

    def inject_routes
      route "mount Blacklight::Oembed::Engine, at: 'oembed'"
    end

    def inject_oembed_configuration
      copy_file "oembed_providers.rb", "config/initializers/oembed_providers.rb"
    end

    def configuration
      inject_into_file 'app/controllers/catalog_controller.rb', after: 'configure_blacklight do |config|' do
        if ENV['CI_TEST_LEGACY_CONFIGURATION'].present? || Gem::Version.new(Blacklight::VERSION) < Gem::Version.new('8.0')
          <<-EOF

            config.show.oembed_field = :oembed_url_ssm
            config.show.partials.insert(1, :oembed)
          EOF
        else
          <<-EOF

          config.show.oembed_field = :oembed_url_ssm
          config.show.render_oembed_using_async_javascript = true
          config.show.embed_component = Blacklight::Oembed::DocumentOembedComponent
          EOF
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-oembed-1.4.0 lib/generators/blacklight_oembed/install_generator.rb
blacklight-oembed-1.3.0 lib/generators/blacklight_oembed/install_generator.rb
blacklight-oembed-1.2.0 lib/generators/blacklight_oembed/install_generator.rb