Remove unused `register_theme` code, expose `serve_public`

This commit is contained in:
Robin Ward 2017-07-28 11:13:21 -04:00
parent a13d146251
commit 5ae79697b8
2 changed files with 13 additions and 38 deletions

View File

@ -2,7 +2,6 @@ require 'digest/sha1'
require 'fileutils'
require_dependency 'plugin/metadata'
require_dependency 'plugin/auth_provider'
require_dependency 'plugin/theme'
class Plugin::CustomEmoji
def self.cache_key
@ -74,6 +73,19 @@ class Plugin::Instance
delegate :name, to: :metadata
def serve_public_dir
public_dir = "#{directory}/public"
if File.exist?(public_dir)
Rails.application.config.before_initialize do |app|
app.middleware.insert_before(
::Rack::Runtime,
::ActionDispatch::Static,
public_dir
)
end
end
end
def add_to_serializer(serializer, attr, define_include_method = true, &block)
klass = "#{serializer.to_s.classify}Serializer".constantize rescue "#{serializer.to_s}Serializer".constantize
@ -259,14 +271,6 @@ class Plugin::Instance
Plugin::CustomEmoji.register(name, url)
end
def register_theme(name)
return unless enabled?
theme = Plugin::Theme.new(self, name)
yield theme
themes << theme
end
def automatic_assets
css = styles.join("\n")
js = javascripts.join("\n")

View File

@ -1,29 +0,0 @@
class Plugin::Theme
attr_reader :color_scheme
def initialize(plugin, name)
@plugin = plugin
@name = name
end
def css(name)
@plugin.register_asset("stylesheets/#{name}.scss")
end
def set_color_scheme(scheme)
@color_scheme = scheme
end
def register_public
public_dir = "#{@plugin.directory}/public"
if File.exist?(public_dir)
Rails.application.config.before_initialize do |app|
app.middleware.insert_before(
::Rack::Runtime,
::ActionDispatch::Static,
public_dir
)
end
end
end
end