Module: Ckeditor
- Defined in:
- lib/ckeditor.rb,
lib/ckeditor/http.rb,
lib/ckeditor/rails.rb,
lib/ckeditor/utils.rb,
lib/ckeditor/version.rb,
lib/ckeditor/orm/base.rb,
lib/ckeditor/text_area.rb,
lib/ckeditor/orm/mongoid.rb,
lib/ckeditor/paginatable.rb,
lib/ckeditor/hooks/cancan.rb,
lib/ckeditor/hooks/pundit.rb,
lib/ckeditor/asset_response.rb,
lib/ckeditor/backend/shrine.rb,
lib/ckeditor/backend/dragonfly.rb,
lib/ckeditor/backend/paperclip.rb,
lib/ckeditor/hooks/simple_form.rb,
lib/ckeditor/orm/active_record.rb,
lib/ckeditor/backend/carrierwave.rb,
lib/ckeditor/helpers/controllers.rb,
lib/ckeditor/helpers/form_helper.rb,
lib/ckeditor/helpers/view_helper.rb,
lib/ckeditor/helpers/form_builder.rb,
lib/ckeditor/utils/javascript_code.rb,
lib/ckeditor/backend/active_storage.rb,
lib/generators/ckeditor/install_generator.rb,
lib/generators/ckeditor/pundit_policy_generator.rb,
lib/generators/ckeditor/templates/mongoid/shrine/ckeditor/picture.rb,
lib/generators/ckeditor/templates/mongoid/shrine/ckeditor/attachment_file.rb
Defined Under Namespace
Modules: ApplicationHelper, Backend, Generators, Helpers, Hooks, Http, Orm, Utils, Version
Classes: ApplicationController, Asset, AssetResponse, AttachmentFile, AttachmentFilePolicy, AttachmentFileUploader, AttachmentFilesController, Engine, Paginatable, Picture, PicturePolicy, PictureUploader, PicturesController, TextArea
Constant Summary
collapse
- IMAGE_TYPES =
%w[image/jpeg image/png image/gif image/jpg image/pjpeg image/tiff image/x-png].freeze
- DEFAULT_AUTHORIZE =
-> {}
- AUTHORIZATION_ADAPTERS =
{}
- DEFAULT_CURRENT_USER =
lambda do
request.env['warden'].try(:user) || respond_to?(:current_user) && current_user
end
- @@image_file_types =
%w[jpg jpeg png gif tiff]
- @@flash_file_types =
%w[swf]
- @@attachment_file_types =
%w[doc docx xls odt ods pdf rar zip tar tar.gz swf]
- @@relative_path =
'ckeditor'
- @@asset_path =
nil
- @@run_on_precompile =
true
- @@default_per_page =
24
- @@cdn_url =
'//cdn.ckeditor.com/4.11.3/standard/ckeditor.js'
- @@js_config_url =
'ckeditor/config.js'
- @@picture_model =
nil
- @@attachment_file_model =
nil
- @@parent_controller =
'ApplicationController'
- @@controller_layout =
'ckeditor/application'
- @@assets_pipeline_enabled =
nil
Class Method Summary
collapse
Class Method Details
.assets ⇒ Object
All css and js files from ckeditor folder
122
123
124
|
# File 'lib/ckeditor.rb', line 122
def self.assets
@assets ||= Ckeditor.cdn_enabled? ? ['ckeditor/config.js'] : []
end
|
.assets=(value) ⇒ Object
126
127
128
|
# File 'lib/ckeditor.rb', line 126
def self.assets=(value)
@assets = value.nil? ? nil : Array(value)
end
|
.assets_pipeline_enabled? ⇒ Boolean
235
236
237
238
|
# File 'lib/ckeditor.rb', line 235
def self.assets_pipeline_enabled?
@@assets_pipeline_enabled = Utils.assets_pipeline_enabled? if @@assets_pipeline_enabled.nil?
@@assets_pipeline_enabled
end
|
.attachment_file_adapter ⇒ Object
180
181
182
|
# File 'lib/ckeditor.rb', line 180
def self.attachment_file_adapter
attachment_file_model.to_adapter
end
|
.attachment_file_model(&block) ⇒ Object
161
162
163
164
165
166
167
168
169
170
171
172
173
|
# File 'lib/ckeditor.rb', line 161
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
|
.attachment_file_model=(value) ⇒ Object
175
176
177
178
|
# File 'lib/ckeditor.rb', line 175
def self.attachment_file_model=(value)
@@attachment_file_model_class = nil
@@attachment_file_model = value
end
|
.authorize_with(*args, &block) ⇒ Object
Setup authorization to be run as a before filter This is run inside the controller instance so you can setup any authorization you need to.
By default, there is no authorization.
To use an authorization adapter, pass the name of the adapter. For example, to use with CanCanCan, pass it like this.
204
205
206
207
208
209
210
211
212
213
214
215
216
|
# File 'lib/ckeditor.rb', line 204
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
|
.base_path ⇒ Object
117
118
119
|
# File 'lib/ckeditor.rb', line 117
def self.base_path
@base_path ||= (asset_path || File.join([Rails.application.config.assets.prefix, '/ckeditor/']))
end
|
.cdn_enabled? ⇒ Boolean
134
135
136
|
# File 'lib/ckeditor.rb', line 134
def self.cdn_enabled?
!@@cdn_url.nil?
end
|
.current_user_method(&block) ⇒ Object
Setup a different method to determine the current user or admin logged in. This is run inside the controller instance and made available as a helper.
By default, request.env.user or current_user will be used.
230
231
232
233
|
# File 'lib/ckeditor.rb', line 230
def self.current_user_method(&block)
@current_user = block if block_given?
@current_user || DEFAULT_CURRENT_USER
end
|
.picture_adapter ⇒ Object
157
158
159
|
# File 'lib/ckeditor.rb', line 157
def self.picture_adapter
picture_model.to_adapter
end
|
.picture_model(&block) ⇒ Object
138
139
140
141
142
143
144
145
146
147
148
149
150
|
# File 'lib/ckeditor.rb', line 138
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
|
.picture_model=(value) ⇒ Object
152
153
154
155
|
# File 'lib/ckeditor.rb', line 152
def self.picture_model=(value)
@@picture_model_class = nil
@@picture_model = value
end
|
.root_path ⇒ Object
113
114
115
|
# File 'lib/ckeditor.rb', line 113
def self.root_path
@root_path ||= Pathname.new(File.dirname(File.expand_path('../', __FILE__)))
end
|
.run_on_precompile? ⇒ Boolean
130
131
132
|
# File 'lib/ckeditor.rb', line 130
def self.run_on_precompile?
@@run_on_precompile
end
|
.setup {|_self| ... } ⇒ Object
Default way to setup Ckeditor. Run rails generate ckeditor to create a fresh initializer with all configuration values.
109
110
111
|
# File 'lib/ckeditor.rb', line 109
def self.setup
yield self
end
|