support server side js and arbitrary assets

proper chaining for emoji so other hooks can be called
This commit is contained in:
Sam
2013-08-01 17:35:31 +10:00
parent d15083d3ee
commit 1132c10074
3 changed files with 19 additions and 3 deletions

View File

@ -103,6 +103,16 @@ class Plugin
@javascripts << js
end
def register_asset(file,opts=nil)
full_path = File.dirname(path) << "/assets/" << file
assets << full_path
if opts == :server_side
@server_side_javascripts ||= []
@server_side_javascripts << full_path
end
end
def automatic_assets
css = ""
js = "(function(){"
@ -149,19 +159,24 @@ class Plugin
assets.concat auto_assets
end
unless assets.blank?
paths = []
assets.each do |asset|
if asset =~ /\.js$/
DiscoursePluginRegistry.javascripts << asset
elsif asset =~ /\.css$|\.scss$/
DiscoursePluginRegistry.stylesheets << asset
end
paths << File.dirname(asset)
end
# TODO possibly amend this to a rails engine
Rails.configuration.assets.paths << auto_generated_path
Rails.configuration.assets.paths << File.dirname(path) + "/assets"
end
if @server_side_javascripts
@server_side_javascripts.each do |js|
DiscoursePluginRegistry.server_side_javascripts << js
end
end
end
def auth_provider(type, opts)