From 46719a32a8acb6136e046107b242f7c36124f52b Mon Sep 17 00:00:00 2001 From: Eric Hayes Date: Tue, 18 Apr 2017 09:06:56 -0700 Subject: [PATCH] Find correct stylesheet path in plugins https://bugzilla.redhat.com/show_bug.cgi?id=1447940 --- lib/pdf_generator.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/pdf_generator.rb b/lib/pdf_generator.rb index fdc898fc16f..beaf219a83d 100644 --- a/lib/pdf_generator.rb +++ b/lib/pdf_generator.rb @@ -42,8 +42,17 @@ def self.sanitize_html(html_string) end private_class_method :sanitize_html + # Search through plugins to find the first existing pdf stylesheet + # + # TODO: this could be refactored later to support multiple stylesheets + # from multiple plugins. + # def self.stylesheet_file_path(stylesheet) - Rails.root.join(*%W(app assets stylesheets #{stylesheet})).to_s + paths = Vmdb::Plugins.instance.vmdb_plugins.map do |plugin| + plugin.root.join("app/assets/stylesheets", stylesheet) + end + + paths.detect { |p| File.exist?(p) } end private_class_method :stylesheet_file_path