Skip to content

Commit

Permalink
Export the script to importmap paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jan 10, 2025
1 parent 230b3bf commit 9e2e85f
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/blacklight_oembed/oembed.esm.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/assets/javascripts/blacklight_oembed/oembed.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
1 change: 1 addition & 0 deletions config/blacklight/oembed/manifest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//= link_tree ../../../javascript .js
3 changes: 3 additions & 0 deletions config/importmap.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# frozen_string_literal: true

pin_all_from File.expand_path("../app/javascript/blacklight-oembed", __dir__), under: "blacklight-oembed"
5 changes: 5 additions & 0 deletions lib/blacklight/oembed/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ class Engine < Rails::Engine
# Allows an adopter to pass additional parameters through to an OEmbed
# service. Examples of this could include `:canvas_index`, or `:max_width`
config.additional_params = []

initializer 'blacklight_oembed.importmap', before: 'importmap' do |app|
app.config.assets.paths << Engine.root.join("app/javascript")
app.config.importmap.paths << Engine.root.join('config/importmap.rb') if app.config.respond_to?(:importmap)
end
end
end
end
4 changes: 4 additions & 0 deletions lib/generators/blacklight_oembed/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ def inject_oembed_configuration
copy_file "oembed_providers.rb", "config/initializers/oembed_providers.rb"
end

def appease_sprockets4
append_to_file 'app/assets/config/manifest.js', "\n//= link blacklight/oembed/manifest.js"
end

def configuration
inject_into_file 'app/controllers/catalog_controller.rb', after: 'configure_blacklight do |config|' do
if ENV['CI_TEST_LEGACY_CONFIGURATION'].present? || Gem::Version.new(Blacklight::VERSION) < Gem::Version.new('8.0')
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let includePathOptions = {
};

const rollupConfig = {
input: 'app/javascript/oembed.js',
input: 'app/javascript/blacklight-oembed/oembed.js',
output: {
file: `app/assets/javascripts/blacklight_oembed/${fileDest}.js`,
format: ESM ? 'es' : 'umd',
Expand Down

0 comments on commit 9e2e85f

Please sign in to comment.