[LON-CAPA-cvs] cvs: loncom /interface lonspeller.pm

www lon-capa-cvs@mail.lon-capa.org
Thu, 22 Jul 2004 20:19:21 -0000


www		Thu Jul 22 16:19:21 2004 EDT

  Modified files:              
    /loncom/interface	lonspeller.pm 
  Log:
  Be able to call as handler
  
  
Index: loncom/interface/lonspeller.pm
diff -u loncom/interface/lonspeller.pm:1.2 loncom/interface/lonspeller.pm:1.3
--- loncom/interface/lonspeller.pm:1.2	Thu Jul 22 15:43:46 2004
+++ loncom/interface/lonspeller.pm	Thu Jul 22 16:19:20 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Interface routines for Aspell
 #
-# $Id: lonspeller.pm,v 1.2 2004/07/22 19:43:46 www Exp $
+# $Id: lonspeller.pm,v 1.3 2004/07/22 20:19:20 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -58,11 +58,33 @@
     return $output;
 }
 
+sub initspeller {
+    unless (defined($speller)) {
+	$speller = Text::Aspell->new;
+	$speller->set_option('lang','en_US');
+	$speller->set_option('sug-mode','fast');
+    }
+}
+
+sub handler {
+    my $r = shift;
+    &Apache::loncommon::content_type($r,'text/html');
+    $r->send_http_header;
+    return OK if $r->header_only;
+
+    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
+
+    &initspeller();
+    $r->print('<html><head><title>'.
+	      &mt('Spell Checker').
+	      '</title></head><body bgcolor="#DDDDDD">'.
+	      &markeduptext($ENV{'form.text'}).
+	      '</body></html>');
+    return OK;
+}
+
 BEGIN {
-    $speller = Text::Aspell->new;
-    $speller->set_option('lang','en_US');
-    $speller->set_option('sug-mode','fast');
-#    $speller->set_option('mode','sgml');
+    &initspeller();
 }
 
 1;