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

www lon-capa-cvs@mail.lon-capa.org
Sat, 01 Nov 2003 17:38:58 -0000


www		Sat Nov  1 12:38:58 2003 EDT

  Modified files:              
    /loncom/publisher	lonpublisher.pm 
  Log:
  Make gathering of metadata hierachical, rather than gather all data encountered
  along the way.
  
  
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.141 loncom/publisher/lonpublisher.pm:1.142
--- loncom/publisher/lonpublisher.pm:1.141	Sat Nov  1 12:09:52 2003
+++ loncom/publisher/lonpublisher.pm	Sat Nov  1 12:38:58 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.141 2003/11/01 17:09:52 www Exp $
+# $Id: lonpublisher.pm,v 1.142 2003/11/01 17:38:58 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -214,12 +214,7 @@
 		$newentry=~s/^\s*//;
 		if ($newentry !~m|^/res|) { $newentry=$prefix.$newentry; }
 	    }
-	    if ($metadatafields{$unikey}) {
-		unless (($metadatafields{$unikey}=~/\Q$newentry\E/) ||
-			($newentry eq '')) {
-		    $metadatafields{$unikey}.=', '.$newentry;
-		}
-	    } else {
+	    unless ($metadatafields{$unikey}=~/\w/) {
 		$metadatafields{$unikey}=$newentry;
 	    }
 	}
@@ -815,6 +810,23 @@
     return (undef,$status);
 }
 
+
+# ============================================== Parse file itself for metadata
+
+
+sub parseformeta {
+    my ($source,$style)=@_;
+    if (($style eq 'ssi') || ($style eq 'prv')) {
+	my $dir=$source;
+	$dir=~s-/[^/]*$--;
+	my $file=$source;
+	$file=(split('/',$file))[-1];
+        $source=&Apache::lonnet::hreflocation($dir,$file);
+	my $allmeta=&Apache::lonnet::ssi_body($source,('grade_target' => 'meta'));
+        &metaeval($allmeta);
+    }
+}
+
 #########################################
 #########################################
 
@@ -952,6 +964,9 @@
 	                                 $ENV{'user.domain'};
 	$metadatafields{'authorspace'}=$cuname.'@'.$cudom;
 
+# ----------------------------------------------------------- Parse file itself
+
+	&parseformeta($source,$style);
 # ------------------------------------------------ Check out directory hierachy
 
         my $thisdisfn=$source;
@@ -990,18 +1005,10 @@
         }
         
     }
+# ------------------------------------------ See if anything new in file itself
+ 
+    &parseformeta($source,$style);
 
-# -------------------------------------------------- Parse content for metadata
-    if (($style eq 'ssi') || ($style eq 'prv')) {
-	my $dir=$source;
-	$dir=~s-/[^/]*$--;
-	my $file=$source;
-	$file=(split('/',$file))[-1];
-        $source=&Apache::lonnet::hreflocation($dir,$file);
-	$allmeta=&Apache::lonnet::ssi_body($source,('grade_target' => 'meta'));
-
-        &metaeval($allmeta);
-    }
 # ---------------- Find and document discrepancies in the parameters and stores
 
     my $chparms='';