Class: BlacklightGallery::Install
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- BlacklightGallery::Install
- Defined in:
- lib/generators/blacklight_gallery/install_generator.rb
Instance Method Summary collapse
- #add_javascript ⇒ Object
- #add_model_mixin ⇒ Object
- #add_openseadragon ⇒ Object
- #add_sprockets_support ⇒ Object
- #add_stylesheet ⇒ Object
- #configuration ⇒ Object
- #uncomment_thumbnail_config ⇒ Object
Instance Method Details
#add_javascript ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/generators/blacklight_gallery/install_generator.rb', line 35 def add_javascript if defined?(Importmap) say 'Installing assets for use with Importmaps', :green append_to_file 'config/importmap.rb', "pin \"jquery\", to: \"https://code.jquery.com/jquery-3.7.1.min.js\"\n" append_to_file 'app/javascript/application.js', after: %r{import Blacklight .*$} do <<~CONTENT import 'jquery' import 'blacklight-gallery' CONTENT end # Append plugin initialization code to main application.js file append_to_file 'app/javascript/application.js' do <<~CONTENT Blacklight.onLoad(function() { $('.documents-masonry').BlacklightMasonry(); $('.documents-slideshow').slideshow(); }); CONTENT end end end |
#add_model_mixin ⇒ Object
19 20 21 22 23 |
# File 'lib/generators/blacklight_gallery/install_generator.rb', line 19 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_openseadragon ⇒ Object
29 30 31 32 33 |
# File 'lib/generators/blacklight_gallery/install_generator.rb', line 29 def add_openseadragon gem "openseadragon", "~> 1.0" Bundler.with_unbundled_env { run 'bundle install' } generate 'openseadragon:install' end |
#add_sprockets_support ⇒ Object
83 84 85 86 87 |
# File 'lib/generators/blacklight_gallery/install_generator.rb', line 83 def add_sprockets_support return unless defined?(Sprockets) append_to_file 'app/assets/config/manifest.js', "\n//= link blacklight_gallery/manifest.js\n" end |
#add_stylesheet ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/generators/blacklight_gallery/install_generator.rb', line 60 def add_stylesheet # Indicates cssbundling-rails with bootstrap usage. if File.exist? 'app/assets/stylesheets/application.bootstrap.scss' append_to_file 'app/assets/stylesheets/application.bootstrap.scss' do <<~CONTENT @import url('blacklight_gallery/gallery.css'); @import url('blacklight_gallery/masonry.css'); @import url('blacklight_gallery/osd_viewer.css'); @import url('blacklight_gallery/slideshow.css'); CONTENT end else append_to_file 'app/assets/stylesheets/application.css' do <<~CONTENT @import url('blacklight_gallery/gallery.css'); @import url('blacklight_gallery/masonry.css'); @import url('blacklight_gallery/osd_viewer.css'); @import url('blacklight_gallery/slideshow.css'); CONTENT end end end |
#configuration ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/generators/blacklight_gallery/install_generator.rb', line 8 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 |
#uncomment_thumbnail_config ⇒ Object
25 26 27 |
# File 'lib/generators/blacklight_gallery/install_generator.rb', line 25 def uncomment_thumbnail_config uncomment_lines 'app/controllers/catalog_controller.rb', /config\.index\.thumbnail_field.*$/ end |