Skip to content

Commit

Permalink
Add config for updated gems
Browse files Browse the repository at this point in the history
  • Loading branch information
taylor-steve committed Jan 13, 2025
1 parent 91c9c52 commit 1aa53ef
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/generators/spotlight/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,38 @@ def add_osd_viewer
generate 'blacklight_gallery:install'
end

def configure_osd_for_sprockets
return unless defined?(Sprockets)

append_to_file 'app/assets/javascripts/application.js', "\n//= require openseadragon\n//= require openseadragon-rails/index\n"

append_to_file 'config/initializers/assets.rb' do
<<~CONTENT
Rails.application.config.assets.paths << Rails.root.join('node_modules/openseadragon/build/openseadragon')
Rails.application.config.assets.paths << Rails.root.join('node_modules/openseadragon/build/openseadragon/images')
CONTENT
end

append_to_file 'app/assets/config/manifest.js', "//= link_tree ../../../node_modules/openseadragon/build/openseadragon/images\n"

inject_into_file 'app/controllers/application_controller.rb', after: 'class ApplicationController < ActionController::Base' do
"\n helper Openseadragon::OpenseadragonHelper\n"
end
end

def add_oembed
unless Bundler.locked_gems.dependencies.key? 'blacklight-oembed'
gem 'blacklight-oembed', '~> 1.0'
bundle_install
end
generate 'blacklight_oembed:install'
copy_file 'config/initializers/oembed.rb'

return unless defined?(Sprockets)

# Use the rolled up assets from blacklight-oembed for sprockets
gsub_file 'app/assets/javascripts/blacklight_oembed.js', "import oembed from 'blacklight_oembed/oembed'",
'//= require blacklight_oembed/oembed'
end

def add_mailer_defaults
Expand Down

0 comments on commit 1aa53ef

Please sign in to comment.