summaryrefslogtreecommitdiff
path: root/mail
diff options
context:
space:
mode:
authorAlex Dupre <ale@FreeBSD.org>2007-01-03 21:38:46 +0000
committerAlex Dupre <ale@FreeBSD.org>2007-01-03 21:38:46 +0000
commit9fcdadecee1eda64d24b9871645e38c8eba7b986 (patch)
treeadba364835d0d69f9dbd39cf0b12a6164f33298f /mail
parent- Update to 1.2.0 (diff)
- Add option to enable remote spell checking capabilities
- Add option to install a local spell checker Approved by: maintainer
Notes
Notes: svn path=/head/; revision=181372
Diffstat (limited to 'mail')
-rw-r--r--mail/roundcube/Makefile20
-rw-r--r--mail/roundcube/files/patch-config_main.inc.php.dist13
-rw-r--r--mail/roundcube/files/spellchecker.php53
-rw-r--r--mail/roundcube/pkg-plist1
4 files changed, 86 insertions, 1 deletions
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 <bsd.port.pre.mk>
@@ -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 @@
+<?php
+/*-
+ * Copyright (c) 2006 Alex Dupre. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+$lang = $_REQUEST["lang"];
+$xml = new SimpleXMLElement(file_get_contents("php://input"));
+$spell = pspell_new($lang, "", "", "utf-8", PSPELL_NORMAL);
+$suggestions = array();
+$offset = 0;
+mb_regex_encoding("UTF-8");
+foreach (mb_split("\n", $xml->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("<spellresponse/>");
+$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