| 1 |
====================================================== |
|---|
| 2 |
HOWTO to use a server-side spellchecker with FCKeditor |
|---|
| 3 |
====================================================== |
|---|
| 4 |
|
|---|
| 5 |
:Author: Marc-Aurèle Darche |
|---|
| 6 |
|
|---|
| 7 |
:Revision: $Id$ |
|---|
| 8 |
|
|---|
| 9 |
.. sectnum:: :depth: 4 |
|---|
| 10 |
.. contents:: :depth: 4 |
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
Introduction |
|---|
| 15 |
============ |
|---|
| 16 |
|
|---|
| 17 |
.. _CPS: http://www.fckeditor.net/ |
|---|
| 18 |
.. _FCKeditor: http://www.fckeditor.net/ |
|---|
| 19 |
|
|---|
| 20 |
The aim of this short documentation is to explain how to use a server-side |
|---|
| 21 |
spellchecker such as `aspell` in the FCKeditor_ WYSIWYG HTML editor in a |
|---|
| 22 |
CPS_ context. |
|---|
| 23 |
|
|---|
| 24 |
The FCKeditor WYSIWYG HTML editor is used for the CPS text widgets when they are |
|---|
| 25 |
in HTML mode. |
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
Setup |
|---|
| 30 |
===== |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
Installing the server-side spellchecker utility |
|---|
| 34 |
----------------------------------------------- |
|---|
| 35 |
|
|---|
| 36 |
First of all you need to have the `aspell` program and needed dictionary |
|---|
| 37 |
installed on the host system:: |
|---|
| 38 |
|
|---|
| 39 |
$ apt-get install aspell aspell-en |
|---|
| 40 |
|
|---|
| 41 |
Of course you could install other dictionaries than the English |
|---|
| 42 |
dictionary. Possible choices are ``aspell-fr``, ``aspell-es``, etc. |
|---|
| 43 |
|
|---|
| 44 |
Then you have to install a PHP module for your web server, for example:: |
|---|
| 45 |
|
|---|
| 46 |
$ apt-get install libapache2-mod-php4 |
|---|
| 47 |
|
|---|
| 48 |
Then you have to install a file from the FCKeditor Zope product on the |
|---|
| 49 |
web server that will be used to perform the spell checking, |
|---|
| 50 |
that is, on the host system, copying |
|---|
| 51 |
``FCKeditor/skins/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.php`` |
|---|
| 52 |
as |
|---|
| 53 |
``/var/www/speller/server-scripts/spellchecker.php`` |
|---|
| 54 |
. |
|---|
| 55 |
|
|---|
| 56 |
And then you need to modify the `spellchecker.php` script so that it corresponds |
|---|
| 57 |
to your environment. Since CPS web pages are served as ``ISO-8859-15`` be sure |
|---|
| 58 |
to specify an ``ISO-8859-15`` locale as the `lang` parameter, otherwise you |
|---|
| 59 |
would receive weird characters (due to encoding problems). |
|---|
| 60 |
|
|---|
| 61 |
Here is an example for using an English dictionary:: |
|---|
| 62 |
|
|---|
| 63 |
$aspell_prog = 'aspell'; |
|---|
| 64 |
$lang = 'en_US@euro'; |
|---|
| 65 |
|
|---|
| 66 |
Here is an example for using a French dictionary:: |
|---|
| 67 |
|
|---|
| 68 |
$aspell_prog = 'aspell'; |
|---|
| 69 |
$lang = 'fr_FR@euro'; |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
Enable server-side spellchecking on the client |
|---|
| 73 |
---------------------------------------------- |
|---|
| 74 |
|
|---|
| 75 |
Then you need to enable the spell checking on the user interface and tell it to |
|---|
| 76 |
use the server-side implementation. |
|---|
| 77 |
|
|---|
| 78 |
To do so you need to customize the FCKeditor configuration file which is:: |
|---|
| 79 |
|
|---|
| 80 |
CPSSchemas/skins/cps_schemas/fckconfig-cps.js |
|---|
| 81 |
|
|---|
| 82 |
The configuration should be:: |
|---|
| 83 |
|
|---|
| 84 |
// Specifying the "SpellerPages" spellchecker server-side implementation |
|---|
| 85 |
FCKConfig.SpellChecker = 'SpellerPages'; |
|---|
| 86 |
|
|---|
| 87 |
// Adding the "SpellCheck" button on the toolbar that you are currently using. |
|---|
| 88 |
// "Semantic" is the default toolbar used by CPSSchemas. |
|---|
| 89 |
FCKConfig.ToolbarSets['Semantic'] = [ |
|---|
| 90 |
['Italic','Bold','FontFormat'], |
|---|
| 91 |
['-','OrderedList','UnorderedList','-','Link','Unlink','-','SpellCheck'], |
|---|
| 92 |
['Image','Table','Rule'], |
|---|
| 93 |
'/', |
|---|
| 94 |
['RemoveFormat','Undo','Redo','Source'] |
|---|
| 95 |
]; |
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 |
Configuring which spellchecking service to use |
|---|
| 99 |
---------------------------------------------- |
|---|
| 100 |
|
|---|
| 101 |
Finally you need to configure which spellchecking service should be used by the |
|---|
| 102 |
client. |
|---|
| 103 |
|
|---|
| 104 |
The actual code of FCKeditor makes it only possible to configure which |
|---|
| 105 |
server-side spellchecker you can/want to use through Apache configuration. |
|---|
| 106 |
|
|---|
| 107 |
Apache |
|---|
| 108 |
...... |
|---|
| 109 |
|
|---|
| 110 |
You can perform the needed configuration through Apache configuration |
|---|
| 111 |
directives. |
|---|
| 112 |
|
|---|
| 113 |
Apache2 virtualhost configuration:: |
|---|
| 114 |
|
|---|
| 115 |
RewriteCond %{REQUEST_URI} ^(.*)/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.php |
|---|
| 116 |
RewriteRule ^/(.*) /var/www/speller/server-scripts/spellchecker.php [L] |
|---|
| 117 |
|
|---|
| 118 |
RewriteCond %{HTTP:Authorization} ^(.*) |
|---|
| 119 |
RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/http/%{HTTP_HOST}:80/cps/VirtualHostRoot/$1 [P,L] |
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
Customizing through skins |
|---|
| 123 |
......................... |
|---|
| 124 |
|
|---|
| 125 |
It would be useful if we could perform the needed configuration through |
|---|
| 126 |
customizing the ``spellChecker.js`` FCKeditor file. |
|---|
| 127 |
Unfortunately it doesn't work. |
|---|
| 128 |
|
|---|
| 129 |
In |
|---|
| 130 |
``FCKeditor/skins/fckeditor/editor/dialog/fck_spellerpages/spellerpages/spellChecker.js`` |
|---|
| 131 |
we would like to just have to modify the following line:: |
|---|
| 132 |
|
|---|
| 133 |
// Original line: |
|---|
| 134 |
//this.spellCheckScript = 'server-scripts/spellchecker.php'; |
|---|
| 135 |
// New configuration example: |
|---|
| 136 |
this.spellCheckScript = 'http://spellmachine/speller/server-scripts/spellchecker.php'; |
|---|
| 137 |
|
|---|
| 138 |
Unfortunately it doesn't work. |
|---|
| 139 |
|
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
.. Local Variables: |
|---|
| 143 |
.. mode: rst |
|---|
| 144 |
.. End: |
|---|
| 145 |
.. vim: set filetype=rst: |
|---|