ckeditor 3.5.4 → 3.6.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +23 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +96 -97
- data/Rakefile +16 -33
- data/app/controllers/ckeditor/attachment_files_controller.rb +4 -4
- data/app/controllers/ckeditor/base_controller.rb +15 -42
- data/app/controllers/ckeditor/pictures_controller.rb +3 -3
- data/app/views/ckeditor/attachment_files/index.html.erb +13 -51
- data/app/views/ckeditor/pictures/index.html.erb +14 -52
- data/app/views/ckeditor/shared/_asset.html.erb +19 -0
- data/app/views/ckeditor/shared/_asset_tmpl.html.erb +21 -0
- data/app/views/layouts/ckeditor.html.erb +16 -23
- data/config/locales/en.ckeditor.yml +3 -7
- data/config/locales/ru.ckeditor.yml +4 -8
- data/config/locales/uk.ckeditor.yml +4 -8
- data/config/routes.rb +3 -3
- data/lib/ckeditor.rb +30 -79
- data/lib/ckeditor/engine.rb +14 -13
- data/lib/ckeditor/helpers/controllers.rb +30 -0
- data/lib/ckeditor/helpers/form_builder.rb +11 -0
- data/lib/ckeditor/helpers/form_helper.rb +25 -0
- data/lib/ckeditor/helpers/view_helper.rb +19 -0
- data/lib/ckeditor/http.rb +81 -0
- data/lib/ckeditor/orm/active_record.rb +91 -0
- data/lib/ckeditor/utils.rb +51 -70
- data/lib/ckeditor/version.rb +2 -7
- data/lib/generators/ckeditor/install_generator.rb +62 -0
- data/lib/generators/ckeditor/models_generator.rb +51 -0
- data/lib/generators/ckeditor/templates/ckeditor.rb +18 -0
- data/lib/generators/ckeditor/templates/ckeditor/config.js +52 -0
- data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_add.jpg +0 -0
- data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_add.png +0 -0
- data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_del.png +0 -0
- data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/gal_more.gif +0 -0
- data/lib/generators/ckeditor/templates/ckeditor/filebrowser/images/preloader.gif +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/ckfnothumb.gif +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/mp3.gif +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/pdf.gif +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/rar.gif +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/swf.gif +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/images → templates/ckeditor/filebrowser/images/thumbs}/xls.gif +0 -0
- data/lib/generators/ckeditor/templates/ckeditor/filebrowser/javascripts/application.js +222 -0
- data/lib/generators/ckeditor/templates/ckeditor/filebrowser/stylesheets/uploader.css +112 -0
- data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/attachment/dialogs/attachment.js +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/images/attachment.png +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/lang/en.js +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/lang/ru.js +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/attachment/lang/uk.js +0 -0
- data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/attachment/plugin.js +0 -0
- data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/embed/dialogs/embed.js +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/images/embed.png +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/lang/en.js +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/lang/ru.js +0 -0
- data/lib/generators/ckeditor/{base/templates/ckeditor/_source → templates/ckeditor}/plugins/embed/lang/uk.js +0 -0
- data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/embed/plugin.js +0 -0
- data/lib/generators/ckeditor/templates/models/active_record/asset.rb +7 -0
- data/lib/generators/ckeditor/templates/models/active_record/attachment_file.rb +15 -0
- data/lib/generators/ckeditor/{migration/templates/models/paperclip → templates/models/active_record}/migration.rb +3 -8
- data/lib/generators/ckeditor/templates/models/active_record/picture.rb +13 -0
- data/test/ckeditor_test.rb +13 -0
- data/test/controllers/attachment_files_controller_test.rb +52 -0
- data/test/controllers/pictures_controller_test.rb +52 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/controllers/application_controller.rb +4 -0
- data/test/dummy/app/controllers/posts_controller.rb +83 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/posts_helper.rb +2 -0
- data/test/dummy/app/models/ckeditor/asset.rb +7 -0
- data/test/dummy/app/models/ckeditor/attachment_file.rb +15 -0
- data/test/dummy/app/models/ckeditor/picture.rb +13 -0
- data/test/dummy/app/models/post.rb +3 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/posts/_form.html.erb +30 -0
- data/test/dummy/app/views/posts/edit.html.erb +6 -0
- data/test/dummy/app/views/posts/index.html.erb +27 -0
- data/test/dummy/app/views/posts/new.html.erb +5 -0
- data/test/dummy/app/views/posts/show.html.erb +5 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +46 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +34 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +26 -0
- data/test/dummy/config/environments/production.rb +49 -0
- data/test/dummy/config/environments/test.rb +35 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/ckeditor.rb +18 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/db/migrate/20110623120047_create_posts.rb +14 -0
- data/test/dummy/db/migrate/20110705195648_create_ckeditor_assets.rb +26 -0
- data/test/dummy/db/schema.rb +36 -0
- data/test/dummy/log/development.log +818 -0
- data/test/dummy/log/production.log +0 -0
- data/test/dummy/log/server.log +0 -0
- data/test/dummy/log/test.log +5398 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/javascripts/application.js +2 -0
- data/test/dummy/public/javascripts/controls.js +965 -0
- data/test/dummy/public/javascripts/dragdrop.js +974 -0
- data/test/dummy/public/javascripts/effects.js +1123 -0
- data/test/dummy/public/javascripts/prototype.js +6001 -0
- data/test/dummy/public/javascripts/rails.js +191 -0
- data/test/dummy/public/stylesheets/scaffold.css +56 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/fixtures/files/rails.png +0 -0
- data/test/dummy/test/fixtures/files/rails.tar.gz +0 -0
- data/test/generators/install_generator_test.rb +18 -0
- data/test/generators/models_generator_test.rb +21 -0
- data/test/integration/navigation_test.rb +7 -0
- data/test/integration/posts_test.rb +41 -0
- data/test/routes_test.rb +47 -0
- data/test/support/integration_case.rb +5 -0
- data/test/test_helper.rb +28 -0
- data/test/tmp/app/models/ckeditor/asset.rb +7 -0
- data/test/tmp/app/models/ckeditor/attachment_file.rb +15 -0
- data/test/tmp/app/models/ckeditor/picture.rb +13 -0
- data/test/tmp/db/migrate/20110711170413_create_ckeditor_assets.rb +26 -0
- metadata +220 -99
- data/CHANGELOG +0 -15
- data/app/helpers/ckeditor/base_helper.rb +0 -21
- data/app/views/ckeditor/_asset.html.erb +0 -20
- data/app/views/ckeditor/_swfupload.html.erb +0 -73
- data/lib/ckeditor/form_builder.rb +0 -22
- data/lib/ckeditor/middleware.rb +0 -18
- data/lib/ckeditor/view_helper.rb +0 -92
- data/lib/generators/ckeditor/base/USAGE +0 -9
- data/lib/generators/ckeditor/base/base_generator.rb +0 -41
- data/lib/generators/ckeditor/base/templates/ckeditor.rb +0 -54
- data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/attachment/dialogs/attachment.js +0 -384
- data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/attachment/plugin.js +0 -44
- data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/embed/dialogs/embed.js +0 -65
- data/lib/generators/ckeditor/base/templates/ckeditor/_source/plugins/embed/plugin.js +0 -43
- data/lib/generators/ckeditor/base/templates/ckeditor/config.js +0 -43
- data/lib/generators/ckeditor/base/templates/ckeditor/css/ckfinder.css +0 -316
- data/lib/generators/ckeditor/base/templates/ckeditor/css/fck_dialog.css +0 -119
- data/lib/generators/ckeditor/base/templates/ckeditor/css/fck_editor.css +0 -448
- data/lib/generators/ckeditor/base/templates/ckeditor/css/swfupload.css +0 -94
- data/lib/generators/ckeditor/base/templates/ckeditor/images/add.gif +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/images/cancelbutton.gif +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/images/doc.gif +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/images/refresh.gif +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/images/select_files.png +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/images/spacer.gif +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/images/toolbar.start.gif +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/images/attachment.png +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/lang/en.js +0 -10
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/lang/ru.js +0 -10
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/attachment/lang/uk.js +0 -10
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/images/embed.png +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/lang/en.js +0 -9
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/lang/ru.js +0 -9
- data/lib/generators/ckeditor/base/templates/ckeditor/plugins/embed/lang/uk.js +0 -9
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/fileprogress.js +0 -266
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/handlers.js +0 -181
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/jquery-1.5.1.min.js +0 -16
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/querystring.js +0 -40
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/rails.js +0 -158
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.js +0 -1
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.queue.js +0 -1
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.swf +0 -0
- data/lib/generators/ckeditor/base/templates/ckeditor/swfupload/swfupload.swfobject.js +0 -111
- data/lib/generators/ckeditor/migration/USAGE +0 -12
- data/lib/generators/ckeditor/migration/migration_generator.rb +0 -46
- data/lib/generators/ckeditor/migration/templates/models/attachment_fu/asset.rb +0 -32
- data/lib/generators/ckeditor/migration/templates/models/attachment_fu/attachment_file.rb +0 -24
- data/lib/generators/ckeditor/migration/templates/models/attachment_fu/migration.rb +0 -30
- data/lib/generators/ckeditor/migration/templates/models/attachment_fu/picture.rb +0 -25
- data/lib/generators/ckeditor/migration/templates/models/paperclip/asset.rb +0 -97
- data/lib/generators/ckeditor/migration/templates/models/paperclip/attachment_file.rb +0 -40
- data/lib/generators/ckeditor/migration/templates/models/paperclip/picture.rb +0 -23
- data/lib/tasks/ckeditor_tasks.rake +0 -3
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/attachment/plugin.js
RENAMED
File without changes
|
data/lib/generators/ckeditor/{base/templates → templates}/ckeditor/plugins/embed/dialogs/embed.js
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Ckeditor::AttachmentFile < Ckeditor::Asset
|
2
|
+
has_attached_file :data,
|
3
|
+
:url => "/ckeditor_assets/attachments/:id/:filename",
|
4
|
+
:path => ":rails_root/public/ckeditor_assets/attachments/:id/:filename"
|
5
|
+
|
6
|
+
validates_attachment_size :data, :less_than => 100.megabytes
|
7
|
+
validates_attachment_presence :data
|
8
|
+
|
9
|
+
def url_thumb
|
10
|
+
@url_thumb ||= begin
|
11
|
+
extname = File.extname(filename).gsub(/^\./, '')
|
12
|
+
"/javascripts/ckeditor/filebrowser/images/thumbs/#{extname}.gif"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -7,11 +7,7 @@ class CreateCkeditorAssets < ActiveRecord::Migration
|
|
7
7
|
|
8
8
|
t.integer :assetable_id
|
9
9
|
t.string :assetable_type, :limit => 30
|
10
|
-
t.string :type, :limit =>
|
11
|
-
t.string :guid, :limit => 10
|
12
|
-
|
13
|
-
t.integer :locale, :limit => 1, :default => 0
|
14
|
-
t.integer :user_id
|
10
|
+
t.string :type, :limit => 30
|
15
11
|
|
16
12
|
# Uncomment it to save images dimensions, if your need it
|
17
13
|
# t.integer :width
|
@@ -20,9 +16,8 @@ class CreateCkeditorAssets < ActiveRecord::Migration
|
|
20
16
|
t.timestamps
|
21
17
|
end
|
22
18
|
|
23
|
-
add_index "ckeditor_assets", ["assetable_type", "type", "assetable_id"], :name => "
|
24
|
-
add_index "ckeditor_assets", ["assetable_type", "assetable_id"], :name => "
|
25
|
-
add_index "ckeditor_assets", ["user_id"], :name => "fk_user"
|
19
|
+
add_index "ckeditor_assets", ["assetable_type", "type", "assetable_id"], :name => "idx_ckeditor_assetable_type"
|
20
|
+
add_index "ckeditor_assets", ["assetable_type", "assetable_id"], :name => "idx_ckeditor_assetable"
|
26
21
|
end
|
27
22
|
|
28
23
|
def self.down
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Ckeditor::Picture < Ckeditor::Asset
|
2
|
+
has_attached_file :data,
|
3
|
+
:url => "/ckeditor_assets/pictures/:id/:style_:basename.:extension",
|
4
|
+
:path => ":rails_root/public/ckeditor_assets/pictures/:id/:style_:basename.:extension",
|
5
|
+
:styles => { :content => '800>', :thumb => '118x100#' }
|
6
|
+
|
7
|
+
validates_attachment_size :data, :less_than => 2.megabytes
|
8
|
+
validates_attachment_presence :data
|
9
|
+
|
10
|
+
def url_content
|
11
|
+
url(:content)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class AttachmentFilesControllerTest < ActionController::TestCase
|
4
|
+
tests Ckeditor::AttachmentFilesController
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@attachment = fixture_file_upload('files/rails.tar.gz', 'application/x-gzip')
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
Ckeditor::AttachmentFile.destroy_all
|
12
|
+
end
|
13
|
+
|
14
|
+
test "index action" do
|
15
|
+
get :index
|
16
|
+
|
17
|
+
assert_equal 200, @response.status
|
18
|
+
assert_template "ckeditor/attachment_files/index"
|
19
|
+
end
|
20
|
+
|
21
|
+
test "create action via filebrowser" do
|
22
|
+
assert_difference 'Ckeditor::AttachmentFile.count' do
|
23
|
+
post :create, :qqfile => @attachment
|
24
|
+
end
|
25
|
+
|
26
|
+
assert_equal 200, @response.status
|
27
|
+
end
|
28
|
+
|
29
|
+
test "create action via CKEditor upload form" do
|
30
|
+
assert_difference 'Ckeditor::AttachmentFile.count' do
|
31
|
+
post :create, :upload => @attachment, :CKEditor => 'ckeditor_field'
|
32
|
+
end
|
33
|
+
|
34
|
+
assert_equal 200, @response.status
|
35
|
+
end
|
36
|
+
|
37
|
+
test "invalid params for create action" do
|
38
|
+
assert_no_difference 'Ckeditor::AttachmentFile.count' do
|
39
|
+
post :create, :qqfile => nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
test "destroy action via filebrowser" do
|
44
|
+
@attachment_file = Ckeditor::AttachmentFile.create :data => @attachment
|
45
|
+
|
46
|
+
assert_difference 'Ckeditor::AttachmentFile.count', -1 do
|
47
|
+
delete :destroy, :id => @attachment_file.id
|
48
|
+
end
|
49
|
+
|
50
|
+
assert_equal 302, @response.status
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PicturesControllerTest < ActionController::TestCase
|
4
|
+
tests Ckeditor::PicturesController
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@image = fixture_file_upload('files/rails.png', 'image/png')
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
Ckeditor::Picture.destroy_all
|
12
|
+
end
|
13
|
+
|
14
|
+
test "index action" do
|
15
|
+
get :index
|
16
|
+
|
17
|
+
assert_equal 200, @response.status
|
18
|
+
assert_template "ckeditor/pictures/index"
|
19
|
+
end
|
20
|
+
|
21
|
+
test "create action via filebrowser" do
|
22
|
+
assert_difference 'Ckeditor::Picture.count' do
|
23
|
+
post :create, :qqfile => @image
|
24
|
+
end
|
25
|
+
|
26
|
+
assert_equal 200, @response.status
|
27
|
+
end
|
28
|
+
|
29
|
+
test "create action via CKEditor upload form" do
|
30
|
+
assert_difference 'Ckeditor::Picture.count' do
|
31
|
+
post :create, :upload => @image, :CKEditor => 'ckeditor_field'
|
32
|
+
end
|
33
|
+
|
34
|
+
assert_equal 200, @response.status
|
35
|
+
end
|
36
|
+
|
37
|
+
test "invalid params for create action" do
|
38
|
+
assert_no_difference 'Ckeditor::Picture.count' do
|
39
|
+
post :create, :qqfile => nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
test "destroy action via filebrowser" do
|
44
|
+
@picture = Ckeditor::Picture.create :data => @image
|
45
|
+
|
46
|
+
assert_difference 'Ckeditor::Picture.count', -1 do
|
47
|
+
delete :destroy, :id => @picture.id
|
48
|
+
end
|
49
|
+
|
50
|
+
assert_equal 302, @response.status
|
51
|
+
end
|
52
|
+
end
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,83 @@
|
|
1
|
+
class PostsController < ApplicationController
|
2
|
+
# GET /posts
|
3
|
+
# GET /posts.xml
|
4
|
+
def index
|
5
|
+
@posts = Post.all
|
6
|
+
|
7
|
+
respond_to do |format|
|
8
|
+
format.html # index.html.erb
|
9
|
+
format.xml { render :xml => @posts }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /posts/1
|
14
|
+
# GET /posts/1.xml
|
15
|
+
def show
|
16
|
+
@post = Post.find(params[:id])
|
17
|
+
|
18
|
+
respond_to do |format|
|
19
|
+
format.html # show.html.erb
|
20
|
+
format.xml { render :xml => @post }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# GET /posts/new
|
25
|
+
# GET /posts/new.xml
|
26
|
+
def new
|
27
|
+
@post = Post.new
|
28
|
+
|
29
|
+
respond_to do |format|
|
30
|
+
format.html # new.html.erb
|
31
|
+
format.xml { render :xml => @post }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# GET /posts/1/edit
|
36
|
+
def edit
|
37
|
+
@post = Post.find(params[:id])
|
38
|
+
end
|
39
|
+
|
40
|
+
# POST /posts
|
41
|
+
# POST /posts.xml
|
42
|
+
def create
|
43
|
+
@post = Post.new(params[:post])
|
44
|
+
|
45
|
+
respond_to do |format|
|
46
|
+
if @post.save
|
47
|
+
format.html { redirect_to(@post, :notice => 'Post was successfully created.') }
|
48
|
+
format.xml { render :xml => @post, :status => :created, :location => @post }
|
49
|
+
else
|
50
|
+
format.html { render :action => "new" }
|
51
|
+
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# PUT /posts/1
|
57
|
+
# PUT /posts/1.xml
|
58
|
+
def update
|
59
|
+
@post = Post.find(params[:id])
|
60
|
+
|
61
|
+
respond_to do |format|
|
62
|
+
if @post.update_attributes(params[:post])
|
63
|
+
format.html { redirect_to(@post, :notice => 'Post was successfully updated.') }
|
64
|
+
format.xml { head :ok }
|
65
|
+
else
|
66
|
+
format.html { render :action => "edit" }
|
67
|
+
format.xml { render :xml => @post.errors, :status => :unprocessable_entity }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# DELETE /posts/1
|
73
|
+
# DELETE /posts/1.xml
|
74
|
+
def destroy
|
75
|
+
@post = Post.find(params[:id])
|
76
|
+
@post.destroy
|
77
|
+
|
78
|
+
respond_to do |format|
|
79
|
+
format.html { redirect_to(posts_url) }
|
80
|
+
format.xml { head :ok }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Ckeditor::AttachmentFile < Ckeditor::Asset
|
2
|
+
has_attached_file :data,
|
3
|
+
:url => "/ckeditor_assets/attachments/:id/:filename",
|
4
|
+
:path => ":rails_root/public/ckeditor_assets/attachments/:id/:filename"
|
5
|
+
|
6
|
+
validates_attachment_size :data, :less_than => 100.megabytes
|
7
|
+
validates_attachment_presence :data
|
8
|
+
|
9
|
+
def url_thumb
|
10
|
+
@url_thumb ||= begin
|
11
|
+
extname = File.extname(filename).gsub(/^\./, '')
|
12
|
+
"/javascripts/ckeditor/filebrowser/images/thumbs/#{extname}.gif"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Ckeditor::Picture < Ckeditor::Asset
|
2
|
+
has_attached_file :data,
|
3
|
+
:url => "/ckeditor_assets/pictures/:id/:style_:basename.:extension",
|
4
|
+
:path => ":rails_root/public/ckeditor_assets/pictures/:id/:style_:basename.:extension",
|
5
|
+
:styles => { :content => '800>', :thumb => '118x100#' }
|
6
|
+
|
7
|
+
validates_attachment_size :data, :less_than => 2.megabytes
|
8
|
+
validates_attachment_presence :data
|
9
|
+
|
10
|
+
def url_content
|
11
|
+
url(:content)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%= form_for(@post) do |f| %>
|
2
|
+
<% if @post.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @post.errors.full_messages.each do |msg| %>
|
8
|
+
<li><%= msg %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<%= f.label :title %>
|
15
|
+
<%= f.text_field :title %>
|
16
|
+
|
17
|
+
<%= f.label :content %>
|
18
|
+
<%= f.cktext_area :content, :width => 800, :height => 400 %>
|
19
|
+
|
20
|
+
<%= f.label :info %>
|
21
|
+
<% if @post.new_record? %>
|
22
|
+
<%= cktext_area :post, :info, :input_html => { :value => "Defaults info content" } %>
|
23
|
+
<% else %>
|
24
|
+
<%= cktext_area :post, :info, :input_html => { :cols => 50, :rows => 70 } %>
|
25
|
+
<% end %>
|
26
|
+
|
27
|
+
<div class="actions">
|
28
|
+
<%= f.submit %>
|
29
|
+
</div>
|
30
|
+
<% end %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<h1>Listing posts</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<th></th>
|
6
|
+
<th></th>
|
7
|
+
<th></th>
|
8
|
+
</tr>
|
9
|
+
|
10
|
+
<% @posts.each do |post| %>
|
11
|
+
<tr>
|
12
|
+
<td><%= link_to 'Show', post %></td>
|
13
|
+
<td><%= link_to 'Edit', edit_post_path(post) %></td>
|
14
|
+
<td><%= link_to 'Destroy', post, :confirm => 'Are you sure?', :method => :delete %></td>
|
15
|
+
</tr>
|
16
|
+
<% end %>
|
17
|
+
</table>
|
18
|
+
|
19
|
+
<br />
|
20
|
+
|
21
|
+
<%= link_to 'New Post', new_post_path %>
|
22
|
+
|
23
|
+
<h2>Text area test</h2>
|
24
|
+
<%= cktext_area_tag("test_area", "Ckeditor") %>
|
25
|
+
|
26
|
+
<h2>Text area test with options</h2>
|
27
|
+
<%= cktext_area_tag("content", "Ckeditor", :input_html => {:cols => 10, :rows => 20}, :toolbar => 'Easy') %>
|