From 2557d85f88c832bf843afe595e53e1ed3bdc056a Mon Sep 17 00:00:00 2001 From: ale Date: Wed, 3 Jan 2007 21:38:46 +0000 Subject: - Add option to enable remote spell checking capabilities - Add option to install a local spell checker Approved by: maintainer --- mail/roundcube/Makefile | 20 +++++++- .../roundcube/files/patch-config_main.inc.php.dist | 13 ++++++ mail/roundcube/files/spellchecker.php | 53 ++++++++++++++++++++++ mail/roundcube/pkg-plist | 1 + 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 mail/roundcube/files/patch-config_main.inc.php.dist create mode 100644 mail/roundcube/files/spellchecker.php (limited to 'mail') diff --git a/mail/roundcube/Makefile b/mail/roundcube/Makefile index ec195d0f1f37..d4cd68ebcc4e 100644 --- a/mail/roundcube/Makefile +++ b/mail/roundcube/Makefile @@ -57,10 +57,11 @@ LOCALBASE?= /usr/local OPTIONS= MYSQL "Use MySQL backend" on \ PGSQL "Use PostgreSQL backend" off - .if defined(PHP_VER) && ${PHP_VER} == 5 OPTIONS+= SQLITE "Use SQLite backend" off .endif +OPTIONS+= SPELLCHECK "Enable spellchecking" off \ + LOCALCHECK "Install internal spellchecker" off .include @@ -80,11 +81,28 @@ USE_PHP+= pgsql USE_PHP+= sqlite .endif +.if defined(WITH_SPELLCHECK) +USE_PHP+= openssl sockets +.endif + +.if defined(WITH_LOCALCHECK) +RCUBECOMP+= spellchecker.php +USE_PHP+= pspell simplexml +PLIST_SUB+= SPELLCHECK="" +.else +PLIST_SUB+= SPELLCHECK="@comment " +.endif + # Avoid INDEX breakage when WITHOUT_MYSQL is defined. USE_PHP?= yes .include "${PORTSDIR}/Mk/bsd.php.mk" +.if defined(WITH_LOCALCHECK) +post-extract: + @${CP} ${FILESDIR}/spellchecker.php ${WRKSRC} +.endif + .if defined(WITH_REPLACE_MAIL_URL) post-patch: @${REINPLACE_CMD} "s/'mail'/'${MAIL}'/g" ${WRKSRC}/index.php \ diff --git a/mail/roundcube/files/patch-config_main.inc.php.dist b/mail/roundcube/files/patch-config_main.inc.php.dist new file mode 100644 index 000000000000..32522321600a --- /dev/null +++ b/mail/roundcube/files/patch-config_main.inc.php.dist @@ -0,0 +1,13 @@ +--- config/main.inc.php.dist.orig Sat Dec 9 19:55:13 2006 ++++ config/main.inc.php.dist Sat Dec 9 19:57:58 2006 +@@ -160,8 +160,8 @@ + // Make use of the built-in spell checker. It is based on GoogieSpell. + $rcmail_config['enable_spellcheck'] = TRUE; + +-// For a locally installed Nox Spell Server, please specify the URI to call it. +-// Get Nox Spell Server from http://orangoo.com/labs/?page_id=72 ++// For a locally installed spellcheker, specify the URI to call it, for example: ++// 'http://' . $_SERVER['HTTP_HOST'] . '/spellchecker.php?lang=' + // Leave empty to use the Google spell checking service, what means + // that the message content will be sent to Google in order to check spelling + $rcmail_config['spellcheck_uri'] = ''; diff --git a/mail/roundcube/files/spellchecker.php b/mail/roundcube/files/spellchecker.php new file mode 100644 index 000000000000..506c4d0331be --- /dev/null +++ b/mail/roundcube/files/spellchecker.php @@ -0,0 +1,53 @@ +text) as $line) { + $len = mb_strlen($line, "UTF-8"); + mb_ereg_search_init($line, "\w+"); + while (($wpos = mb_ereg_search_pos()) != FALSE) { + $word = mb_substr($line, $wpos[0], $wpos[1]); + if (!pspell_check($spell, $word)) { + $woffset = mb_strlen(mb_substr($line, 0, $wpos[0]), "UTF-8"); + $wlen = mb_strlen($word, "UTF-8"); + array_push($suggestions, array($offset + $woffset, $wlen, pspell_suggest($spell, $word))); + } + } + $offset += $len + 1; +} +$xml = new SimpleXMLElement(""); +$xml->addAttribute("error", count($suggestions) ? "1" : "0"); +foreach ($suggestions as $s) { + $c = $xml->addChild("c", join("\t", $s[2])); + $c->addAttribute("o", $s[0]); + $c->addAttribute("l", $s[1]); + $c->addAttribute("s", "1"); +} +header('Content-Type: text/xml'); +echo $xml->asXML(); diff --git a/mail/roundcube/pkg-plist b/mail/roundcube/pkg-plist index 322ae6b86761..8f291ee17c34 100644 --- a/mail/roundcube/pkg-plist +++ b/mail/roundcube/pkg-plist @@ -577,6 +577,7 @@ %%RCUBEDIR%%/skins/default/templates/settings.html %%RCUBEDIR%%/skins/default/templates/showcontact.html %%RCUBEDIR%%/skins/default/watermark.html +%%SPELLCHECK%%%%RCUBEDIR%%/spellchecker.php %%RCUBEDIR%%/temp/.htaccess @dirrm %%RCUBEDIR%%/skins/default/templates @dirrm %%RCUBEDIR%%/skins/default/includes -- cgit