From 65eec147fc7b82e6722ccdf3fb253a087c055279 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 27 Nov 2020 11:54:25 -0500 Subject: [PATCH] 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. --- app/controllers/bootstrap_controller.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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