mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
Add register_color_scheme for plugins
This commit is contained in:
@ -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 = ""
|
||||
|
Reference in New Issue
Block a user