Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request tsechingho#8 from eric1234/master
Browse files Browse the repository at this point in the history
Support for ckeditor 4.0
  • Loading branch information
tsechingho committed Dec 5, 2012
2 parents 0f551f5 + 9e195b8 commit fb6f881
Show file tree
Hide file tree
Showing 395 changed files with 2,569 additions and 2,130 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The `ckeditor_rails` gem integrates the `CKEditor` with the Rails asset pipeline

Include `ckeditor_rails` in Gemefile

gem 'ckeditor_rails', :require => 'ckeditor-rails'
gem 'ckeditor_rails'

Then run `bundle install`

Expand Down
3 changes: 1 addition & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ desc "Update CKEditor Library, VERSION is required."
task "update-ckeditor" do
files = SourceFile.new
files.fetch ENV['VERSION']
files.destination_root = "vendor/assets"
files.move
files.fix_css
files.fix_js
files.cleanup
end
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
//= require ckeditor/basepath
//= require ckeditor/ckeditor
//= require ckeditor/adapters/jquery
//= require ckeditor/jquery
153 changes: 56 additions & 97 deletions lib/ckeditor-rails/source_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,136 +5,95 @@ class SourceFile < Thor
source_root 'tmp'

desc "fetch VERSION", "fetch source files from http://ckeditor.com/"
def fetch(version)
download_url = file_url(version)
extract_path = self.class.source_root
archive_file = "#{extract_path}/#{filename(version)}"
def fetch version
download_url = file_url version
archive_file = "#{source_root}/#{filename(version)}"

in_root do
say_status(" fetch", archive_file, :green)
get(download_url, archive_file)
if File.exist?(archive_file)
FileUtils.mkdir_p(extract_path)
extract(archive_file, extract_path)
FileUtils.rm_rf(archive_file)
say_status " fetch", archive_file, :green
get download_url, archive_file
if File.exist? archive_file
FileUtils.mkdir_p source_root
extract archive_file, source_root
FileUtils.rm_rf archive_file
end
end

inside "lib" do
gsub_file "ckeditor-rails/version.rb", /VERSION\s=\s"(\d|\.)+"$/ do |match|
%Q{VERSION = "#{version}"}
end
end if File.exist?(extract_path)
end if File.exist? source_root
end

desc "move", "move source files to vendor/assets"
desc "move", "move source files"
def move
self.destination_root = "vendor/assets"

copy_file "ckeditor/adapters/jquery.js", "javascripts/ckeditor/adapters/jquery.js"
copy_file "ckeditor/ckeditor.js", "javascripts/ckeditor/ckeditor.js"
copy_file "ckeditor/ckeditor_basic.js", "javascripts/ckeditor/ckeditor_basic.js"
copy_file "ckeditor/config.js", "javascripts/ckeditor/config.js"
copy_file "ckeditor/contents.css", "stylesheets/ckeditor/contents.css"

directory "ckeditor/images", "images/ckeditor/images"
directory "ckeditor/lang", "javascripts/ckeditor/lang"

copy_file "ckeditor/LICENSE.html", "javascripts/ckeditor/LICENSE.html"

directory "ckeditor/plugins", "javascripts/ckeditor/plugins"
move_image_files_of_plugins

copy_image_files_of_skin(%w{kama office2003 v2})

directory "ckeditor/themes", "javascripts/ckeditor/themes"
end

desc "fix_css", "fix some css caused precompilation error"
def fix_css
self.destination_root = "vendor/assets"
inside destination_root do
skin_names = %w{kama office2003 v2}
skin_names.each do |name|
gsub_file "stylesheets/ckeditor/skins/#{name}/dialog.css", /\+margin/, "margin"
gsub_file "stylesheets/ckeditor/skins/#{name}/editor.css", /filter\:\;/, ""
FileUtils.rm_rf destination_root

[
['js', 'javascripts'],
['css', 'stylesheets'],
].each do |(type, asset_path)|
Dir["#{source_root}/ckeditor/*.#{type}"].each do |file|
file = File.basename file
copy_file "ckeditor/#{file}", "#{asset_path}/ckeditor/#{file}"
end
gsub_file "stylesheets/ckeditor/skins/office2003/editor.css", /\!height\:28px\;\!line-height\:28px\;/, ""
gsub_file "javascripts/ckeditor/plugins/uicolor/yui/assets/yui.css", /\*html/, "* html"
end
end

desc 'fix_js', 'fix some js caused execution error'
def fix_js
self.destination_root = "vendor/assets"
inside destination_root do
# Change the way IE detected to avoid compilation bug in production
%w{ckeditor ckeditor_basic}.each do |name|
gsub_file "javascripts/ckeditor/#{name}.js", "/*@cc_on!@*/false", "b.indexOf('msie')>-1"
end
end
end

desc "convert", "convert css to sass file by sass-convert"
def convert
self.destination_root = "vendor/assets"
inside destination_root do
skin_names = %w{kama office2003 v2}
skin_names.each do |name|
path = "stylesheets/ckeditor/skins/#{name}"
run("sass-convert -F css -T sass #{path}/dialog.css #{path}/dialog.css.sass")
run("sass-convert -F css -T sass #{path}/editor.css #{path}/editor.css.sass")
run("sass-convert -F css -T sass #{path}/templates.css #{path}/templates.css.sass")
remove_file "#{path}/dialog.css"
remove_file "#{path}/editor.css"
remove_file "#{path}/templates.css"
end
end
copy_file "ckeditor/LICENSE.md", "javascripts/ckeditor/LICENSE.md"
directory "ckeditor/lang", "javascripts/ckeditor/lang"
copy_plugins
copy_skins
end

desc "clean", "clean up useless files"
def cleanup
self.destination_root = "vendor/assets"
FileUtils.rm_rf(self.class.source_root)
FileUtils.rm_rf source_root
end

protected

def file_url(version)
def file_url version
"http://download.cksource.com/CKEditor/CKEditor/CKEditor%20#{version}/#{filename(version)}"
end

def filename(version)
"ckeditor_#{version}.tar.gz"
def filename version
"ckeditor_#{version}_full.tar.gz"
end

def extract(file_path, output_path)
system("tar --exclude=*.php --exclude=*.asp -C '#{output_path}' -xzf '#{file_path}' ckeditor")
def extract file_path, output_path
system "tar -C '#{output_path}' -xzf '#{file_path}' ckeditor"
end

def move_image_files_of_plugins
files = Dir.glob("#{destination_root}/javascripts/ckeditor/plugins/*/*/*")
files.each do |file|
if file =~ /\.(png|gif)$/
filename = file.sub("#{destination_root}/javascripts/", '')
destination_path = filename.sub(/\/\w+\.\w+$/, '')
in_root do
FileUtils.mkdir_p("#{destination_root}/images/#{destination_path}")
FileUtils.mv(file, "#{destination_root}/images/#{filename}")
end
end
def copy_plugins
Dir["#{source_root}/ckeditor/plugins/*"].each do |plugin|
copy_all "plugins/#{File.basename plugin}"
end
end

def copy_image_files_of_skin(skin_names = %w{kama office2003 v2})
skin_names.each do |name|
copy_file "ckeditor/skins/#{name}/dialog.css", "stylesheets/ckeditor/skins/#{name}/dialog.css"
copy_file "ckeditor/skins/#{name}/editor.css", "stylesheets/ckeditor/skins/#{name}/editor.css"
copy_file "ckeditor/skins/#{name}/icons.png", "images/ckeditor/skins/#{name}/icons.png"
copy_file "ckeditor/skins/#{name}/icons_rtl.png", "images/ckeditor/skins/#{name}/icons_rtl.png"
directory "ckeditor/skins/#{name}/images", "images/ckeditor/skins/#{name}/images"
copy_file "ckeditor/skins/#{name}/skin.js", "javascripts/ckeditor/skins/#{name}/skin.js"
copy_file "ckeditor/skins/#{name}/templates.css", "stylesheets/ckeditor/skins/#{name}/templates.css"
def copy_skins
Dir["#{source_root}/ckeditor/skins/*"].each do |skin|
copy_all "skins/#{File.basename skin}"
end
end

def copy_all path
copy_type path, 'css', 'stylesheets'
copy_type path, 'js', 'javascripts'
copy_type path, 'png', 'images'
copy_type path, 'gif', 'images'
copy_type path, 'jpg', 'images'
end

def copy_type path, type, asset_path
files = Dir["#{source_root}/ckeditor/#{path}/**/*.#{type}"]
files.each do |file|
file = file.sub /^#{Regexp.escape source_root}\//, ''
copy_file file, "#{asset_path}/#{file}"
end
end

def source_root
self.class.source_root
end
end
4 changes: 2 additions & 2 deletions lib/ckeditor-rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Ckeditor
module Rails
VERSION = "3.6.4.1"
EDITOR_VERSION = "3.6.4"
VERSION = "4.0"
EDITOR_VERSION = "4.0"
end
end
1 change: 1 addition & 0 deletions lib/ckeditor_rails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require 'ckeditor-rails'
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed vendor/assets/images/ckeditor/skins/kama/icons.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed vendor/assets/images/ckeditor/skins/v2/icons.png
Diff not rendered.
Binary file removed vendor/assets/images/ckeditor/skins/v2/icons_rtl.png
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed vendor/assets/images/ckeditor/skins/v2/images/mini.gif
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Loading

0 comments on commit fb6f881

Please sign in to comment.