Class: BlacklightGallery::Install

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

Instance Method Summary collapse

Instance Method Details

#add_model_mixinObject



28
29
30
31
32
# File 'lib/generators/blacklight_gallery/install_generator.rb', line 28

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

#add_openseadragonObject



34
35
36
37
38
# File 'lib/generators/blacklight_gallery/install_generator.rb', line 34

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

#assetsObject



8
9
10
11
12
13
14
15
# File 'lib/generators/blacklight_gallery/install_generator.rb', line 8

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

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

#configurationObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/generators/blacklight_gallery/install_generator.rb', line 17

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" \
    "\n    # config.view.gallery.classes = 'row-cols-2 row-cols-md-3'" \
    "\n    config.view.masonry.document_component = Blacklight::Gallery::DocumentComponent" \
    "\n    config.view.slideshow.document_component = Blacklight::Gallery::SlideshowComponent" \
    "\n    config.show.tile_source_field = :content_metadata_image_iiif_info_ssm" \
    "\n    config.show.partials.insert(1, :openseadragon)"
  end
end