forked from jfernandez/fckeditor
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added spell check, fixed flash, fixed path issues
git-svn-id: svn://rubyforge.org//var/svn/fckeditorp/trunk/fckeditor@22 13c73f65-831a-0410-84ff-c4c9c9a2e73e
- Loading branch information
srutherford
committed
Aug 26, 2006
1 parent
086b94e
commit 3da68c5
Showing
9 changed files
with
175 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
|
||
<%= stylesheet_link_tag "/javascripts/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellerStyle" %> | ||
<%= javascript_include_tag "fckeditor/editor/dialog/fck_spellerpages/spellerpages/wordWindow" %> | ||
<script type="text/javascript" language="javascript"> | ||
// <![CDATA[ | ||
var suggs = new Array(); | ||
var words = new Array(); | ||
var textinputs = new Array(); | ||
var error; | ||
|
||
textinputs[0] = decodeURIComponent('<%= @original_text %>'); | ||
words[0] = []; | ||
suggs[0] = []; | ||
|
||
<% @words.each_with_index do |pair, i| %> | ||
words[0][<%= i %>] = '<%= pair[0] %>'; | ||
suggs[0][<%= i %>] = [<%= pair[1] %>]; | ||
<% end %> | ||
|
||
var wordWindowObj = new wordWindow(); | ||
wordWindowObj.originalSpellings = words; | ||
wordWindowObj.suggestions = suggs; | ||
wordWindowObj.textInputs = textinputs; | ||
|
||
function init_spell() { | ||
// check if any error occured during server-side processing | ||
if( error ) { | ||
alert( error ); | ||
} else { | ||
// call the init_spell() function in the parent frameset | ||
if (parent.frames.length) { | ||
parent.init_spell( wordWindowObj ); | ||
} else { | ||
alert('This page was loaded outside of a frameset. It might not display properly'); | ||
} | ||
} | ||
} | ||
</script> | ||
</head> | ||
<body onload="init_spell();"> | ||
|
||
<script type="text/javascript" language="javascript"> | ||
// <![CDATA[ | ||
wordWindowObj.writeBody(); | ||
// ]]> | ||
</script> | ||
|
||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Interfaces with aspell and returns results ready for FCKeditor-friendly javascript | ||
class FckeditorSpellCheck | ||
|
||
# call aspell and retrieve the results | ||
def self.check_spelling(text) | ||
if RUBY_PLATFORM =~ /mswin/i | ||
aspell_program = 'c:\program files\aspell\bin\aspell' # windows | ||
else | ||
aspell_program = 'aspell' # every other OS on the planet | ||
end | ||
|
||
# call aspell | ||
command = "\"#{aspell_program}\" -a --lang=en_US --encoding=utf-8 -H 2>&1" | ||
output = IO.popen(command, 'r+') {|io| io.puts(text); io.close_write; io.read } | ||
|
||
# return an array of results | ||
output.split("\n").collect {|line| parse_aspell_line(line) }.compact | ||
end | ||
|
||
private | ||
|
||
# return a 2-D array of results, where each element in the array has a pair | ||
# of values: [ escaped word, comma separted list of escaped suggestions ] | ||
def self.parse_aspell_line(line) | ||
if line =~ /^&/ | ||
details = line.split(' ', 5) | ||
[ escape(details[1]), get_suggestions(details[4]) ] | ||
end | ||
end | ||
|
||
# quote and escape the individual suggestions | ||
def self.get_suggestions(value) | ||
value.split(', ').collect {|x| "'#{escape(x)}'"}.join(', ') | ||
end | ||
|
||
# properly escape single-quote for javascript | ||
def self.escape(x) | ||
x.gsub(/'/, '\\\\\'') | ||
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
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