2016-05-10 16:50:01 +02:00
|
|
|
class PluginRegistry
|
|
|
|
class << self
|
|
|
|
attr_writer :javascripts
|
|
|
|
attr_writer :stylesheets
|
|
|
|
|
|
|
|
def asset_globs
|
|
|
|
@asset_globs ||= Set.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def javascripts
|
|
|
|
@javascripts ||= Set.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def stylesheets
|
|
|
|
@stylesheets ||= Set.new
|
|
|
|
end
|
2016-05-24 11:43:47 +02:00
|
|
|
|
|
|
|
def code_insertions
|
|
|
|
@code_insertions ||= {}
|
|
|
|
end
|
2016-05-10 16:50:01 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.register_glob(root, extension, options=nil)
|
2019-01-31 17:15:26 +01:00
|
|
|
asset_globs << [root, extension, options || {}]
|
2016-05-10 16:50:01 +02:00
|
|
|
end
|
|
|
|
|
2019-01-31 17:15:26 +01:00
|
|
|
def self.register_asset(asset, _opts = nil)
|
2016-05-10 16:50:01 +02:00
|
|
|
if asset =~ /\.js$|\.js\.erb$|\.js\.es6$|\.coffee$|\.coffee\.erb/
|
2019-01-31 17:15:26 +01:00
|
|
|
javascripts << asset
|
2016-05-10 16:50:01 +02:00
|
|
|
elsif asset =~ /\.css$|\.scss$/
|
2019-01-31 17:15:26 +01:00
|
|
|
stylesheets << asset
|
2016-05-10 16:50:01 +02:00
|
|
|
end
|
2016-06-16 17:37:56 +02:00
|
|
|
end
|
2016-05-25 12:23:25 +02:00
|
|
|
|
2016-06-16 17:37:56 +02:00
|
|
|
def self.insert_code(key)
|
2019-01-31 17:15:26 +01:00
|
|
|
code_insertions[key]&.join('\n')
|
2016-05-10 16:50:01 +02:00
|
|
|
end
|
|
|
|
end
|