Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config for updated gems #3402

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/openseadragon-rails\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
Loading