[LON-CAPA-cvs] cvs: loncom /homework edit.pm structuretags.pm /interface lonaboutme.pm lonbulletin.pm lonfeedback.pm lonhtmlcommon.pm lonnavmaps.pm lonparmset.pm lonsimplepage.pm lonspeller.pm lonsyllabus.pm /xml lonxml.pm

www lon-capa-cvs@mail.lon-capa.org
Tue, 27 Jul 2004 23:35:34 -0000


This is a MIME encoded message

--www1090971334
Content-Type: text/plain

www		Tue Jul 27 19:35:34 2004 EDT

  Modified files:              
    /loncom/homework	edit.pm structuretags.pm 
    /loncom/interface	lonaboutme.pm lonbulletin.pm lonfeedback.pm 
                     	lonhtmlcommon.pm lonnavmaps.pm lonparmset.pm 
                     	lonsimplepage.pm lonspeller.pm lonsyllabus.pm 
    /loncom/xml	lonxml.pm 
  Log:
  Spelling links
  
  
--www1090971334
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20040727193534.txt"

Index: loncom/homework/edit.pm
diff -u loncom/homework/edit.pm:1.84 loncom/homework/edit.pm:1.85
--- loncom/homework/edit.pm:1.84	Mon Jun  7 21:32:01 2004
+++ loncom/homework/edit.pm	Tue Jul 27 19:35:33 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # edit mode helpers
 #
-# $Id: edit.pm,v 1.84 2004/06/08 01:32:01 www Exp $
+# $Id: edit.pm,v 1.85 2004/07/27 23:35:33 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -504,7 +504,9 @@
 	'" cols="'.$cols.'" name="homework_edit_'.
 	$Apache::lonxml::curdepth.'" id="homework_edit_'.
 	$Apache::lonxml::curdepth.'">'.
-	&HTML::Entities::encode($data,'<>&"').'</textarea>'."\n";
+	&HTML::Entities::encode($data,'<>&"').'</textarea>'.
+	($usehtmlarea?&Apache::lonhtmlcommon::spelllink('lonhomework',
+			 'homework_edit_'.$Apache::lonxml::curdepth):'')."\n";
 }
 
 sub modifiedfield {
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.260 loncom/homework/structuretags.pm:1.261
--- loncom/homework/structuretags.pm:1.260	Sat Jul  3 16:52:19 2004
+++ loncom/homework/structuretags.pm	Tue Jul 27 19:35:33 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.260 2004/07/03 20:52:19 albertel Exp $
+# $Id: structuretags.pm,v 1.261 2004/07/27 23:35:33 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -83,7 +83,8 @@
 	$result=&Apache::londefdef::start_html($target,$token,$tagstack,
 					       $parstack,$parser,$safeeval);
 	$head_tag_start='<head>'.&Apache::lonmenu::registerurl(undef,$target).
-	    &Apache::lonhtmlcommon::htmlareaheaders();
+	    &Apache::lonhtmlcommon::htmlareaheaders().
+	    &Apache::lonhtmlcommon::spellheader();
     }
     my $body_tag_start;
     if (!defined($found{'body'})) {
Index: loncom/interface/lonaboutme.pm
diff -u loncom/interface/lonaboutme.pm:1.28 loncom/interface/lonaboutme.pm:1.29
--- loncom/interface/lonaboutme.pm:1.28	Thu Jul 15 17:08:45 2004
+++ loncom/interface/lonaboutme.pm	Tue Jul 27 19:35:34 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # "About Me" Personal Information
 #
-# $Id: lonaboutme.pm,v 1.28 2004/07/15 21:08:45 matthew Exp $
+# $Id: lonaboutme.pm,v 1.29 2004/07/27 23:35:34 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -174,6 +174,9 @@
               $message=~s/\n/\<br \/\>/g;
               $message
              =~s/(http\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
+	      if ($allowed) {
+		  $message=&Apache::lonspeller::markeduptext($message);
+	      }
 	      $message=&Apache::lontexconvert::msgtexconverted($message);
 	      if ($target ne 'tex') {
 		  $r->print('<h3>'.$syllabusfields{$_}.'</h3><blockquote>'.
Index: loncom/interface/lonbulletin.pm
diff -u loncom/interface/lonbulletin.pm:1.24 loncom/interface/lonbulletin.pm:1.25
--- loncom/interface/lonbulletin.pm:1.24	Mon May 10 14:44:40 2004
+++ loncom/interface/lonbulletin.pm	Tue Jul 27 19:35:34 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Bulletin Board Handler
 #
-# $Id: lonbulletin.pm,v 1.24 2004/05/10 18:44:40 sakharuk Exp $
+# $Id: lonbulletin.pm,v 1.25 2004/07/27 23:35:34 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -169,7 +169,10 @@
               $message
         =~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
 	      $message=&Apache::lontexconvert::msgtexconverted($message);
-            unless ($_ eq 'aaa_title') {
+	      if ($allowed) {
+		  $message=&Apache::lonspeller::markeduptext($message);
+	      }
+	      unless ($_ eq 'aaa_title') {
 		if (($_ ne 'bbb_content') || ($allowed)) {
 		    if ($target ne 'tex') {
 			$r->print('<h3>'.$syllabusfields{$_}.'</h3>');
Index: loncom/interface/lonfeedback.pm
diff -u loncom/interface/lonfeedback.pm:1.106 loncom/interface/lonfeedback.pm:1.107
--- loncom/interface/lonfeedback.pm:1.106	Sat Jul 24 14:19:38 2004
+++ loncom/interface/lonfeedback.pm	Tue Jul 27 19:35:34 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Feedback
 #
-# $Id: lonfeedback.pm,v 1.106 2004/07/24 18:19:38 www Exp $
+# $Id: lonfeedback.pm,v 1.107 2004/07/27 23:35:34 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1428,6 +1428,7 @@
 
 sub no_redirect_back {
   my ($r,$feedurl) = @_;
+  my $nofeed=&mt('Sorry, no feedback possible on this resource  ...');
   $r->print (<<ENDNOREDIR);
 <html>
 <head><title>Feedback not sent</title>
@@ -1442,7 +1443,7 @@
 </head>
 <body bgcolor="#FFFFFF" onLoad='if (window.name!="loncapaclient") { self.close(); }'>
 <img align="right" src="/adm/lonIcons/lonlogos.gif" />
-<b>Sorry, no feedback possible on this resource  ...</b>
+<b>$nofeed</b>
 </body>
 </html>
 ENDNOREDIRTWO
@@ -1509,25 +1510,25 @@
 sub clear_out_html {
   my ($message,$override)=@_;
   unless (&Apache::lonhtmlcommon::htmlareablocked()) { return $message; }
+# Always allow the <m>-tag
+  my %html=(M=>1);
+# Check if more is allowed
   my $cid=$ENV{'request.course.id'};
   if (($ENV{"course.$cid.allow_limited_html_in_feedback"} =~ m/yes/i) ||
       ($override)) {
       # allows <B> <I> <P> <A> <LI> <OL> <UL> <EM> <BR> <TT> <STRONG> 
       # <BLOCKQUOTE> <DIV .*> <DIV> <IMG> <M> <SPAN> <H1> <H2> <H3> <H4> <SUB>
       # <SUP>
-      my %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1,
-		BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1,
-                M=>1, SUB=>1, SUP=>1, SPAN=>1, 
-		H1=>1, H2=>1, H3=>1, H4=>1, H5=>1);
-
-      $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/
+      %html=(B=>1, I=>1, P=>1, A=>1, LI=>1, OL=>1, UL=>1, EM=>1,
+	     BR=>1, TT=>1, STRONG=>1, BLOCKQUOTE=>1, DIV=>1, IMG=>1,
+	     M=>1, SUB=>1, SUP=>1, SPAN=>1, 
+	     H1=>1, H2=>1, H3=>1, H4=>1, H5=>1);
+  }
+# Do the substitution of everything that is not explicitly allowed
+  $message =~ s/\<(\/?\s*(\w+)[^\>\<]*)/
 	  {($html{uc($2)}&&(length($1)<1000))?"\<$1":"\&lt;$1"}/ge;
-      $message =~ s/(\<?\s*(\w+)[^\<\>]*)\>/
+  $message =~ s/(\<?\s*(\w+)[^\<\>]*)\>/
 	  {($html{uc($2)}&&(length($1)<1000))?"$1\>":"$1\&gt;"}/ge;
-  } else {
-      $message=~s/\</\&lt\;/g;
-      $message=~s/\>/\&gt\;/g;
-  }
   return $message;
 }
 
@@ -1757,7 +1758,7 @@
 }
 
 sub generate_preview_button {
-    my $pre=&mt("Show Preview");
+    my $pre=&mt("Show Preview and Check Spelling");
     return(<<ENDPREVIEW);
 <form name="preview" action="/adm/feedback?preview=1" method="post" target="preview">
 <input type="hidden" name="subject">
Index: loncom/interface/lonhtmlcommon.pm
diff -u loncom/interface/lonhtmlcommon.pm:1.84 loncom/interface/lonhtmlcommon.pm:1.85
--- loncom/interface/lonhtmlcommon.pm:1.84	Mon Jul 26 17:57:27 2004
+++ loncom/interface/lonhtmlcommon.pm	Tue Jul 27 19:35:34 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common html routines
 #
-# $Id: lonhtmlcommon.pm,v 1.84 2004/07/26 21:57:27 albertel Exp $
+# $Id: lonhtmlcommon.pm,v 1.85 2004/07/27 23:35:34 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -869,6 +869,33 @@
     return $output.'</font>'.($noformat?'':'</b></tt><br />');
 }
 
+# --------------------- A function that generates a window for the spellchecker
+
+sub spellheader {
+    my $nothing = &javascript_nothing();
+    return (<<ENDCHECK);
+<script type="text/javascript"> 
+var checkwin;
+
+function spellcheckerwindow() {
+    checkwin=window.open($nothing,'spellcheckwin','height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no');
+    checkwin.document.writeln('<html><body bgcolor="#DDDDDD"><form name="spellcheckform" action="/adm/spellcheck" method="post"><input type="hidden" name="text" value="" /></form></body></html>');
+    checkwin.document.close();
+}
+</script>
+ENDCHECK
+}
+
+# ---------------------------------- Generate link to spell checker for a field
+
+sub spelllink {
+    my ($form,$field)=@_;
+    my $linktext=&mt('Check Spelling');
+    return (<<ENDLINK);
+<a href="javascript:if (typeof(document.$form.onsubmit)!='undefined') { document.$form.onsubmit();};spellcheckerwindow();checkwin.document.forms.spellcheckform.text.value=this.document.forms.$form.$field.value;checkwin.document.forms.spellcheckform.submit();">$linktext</a>
+ENDLINK
+}
+
 # ------------------------------------------------- Output headers for HTMLArea
 
 sub htmlareaheaders {
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.272 loncom/interface/lonnavmaps.pm:1.273
--- loncom/interface/lonnavmaps.pm:1.272	Mon Jul 26 18:30:15 2004
+++ loncom/interface/lonnavmaps.pm	Tue Jul 27 19:35:34 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.272 2004/07/26 22:30:15 albertel Exp $
+# $Id: lonnavmaps.pm,v 1.273 2004/07/27 23:35:34 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -100,7 +100,7 @@
     }
     if ($mode eq 'link') {
 	$result.='<a href="javascript:launch_navmapwin();void(0);">'
-	    .&mt("Launch Navmaps in seperate window")."</a> ";
+	    .&mt("Launch navigation in separate window")."</a> ";
     }
     return $result;
 }
@@ -275,7 +275,7 @@
     if ($ENV{'environment.remotenavmap'} eq 'on') {
 #        $r->print("<a href='navmaps?collapseExternal'>" .
         $r->print("<a href='javascript:collapse();void(0);'>" .
-		  &mt("Close external navmaps").
+		  &mt("Close separate navigation window").
 		  "</a>&nbsp;&nbsp;&nbsp;&nbsp;");
     } 
 
Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.170 loncom/interface/lonparmset.pm:1.171
--- loncom/interface/lonparmset.pm:1.170	Thu Jul 22 19:18:00 2004
+++ loncom/interface/lonparmset.pm	Tue Jul 27 19:35:34 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.170 2004/07/22 23:18:00 raeburn Exp $
+# $Id: lonparmset.pm,v 1.171 2004/07/27 23:35:34 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -542,7 +542,7 @@
 
 =item B<typep>: hash, id->type, where "type" contains the extension of the file, thus, I<problem exam quiz assess survey form>.
 
-=item B<keyp>: hash, id->key list, will contain a comma seperated list of the meta-data keys available for the given id
+=item B<keyp>: hash, id->key list, will contain a comma separated list of the meta-data keys available for the given id
 
 =item B<allparms>: hash, name of parameter->display value (what is the display value?)
 
Index: loncom/interface/lonsimplepage.pm
diff -u loncom/interface/lonsimplepage.pm:1.21 loncom/interface/lonsimplepage.pm:1.22
--- loncom/interface/lonsimplepage.pm:1.21	Thu Jun  3 10:28:39 2004
+++ loncom/interface/lonsimplepage.pm	Tue Jul 27 19:35:34 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Simple Page Editor
 #
-# $Id: lonsimplepage.pm,v 1.21 2004/06/03 14:28:39 www Exp $
+# $Id: lonsimplepage.pm,v 1.22 2004/07/27 23:35:34 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -179,6 +179,9 @@
 		$message
 		    =~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
 		$message=&Apache::lontexconvert::msgtexconverted($message);
+		if ($allowed) {
+		    $message=&Apache::lonspeller::markeduptext($message);
+		}
 		unless ($_ eq 'aaa_title') {
 		    if (($_ ne 'bbb_content') || ($allowed)) {
 			if ($target ne 'tex') {
Index: loncom/interface/lonspeller.pm
diff -u loncom/interface/lonspeller.pm:1.5 loncom/interface/lonspeller.pm:1.6
--- loncom/interface/lonspeller.pm:1.5	Fri Jul 23 15:47:57 2004
+++ loncom/interface/lonspeller.pm	Tue Jul 27 19:35:34 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Interface routines for Aspell
 #
-# $Id: lonspeller.pm,v 1.5 2004/07/23 19:47:57 www Exp $
+# $Id: lonspeller.pm,v 1.6 2004/07/27 23:35:34 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,6 +37,7 @@
 use strict;
 
 my $speller;
+my $insidelink;
 
 sub spellcheck_language {
     if ($ENV{'form.lang'}) { return $ENV{'form.lang'}; }
@@ -55,21 +56,20 @@
     my $input=shift;
     my $output='';
     &set_language();
-    foreach my $word (split(/\W+/,$input)) {
-	if ($speller->check($word)) {
-	    $output.=$word.' ';
+    foreach my $word (split(/\b/,$input)) {
+	if (($word=~/\W/) || ($word=~/^(lt|gt|nbsp|amp)$/i)
+	    || ($speller->check($word))) {
+	    $output.=$word;
 	} else {
 	    my $suggestions=join(' ',$speller->suggest($word));
-	    &Apache::lonnet::logthis($suggestions);
 	    $suggestions=~s/\'/\\\'/gs;
-	    if ($suggestions) {
+	    if (($suggestions) && (!$insidelink)) {
 		$output.='<a href="javascript:alert('."'".
 		    $suggestions."');".
 		    '">';
 	    }
 	    $output.='<font color="red">'.$word.'</font>';
-	    if ($suggestions) { $output.='</a>'; }
-	    $output.=' ';
+	    if (($suggestions) && (!$insidelink)) { $output.='</a>'; }
 	}
     }
     return $output;
@@ -80,19 +80,29 @@
     my $input=shift;
     my $output='';
     my $parser=HTML::LCParser->new(\$input);
+    $insidelink=0;
     my $token;
     while ($token=$parser->get_token) {
 	if ($token->[0] eq 'T') {
 	    $output.=&textsection($token->[1]);
 	} elsif ($token->[0] eq 'S') {
 	    $output.=$token->[4];
-	    if ($token->[1] eq 'm') {
-		$output.=$parser->get_text('/m');
+	    foreach my $tag ('m','script') {
+		if ($token->[1] eq $tag) {
+		    $output.=$parser->get_text('/'.$tag);
+		}
+	    }
+	    if ($token->[1] eq 'a') {
+		$insidelink=1;
 	    }
 	} elsif ($token->[0] eq 'E') {
 	    $output.=$token->[2];
+	    if ($token->[1] eq 'a') {
+		$insidelink=0;
+	    }
 	}
     }
+    $insidelink=0;
     return $output;
 }
 
@@ -100,8 +110,8 @@
     unless (defined($speller)) {
 	$speller = Text::Aspell->new;
 	$speller->set_option('lang','en_US');
-	$speller->set_option('sug-mode','fast');
     }
+    $insidelink=0;
 }
 
 sub handler {
Index: loncom/interface/lonsyllabus.pm
diff -u loncom/interface/lonsyllabus.pm:1.37 loncom/interface/lonsyllabus.pm:1.38
--- loncom/interface/lonsyllabus.pm:1.37	Fri Jun 11 12:37:42 2004
+++ loncom/interface/lonsyllabus.pm	Tue Jul 27 19:35:34 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Syllabus
 #
-# $Id: lonsyllabus.pm,v 1.37 2004/06/11 16:37:42 sakharuk Exp $
+# $Id: lonsyllabus.pm,v 1.38 2004/07/27 23:35:34 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,6 +37,7 @@
 use Apache::lonannounce;
 use Apache::lonlocal;
 use Apache::lonhtmlcommon;
+use Apache::lonspeller();
 
 sub handler {
     my $r = shift;
@@ -286,6 +287,9 @@
                  $message=~s/\n/\<br \/\>/g;
                  $message
            =~s/(https*\:\/\/[^\s]+)/\<a href=\"$1\"\>\<tt\>$1\<\/tt\>\<\/a\>/g;
+		 if ($allowed) {
+		     $message=&Apache::lonspeller::markeduptext($message);
+		 }
 	         $message=&Apache::lontexconvert::msgtexconverted($message);
 		 if ($target ne 'tex') {
 		     $r->print('<h3>'.$syllabusfields{$_}.'</h3><blockquote>'.
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.332 loncom/xml/lonxml.pm:1.333
--- loncom/xml/lonxml.pm:1.332	Mon Jul 26 12:23:47 2004
+++ loncom/xml/lonxml.pm	Tue Jul 27 19:35:34 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.332 2004/07/26 16:23:47 sakharuk Exp $
+# $Id: lonxml.pm,v 1.333 2004/07/27 23:35:34 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1127,7 +1127,8 @@
       my $initialize='';
       if ($filetype eq 'html') {
 	  my $addbuttons=&Apache::lonhtmlcommon::htmlareaaddbuttons();
-	  $initialize=&Apache::lonhtmlcommon::htmlareaheaders().(<<FULLPAGE);
+	  $initialize=&Apache::lonhtmlcommon::htmlareaheaders().
+	      &Apache::lonhtmlcommon::spellheader().(<<FULLPAGE);
 <script type="text/javascript">
 $addbuttons
 
@@ -1157,11 +1158,12 @@
 <input type="submit" name="savethisfile" accesskey="s"  value="$lt{'st'}" />
 <input type="submit" name="viewmode" accesskey="v" value="$lt{'vi'}" />
 BUTTONS
+      $buttons.=&Apache::lonhtmlcommon::spelllink('xmledit','filecont');
       my $editfooter=(<<ENDFOOTER);
 $initialize
 <hr />
 <a name="editsection" />
-<form method="post">
+<form method="post" name="xmledit">
 $xml_help
 <input type="hidden" name="editmode" value="$lt{'ed'}" />
 $buttons<br />

--www1090971334--