Permalink
Browse files

MDL-17368 removing unused html area spell checker - we have our own i…

…mplementation; backported from MOODLE_19_STABLE
  • Loading branch information...
1 parent 0fb9aeb commit 8406cf8ca864ea0545db5d4419de6c8c556ddce6 skodak committed Dec 8, 2008
Deleted file not rendered
@@ -1,37 +0,0 @@
-// I18N constants
-
-// LANG: "en", ENCODING: UTF-8 | ISO-8859-1
-// Author: Mihai Bazon, <mishoo@infoiasi.ro>
-
-// FOR TRANSLATORS:
-//
-// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE
-// (at least a valid email address)
-//
-// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING;
-// (if this is not possible, please include a comment
-// that states what encoding is necessary.)
-
-SpellChecker.I18N = {
- "CONFIRM_LINK_CLICK" : "Please confirm that you want to open this link",
- "Cancel" : "Cancel",
- "Dictionary" : "Dictionary",
- "Finished list of mispelled words" : "Finished list of mispelled words",
- "I will open it in a new page." : "I will open it in a new page.",
- "Ignore all" : "Ignore all",
- "Ignore" : "Ignore",
- "NO_ERRORS" : "No mispelled words found with the selected dictionary.",
- "NO_ERRORS_CLOSING" : "Spell check complete, didn't find any mispelled words. Closing now...",
- "OK" : "OK",
- "Original word" : "Original word",
- "Please wait. Calling spell checker." : "Please wait. Calling spell checker.",
- "Please wait: changing dictionary to" : "Please wait: changing dictionary to",
- "QUIT_CONFIRMATION" : "This will drop changes and quit spell checker. Please confirm.",
- "Re-check" : "Re-check",
- "Replace all" : "Replace all",
- "Replace with" : "Replace with",
- "Replace" : "Replace",
- "SC-spell-check" : "Spell-check",
- "Suggestions" : "Suggestions",
- "pliz weit ;-)" : "pliz weit ;-)"
-};
@@ -1,37 +0,0 @@
-// I18N constants
-
-// LANG: "ro", ENCODING: UTF-8
-// Author: Mihai Bazon, <mishoo@infoiasi.ro>
-
-// FOR TRANSLATORS:
-//
-// 1. PLEASE PUT YOUR CONTACT INFO IN THE ABOVE LINE
-// (at least a valid email address)
-//
-// 2. PLEASE TRY TO USE UTF-8 FOR ENCODING;
-// (if this is not possible, please include a comment
-// that states what encoding is necessary.)
-
-SpellChecker.I18N = {
- "CONFIRM_LINK_CLICK" : "Vă rog confirmaţi că vreţi să deschideţi acest link",
- "Cancel" : "Anulează",
- "Dictionary" : "Dicţionar",
- "Finished list of mispelled words" : "Am terminat lista de cuvinte greşite",
- "I will open it in a new page." : "O voi deschide într-o altă fereastră.",
- "Ignore all" : "Ignoră toate",
- "Ignore" : "Ignoră",
- "NO_ERRORS" : "Nu am găsit nici un cuvânt greşit cu acest dicţionar.",
- "NO_ERRORS_CLOSING" : "Am terminat, nu am detectat nici o greşeală. Acum închid fereastra...",
- "OK" : "OK",
- "Original word" : "Cuvântul original",
- "Please wait. Calling spell checker." : "Vă rog aşteptaţi. Apelez spell-checker-ul.",
- "Please wait: changing dictionary to" : "Vă rog aşteptaţi. Schimb dicţionarul cu",
- "QUIT_CONFIRMATION" : "Doriţi să renunţaţi la modificări şi să închid spell-checker-ul?",
- "Re-check" : "Scanează",
- "Replace all" : "Înlocuieşte toate",
- "Replace with" : "Înlocuieşte cu",
- "Replace" : "Înlocuieşte",
- "SC-spell-check" : "Detectează greşeli",
- "Suggestions" : "Sugestii",
- "pliz weit ;-)" : "va rog ashteptatzi ;-)"
-};
@@ -1,115 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.2//EN">
-<html>
- <head>
- <title>HTMLArea Spell Checker</title>
- </head>
-
- <body>
- <h1>HTMLArea Spell Checker</h1>
-
- <p>The HTMLArea Spell Checker subsystem consists of the following
- files:</p>
-
- <ul>
-
- <li>spell-checker.js &mdash; the spell checker plugin interface for
- HTMLArea</li>
-
- <li>spell-checker-ui.html &mdash; the HTML code for the user
- interface</li>
-
- <li>spell-checker-ui.js &mdash; functionality of the user
- interface</li>
-
- <li>spell-checker-logic.cgi &mdash; Perl CGI script that checks a text
- given through POST for spelling errors</li>
-
- <li>spell-checker-style.css &mdash; style for mispelled words</li>
-
- <li>lang/en.js &mdash; main language file (English).</li>
-
- </ul>
-
- <h2>Process overview</h2>
-
- <p>
- When an end-user clicks the "spell-check" button in the HTMLArea
- editor, a new window is opened with the URL of "spell-check-ui.html".
- This window initializes itself with the text found in the editor (uses
- <tt>window.opener.SpellChecker.editor</tt> global variable) and it
- submits the text to the server-side script "spell-check-logic.cgi".
- The target of the FORM is an inline frame which is used both to
- display the text and correcting.
- </p>
-
- <p>
- Further, spell-check-logic.cgi calls Aspell for each portion of plain
- text found in the given HTML. It rebuilds an HTML file that contains
- clear marks of which words are incorrect, along with suggestions for
- each of them. This file is then loaded in the inline frame. Upon
- loading, a JavaScript function from "spell-check-ui.js" is called.
- This function will retrieve all mispelled words from the HTML of the
- iframe and will setup the user interface so that it allows correction.
- </p>
-
- <h2>The server-side script (spell-check-logic.cgi)</h2>
-
- <p>
- <strong>Unicode safety</strong> &mdash; the program <em>is</em>
- Unicode safe. HTML entities are expanded into their corresponding
- Unicode characters. These characters will be matched as part of the
- word passed to Aspell. All texts passed to Aspell are in Unicode
- (when appropriate). However, Aspell seems to not support Unicode
- yet (<a
- href="http://mail.gnu.org/archive/html/aspell-user/2000-11/msg00007.html">thread concerning Aspell and Unicode</a>).
- This mean that words containing Unicode
- characters that are not in 0..255 are likely to be reported as "mispelled" by Aspell.
- </p>
-
- <p>
- I digged the Net for a couple of hours today and I can't seem to find
- any open-source spell checker that has Unicode support. For this
- reason we keep using Aspell, because it also seems to have the
- best suggestions engine. Unicode support will eventually be
- implemented in Aspell. <a href="mailto:kevin@atkinson.dhs.org">Email
- Kevin Atkinson</a> (Aspell author and maintainer) about this ;-)
- </p>
-
- <p>
- The Perl Unicode manual (man perluniintro) states:
- </p>
-
- <blockquote>
- <em>
- Starting from Perl 5.6.0, Perl has had the capacity to handle Unicode
- natively. Perl 5.8.0, however, is the first recommended release for
- serious Unicode work. The maintenance release 5.6.1 fixed many of the
- problems of the initial Unicode implementation, but for example regular
- expressions still do not work with Unicode in 5.6.1.
- </em>
- </blockquote>
-
- <p>In other words, do <em>not</em> assume that this script is
- Unicode-safe on Perl interpreters older than 5.8.0.</p>
-
- <p>The following Perl modules are required:</p>
-
- <ul>
- <li><a href="http://search.cpan.org/search?query=Text%3A%3AAspell&mode=all" target="_blank">Text::Aspell</a></li>
- <li><a href="http://search.cpan.org/search?query=HTML%3A%3AParser&mode=all" target="_blank">HTML::Parser</a></li>
- <li><a href="http://search.cpan.org/search?query=HTML%3A%3AEntities&mode=all" target="_blank">HTML::Entities</a></li>
- <li><a href="http://search.cpan.org/search?query=CGI&mode=all" target="_blank">CGI</a></li>
- </ul>
-
- <p>Of these, only Text::Aspell might need to be installed manually. The
- others are likely to be available by default in most Perl distributions.</p>
-
- <hr />
- <address><a href="http://students.infoiasi.ro/~mishoo/">Mihai Bazon</a></address>
-<!-- Created: Thu Jul 17 13:22:27 EEST 2003 -->
-<!-- hhmts start -->
-Last modified on Sun Aug 10 12:28:24 2003
-<!-- hhmts end -->
-<!-- doc-lang: English -->
- </body>
-</html>
@@ -1,155 +1 @@
-#! /usr/bin/perl -w
-# Spell Checker Plugin for HTMLArea-3.0
-# Implementation by Mihai Bazon. Sponsored by www.americanbible.org
-#
-# htmlArea v3.0 - Copyright (c) 2002 interactivetools.com, inc.
-# This notice MUST stay intact for use (see license.txt).
-#
-# A free WYSIWYG editor replacement for <textarea> fields.
-# For full source code and docs, visit http://www.interactivetools.com/
-#
-# Version 3.0 developed by Mihai Bazon for InteractiveTools.
-# http://students.infoiasi.ro/~mishoo
-#
-# $Id$
-
-use strict;
-use utf8;
-use Encode;
-use Text::Aspell;
-use HTML::Parser;
-use HTML::Entities;
-use CGI;
-
-my $debug = 0;
-
-open (DEBUG, '>:encoding(UTF-8)', '> /tmp/spell-check-debug.log') if $debug;
-
-# use Data::Dumper; # for debug only
-
-my $speller = new Text::Aspell;
-my $cgi = new CGI;
-
-# FIXME: report a nice error...
-die "Can't create speller!" unless $speller;
-
-# add configurable option for this
-my $dict = $cgi->param('dictionary') || 'en_US';
-$speller->set_option('lang', $dict);
-
-# ultra, fast, normal, bad-spellers
-# bad-spellers seems to cause segmentation fault
-$speller->set_option('sug-mode', 'ultra');
-
-my @replacements = ();
-
-sub text_handler {
- my ($offset, $length, $text, $is_cdata) = @_;
- if ($is_cdata or $text =~ /^\s*$/) {
- return 0;
- }
- # print STDERR "*** OFFSET: $offset, LENGTH: $length, $text\n";
- $text = decode_entities($text);
- $text =~ s/&#([0-9]+);/chr($1)/eg;
- $text =~ s/&#x([0-9a-fA-F]+);/chr(hex $1)/eg;
- my $repl = spellcheck($text);
- if ($repl) {
- push(@replacements, [ $offset, $length, $repl ]);
- }
-}
-
-my $p = HTML::Parser->new
- (api_version => 3,
- handlers => { start => [ sub {
- my ($self, $tagname, $attrs) = @_;
- # print STDERR "\033[1;31m parsing tag: $tagname\033[0m\n";
- # following we skip words that have already been marked as "fixed".
- if ($tagname eq "span" and $attrs->{class} =~ /HA-spellcheck-fixed/) {
- $self->handler(text => undef);
- }
- }, "self, tagname, attr"
- ],
- end => [ sub {
- my ($self, $tagname) = @_;
- # print STDERR "\033[1;32m END tag: $tagname\033[0m\n";
- $self->handler(text => \&text_handler, 'offset, length, dtext, is_cdata');
- }, "self, tagname"
- ]
- }
- );
-$p->handler(text => \&text_handler, 'offset, length, dtext, is_cdata');
-$p->case_sensitive(1);
-my $file_content = $cgi->param('content');
-
-if ($debug) {
- open (FOO, '>:encoding(UTF-8)', '/tmp/spell-check-before');
- print FOO $file_content, "\n";
- close(FOO);
-}
-
-$p->parse($file_content);
-$p->eof();
-
-foreach (reverse @replacements) {
- substr($file_content, $_->[0], $_->[1], $_->[2]);
-}
-
-# we output UTF-8
-binmode(STDOUT, ':encoding(UTF-8)'); # apparently, this sucks.
-print "Content-type: text/html; charset: utf-8\n\n";
-print qq^
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<link rel="stylesheet" type="text/css" media="all" href="spell-check-style.css" />
-</head>
-<body onload="window.parent.finishedSpellChecking();">^;
-
-print $file_content;
-if ($cgi->param('init') eq '1') {
- my @dicts = $speller->dictionary_info();
- my $dictionaries = '';
- foreach my $i (@dicts) {
- $dictionaries .= ',' . $i->{name} unless $i->{jargon};
- }
- $dictionaries =~ s/^,//;
- print qq^
-<div id="HA-spellcheck-dictionaries"
->$dictionaries</div>
-^;
-}
-
-if ($debug) {
- open (FOO, '>:encoding(UTF-8)', '/tmp/spell-check-after');
- print FOO $file_content, "\n";
- close(FOO);
-}
-
-print '</body></html>';
-
-# Perl is beautiful.
-sub spellcheck {
- my $text = shift;
- sub check { # called for each word in the text
- # input is in UTF-8
- my $U_word = shift;
- my $word = encode($speller->get_option('encoding'), $U_word);
- print DEBUG "*$U_word* ----> |$word|\n" if $debug;
- if ($speller->check($word)) {
- return $U_word; # we return the word in UTF-8
- } else {
- # we should have suggestions; give them back to browser in UTF-8
- my $suggestions = decode($speller->get_option('encoding'), join(',', $speller->suggest($word)));
- my $ret = '<span class="HA-spellcheck-error">'.$U_word.'</span><span class="HA-spellcheck-suggestions">'.$suggestions.'</span>';
- return $ret;
- }
- }
- $text =~ s/([[:word:]']+)/check($1)/egs;
- # $text =~ s/(\w+)/check($1)/egs;
-
- # the following is definitely what we want to use; too bad it sucks most.
- # $text =~ s/(\p{IsWord}+)/check($1)/egs;
- return $text;
-}
@@ -1,10 +0,0 @@
-.HA-spellcheck-error { border-bottom: 2px dotted #f00; cursor: default; }
-.HA-spellcheck-same { background-color: #ff8; color: #000; }
-.HA-spellcheck-hover { background-color: #433; color: white; }
-.HA-spellcheck-fixed { border-bottom: 1px dotted #0b8; }
-.HA-spellcheck-current { background-color: #7be; color: #000; }
-.HA-spellcheck-suggestions { display: none; }
-
-#HA-spellcheck-dictionaries { display: none; }
-
-a:link, a:visited { color: #55e; }
Oops, something went wrong.

0 comments on commit 8406cf8

Please sign in to comment.