mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-20 14:54:15 +01:00
Merge branch 'dev' into host
This commit is contained in:
commit
864f034859
@ -11,7 +11,7 @@ Metrics/AbcSize:
|
|||||||
Metrics/ClassLength:
|
Metrics/ClassLength:
|
||||||
Max: 200
|
Max: 200
|
||||||
Style/BracesAroundHashParameters:
|
Style/BracesAroundHashParameters:
|
||||||
EnforcedStyle: context_dependent
|
EnforcedStyle: braces
|
||||||
Style/RegexpLiteral:
|
Style/RegexpLiteral:
|
||||||
EnforcedStyle: slashes
|
EnforcedStyle: slashes
|
||||||
Style/EmptyElse:
|
Style/EmptyElse:
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require_dependency 'plugin/instance'
|
require_dependency 'plugin/instance'
|
||||||
|
|
||||||
module FabManager
|
module FabManager
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# File size validator for CarrierWave
|
# File size validator for CarrierWave
|
||||||
# https://github.com/jnicklas/carrierwave/wiki/How-to%3A-Validate-attachment-file-size
|
# https://github.com/jnicklas/carrierwave/wiki/How-to%3A-Validate-attachment-file-size
|
||||||
|
|
||||||
class FileSizeValidator < ActiveModel::EachValidator
|
class FileSizeValidator < ActiveModel::EachValidator
|
||||||
MESSAGES = { :is => :wrong_size, :minimum => :size_too_small, :maximum => :size_too_big }.freeze
|
MESSAGES = { is: :wrong_size, minimum: :size_too_small, maximum: :size_too_big }.freeze
|
||||||
CHECKS = { :is => :==, :minimum => :>=, :maximum => :<= }.freeze
|
CHECKS = { is: :==, minimum: :>=, maximum: :<= }.freeze
|
||||||
|
|
||||||
DEFAULT_TOKENIZER = lambda { |value| value.split(//) }
|
DEFAULT_TOKENIZER = ->(value) { value.split(//) }
|
||||||
RESERVED_OPTIONS = [:minimum, :maximum, :within, :is, :tokenizer, :too_short, :too_long]
|
RESERVED_OPTIONS = %i[minimum maximum within is tokenizer too_short too_long].freeze
|
||||||
|
|
||||||
def initialize(options)
|
def initialize(options)
|
||||||
if range = (options.delete(:in) || options.delete(:within))
|
if range = (options.delete(:in) || options.delete(:within))
|
||||||
raise ArgumentError, ":in and :within must be a Range" unless range.is_a?(Range)
|
raise ArgumentError, ':in and :within must be a Range' unless range.is_a?(Range)
|
||||||
options[:minimum], options[:maximum] = range.begin, range.end
|
|
||||||
|
options[:minimum] = range.begin
|
||||||
|
options[:maximum] = range.end
|
||||||
options[:maximum] -= 1 if range.exclude_end?
|
options[:maximum] -= 1 if range.exclude_end?
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -21,23 +24,19 @@ class FileSizeValidator < ActiveModel::EachValidator
|
|||||||
def check_validity!
|
def check_validity!
|
||||||
keys = CHECKS.keys & options.keys
|
keys = CHECKS.keys & options.keys
|
||||||
|
|
||||||
if keys.empty?
|
raise ArgumentError, 'Range unspecified. Specify the :within, :maximum, :minimum, or :is option.' if keys.empty?
|
||||||
raise ArgumentError, 'Range unspecified. Specify the :within, :maximum, :minimum, or :is option.'
|
|
||||||
end
|
|
||||||
|
|
||||||
keys.each do |key|
|
keys.each do |key|
|
||||||
value = options[key]
|
value = options[key]
|
||||||
|
|
||||||
unless value.is_a?(Integer) && value >= 0
|
raise ArgumentError, ":#{key} must be a nonnegative Integer" unless value.is_a?(Integer) && value >= 0
|
||||||
raise ArgumentError, ":#{key} must be a nonnegative Integer"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_each(record, attribute, value)
|
def validate_each(record, attribute, value)
|
||||||
raise(ArgumentError, "A CarrierWave::Uploader::Base object was expected") unless value.kind_of? CarrierWave::Uploader::Base
|
raise(ArgumentError, 'A CarrierWave::Uploader::Base object was expected') unless value.is_a? CarrierWave::Uploader::Base
|
||||||
|
|
||||||
value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)
|
value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.is_a?(String)
|
||||||
|
|
||||||
CHECKS.each do |key, validity_check|
|
CHECKS.each do |key, validity_check|
|
||||||
next unless check_value = options[key]
|
next unless check_value = options[key]
|
||||||
@ -61,6 +60,7 @@ class FileSizeValidator < ActiveModel::EachValidator
|
|||||||
Helper.instance
|
Helper.instance
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# provides dependencies
|
||||||
class Helper
|
class Helper
|
||||||
include Singleton
|
include Singleton
|
||||||
include ActionView::Helpers::NumberHelper
|
include ActionView::Helpers::NumberHelper
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
active_provider = AuthProvider.active
|
active_provider = AuthProvider.active
|
||||||
|
|
||||||
if active_provider.providable_type != DatabaseProvider.name
|
if active_provider.providable_type != DatabaseProvider.name
|
||||||
require_relative "strategies/sso_#{active_provider.provider_type}_provider"
|
require_relative "strategies/sso_#{active_provider.provider_type}_provider"
|
||||||
end
|
end
|
||||||
|
@ -1,115 +1,135 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'omniauth-oauth2'
|
require 'omniauth-oauth2'
|
||||||
|
|
||||||
module OmniAuth
|
module OmniAuth::Strategies
|
||||||
module Strategies
|
# Authentication strategy provided trough oAuth 2.0
|
||||||
class SsoOauth2Provider < OmniAuth::Strategies::OAuth2
|
class SsoOauth2Provider < OmniAuth::Strategies::OAuth2
|
||||||
|
|
||||||
def self.active_provider
|
def self.active_provider
|
||||||
active_provider = AuthProvider.active
|
active_provider = AuthProvider.active
|
||||||
if active_provider.providable_type != OAuth2Provider.name
|
if active_provider.providable_type != OAuth2Provider.name
|
||||||
raise "Trying to instantiate the wrong provider: Expected OAuth2Provider, received #{active_provider.providable_type}"
|
raise "Trying to instantiate the wrong provider: Expected OAuth2Provider, received #{active_provider.providable_type}"
|
||||||
end
|
|
||||||
active_provider
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Strategy name.
|
active_provider
|
||||||
option :name, active_provider.strategy_name
|
end
|
||||||
|
|
||||||
|
# Strategy name.
|
||||||
|
option :name, active_provider.strategy_name
|
||||||
|
|
||||||
|
|
||||||
option :client_options, {
|
option :client_options,
|
||||||
:site => active_provider.providable.base_url,
|
{ site: active_provider.providable.base_url,
|
||||||
:authorize_url => active_provider.providable.authorization_endpoint,
|
authorize_url: active_provider.providable.authorization_endpoint,
|
||||||
:token_url => active_provider.providable.token_endpoint
|
token_url: active_provider.providable.token_endpoint }
|
||||||
|
|
||||||
|
|
||||||
|
uid { parsed_info['user.uid'.to_sym] }
|
||||||
|
|
||||||
|
info do
|
||||||
|
{
|
||||||
|
mapping: parsed_info
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
uid { parsed_info['user.uid'.to_sym] }
|
extra do
|
||||||
|
{
|
||||||
|
raw_info: raw_info
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
info do
|
# retrieve data from various url, querying each only once
|
||||||
{
|
def raw_info
|
||||||
:mapping => parsed_info
|
@raw_info ||= {}
|
||||||
}
|
unless @raw_info.size.positive?
|
||||||
end
|
OmniAuth::Strategies::SsoOauth2Provider.active_provider.providable.o_auth2_mappings.each do |mapping|
|
||||||
|
unless @raw_info.key?(mapping.api_endpoint.to_sym)
|
||||||
extra do
|
@raw_info[mapping.api_endpoint.to_sym] = access_token.get(mapping.api_endpoint).parsed
|
||||||
{
|
|
||||||
:raw_info => raw_info
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
# retrieve data from various url, querying each only once
|
|
||||||
def raw_info
|
|
||||||
@raw_info ||= Hash.new
|
|
||||||
unless @raw_info.size > 0
|
|
||||||
OmniAuth::Strategies::SsoOauth2Provider.active_provider.providable.o_auth2_mappings.each do |mapping|
|
|
||||||
unless @raw_info.has_key?(mapping.api_endpoint.to_sym)
|
|
||||||
@raw_info[mapping.api_endpoint.to_sym] = access_token.get(mapping.api_endpoint).parsed
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@raw_info
|
|
||||||
end
|
end
|
||||||
|
@raw_info
|
||||||
|
end
|
||||||
|
|
||||||
|
def parsed_info
|
||||||
|
@parsed_info ||= {}
|
||||||
|
unless @parsed_info.size.positive?
|
||||||
|
OmniAuth::Strategies::SsoOauth2Provider.active_provider.providable.o_auth2_mappings.each do |mapping|
|
||||||
|
|
||||||
def parsed_info
|
if mapping.transformation
|
||||||
@parsed_info ||= Hash.new
|
case mapping.transformation['type']
|
||||||
unless @parsed_info.size > 0
|
## INTEGER
|
||||||
OmniAuth::Strategies::SsoOauth2Provider.active_provider.providable.o_auth2_mappings.each do |mapping|
|
when 'integer'
|
||||||
|
@parsed_info[local_sym(mapping)] = map_integer(mapping.transformation,
|
||||||
|
mapping.api_endpoint.to_sym,
|
||||||
|
mapping.api_field)
|
||||||
|
|
||||||
if mapping.transformation
|
## BOOLEAN
|
||||||
case mapping.transformation['type']
|
when 'boolean'
|
||||||
## INTEGER
|
@parsed_info[local_sym(mapping)] = map_boolean(mapping.transformation,
|
||||||
when 'integer'
|
mapping.api_endpoint.to_sym,
|
||||||
mapping.transformation['mapping'].each do |m|
|
mapping.api_field)
|
||||||
if m['from'] == raw_info[mapping.api_endpoint.to_sym][mapping.api_field]
|
|
||||||
@parsed_info[local_sym(mapping)] = m['to']
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
# if no transformation had set any value, set the raw value
|
|
||||||
unless @parsed_info[local_sym(mapping)]
|
|
||||||
@parsed_info[local_sym(mapping)] = raw_info[mapping.api_endpoint.to_sym][mapping.api_field]
|
|
||||||
end
|
|
||||||
|
|
||||||
## BOOLEAN
|
## DATE
|
||||||
when 'boolean'
|
when 'date'
|
||||||
@parsed_info[local_sym(mapping)] = !(raw_info[mapping.api_endpoint.to_sym][mapping.api_field] == mapping.transformation['false_value'])
|
@params[local_sym(mapping)] = map_date(mapping.transformation,
|
||||||
@parsed_info[local_sym(mapping)] = (raw_info[mapping.api_endpoint.to_sym][mapping.api_field] == mapping.transformation['true_value'])
|
mapping.api_endpoint.to_sym,
|
||||||
|
mapping.api_field)
|
||||||
|
|
||||||
## DATE
|
## OTHER TRANSFORMATIONS (not supported)
|
||||||
when 'date'
|
|
||||||
case mapping.transformation['format']
|
|
||||||
when 'iso8601'
|
|
||||||
@parsed_info[local_sym(mapping)] = DateTime.iso8601(raw_info[mapping.api_endpoint.to_sym][mapping.api_field])
|
|
||||||
when 'rfc2822'
|
|
||||||
@parsed_info[local_sym(mapping)] = DateTime.rfc2822(raw_info[mapping.api_endpoint.to_sym][mapping.api_field])
|
|
||||||
when 'rfc3339'
|
|
||||||
@parsed_info[local_sym(mapping)] = DateTime.rfc3339(raw_info[mapping.api_endpoint.to_sym][mapping.api_field])
|
|
||||||
when 'timestamp-s'
|
|
||||||
@parsed_info[local_sym(mapping)] = DateTime.strptime(raw_info[mapping.api_endpoint.to_sym][mapping.api_field],'%s')
|
|
||||||
when 'timestamp-ms'
|
|
||||||
@parsed_info[local_sym(mapping)] = DateTime.strptime(raw_info[mapping.api_endpoint.to_sym][mapping.api_field],'%Q')
|
|
||||||
else
|
|
||||||
@parsed_info[local_sym(mapping)] = DateTime.parse(raw_info[mapping.api_endpoint.to_sym][mapping.api_field])
|
|
||||||
end
|
|
||||||
|
|
||||||
## OTHER TRANSFORMATIONS (not supported)
|
|
||||||
else
|
|
||||||
@parsed_info[local_sym(mapping)] = raw_info[mapping.api_endpoint.to_sym][mapping.api_field]
|
|
||||||
end
|
|
||||||
|
|
||||||
## NO TRANSFORMATION
|
|
||||||
else
|
else
|
||||||
@parsed_info[local_sym(mapping)] = raw_info[mapping.api_endpoint.to_sym][mapping.api_field]
|
@parsed_info[local_sym(mapping)] = raw_info[mapping.api_endpoint.to_sym][mapping.api_field]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
## NO TRANSFORMATION
|
||||||
|
else
|
||||||
|
@parsed_info[local_sym(mapping)] = raw_info[mapping.api_endpoint.to_sym][mapping.api_field]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@parsed_info
|
|
||||||
end
|
end
|
||||||
|
@parsed_info
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def local_sym(mapping)
|
|
||||||
(mapping.local_model+'.'+mapping.local_field).to_sym
|
def local_sym(mapping)
|
||||||
|
(mapping.local_model + '.' + mapping.local_field).to_sym
|
||||||
|
end
|
||||||
|
|
||||||
|
def map_integer(transformation, api_endpoint, api_field)
|
||||||
|
value = nil
|
||||||
|
transformation['mapping'].each do |m|
|
||||||
|
if m['from'] == raw_info[api_endpoint][api_field]
|
||||||
|
value = m['to']
|
||||||
|
break
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
# if no transformation had set any value, return the raw value
|
||||||
|
value || raw_info[api_endpoint.to_sym][api_field]
|
||||||
|
end
|
||||||
|
|
||||||
|
def map_boolean(transformation, api_endpoint, api_field)
|
||||||
|
return false if raw_info[api_endpoint][api_field] == transformation['false_value']
|
||||||
|
|
||||||
|
true if raw_info[api_endpoint][api_field] == transformation['true_value']
|
||||||
|
end
|
||||||
|
|
||||||
|
def map_date(transformation, api_endpoint, api_field)
|
||||||
|
case transformation['format']
|
||||||
|
when 'iso8601'
|
||||||
|
DateTime.iso8601(raw_info[api_endpoint][api_field])
|
||||||
|
when 'rfc2822'
|
||||||
|
DateTime.rfc2822(raw_info[api_endpoint][api_field])
|
||||||
|
when 'rfc3339'
|
||||||
|
DateTime.rfc3339(raw_info[api_endpoint][api_field])
|
||||||
|
when 'timestamp-s'
|
||||||
|
DateTime.strptime(raw_info[api_endpoint][api_field], '%s')
|
||||||
|
when 'timestamp-ms'
|
||||||
|
DateTime.strptime(raw_info[api_endpoint][api_field], '%Q')
|
||||||
|
else
|
||||||
|
DateTime.parse(raw_info[api_endpoint][api_field])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,98 +1,97 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'fileutils'
|
require 'fileutils'
|
||||||
require 'plugin_registry'
|
require 'plugin_registry'
|
||||||
|
|
||||||
module Plugin
|
class Plugin::Instance
|
||||||
class Instance
|
attr_accessor :path
|
||||||
attr_accessor :path#, :directory
|
|
||||||
|
|
||||||
[:assets, :initializers, :javascripts, :styles].each do |att|
|
%i[assets initializers javascripts styles].each do |att|
|
||||||
class_eval %Q{
|
class_eval %(
|
||||||
def #{att}
|
def #{att}
|
||||||
@#{att} ||= []
|
@#{att} ||= []
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.find_all(parent_path)
|
|
||||||
[].tap { |plugins|
|
|
||||||
# also follows symlinks - http://stackoverflow.com/q/357754
|
|
||||||
Dir["#{parent_path}/**/*/**/plugin.rb"].sort.each do |path|
|
|
||||||
|
|
||||||
source = File.read(path)
|
|
||||||
# metadata = Plugin::Metadata.parse(source)
|
|
||||||
plugins << self.new(nil, path)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
def initialize(metadata=nil, path=nil)
|
|
||||||
@metadata = metadata
|
|
||||||
@path = path
|
|
||||||
#@directory = path.match(/(.*)\/plugin.rb/)[1]
|
|
||||||
@idx = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
def activate!
|
|
||||||
if @path
|
|
||||||
root_path = "#{File.dirname(@path)}/assets/javascripts"
|
|
||||||
PluginRegistry.register_glob(root_path, 'coffee.erb')
|
|
||||||
end
|
end
|
||||||
|
), __FILE__, __LINE__ - 4
|
||||||
|
end
|
||||||
|
|
||||||
self.instance_eval File.read(path), path # execute all code of the plugin main file ! (named plugin.rb)
|
def self.find_all(parent_path)
|
||||||
|
[].tap { |plugins|
|
||||||
|
# also follows symlinks - http://stackoverflow.com/q/357754
|
||||||
|
Dir["#{parent_path}/**/*/**/plugin.rb"].sort.each do |path|
|
||||||
|
plugins << new(nil, path)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
register_assets! unless assets.blank?
|
def initialize(metadata=nil, path=nil)
|
||||||
|
@metadata = metadata
|
||||||
|
@path = path
|
||||||
|
@idx = 0
|
||||||
|
end
|
||||||
|
|
||||||
Rails.configuration.assets.paths << File.dirname(path) + "/assets"
|
def activate!
|
||||||
|
if @path
|
||||||
Rails.configuration.assets.precompile += [lambda do |filename, path|
|
root_path = "#{File.dirname(@path)}/assets/javascripts"
|
||||||
(Dir["plugins/*/assets/templates"].any? { |p| path.include?(p) }) # useless because already included in application.css/js || (%w(.js).include?(File.extname(filename)) && Dir["plugins/*/assets/javascripts"].any? { |p| path.include?(p) }) || (%w(.css).include?(File.extname(filename)) && Dir["plugins/*/assets/stylesheets"].any? { |p| path.include?(p) })
|
PluginRegistry.register_glob(root_path, 'coffee.erb')
|
||||||
end] #
|
|
||||||
|
|
||||||
Rails.configuration.sass.load_paths += Dir["plugins/*/assets/stylesheets"]
|
|
||||||
|
|
||||||
|
|
||||||
# Automatically include rake tasks
|
|
||||||
Rake.add_rakelib(File.dirname(path) + "/lib/tasks")
|
|
||||||
|
|
||||||
# Automatically include migrations
|
|
||||||
Rails.configuration.paths["db/migrate"] << File.dirname(path) + "/db/migrate"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def register_asset(file, opts=nil) # to be used by the plugin !
|
instance_eval File.read(path), path # execute all code of the plugin main file ! (named plugin.rb)
|
||||||
full_path = File.dirname(path) << "/assets/" << file
|
|
||||||
assets << [full_path, opts]
|
|
||||||
end
|
|
||||||
|
|
||||||
def register_code_insertion(key, code)
|
register_assets! unless assets.blank?
|
||||||
PluginRegistry.code_insertions[key] ||= []
|
|
||||||
PluginRegistry.code_insertions[key] << code
|
|
||||||
end
|
|
||||||
|
|
||||||
def register_css(style) # useless ?
|
Rails.configuration.assets.paths << "#{File.dirname(path)}/assets"
|
||||||
styles << style
|
|
||||||
end
|
|
||||||
|
|
||||||
def after_initialize(&block)
|
Rails.configuration.assets.precompile += [lambda do |_filename, path|
|
||||||
initializers << block
|
(Dir['plugins/*/assets/templates'].any? { |p| path.include?(p) })
|
||||||
end
|
end]
|
||||||
|
|
||||||
def notify_after_initialize
|
Rails.configuration.sass.load_paths += Dir['plugins/*/assets/stylesheets']
|
||||||
initializers.each do |callback|
|
|
||||||
begin
|
|
||||||
callback.call(self)
|
# Automatically include rake tasks
|
||||||
rescue ActiveRecord::StatementInvalid => e
|
Rake.add_rakelib("#{File.dirname(path)}/lib/tasks")
|
||||||
# When running db:migrate for the first time on a new database, plugin initializers might
|
|
||||||
# try to use models. Tolerate it.
|
# Automatically include migrations
|
||||||
raise e unless e.message.try(:include?, "PG::UndefinedTable")
|
Rails.configuration.paths['db/migrate'] << "#{File.dirname(path)}/db/migrate"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# to be used by the plugin !
|
||||||
|
def register_asset(file, opts=nil)
|
||||||
|
full_path = File.dirname(path) << '/assets/' << file
|
||||||
|
assets << [full_path, opts]
|
||||||
|
end
|
||||||
|
|
||||||
|
def register_code_insertion(key, code)
|
||||||
|
PluginRegistry.code_insertions[key] ||= []
|
||||||
|
PluginRegistry.code_insertions[key] << code
|
||||||
|
end
|
||||||
|
|
||||||
|
# useless ?
|
||||||
|
def register_css(style)
|
||||||
|
styles << style
|
||||||
|
end
|
||||||
|
|
||||||
|
def after_initialize(&block)
|
||||||
|
initializers << block
|
||||||
|
end
|
||||||
|
|
||||||
|
def notify_after_initialize
|
||||||
|
initializers.each do |callback|
|
||||||
|
begin
|
||||||
|
callback.call(self)
|
||||||
|
rescue ActiveRecord::StatementInvalid => e
|
||||||
|
# When running db:migrate for the first time on a new database, plugin initializers might
|
||||||
|
# try to use models. Tolerate it.
|
||||||
|
raise e unless e.message.try(:include?, 'PG::UndefinedTable')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
def register_assets!
|
|
||||||
assets.each do |asset, opts|
|
def register_assets!
|
||||||
PluginRegistry.register_asset(asset, opts)
|
assets.each do |asset, opts|
|
||||||
end
|
PluginRegistry.register_asset(asset, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -21,38 +21,18 @@ class PluginRegistry
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.register_glob(root, extension, options=nil)
|
def self.register_glob(root, extension, options=nil)
|
||||||
self.asset_globs << [root, extension, options || {}]
|
asset_globs << [root, extension, options || {}]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.register_asset(asset, opts=nil)
|
def self.register_asset(asset, _opts = nil)
|
||||||
if asset =~ /\.js$|\.js\.erb$|\.js\.es6$|\.coffee$|\.coffee\.erb/
|
if asset =~ /\.js$|\.js\.erb$|\.js\.es6$|\.coffee$|\.coffee\.erb/
|
||||||
# if opts == :admin
|
javascripts << asset
|
||||||
# self.admin_javascripts << asset
|
|
||||||
# else
|
|
||||||
# if opts == :server_side
|
|
||||||
# self.server_side_javascripts << asset
|
|
||||||
# end
|
|
||||||
self.javascripts << asset
|
|
||||||
# end
|
|
||||||
elsif asset =~ /\.css$|\.scss$/
|
elsif asset =~ /\.css$|\.scss$/
|
||||||
# if opts == :mobile
|
stylesheets << asset
|
||||||
# self.mobile_stylesheets << asset
|
|
||||||
# elsif opts == :desktop
|
|
||||||
# self.desktop_stylesheets << asset
|
|
||||||
# elsif opts == :variables
|
|
||||||
# self.sass_variables << asset
|
|
||||||
# else
|
|
||||||
self.stylesheets << asset
|
|
||||||
# end
|
|
||||||
|
|
||||||
# elsif asset =~ /\.hbs$/
|
|
||||||
# self.handlebars << asset
|
|
||||||
# elsif asset =~ /\.js\.handlebars$/
|
|
||||||
# self.handlebars << asset
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.insert_code(key)
|
def self.insert_code(key)
|
||||||
self.code_insertions[key]&.join('\n')
|
code_insertions[key]&.join('\n')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user