Add register_color_scheme for plugins

This commit is contained in:
Neil Lalonde
2014-06-03 12:36:34 -04:00
parent bb0cf87684
commit 3e16ac62c3
4 changed files with 75 additions and 6 deletions

View File

@ -5,7 +5,7 @@ require_dependency 'plugin/auth_provider'
class Plugin::Instance
attr_reader :auth_providers, :assets, :styles
attr_reader :auth_providers, :assets, :styles, :color_schemes
attr_accessor :path, :metadata
def self.find_all(parent_path)
@ -23,6 +23,7 @@ class Plugin::Instance
@metadata = metadata
@path = path
@assets = []
@color_schemes = []
# Automatically include all ES6 JS files
if @path
@ -32,6 +33,7 @@ class Plugin::Instance
register_asset(relative)
end
end
end
def name
@ -85,6 +87,10 @@ class Plugin::Instance
end
def notify_after_initialize
color_schemes.each do |c|
ColorScheme.create_from_base(name: c[:name], colors: c[:colors]) unless ColorScheme.where(name: c[:name]).exists?
end
if @after_initialize
@after_initialize.each do |callback|
callback.call
@ -107,6 +113,10 @@ class Plugin::Instance
assets << [full_path, opts]
end
def register_color_scheme(name, colors)
color_schemes << {name: name, colors: colors}
end
def automatic_assets
css = ""
js = ""