mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 09:10:25 +08:00
Move register_asset
into PluginRegistry
-- the logic works better
there.
This commit is contained in:
parent
2b817f826b
commit
663cd93c6d
4 changed files with 103 additions and 99 deletions
|
@ -40,7 +40,6 @@ class Plugin::Instance
|
|||
register_asset(relative)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def name
|
||||
|
@ -186,7 +185,6 @@ class Plugin::Instance
|
|||
Rails.configuration.assets.paths << File.dirname(path) + "/assets"
|
||||
end
|
||||
|
||||
|
||||
public_data = File.dirname(path) + "/public"
|
||||
if Dir.exists?(public_data)
|
||||
target = Rails.root.to_s + "/public/plugins/"
|
||||
|
@ -243,31 +241,7 @@ class Plugin::Instance
|
|||
|
||||
def register_assets!
|
||||
assets.each do |asset, opts|
|
||||
if asset =~ /\.js$|\.js\.erb$|\.js\.es6$/
|
||||
if opts == :admin
|
||||
DiscoursePluginRegistry.admin_javascripts << asset
|
||||
else
|
||||
if opts == :server_side
|
||||
DiscoursePluginRegistry.server_side_javascripts << asset
|
||||
end
|
||||
DiscoursePluginRegistry.javascripts << asset
|
||||
end
|
||||
elsif asset =~ /\.css$|\.scss$/
|
||||
if opts == :mobile
|
||||
DiscoursePluginRegistry.mobile_stylesheets << asset
|
||||
elsif opts == :desktop
|
||||
DiscoursePluginRegistry.desktop_stylesheets << asset
|
||||
elsif opts == :variables
|
||||
DiscoursePluginRegistry.sass_variables << asset
|
||||
else
|
||||
DiscoursePluginRegistry.stylesheets << asset
|
||||
end
|
||||
|
||||
elsif asset =~ /\.hbs$/
|
||||
DiscoursePluginRegistry.handlebars << asset
|
||||
elsif asset =~ /\.js\.handlebars$/
|
||||
DiscoursePluginRegistry.handlebars << asset
|
||||
end
|
||||
DiscoursePluginRegistry.register_asset(asset, opts)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue