bcms_fckeditor 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/bcms_fckeditor.rb
CHANGED
@@ -1,2 +1,88 @@
|
|
1
1
|
require 'bcms_fckeditor/routes'
|
2
2
|
Cms.wysiwig_js = ['/bcms/fckeditor/fckeditor.js', '/bcms/fckeditor/editor.js']
|
3
|
+
|
4
|
+
# FCKeditor's file browser functionality is handled by SectionController#file_browser.
|
5
|
+
# However, the current implementation does not handle file uploads or cerating
|
6
|
+
# new sections or 'folders'.
|
7
|
+
# This patch implements a FCKeditor connector that plays well with BrowserCMS.
|
8
|
+
Cms::SectionsController.class_eval do
|
9
|
+
|
10
|
+
protect_from_forgery :except => :file_browser
|
11
|
+
|
12
|
+
# All requests generated by the file browser are handled by this controller
|
13
|
+
# action. Currently, there are 3 commands implemented:
|
14
|
+
# a) Uploading a new image, which creates a new ImageBlock
|
15
|
+
# b) Creating a new CMS Section
|
16
|
+
# c) Displaying file browser contents
|
17
|
+
def file_browser
|
18
|
+
@section = Section.find_by_name_path(params[:CurrentFolder])
|
19
|
+
if request.post? && params[:NewFile]
|
20
|
+
handle_file_browser_upload
|
21
|
+
elsif params[:NewFolderName]
|
22
|
+
create_section
|
23
|
+
else
|
24
|
+
render_file_browser
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
# Sections created through FCKeditor's file browser, are assigned to groups
|
31
|
+
# "guest", "cms-admin" and "content-editor" and are hidden from menues by
|
32
|
+
# default.
|
33
|
+
def create_section
|
34
|
+
section_path = build_path(params[:NewFolderName].to_slug)
|
35
|
+
|
36
|
+
begin
|
37
|
+
Section.create!(:name => params[:NewFolderName],
|
38
|
+
:path => section_path,
|
39
|
+
:parent_id => @section.id,
|
40
|
+
:group_ids => [1, 2, 3],
|
41
|
+
:hidden => true)
|
42
|
+
@result = "0"
|
43
|
+
rescue Exception => e
|
44
|
+
build_error_string(e)
|
45
|
+
end
|
46
|
+
|
47
|
+
render_response
|
48
|
+
end
|
49
|
+
|
50
|
+
# According to FCKeditor's documentation, server side connectors should rename
|
51
|
+
# a file when a file with the same name exists on the filesystem.
|
52
|
+
# This connector does not behave that way. If a filename exists, an error is
|
53
|
+
# returned. The rationale behind this decision is that uploading a file through the
|
54
|
+
# FCKeditor's file browser is essentially just another interface to creating a FileBlock
|
55
|
+
# or an ImageBlock.
|
56
|
+
def handle_file_browser_upload
|
57
|
+
upfile = params[:NewFile]
|
58
|
+
klass = params[:Type] == "File" ? FileBlock : ImageBlock
|
59
|
+
file_path = build_path(upfile.original_filename)
|
60
|
+
|
61
|
+
begin
|
62
|
+
klass.create!(:attachment_section => @section,
|
63
|
+
:attachment_file => upfile,
|
64
|
+
:attachment_file_path => file_path,
|
65
|
+
:publish_on_save => true,
|
66
|
+
:name => upfile.original_filename.capitalize)
|
67
|
+
@result = "0"
|
68
|
+
rescue Exception => e
|
69
|
+
build_error_string(e)
|
70
|
+
end
|
71
|
+
|
72
|
+
render_response
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def error_string(e)
|
78
|
+
@result = "1, '#{escape_javascript(e.message.to_sentence)}'"
|
79
|
+
end
|
80
|
+
|
81
|
+
def build_path(resource_name)
|
82
|
+
"%s%s%s" % [@section.path, @section.path == "/" ? "" : "/", resource_name]
|
83
|
+
end
|
84
|
+
|
85
|
+
def render_response
|
86
|
+
render :text => %Q{<script type="text/javascript">window.parent.frames['frmUpload'].OnUploadCompleted(#{@result});</script>}, :layout => false
|
87
|
+
end
|
88
|
+
end
|
@@ -187,7 +187,7 @@ function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
|
|
187
187
|
<frame src="frmresourcetype.html" scrolling="no" frameborder="0">
|
188
188
|
<frame name="frmFolders" src="frmfolders.html" scrolling="auto" frameborder="1">
|
189
189
|
</frameset>
|
190
|
-
<frameset rows="50,*,
|
190
|
+
<frameset rows="50,*,50" framespacing="0">
|
191
191
|
<frame name="frmActualFolder" src="frmactualfolder.html" scrolling="no" frameborder="0">
|
192
192
|
<frame name="frmResourcesList" src="frmresourceslist.html" scrolling="auto" frameborder="1">
|
193
193
|
<frameset cols="150,*,0" framespacing="0" frameborder="0">
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bcms_fckeditor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 17
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- BrowserMedia
|
@@ -9,19 +15,25 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-12-20 00:00:00 -06:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: browsercms
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 3
|
32
|
+
- 1
|
33
|
+
- 0
|
23
34
|
version: 3.1.0
|
24
|
-
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
25
37
|
description: A module for replacing the default WYSIWIG editor of browsercms with FCKEditor 2.6.3.
|
26
38
|
email: github@browsermedia.com
|
27
39
|
executables: []
|
@@ -356,6 +368,11 @@ files:
|
|
356
368
|
- LICENSE.txt
|
357
369
|
- README
|
358
370
|
- README.markdown
|
371
|
+
- test/custom_assertions.rb
|
372
|
+
- test/integration/cms/fckeditor_test.rb
|
373
|
+
- test/performance/browsing_test.rb
|
374
|
+
- test/test_helper.rb
|
375
|
+
- test/test_logging.rb
|
359
376
|
has_rdoc: true
|
360
377
|
homepage: http://github.com/browsermedia/bcms_fckeditor
|
361
378
|
licenses: []
|
@@ -366,21 +383,27 @@ rdoc_options:
|
|
366
383
|
require_paths:
|
367
384
|
- lib
|
368
385
|
required_ruby_version: !ruby/object:Gem::Requirement
|
386
|
+
none: false
|
369
387
|
requirements:
|
370
388
|
- - ">="
|
371
389
|
- !ruby/object:Gem::Version
|
390
|
+
hash: 3
|
391
|
+
segments:
|
392
|
+
- 0
|
372
393
|
version: "0"
|
373
|
-
version:
|
374
394
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
395
|
+
none: false
|
375
396
|
requirements:
|
376
397
|
- - ">="
|
377
398
|
- !ruby/object:Gem::Version
|
399
|
+
hash: 3
|
400
|
+
segments:
|
401
|
+
- 0
|
378
402
|
version: "0"
|
379
|
-
version:
|
380
403
|
requirements: []
|
381
404
|
|
382
405
|
rubyforge_project: bcms_fckeditor
|
383
|
-
rubygems_version: 1.3.
|
406
|
+
rubygems_version: 1.3.7
|
384
407
|
signing_key:
|
385
408
|
specification_version: 3
|
386
409
|
summary: A WYSIWIG editor for browsercms
|