Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: Add plugin js / plugin test js to bootstrap.json

Robin Ward65eec147fc7b
diff --git a/app/controllers/bootstrap_controller.rb b/app/controllers/bootstrap_controller.rb
index c7822b453b1..ebd68eebe11 100644
--- a/app/controllers/bootstrap_controller.rb
+++ b/app/controllers/bootstrap_controller.rb
@@ -30,7 +30,7 @@ class BootstrapController < ApplicationController
desktop_view: !mobile_view?,
request: request
).each do |file|
- add_style(file)
+ add_style(file, plugin: true)
end
add_style(mobile_view? ? :mobile_theme : :desktop_theme) if theme_ids.present?
@@ -42,12 +42,20 @@ class BootstrapController < ApplicationController
extra_locales << ExtraLocalesController.url('admin')
end
+ plugin_js = Discourse.find_plugin_js_assets(
+ include_official: allow_plugins?,
+ include_unofficial: allow_third_party_plugins?,
+ request: request
+ ).map { |f| script_asset_path(f) }
+
bootstrap = {
theme_ids: theme_ids,
title: SiteSetting.title,
current_homepage: current_homepage,
locale_script: locale,
stylesheets: @stylesheets,
+ plugin_js: plugin_js,
+ plugin_test_js: [script_asset_path("plugin_tests")],
setup_data: client_side_setup_data,
preloaded: @preloaded,
}
@@ -66,7 +74,7 @@ private
end
end
- def add_style(target)
+ def add_style(target, opts = nil)
if styles = Stylesheet::Manager.stylesheet_details(target, 'all', theme_ids)
styles.each do |style|
@stylesheets << {
@@ -74,7 +82,7 @@ private
media: 'all',
theme_id: style[:theme_id],
target: style[:target]
- }
+ }.merge(opts || {})
end
end
end