Sha256: 21f8a46b7fe5cb5200c181e384b0716db084d3188dc7ead4022469839640390a

Contents?: true

Size: 1.75 KB

Versions: 5

Compression:

Stored size: 1.75 KB

Contents

require 'rails/generators'

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

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

    def configuration
      inject_into_file 'app/controllers/catalog_controller.rb', after: "configure_blacklight do |config|" do
        "\n    config.view.gallery(document_component: Blacklight::Gallery::DocumentComponent, icon: Blacklight::Gallery::Icons::GalleryComponent)" \
        "\n    config.view.masonry(document_component: Blacklight::Gallery::DocumentComponent, icon: Blacklight::Gallery::Icons::MasonryComponent)" \
        "\n    config.view.slideshow(document_component: Blacklight::Gallery::SlideshowComponent, icon: Blacklight::Gallery::Icons::SlideshowComponent)" \
        "\n    config.show.tile_source_field = :content_metadata_image_iiif_info_ssm" \
        "\n    config.show.partials ||= []" \
        "\n    config.show.partials.insert(1, :openseadragon)"
      end
    end

    def add_model_mixin
      inject_into_file 'app/models/solr_document.rb', after: "include Blacklight::Solr::Document" do
       "\n  include Blacklight::Gallery::OpenseadragonSolrDocument\n"
      end
    end

    def add_openseadragon
      gem "openseadragon", "~> 1.0"
      Bundler.with_clean_env { run 'bundle install' }
      generate 'openseadragon:install'
    end

    def assets
      copy_file "blacklight_gallery.css.scss", "app/assets/stylesheets/blacklight_gallery.css.scss"

      return unless defined?(Sprockets)

      append_to_file 'app/assets/config/manifest.js', "\n//= link blacklight_gallery/manifest.js\n"

      insert_into_file "app/assets/javascripts/application.js", after: '//= require blacklight/blacklight' do
        "\n//= require blacklight_gallery/blacklight-gallery"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blacklight-gallery-4.8.4 lib/generators/blacklight_gallery/install_generator.rb
blacklight-gallery-4.8.3 lib/generators/blacklight_gallery/install_generator.rb
blacklight-gallery-4.8.2 lib/generators/blacklight_gallery/install_generator.rb
blacklight-gallery-4.8.1 lib/generators/blacklight_gallery/install_generator.rb
blacklight-gallery-4.8.0 lib/generators/blacklight_gallery/install_generator.rb