From 564eb8c20fc7554a6b06f9d64a6a7c22b3cee361 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 18 Apr 2017 17:49:56 -0400 Subject: [PATCH] Allow plugins to add vendored files for the text pipeline --- lib/discourse_plugin_registry.rb | 9 ++++++++- lib/pretty_text.rb | 4 ++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/discourse_plugin_registry.rb b/lib/discourse_plugin_registry.rb index 8e4a12eda04..568c48932d0 100644 --- a/lib/discourse_plugin_registry.rb +++ b/lib/discourse_plugin_registry.rb @@ -63,6 +63,11 @@ class DiscoursePluginRegistry def html_builders @html_builders ||= {} end + + def vendored_pretty_text + @vendored_pretty_text ||= Set.new + end + end def register_js(filename, options={}) @@ -107,6 +112,8 @@ class DiscoursePluginRegistry if asset =~ JS_REGEX if opts == :admin self.admin_javascripts << asset + elsif opts == :vendored_pretty_text + self.vendored_pretty_text << asset else self.javascripts << asset end @@ -120,7 +127,6 @@ class DiscoursePluginRegistry else self.stylesheets << asset end - elsif asset =~ HANDLEBARS_REGEX self.handlebars << asset end @@ -181,6 +187,7 @@ class DiscoursePluginRegistry serialized_current_user_fields asset_globs.clear html_builders.clear + vendored_pretty_text.clear end def self.setup(plugin_class) diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index 036a50d6bd1..d9000e102f8 100644 --- a/lib/pretty_text.rb +++ b/lib/pretty_text.rb @@ -94,6 +94,10 @@ module PrettyText end end + DiscoursePluginRegistry.vendored_pretty_text.each do |vpt| + ctx.eval(File.read(vpt)) + end + ctx end