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

This allows 3rd party clients (such as Ember CLI) to run plugins and
their tests.
This commit is contained in:
Robin Ward 2020-11-27 11:54:25 -05:00
parent 7af663ca63
commit 65eec147fc
1 changed files with 11 additions and 3 deletions

View File

@ -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