[LON-CAPA-cvs] cvs: loncom /xml londefdef.pm

sakharuk lon-capa-cvs@mail.lon-capa.org
Wed, 28 Jan 2004 19:59:14 -0000


sakharuk		Wed Jan 28 14:59:14 2004 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
  Log:
  First attempt of cleanup of <img> tag.
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.194 loncom/xml/londefdef.pm:1.195
--- loncom/xml/londefdef.pm:1.194	Wed Jan 28 12:16:27 2004
+++ loncom/xml/londefdef.pm	Wed Jan 28 14:59:13 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.194 2004/01/28 17:16:27 albertel Exp $
+# $Id: londefdef.pm,v 1.195 2004/01/28 19:59:13 sakharuk Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -2100,6 +2100,8 @@
 	    }
 	    $currentstring.='[IMAGE: '.$alttag.']';
 	}
+	$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
+	&image_replication($src);
     } elsif ($target eq 'tex') {
 	$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
 	&image_replication($src);
@@ -2153,16 +2155,8 @@
 			$currentstring .= '\vskip 1 mm \noindent\graphicspath{{'.$path.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
 		    }
 		} else {
-		    #there aren't eps or ps - so create eps 
-		    my $temp_file;
-		    my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
-		    $temp_file = Apache::File->new('>>'.$filename); 
-		    print $temp_file "$src\n";
-		    $newsrc=~s/\/home\/httpd\/html\/res//;
-		    $newsrc=~s/\/home\/([^\/]*)\/public_html\//\/$1\//;
-		    $newsrc=~s/\/\.\//\//;
-		    $newsrc=~s/\/([^\/]+)\.(ps|eps)/\//;
-		    $currentstring .= '\vskip 1 mm \graphicspath{{/home/httpd/prtspool'.$newsrc.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
+		    #care about eps dynamical generation
+		    $currentstring.='\vskip 1 mm '.&eps_generation($src,$file,$width_param);
 		}
 	    }
 	} else {
@@ -3344,6 +3338,20 @@
 	if ($result ne OK) { &Apache::lonnet::repcopy($pssrc); }
     }
     return '';
+}
+
+sub eps_generation {
+    my ($src,$file,$width_param) = @_;	     
+    my $filename = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
+    my $temp_file = Apache::File->new('>>'.$filename); 
+    print $temp_file "$src\n";
+    my $newsrc = $src;
+    $newsrc =~ s/(\.gif|\.jpg|\.jpeg)$/\.eps/i;
+    $newsrc=~s/\/home\/httpd\/html\/res//;
+    $newsrc=~s/\/home\/([^\/]*)\/public_html\//\/$1\//;
+    $newsrc=~s/\/\.\//\//;
+    $newsrc=~s/\/([^\/]+)\.(ps|eps)/\//;
+    return ' \graphicspath{{/home/httpd/prtspool'.$newsrc.'}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
 }
 
 sub recalc {