[LON-CAPA-cvs] cvs: loncom /html/adm/lonIcons angry.gif baeh.gif bigsmile.gif coolindiff.gif coolsmile.gif cry.gif frowny.gif hrrm.gif huh.gif lipsrsealed.gif rolleyes.gif shocked.gif smiley.gif wink.gif /xml lontexconvert.pm

www lon-capa-cvs@mail.lon-capa.org
Thu, 13 Mar 2003 16:16:07 -0000


www		Thu Mar 13 11:16:07 2003 EDT

  Added files:                 
    /loncom/html/adm/lonIcons	angry.gif baeh.gif bigsmile.gif 
                             	coolindiff.gif coolsmile.gif cry.gif 
                             	frowny.gif hrrm.gif huh.gif 
                             	lipsrsealed.gif rolleyes.gif shocked.gif 
                             	smiley.gif wink.gif 

  Modified files:              
    /loncom/xml	lontexconvert.pm 
  Log:
  Technology breakthrough: fully de-noser compatible smiley generator
  
  
Index: loncom/xml/lontexconvert.pm
diff -u loncom/xml/lontexconvert.pm:1.19 loncom/xml/lontexconvert.pm:1.20
--- loncom/xml/lontexconvert.pm:1.19	Thu Feb 27 16:01:39 2003
+++ loncom/xml/lontexconvert.pm	Thu Mar 13 11:16:07 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # TeX Conversion Module
 #
-# $Id: lontexconvert.pm,v 1.19 2003/02/27 21:01:39 albertel Exp $
+# $Id: lontexconvert.pm,v 1.20 2003/03/13 16:16:07 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -132,6 +132,29 @@
     return &converted(\$string);
 }
 
+sub smiley {
+   my $expression=shift;
+   if ($ENV{'browser.imagesuppress'} eq 'on') { return $expression; }
+   my %smileys=('\:\-*\)' => 'smiley',
+                '8\-*\)'  => 'coolsmile',
+                '8\-*I'   => 'coolindiff',
+                ':\-*\('  => 'frowny',
+                '\:\-*(o|O|\(\))' => 'shocked',
+                '\;\-*\)' => 'wink',
+                '\:\-*P'  => 'baeh',
+                '\:\-*(\\\|\\/)' => 'hrrm',
+                '\:\-*D'  => 'bigsmile',
+                '\:\-*C'  => 'angry',
+                '\:(\'|\`)\-*\(' => 'cry',
+                '\:\-*(X|\#)' => 'lipsrsealed',
+                '\:\-*S' => 'huh');
+   my $iconpath=$Apache::lonnet::perlvar{'lonIconsURL'};
+   foreach (keys %smileys) {
+      $expression=~s/$_/\<img src="$iconpath\/$smileys{$_}.gif" \/\>/gs; 
+   }
+   return $expression;
+}
+
 sub msgtexconverted {
     my $message=shift;
 
@@ -155,7 +178,7 @@
     $message=~s/(\$.+?\$)/&to_convert($1)/ge;
     $message=~s/(\\\(.+?\\\))/&to_convert($1)/ge;
     $message=~s/(\\\[.+?\\\])/&to_convert($1)/ge;
-    return $message.$errorstring;
+    return &smiley($message).$errorstring;
 }
 
 1;