[LON-CAPA-cvs] cvs: loncom /publisher lonpublisher.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 21 Oct 2003 20:18:45 -0000


albertel		Tue Oct 21 16:18:45 2003 EDT

  Modified files:              
    /loncom/publisher	lonpublisher.pm 
  Log:
  -BUG #1984, publication should notice when default.meta has a relative path file and update the relative path
  
  
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.139 loncom/publisher/lonpublisher.pm:1.140
--- loncom/publisher/lonpublisher.pm:1.139	Tue Oct 21 15:50:15 2003
+++ loncom/publisher/lonpublisher.pm	Tue Oct 21 16:18:45 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.139 2003/10/21 19:50:15 albertel Exp $
+# $Id: lonpublisher.pm,v 1.140 2003/10/21 20:18:45 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -181,7 +181,7 @@
 #########################################
 #########################################
 sub metaeval {
-    my $metastring=shift;
+    my ($metastring,$prefix)=@_;
    
     my $parser=HTML::LCParser->new(\$metastring);
     my $token;
@@ -209,14 +209,18 @@
 		    $metadatakeys{$unikey}=$_;
 		}
 	    }
+	    my $newentry=$parser->get_text('/'.$entry);
+	    if ($entry eq 'customdistributionfile') {
+		$newentry=~s/^\s*//;
+		if ($newentry !~m|^/res|) { $newentry=$prefix.$newentry; }
+	    }
 	    if ($metadatafields{$unikey}) {
-		my $newentry=$parser->get_text('/'.$entry);
 		unless (($metadatafields{$unikey}=~/\Q$newentry\E/) ||
 			($newentry eq '')) {
 		    $metadatafields{$unikey}.=', '.$newentry;
 		}
 	    } else {
-		$metadatafields{$unikey}=$parser->get_text('/'.$entry);
+		$metadatafields{$unikey}=$newentry;
 	    }
 	}
     }
@@ -260,7 +264,7 @@
 #########################################
 #########################################
 sub metaread {
-    my ($logfile,$fn)=@_;
+    my ($logfile,$fn,$prefix)=@_;
     unless (-e $fn) {
 	print($logfile 'No file '.$fn."\n");
         return '<br /><b>No file:</b> <tt>'.$fn.'</tt>';
@@ -268,10 +272,10 @@
     print($logfile 'Processing '.$fn."\n");
     my $metastring;
     {
-     my $metafh=Apache::File->new($fn);
-     $metastring=join('',<$metafh>);
+	my $metafh=Apache::File->new($fn);
+	$metastring=join('',<$metafh>);
     }
-    &metaeval($metastring);
+    &metaeval($metastring,$prefix);
     return '<br /><b>Processed file:</b> <tt>'.$fn.'</tt>';
 }
 
@@ -955,9 +959,11 @@
 
         my $currentpath='/home/'.$cuname.'/';
 
+	my $prefix='../'x($#urlparts);
         foreach (@urlparts) {
 	    $currentpath.=$_.'/';
-            $scrout.=&metaread($logfile,$currentpath.'default.meta');
+            $scrout.=&metaread($logfile,$currentpath.'default.meta',$prefix);
+	    $prefix=~s|^\.\./||;
         }
 
 # ------------------- Clear out parameters and stores (there should not be any)