module Ckeditor
def self.assets
def self.assets @assets ||= Ckeditor.cdn_enabled? ? ['ckeditor/config.js'] : [] end
def self.assets=(value)
def self.assets=(value) @assets = value.nil? ? nil : Array(value) end
def self.assets_pipeline_enabled?
def self.assets_pipeline_enabled? @@assets_pipeline_enabled = Utils.assets_pipeline_enabled? if @@assets_pipeline_enabled.nil? @@assets_pipeline_enabled end
def self.attachment_file_adapter
def self.attachment_file_adapter attachment_file_model.to_adapter end
def self.attachment_file_model(&block)
def self.attachment_file_model(&block) if block_given? self.attachment_file_model = block else @@attachment_file_model_class ||= begin if @@attachment_file_model.respond_to? :call @@attachment_file_model.call else @@attachment_file_model || Ckeditor::AttachmentFile end end end end
def self.attachment_file_model=(value)
def self.attachment_file_model=(value) @@attachment_file_model_class = nil @@attachment_file_model = value end
def self.authorize_with(*args, &block)
- Example: CanCanCan -
Example: Custom -
def self.authorize_with(*args, &block) extension = args.shift if extension @authorize = lambda do @authorization_adapter = Ckeditor::AUTHORIZATION_ADAPTERS[extension].new(*([self] + args).compact) end elsif block_given? @authorize = block end @authorize || DEFAULT_AUTHORIZE end
def self.base_path
def self.base_path @base_path ||= (asset_path || File.join([Rails.application.config.assets.prefix, '/ckeditor/'])) end
def self.cdn_enabled?
def self.cdn_enabled? !@@cdn_url.nil? end
def self.current_user_method(&block)
- Example: Custom -
def self.current_user_method(&block) @current_user = block if block_given? @current_user || DEFAULT_CURRENT_USER end
def self.picture_adapter
def self.picture_adapter picture_model.to_adapter end
def self.picture_model(&block)
def self.picture_model(&block) if block_given? self.picture_model = block else @@picture_model_class ||= begin if @@picture_model.respond_to? :call @@picture_model.call else @@picture_model || Ckeditor::Picture end end end end
def self.picture_model=(value)
def self.picture_model=(value) @@picture_model_class = nil @@picture_model = value end
def self.root_path
def self.root_path @root_path ||= Pathname.new(File.dirname(File.expand_path('../', __FILE__))) end
def self.run_on_precompile?
def self.run_on_precompile? @@run_on_precompile end
def self.setup
end
config.attachment_file_types += ["xml"]
config.default_per_page = 30
Ckeditor.setup do |config|
@example
a fresh initializer with all configuration values.
Default way to setup Ckeditor. Run rails generate ckeditor to create
def self.setup yield self end