A platform for community discussion. Free, open, simple.
FIX: Use CDN for the `discourse-internet-explorer`
Robin Ward556d66a97c16
diff --git a/lib/discourse.rb b/lib/discourse.rbindex f4819a210e6..62ba6133164 100644--- a/lib/discourse.rb+++ b/lib/discourse.rb@@ -194,6 +194,7 @@ module DiscourseSTDERR.puts "Could not activate #{p.metadata.name}, discourse does not meet required version (#{v})"endend+ DiscourseEvent.trigger(:after_plugin_activation)enddef self.disabled_plugin_namesdiff --git a/plugins/discourse-internet-explorer/plugin.rb b/plugins/discourse-internet-explorer/plugin.rbindex 0e97cf4cbd6..5eff00501c4 100644--- a/plugins/discourse-internet-explorer/plugin.rb+++ b/plugins/discourse-internet-explorer/plugin.rb@@ -11,6 +11,14 @@ hide_plugin if self.respond_to?(:hide_plugin)register_asset 'stylesheets/ie.scss'+# We can't use register asset for an optional resource. Instead copy it after plugins have+# been activated so it can be uploaded to CDNs.+DiscourseEvent.on(:after_plugin_activation) do ||+ polyfill_path = "#{Plugin::Instance.js_path}/#{self.directory_name}-optional.js"+ puts polyfill_path+ FileUtils.cp("#{Rails.root}/public/plugins/discourse-internet-explorer/js/ie.js", polyfill_path)+end+after_initialize do# Conditionally load the stylesheet. There is unfortunately no easy way to do this via@@ -47,7 +55,7 @@ after_initialize do# to be loaded before other filesregister_html_builder('server:before-script-load') do |controller|if BrowserDetection.browser(controller.request.env['HTTP_USER_AGENT']) == :ie- path = "#{Discourse.base_uri}/plugins/discourse-internet-explorer/js/ie.js"+ path = controller.helpers.script_asset_path('plugins/discourse-internet-explorer-optional')<<~JAVASCRIPT<script src="#{path}"></script>