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

foxr lon-capa-cvs@mail.lon-capa.org
Fri, 22 Jul 2005 11:44:52 -0000


foxr		Fri Jul 22 07:44:52 2005 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
  Log:
  defect 4246 : in get_eps_image:  Retain information about the original
  file extension so that a single resource can print with images like:
  file.gif and file.jpg e.g.  The idea is that instead of both of these
  converting to file.eps they'll convert to file.gif.eps and file.jpg.eps
  respectively.
    See also r1.84 for ../interface/printout.pl
  which must couple to this change as it is what actually generates the .eps
  files.
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.281 loncom/xml/londefdef.pm:1.282
--- loncom/xml/londefdef.pm:1.281	Tue Jul 12 17:05:49 2005
+++ loncom/xml/londefdef.pm	Fri Jul 22 07:44:51 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.281 2005/07/12 21:05:49 foxr Exp $
+# $Id: londefdef.pm,v 1.282 2005/07/22 11:44:51 foxr Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -47,7 +47,7 @@
 use Apache::lonmenu();
 use Apache::lonmeta();
 use Apache::Constants qw(:common);
-
+use File::Basename;
 
 BEGIN {
 
@@ -3962,6 +3962,7 @@
     my ($src)=@_;
     my $orig_src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1], $src);
     &Apache::lonxml::debug("get_eps_image: Original image: $orig_src");
+    my ($spath, $sname, $sext) = fileparse($src, qr/\.(gif|png|jpg|jpeg)/i);
     $src=~s/\.(gif|png|jpg|jpeg)$/\.eps/i;
     $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
     &Apache::lonxml::debug("Filelocation gives: $src");
@@ -3994,6 +3995,9 @@
 	}
     }
     my ($path,$file)=($src=~m|(.*)/([^/]*)$|);
+    if ($sext ne "") {		# Put the ext. back in to uniquify.
+	$file =~ s/\.eps$/$sext.eps/;
+    }
     &Apache::lonxml::debug("get_eps_image returning: $path / $file<BR />");
     return ($path.'/',$file);
 }