Allow plugins to add vendored files for the text pipeline

This commit is contained in:
Robin Ward 2017-04-18 17:49:56 -04:00
parent e7b0ce1334
commit 564eb8c20f
2 changed files with 12 additions and 1 deletions

View File

@ -63,6 +63,11 @@ class DiscoursePluginRegistry
def html_builders def html_builders
@html_builders ||= {} @html_builders ||= {}
end end
def vendored_pretty_text
@vendored_pretty_text ||= Set.new
end
end end
def register_js(filename, options={}) def register_js(filename, options={})
@ -107,6 +112,8 @@ class DiscoursePluginRegistry
if asset =~ JS_REGEX if asset =~ JS_REGEX
if opts == :admin if opts == :admin
self.admin_javascripts << asset self.admin_javascripts << asset
elsif opts == :vendored_pretty_text
self.vendored_pretty_text << asset
else else
self.javascripts << asset self.javascripts << asset
end end
@ -120,7 +127,6 @@ class DiscoursePluginRegistry
else else
self.stylesheets << asset self.stylesheets << asset
end end
elsif asset =~ HANDLEBARS_REGEX elsif asset =~ HANDLEBARS_REGEX
self.handlebars << asset self.handlebars << asset
end end
@ -181,6 +187,7 @@ class DiscoursePluginRegistry
serialized_current_user_fields serialized_current_user_fields
asset_globs.clear asset_globs.clear
html_builders.clear html_builders.clear
vendored_pretty_text.clear
end end
def self.setup(plugin_class) def self.setup(plugin_class)

View File

@ -94,6 +94,10 @@ module PrettyText
end end
end end
DiscoursePluginRegistry.vendored_pretty_text.each do |vpt|
ctx.eval(File.read(vpt))
end
ctx ctx
end end