Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit ce367297782946cc93ba20e5a6180da1acbbbbcd @galetahub committed Jun 23, 2011
Showing with 10,693 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. +22 −0 Gemfile
  3. +117 −0 Gemfile.lock
  4. +20 −0 MIT-LICENSE
  5. +83 −0 README.rdoc
  6. +29 −0 Rakefile
  7. +23 −0 app/controllers/ckeditor/attachment_files_controller.rb
  8. +32 −0 app/controllers/ckeditor/base_controller.rb
  9. +23 −0 app/controllers/ckeditor/pictures_controller.rb
  10. +32 −0 app/views/layouts/ckeditor.html.erb
  11. +21 −0 ckeditor.gemspec
  12. +6 −0 config/routes.rb
  13. +25 −0 lib/ckeditor.rb
  14. +25 −0 lib/ckeditor/engine.rb
  15. +11 −0 lib/ckeditor/helpers/form_builder.rb
  16. +25 −0 lib/ckeditor/helpers/form_helper.rb
  17. +19 −0 lib/ckeditor/helpers/view_helper.rb
  18. +15 −0 lib/ckeditor/hooks/formtastic.rb
  19. +28 −0 lib/ckeditor/hooks/simple_form.rb
  20. +51 −0 lib/ckeditor/utils.rb
  21. +6 −0 lib/ckeditor/version.rb
  22. +46 −0 lib/generators/ckeditor/install_generator.rb
  23. 0 lib/generators/ckeditor/templates/ckeditor.rb
  24. +13 −0 test/ckeditor_test.rb
  25. +7 −0 test/dummy/Rakefile
  26. +4 −0 test/dummy/app/controllers/application_controller.rb
  27. +83 −0 test/dummy/app/controllers/posts_controller.rb
  28. +2 −0 test/dummy/app/helpers/application_helper.rb
  29. +2 −0 test/dummy/app/helpers/posts_helper.rb
  30. +3 −0 test/dummy/app/models/post.rb
  31. +14 −0 test/dummy/app/views/layouts/application.html.erb
  32. +30 −0 test/dummy/app/views/posts/_form.html.erb
  33. +6 −0 test/dummy/app/views/posts/edit.html.erb
  34. +27 −0 test/dummy/app/views/posts/index.html.erb
  35. +5 −0 test/dummy/app/views/posts/new.html.erb
  36. +5 −0 test/dummy/app/views/posts/show.html.erb
  37. +4 −0 test/dummy/config.ru
  38. +45 −0 test/dummy/config/application.rb
  39. +10 −0 test/dummy/config/boot.rb
  40. +34 −0 test/dummy/config/database.yml
  41. +5 −0 test/dummy/config/environment.rb
  42. +26 −0 test/dummy/config/environments/development.rb
  43. +49 −0 test/dummy/config/environments/production.rb
  44. +35 −0 test/dummy/config/environments/test.rb
  45. +7 −0 test/dummy/config/initializers/backtrace_silencers.rb
  46. +10 −0 test/dummy/config/initializers/inflections.rb
  47. +5 −0 test/dummy/config/initializers/mime_types.rb
  48. +7 −0 test/dummy/config/initializers/secret_token.rb
  49. +8 −0 test/dummy/config/initializers/session_store.rb
  50. +5 −0 test/dummy/config/locales/en.yml
  51. +4 −0 test/dummy/config/routes.rb
  52. +14 −0 test/dummy/db/migrate/20110623120047_create_posts.rb
  53. +22 −0 test/dummy/db/schema.rb
  54. +26 −0 test/dummy/public/404.html
  55. +26 −0 test/dummy/public/422.html
  56. +26 −0 test/dummy/public/500.html
  57. 0 test/dummy/public/favicon.ico
  58. +2 −0 test/dummy/public/javascripts/application.js
  59. +965 −0 test/dummy/public/javascripts/controls.js
  60. +974 −0 test/dummy/public/javascripts/dragdrop.js
  61. +1,123 −0 test/dummy/public/javascripts/effects.js
  62. +6,001 −0 test/dummy/public/javascripts/prototype.js
  63. +191 −0 test/dummy/public/javascripts/rails.js
  64. 0 test/dummy/public/stylesheets/.gitkeep
  65. +56 −0 test/dummy/public/stylesheets/scaffold.css
  66. +6 −0 test/dummy/script/rails
  67. +13 −0 test/generators/install_generator_test.rb
  68. +7 −0 test/integration/navigation_test.rb
  69. +41 −0 test/integration/posts_test.rb
  70. +47 −0 test/routes_test.rb
  71. +5 −0 test/support/integration_case.rb
  72. +27 −0 test/test_helper.rb
@@ -0,0 +1,7 @@
+.bundle/
+log/*.log
+pkg/
+test/dummy/db/*.sqlite3
+test/dummy/log/*.log
+test/dummy/tmp/
+test/tmp
@@ -0,0 +1,22 @@
+source "http://rubygems.org"
+
+gemspec
+
+gem "rails", "3.0.9"
+
+platforms :ruby do
+ gem "mysql2", '0.2.11'
+
+ group :development, :test do
+ gem "capybara", ">= 0.4.0"
+ gem "redgreen", "~> 1.2.2"
+
+ # To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
+ # gem 'ruby-debug'
+ # gem 'ruby-debug19'
+ end
+
+ group :development do
+ gem "mongrel"
+ end
+end
@@ -0,0 +1,117 @@
+PATH
+ remote: .
+ specs:
+ ckeditor (3.6.0.dev)
+ mime-types (~> 1.16)
+ orm_adapter (~> 0.0.5)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ abstract (1.0.0)
+ actionmailer (3.0.9)
+ actionpack (= 3.0.9)
+ mail (~> 2.2.19)
+ actionpack (3.0.9)
+ activemodel (= 3.0.9)
+ activesupport (= 3.0.9)
+ builder (~> 2.1.2)
+ erubis (~> 2.6.6)
+ i18n (~> 0.5.0)
+ rack (~> 1.2.1)
+ rack-mount (~> 0.6.14)
+ rack-test (~> 0.5.7)
+ tzinfo (~> 0.3.23)
+ activemodel (3.0.9)
+ activesupport (= 3.0.9)
+ builder (~> 2.1.2)
+ i18n (~> 0.5.0)
+ activerecord (3.0.9)
+ activemodel (= 3.0.9)
+ activesupport (= 3.0.9)
+ arel (~> 2.0.10)
+ tzinfo (~> 0.3.23)
+ activeresource (3.0.9)
+ activemodel (= 3.0.9)
+ activesupport (= 3.0.9)
+ activesupport (3.0.9)
+ arel (2.0.10)
+ builder (2.1.2)
+ capybara (1.0.0)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (~> 0.2.0)
+ xpath (~> 0.1.4)
+ cgi_multipart_eof_fix (2.5.0)
+ childprocess (0.1.9)
+ ffi (~> 1.0.6)
+ daemons (1.1.4)
+ erubis (2.6.6)
+ abstract (>= 1.0.0)
+ fastthread (1.0.7)
+ ffi (1.0.9)
+ gem_plugin (0.2.3)
+ i18n (0.5.0)
+ json_pure (1.5.3)
+ mail (2.2.19)
+ activesupport (>= 2.3.6)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.16)
+ mongrel (1.1.5)
+ cgi_multipart_eof_fix (>= 2.4)
+ daemons (>= 1.0.3)
+ fastthread (>= 1.0.1)
+ gem_plugin (>= 0.2.3)
+ mysql2 (0.2.11)
+ nokogiri (1.4.6)
+ orm_adapter (0.0.5)
+ polyglot (0.3.1)
+ rack (1.2.3)
+ rack-mount (0.6.14)
+ rack (>= 1.0.0)
+ rack-test (0.5.7)
+ rack (>= 1.0)
+ rails (3.0.9)
+ actionmailer (= 3.0.9)
+ actionpack (= 3.0.9)
+ activerecord (= 3.0.9)
+ activeresource (= 3.0.9)
+ activesupport (= 3.0.9)
+ bundler (~> 1.0)
+ railties (= 3.0.9)
+ railties (3.0.9)
+ actionpack (= 3.0.9)
+ activesupport (= 3.0.9)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.4)
+ rake (0.9.2)
+ rdoc (3.6.1)
+ redgreen (1.2.2)
+ rubyzip (0.9.4)
+ selenium-webdriver (0.2.1)
+ childprocess (>= 0.1.7)
+ ffi (>= 1.0.7)
+ json_pure
+ rubyzip
+ thor (0.14.6)
+ treetop (1.4.9)
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.28)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ capybara (>= 0.4.0)
+ ckeditor!
+ mongrel
+ mysql2 (= 0.2.11)
+ rails (= 3.0.9)
+ redgreen (~> 1.2.2)
@@ -0,0 +1,20 @@
+Copyright 2011 AIMBULANCE
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,83 @@
+= Ckeditor
+
+CKEditor is a text editor to be used inside web pages. It's a WYSIWYG editor, which means that the text being edited on it looks as similar as possible to
+the results users have when publishing it. It brings to the web common editing features found on desktop editing applications like Microsoft Word and OpenOffice.
+
+== Features
+
+* Rails 3 integration
+* Files browser
+* HTML5 files uploader
+* Hooks for formtastic and simple_form forms generators
+
+== Install (not currently available, under construction)
+
+ gem "ckeditor", "~> 3.6.0"
+
+ rails generate ckeditor:install
+
+You can pass version of ckeditor to download (http://ckeditor.com/download/releases):
+
+ rails generate ckeditor:install --version=3.5.4
+
+== Usage
+
+ <%= javascript_include_tag :ckeditor %>
+
+ cktext_area_tag("test_area", "Ckeditor is the best")
+
+ cktext_area_tag("content", "Ckeditor", :input_html => {:cols => 10, :rows => 20}, :toolbar => 'Easy')
+
+* input_html - Options for text_area tag, others for ckeditor javascript configuration.
+* language - appends automatically, by default is I18n.locale
+* available ckeditor options - http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
+
+For configure ckeditor default options check:
+
+ public/javascripts/ckeditor/config.js
+
+This stylesheet use editor for displaying edit area:
+
+ public/javascripts/ckeditor/contents.css
+
+FormBuilder helper for more usefully:
+
+ <%= form_for @page do |form| -%>
+ ...
+ <%= form.cktext_area :notes, :toolbar => 'Full', :width => 800, :height => 400 %>
+ ...
+ <%= form.cktext_area :content, :input_html => { :value => "Default value" } %>
+ ...
+ <%= cktext_area :page, :info %>
+ <% end -%>
+
+=== AJAX
+
+Jquery sample:
+
+ <script type='text/javascript' charset='UTF-8'>
+ $(document).ready(function(){
+ $('form[data-remote]').bind("ajax:before", function(){
+ for (instance in CKEDITOR.instances){
+ CKEDITOR.instances[instance].updateElement();
+ }
+ });
+ });
+ </script>
+
+=== Formtastic integration
+
+ <%= form.input :content, :as => :ckeditor %>
+ <%= form.input :content, :as => :ckeditor, :input_html => { :height => 400 } %>
+
+=== SimpleForm integration
+
+ <%= form.ckeditor :content, :label => false, :input_html => { :toolbar => 'Full' } %>
+
+== I18n
+
+== Tests
+
+ rake test
+
+This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,29 @@
+# encoding: UTF-8
+require 'rubygems'
+begin
+ require 'bundler/setup'
+rescue LoadError
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
+end
+
+require 'rake'
+require 'rdoc/task'
+
+require 'rake/testtask'
+
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = false
+end
+
+task :default => :test
+
+RDoc::Task.new do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'Ckeditor'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README.rdoc')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
@@ -0,0 +1,23 @@
+class Ckeditor::AttachmentFilesController < Ckeditor::BaseController
+
+ def index
+ @attachments = Ckeditor.file_model.order("id DESC")
+ respond_with(@attachments)
+ end
+
+ def create
+ @attachment = Ckeditor.file_model.new
+ respond_with_asset(@attachment)
+ end
+
+ def destroy
+ @attachment.destroy
+ respond_with(@attachment, :location => ckeditor_attachments_path)
+ end
+
+ protected
+
+ def find_asset
+ @attachment = Ckeditor.file_model.find(params[:id])
+ end
+end
@@ -0,0 +1,32 @@
+class Ckeditor::BaseController < ApplicationController
+ respond_to :html, :json
+ layout "ckeditor"
+
+ protected
+
+ def respond_with_asset(record)
+ unless params[:CKEditor].blank?
+ params[@swf_file_post_name] = params.delete(:upload)
+ end
+
+ options = {}
+
+ params.each do |k, v|
+ key = k.to_s.downcase
+ options[key] = v if record.respond_to?("#{key}=")
+ end
+
+ record.attributes = options
+ record.user ||= current_user if respond_to?(:current_user)
+
+ if record.valid? && record.save
+ body = params[:CKEditor].blank? ? record.to_json(:only=>[:id, :type], :methods=>[:url, :content_type, :size, :filename, :format_created_at], :root => "asset") : %Q"<script type='text/javascript'>
+ window.parent.CKEDITOR.tools.callFunction(#{params[:CKEditorFuncNum]}, '#{Ckeditor::Utils.escape_single_quotes(record.url_content)}');
+ </script>"
+
+ render :text => body
+ else
+ render :nothing => true
+ end
+ end
+end
@@ -0,0 +1,23 @@
+class Ckeditor::PicturesController < Ckeditor::BaseController
+
+ def index
+ @pictures = Ckeditor.image_model.order("id DESC")
+ respond_with(@pictures)
+ end
+
+ def create
+ @picture = Ckeditor.image_model.new
+ respond_with_asset(@picture)
+ end
+
+ def destroy
+ @picture.destroy
+ respond_with(@picture, :location => ckeditor_pictures_path)
+ end
+
+ protected
+
+ def find_asset
+ @picture = Ckeditor.image_model.find(params[:id])
+ end
+end
@@ -0,0 +1,32 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title><%= I18n.t('page_title', :scope => [:ckeditor]) %></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <meta name="robots" content="noindex, nofollow">
+ <%= csrf_meta_tag %>
+
+ <link href="/javascripts/ckeditor/css/fck_editor.css" type="text/css" rel="stylesheet">
+ <link href="/javascripts/ckeditor/css/fck_dialog.css" type="text/css" rel="stylesheet">
+ <link href="/javascripts/ckeditor/css/ckfinder.css" type="text/css" rel="stylesheet">
+ <link href="/javascripts/ckeditor/css/swfupload.css" type="text/css" rel="stylesheet">
+
+ <script src="/javascripts/ckeditor/swfupload/jquery-1.5.1.min.js" type="text/javascript"></script>
+ <script src="/javascripts/ckeditor/swfupload/swfupload.js" type="text/javascript"></script>
+ <script src="/javascripts/ckeditor/swfupload/swfupload.queue.js" type="text/javascript"></script>
+ <script src="/javascripts/ckeditor/swfupload/fileprogress.js" type="text/javascript"></script>
+ <script src="/javascripts/ckeditor/swfupload/handlers.js" type="text/javascript"></script>
+ <script src="/javascripts/ckeditor/swfupload/querystring.js" type="text/javascript"></script>
+ <script src="/javascripts/ckeditor/swfupload/rails.js" type="text/javascript"></script>
+
+ <script type="text/javascript">
+ var params = new Querystring();
+ var CKEditorFuncNum = params.get("CKEditorFuncNum");
+ var CKEditorName = params.get("CKEditor");
+ var CKEDITOR = window.opener.CKEDITOR;
+ var editor = CKEDITOR.instances[CKEditorName];
+ </script>
+</head>
+<body style="margin: 0px; padding: 0px;">
+ <%= yield %>
+</body>
+</html>
Oops, something went wrong. Retry.

0 comments on commit ce36729

Please sign in to comment.