From 5ae79697b815ab09063a340578c63a6a9291f14f Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 28 Jul 2017 11:13:21 -0400 Subject: [PATCH] Remove unused `register_theme` code, expose `serve_public` --- lib/plugin/instance.rb | 22 +++++++++++++--------- lib/plugin/theme.rb | 29 ----------------------------- 2 files changed, 13 insertions(+), 38 deletions(-) delete mode 100644 lib/plugin/theme.rb diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb index 50867afaa0e..168c3a36c65 100644 --- a/lib/plugin/instance.rb +++ b/lib/plugin/instance.rb @@ -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") diff --git a/lib/plugin/theme.rb b/lib/plugin/theme.rb deleted file mode 100644 index 41ba7dc9992..00000000000 --- a/lib/plugin/theme.rb +++ /dev/null @@ -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