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

foxr lon-capa-cvs@mail.lon-capa.org
Mon, 06 Nov 2006 11:39:06 -0000


foxr		Mon Nov  6 06:39:06 2006 EDT

  Modified files:              
    /loncom/xml	londefdef.pm 
  Log:
  queue existing ps/eps files to be copied so that files with ' ' in their names
  won't fail printing
  
  
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.340 loncom/xml/londefdef.pm:1.341
--- loncom/xml/londefdef.pm:1.340	Mon Oct 16 07:05:20 2006
+++ loncom/xml/londefdef.pm	Mon Nov  6 06:39:02 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Tags Default Definition Module 
 #
-# $Id: londefdef.pm,v 1.340 2006/10/16 11:05:20 foxr Exp $
+# $Id: londefdef.pm,v 1.341 2006/11/06 11:39:02 foxr Exp $
 # 
 #
 # Copyright Michigan State University Board of Trustees
@@ -2852,6 +2852,7 @@
 	#if original gif/jpg/png file exist do following:
 	my $origsrc=$src;
 	my ($path,$file) = &get_eps_image($src);
+	# &Apache::lonnet::logthis("Image source: $src result: $path $file");
 	$src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
 	&Apache::lonxml::debug("path = $path file = $file src = $src");
 	if (-e $src) {
@@ -2865,6 +2866,13 @@
 	    my $size;
 	    if ($width_param)  { $size.='width='.$width_param.' mm,'; }
 	    if ($height_param) { $size.='height='.$height_param.' mm]'; }
+	    # Default size if not able to extract that (e.g. eps image).
+	    
+	    # &Apache::lonnet::logthis("Size = $size");
+	    if ($size eq "0 mm") {
+		$size = "50 mm]";     # Default to 1 column width for 2 column.
+	    }
+	    
 	    $size='['.$size;
 	    $size=~s/,$/]/; 
 	    $currentstring .= '\graphicspath{{'.$destpath.'}}'
@@ -4240,6 +4248,7 @@
     $src=&Apache::lonnet::filelocation($Apache::lonxml::pwd[-1],$src);
     &Apache::lonxml::debug("Filelocation gives: $src");
     if (! -e $src) {
+	# &Apache::lonnet::logthis("$src does not exist...repcopying");
 	&Apache::lonxml::debug("$src does not exist");
 	if (&Apache::lonnet::repcopy($src) ne 'ok' ) {
 	    &Apache::lonxml::debug("Repcopy of $src failed (1)");
@@ -4251,6 +4260,7 @@
 	    &Apache::lonxml::debug("repcopy of $src ... $didrepcopy");
 	    if ( (not -e $src) ||
 		($didrepcopy ne 'ok')) {
+		# &Apache::lonnet::logthis("queuing $orig_src for dynamic eps gen");
 		&Apache::lonxml::debug("Failed to find or replicate $src");
 
 		#if replication failed try to produce eps file dynamically
@@ -4267,8 +4277,24 @@
 		if ($sext ne "") {	 # Put the ext. back in to uniquify.
 		    $src =~ s/\.eps$/$sext.eps/;
 		}
+
 	    }
 	}
+    } else {
+# 	&Apache::lonnet::logthis("$src exists. queueing for copy.");
+# 	&Apache::lonnet::logthis("Got eps already.. queue for copy");
+	# If the postscript file has spaces in its name,
+	# LaTeX will gratuitiously vomit.  Therefore
+	# queue such files for copy with " " replaced by "_".
+	# printout.pm will know them by their .ps  or .eps extensions.
+	my $newsrc = $orig_src;
+	$newsrc    =~  s|(.*)/res/|/home/httpd/html/res/|;
+	open(FILE,">>/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat");
+#	&Apache::lonnet::logthis("Queueing $newsrc for copy");
+	print FILE "$newsrc\n";
+	close FILE;
+	$src=~s|/home/httpd/html/res|/home/httpd/prtspool|;
+	$src=~s|/home/([^/]*)/public_html/|/home/httpd/prtspool/$1/|;
     }
     my ($path,$file)=($src=~m|(.*)/([^/]*)$|);
     &Apache::lonxml::debug("get_eps_image returning: $path / $file<BR />");