A platform for community discussion. Free, open, simple.
FIX: properly load desktop and mobile only plugin css assets.
Vinoth Kannan41f22946c36a
diff --git a/app/views/common/_discourse_stylesheet.html.erb b/app/views/common/_discourse_stylesheet.html.erbindex d16cb7cb4e7..690f3a2711b 100644--- a/app/views/common/_discourse_stylesheet.html.erb+++ b/app/views/common/_discourse_stylesheet.html.erb@@ -12,6 +12,6 @@<%= discourse_stylesheet_link_tag(mobile_view? ? :mobile_theme : :desktop_theme) %><%- end %>-<%- Discourse.find_plugin_css_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?).each do |file| %>+<%- Discourse.find_plugin_css_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?, mobile_view: mobile_view?).each do |file| %><%= discourse_stylesheet_link_tag(file) %><%- end %>diff --git a/lib/discourse.rb b/lib/discourse.rbindex fb19a776f1e..86efda52355 100644--- a/lib/discourse.rb+++ b/lib/discourse.rb@@ -215,9 +215,18 @@ module Discourseenddef self.find_plugin_css_assets(args)- self.find_plugins(args).find_all do |plugin|+ plugins = self.find_plugins(args)++ assets = plugins.find_all do |plugin|plugin.css_asset_exists?end.map { |plugin| plugin.directory_name }++ target = args[:mobile_view] ? :mobile : :desktop+ assets += plugins.find_all do |plugin|+ plugin.css_asset_exists?(target)+ end.map { |plugin| "#{plugin.directory_name}_#{target}" }++ assetsenddef self.find_plugin_js_assets(args)diff --git a/lib/discourse_plugin_registry.rb b/lib/discourse_plugin_registry.rbindex f8111ed71be..800b9364c10 100644--- a/lib/discourse_plugin_registry.rb+++ b/lib/discourse_plugin_registry.rb@@ -183,8 +183,15 @@ class DiscoursePluginRegistryendend- def self.stylesheets_exists?(plugin_directory_name)- self.stylesheets[plugin_directory_name].present? || self.mobile_stylesheets[plugin_directory_name].present? || self.desktop_stylesheets[plugin_directory_name].present?+ def self.stylesheets_exists?(plugin_directory_name, target = nil)+ case target+ when :desktop+ self.desktop_stylesheets[plugin_directory_name].present?+ when :mobile+ self.mobile_stylesheets[plugin_directory_name].present?+ else+ self.stylesheets[plugin_directory_name].present?+ endenddef self.register_seed_data(key, value)diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rbindex b8158fa7575..3c45aa7a893 100644--- a/lib/plugin/instance.rb+++ b/lib/plugin/instance.rb@@ -658,8 +658,8 @@ class Plugin::Instance@directory_name ||= File.dirname(path).split("/").lastend- def css_asset_exists?- DiscoursePluginRegistry.stylesheets_exists?(directory_name)+ def css_asset_exists?(target = nil)+ DiscoursePluginRegistry.stylesheets_exists?(directory_name, target)enddef js_asset_exists?