How to Integrate a Spell Checker into NetMail Templates
Novell Cool Solutions: Feature
By Matt DeFoor
Reader Rating
from 7 ratings
|
Digg This -
Slashdot This
Posted: 12 Sep 2003 |
Those loking for a spelchecker need to louk know futher! :-)
The following provides detailed instructions on how to integrate a spellchecker into the NetMail Modweb templates.
Introduction
Implementing a spellcheck into NetMail Modweb templates has been a much requested feature. Using the SpellChecker engine from SpellChecker.net and a few tricks with Apache you can enhance the feature set of NetMail.
Unfornate Side-effects
There are several technical hurdles that have to be cleared before you can successfully integrate the SpellChecker engine into Modweb. First, you should ask yourself how comfortable you are with running Apache and the Modwebd agent on NetWare versus one of the NetMail supported UNIX variants (Linux, Solaris, etc). This will impact the configuration needed to make the integration successful.
Also the SpellChecker.net product uses JavaScript to update document contents and a CGI program to interface with spellchecking engine. Because the engine runs natively on many UNIX platforms it is natural for one to run Apache and the CGI program on the same machine as well as many HTML forms. With this configuration, you could easily use the engine to spellcheck any textbox within the same domain.
However, NetMail's Modweb agent is its own web server. To run Apache with PHP/PERL CGI support and Modweb on the same machine would require that one of the http servers reside on a separate port (e.g. 81). Your port configuration might look like the following:
| Apache+PHP/Perl | Modwebd agent |
| your.domain.com | your.domain.com:81 |
According to the JavaScript Same Origin Policy, JavaScript cannot be used to update or set document properties originating in one domain from another domain. The policy states your.domain.com and your.domain.com:81 are different domains even though they share the same protocol and hostname. The differing ports cause the Same Origin Policy to be invoked thus restricting the ability to update document properties from a different origin even though they reside on the same machine!
"I don't care about the crosswords, man! Just the jumbles! The jumbles!"
Using the Apache mod_proxy module provides a means to bypass this restriction. However, as indicated above, it requires that you examine how comfortable you are with running Apache on NetWare. It also requires that you choose which version of Apache and NetWare. Some might choose to run it on Solaris or Linux. The following contains information on how to configure Apache 2.0 + PHP on NetWare 6.5. The SpellChecker engine will be running on Red Hat Linux 8.0 (but that is irrelevant because I could have easily chosen FreeBSD, Solaris or HP/UX).
Configuring Apache
The Apache httpd.conf file (sys:\apache2\conf\httpd.conf) needs to be configured to load the mod_proxy and mod_rewrite modules. The following lines need to be added or uncommented in the DSO modules section:
LoadModule proxy_module modules/proxy.nlm
LoadModule proxy_connect_module modules/proxycon.nlm
LoadModule proxy_http_module modules/proxyhtp.nlm
LoadModule rewrite_module modules/rewrite.nlm
Make sure the server is configured to parse PHP (we're using the PHP version of the SpellChecker.net CGI). If the following line is not in your httpd.conf file, add it before the AddHandler directives:
AddType application/x-httpd-php .phpAt the end of the httpd.conf file, the NetWare OS install will often put Include directives to load Tomcat, mod_nsn, mod_perl and mod_php. Make sure that the following line is uncommented to load mod_php:
Include sys:/apache2/conf/mod_php.conf
Virtual Hosts will be used to direct traffic to the appropriate web service running on the machine. The following need to be added to the httpd.conf file:
# Virtual host for port 80
NameVirtualHost 192.168.1.2:80
<VirtualHost 192.168.1.2:80>
ServerName your.domain.com:80
ServerAlias your.domain.com
ErrorLog logs/machinename-error_log
CustomLog logs/machinename-access_log common
# Turn on rewrites for this domain
RewriteEngine On
# Log all rewrites...these files could get big
# You may want to disable them after going into production
RewriteLog logs/rewrite_log
RewriteLogLevel 1
# Rewrite all requests bound for Spellchecker CGI script
# to the correct web service...in this case, Apache on port 81
RewriteRule sproxy(.+) http://your.domain.com:81/sproxy$1 [P,L]
# Else rewrite all URLS to go the Modweb agent running on port 88
RewriteRule (.+) http://your.domain.com:88$1 [P,L]
</VirtualHost>
Listen 192.168.1.3:81
NameVirtualHost 192.168.1.3:81
<VirtualHost 192.168.1.3:81>
ServerAdmin webmaster@your.domain.com
ServerName your.domain.com:81
ServerAlias your.domain.com
DocumentRoot "SYS:/APACHE2/htdocs"
ErrorLog logs/machinename_81-error_log
CustomLog logs/machinename_81-access_log common
</VirtualHost>
This configuration creates an additional Virtual Host that listens on port 81. This is the port where normal http traffic will be sent. The port 80 listener acts a redirector for all traffic based on what the rewrite module encounters. The NetMail Modweb agent should be configured for port 88 (or something else, just make sure you're consistent in all your configs). This will not affect current users that are directing their clients to port 80 for NetMail because the rewrite engine will take care of handling their requests.
CAVEAT: NetWare 6.5 has abundant web services these days. Therefore, you'll want to make sure that your port selection doesn't conflict with the NetWare Remote Manager (NRM) and any other services that you may have installed. I'd recommend changing the default port for NRM to something like 8008. By default it will consume ports 80 and 81.
With this configuration in place and all potential port conflicts resolved, you should be able to start Modwebd.NLM and Apache (ap2webup.ncf) and access the NetMail Modweb interfaces. If you can't, check the respective error logs (sys:\apache2\logs\startup.err is a good place to start).
Modweb Templates
To some, modifying the Modweb templates is an arcane process. Not so! Here's the skinny on what files in both templates to edit and the commands to compile them! And you thought I was all fluff! Hrmphf! I will presume that you have downloaded the template sources though!
WebAccess Template
Edit compose.htt and put the following in the <HEAD></HEAD> tags:
<script type="text/javascript" language="javascript src=http://your.domain.com:81/spch.js></script>
NOTE: You could do this in any of the template files that has a textbox for which you'd like to enable spellchecking. OK. I'll make it easy for you: composeapp.htt, composenote.htt, composetask.htt.
See spch.js? That's the JavaScript file that you'll download from SpellChecker.net. I chose to put it in the document root (sys:apache2\htdocs\) of the Apache server.
You'll want to decide where your "Spell Check" button will appear. I chose to put it above the rest of the action buttons in the compose window:
<TD Align="left" valign="top"><BR>
<!-- This is what I added -->
<INPUT TYPE="BUTTON" VALUE="Spell Check" onclick="var
f=document.forms[0]; doSpell( 'en', f.TextBody, document.location.protocol
+ '//your.domain.com/sproxy.php', true);">
<!-- End what I added -->
<INPUT Type=image name="ActionSendMsg" alt="{
String Compose.Image.AltText.send}" src="{Image SendDarkTxt}" border=0><BR>
<INPUT Type=image name="ActionLoadPageAddressBook" alt="{
String Compose.Image.AltText.directory}" src="{Image AddressBookDarkTxt}"
border=0><BR>
<INPUT Type=image name="ActionLoadPageAttachments" alt="{String
Compose.Image.AltText.attach}" src="{Image AttachDarkTxt}" border=0><BR>
<A HRef="{Compose.Cancel KillMe}" onClick="return onCancel();"><IMG
src="{Image CancelDarkTxt}" alt="{String Button.Image.AltText.btnCancel}"
border=0></A><BR>
</TD>
Here's the analysis of the added HTML:
Make a button with a value of "Spell Check". When the button is clicked, it calls the doSpell function which is loaded from the JavaScript that we included earlier. The doSpell function is called with a default language (english), the name of the textbox we want to spellcheck and the location of the PHP CGI program (sproxy.php) that is responsible for interacting with the SpellChecker engine. Again, sproxy.php is located in the document root of the Apache server.
<INPUT TYPE="BUTTON" VALUE="Spell Check" onclick="var f=document.forms[0]; doSpell( 'en', f.TextBody, document.location.protocol + '//your.domain.com/sproxy.php', true);">
That's it! You're done. You're ready to compile!
Let's say that your directory looks something like this:
F:\novell\sdk\netmail\templates>dir
Volume in drive F has no label.
Volume Serial Number is 07D2-0307
Directory of F:\novell\sdk\netmail\templates
06/11/2003 11:34a <DIR> .
06/11/2003 11:34a <DIR> ..
03/24/2003 03:33p <DIR> mrbpublic
03/24/2003 03:33p <DIR> mrbpublic_org
03/24/2003 03:33p <DIR> webacc
03/24/2003 03:33p <DIR> webmail
11/08/2002 02:29p 69,632 MWCOMP.EXE
06/11/2003 01:33p <DIR> INCLUDE
1 File(s) 69,632 bytes
7 Dir(s) 41,859,317,760 bytes free
Assuming that your template directories are in the current directory and that you've copied the INCLUDE directory from the UNSUPP directory of the NetMail distribution and that mwcomp.exe is in the current directory, you can do the following:
mwcomp webacc -b:.\ -t:.\ -i:\include
You should end up with webacc.ctp in the current directory. Rename sys:\system\modweb\webacc.ctp to something else (webacc.old) and copy the new file to the same location and restart modwebd. You should have a "Spell Check" button in your compose window. It should work assuming that you've followed all the steps above and configured the SpellChecker engine on some other machine.
WebMail Template
Edit compose.htt and put the following in the <HEAD></HEAD> tags:
<script type="text/javascript" language="javascript" src=http://your.domain.com:81/spch.js></script>
NOTE: You could do this in any of the template files that has a textbox for which you'd like to enable spellchecking.
You'll want to decide where your "Spell Check" button will appear. I chose to put it next to the "Send" button in the compose window:
<TD bgColor="{Color FieldBodyBg}"><TEXTAREA cols=55 name="TextBody"
rows=15 wrap=virtual TabIndex=5>{Compose.Value BODY}</TEXTAREA>
<!-- This is what I added -->
<INPUT TYPE="BUTTON" VALUE="Spell Check" onclick="var
f=document.forms[0]; doSpell( 'en', f.TextBody, document.location.protocol +
'//your.domain.com/sproxy.php', true);">
<!-- End what I added -->
<INPUT alt={String Compose.Send} border=0 name="ActionSendMsg"
src="{Image SendBar}" type=image>
</TD>
That's it! You're done. You're ready to compile!
Let's say that your directory looks something like this:
F:\novell\sdk\netmail\templates>dir
Volume in drive F has no label.
Volume Serial Number is 07D2-0307
Directory of F:\novell\sdk\netmail\templates
06/11/2003 11:34a <DIR> .
06/11/2003 11:34a <DIR> ..
03/24/2003 03:33p <DIR> mrbpublic
03/24/2003 03:33p <DIR> mrbpublic_org
03/24/2003 03:33p <DIR> webacc
03/24/2003 03:33p <DIR> webmail
11/08/2002 02:29p 69,632 MWCOMP.EXE
06/11/2003 01:33p <DIR> INCLUDE
1 File(s) 69,632 bytes
7 Dir(s) 41,859,317,760 bytes free
Assuming that your template directories are in the current directory and that you've copied the INCLUDE directory from the UNSUPP directory of the NetMail distribution and that mwcomp.exe is in the current directory, you can do the following:
mwcomp webmail -b:.\ -t:.\ -i:\include
You should end up with webmail.ctp in the current directory. Rename sys:\system\modweb\webmail.ctp to something else (webmail.old) and copy the new file to the same location and restart modwebd. You should have a "Spell Check" button in your compose window. It should work assuming that you've followed all the steps above and configured the SpellChecker engine on some other machine.
"You're like a chainsaw running through a dictionary"...or Conclusion
All assumptions aside, things should be working well assuming that you've downloaded the appropriate files from www.spellchecker.net, followed their configuration instructions and mine.
Happy spellchecking!
Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com
