-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
439 changed files
with
12,771 additions
and
2,898 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,13 @@ | ||
# Include hook code here | ||
require 'ckeditor_config' | ||
require 'ckeditor' | ||
require 'ckeditor_version' | ||
require 'ckeditor_file_utils' | ||
Dir[File.join(File.dirname(__FILE__), 'vendor/*/lib')].each do |path| | ||
$LOAD_PATH.unshift path | ||
end | ||
|
||
CkeditorFileUtils.check_and_install | ||
require 'ckeditor' | ||
|
||
# make plugin controller available to app | ||
config.load_paths += %W(#{Ckeditor::PLUGIN_CONTROLLER_PATH} #{Ckeditor::PLUGIN_HELPER_PATH}) | ||
|
||
Rails::Initializer.run(:set_load_path, config) | ||
|
||
ActionView::Base.send(:include, Ckeditor::Helper) | ||
|
||
# require the controller | ||
require 'ckeditor_controller' | ||
|
||
class ActionController::Routing::RouteSet | ||
unless (instance_methods.include?('draw_with_ckeditor')) | ||
class_eval <<-"end_eval", __FILE__, __LINE__ | ||
alias draw_without_ckeditor draw | ||
def draw_with_ckeditor | ||
draw_without_ckeditor do |map| | ||
map.connect 'ckeditor/images', :controller => 'ckeditor', :action => 'images' | ||
map.connect 'ckeditor/files', :controller => 'ckeditor', :action => 'files' | ||
map.connect 'ckeditor/create', :controller => 'ckeditor', :action => 'create' | ||
yield map | ||
end | ||
end | ||
alias draw draw_with_ckeditor | ||
end_eval | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module Ckeditor | ||
|
||
class Config | ||
cattr_accessor :filepath | ||
@@filepath = File.join(RAILS_ROOT, "config/ckeditor.yml") | ||
|
||
@@available_settings = (File.exists?(@@filepath) ? YAML::load(File.open(@@filepath))[RAILS_ENV] : nil) | ||
|
||
class << self | ||
|
||
def [](name) | ||
return if @@available_settings.nil? | ||
@@available_settings[name.to_s] | ||
end | ||
|
||
def method_missing(method, *args) | ||
method_name = method.to_s | ||
return self[method_name].to_s if !@@available_settings.nil? && @@available_settings.keys.include?(method_name) | ||
super | ||
end | ||
|
||
def exists? | ||
File.exists?(@@filepath) | ||
end | ||
|
||
def create_yml | ||
unless File.exists?(@@filepath) | ||
ck_config = File.join(RAILS_ROOT, 'vendor/plugins/rails-ckeditor/', 'ckeditor.yml.tpl') | ||
FileUtils.cp ck_config, @@filepath unless File.exist?(@@filepath) | ||
|
||
log "#{@@filepath} example file created!" | ||
log "Please modify your settings" | ||
else | ||
log "config/#{@@filepath} already exists. Aborting task..." | ||
end | ||
end | ||
|
||
def log(message) | ||
STDOUT.puts message | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.