Diff for /loncom/publisher/lonpublisher.pm between versions 1.139 and 1.143

version 1.139, 2003/10/21 19:50:15 version 1.143, 2003/11/04 16:15:56
Line 181  nothing Line 181  nothing
 #########################################  #########################################
 #########################################  #########################################
 sub metaeval {  sub metaeval {
     my $metastring=shift;      my ($metastring,$prefix)=@_;
         
     my $parser=HTML::LCParser->new(\$metastring);      my $parser=HTML::LCParser->new(\$metastring);
     my $token;      my $token;
Line 209  sub metaeval { Line 209  sub metaeval {
     $metadatakeys{$unikey}=$_;      $metadatakeys{$unikey}=$_;
  }   }
     }      }
     if ($metadatafields{$unikey}) {      my $newentry=$parser->get_text('/'.$entry);
  my $newentry=$parser->get_text('/'.$entry);      if ($entry eq 'customdistributionfile') {
  unless (($metadatafields{$unikey}=~/\Q$newentry\E/) ||   $newentry=~s/^\s*//;
  ($newentry eq '')) {   if ($newentry !~m|^/res|) { $newentry=$prefix.$newentry; }
     $metadatafields{$unikey}.=', '.$newentry;      }
  }      unless ($metadatafields{$unikey}=~/\w/) {
     } else {   $metadatafields{$unikey}=$newentry;
  $metadatafields{$unikey}=$parser->get_text('/'.$entry);  
     }      }
  }   }
     }      }
Line 260  XHTML text that indicates successful rea Line 259  XHTML text that indicates successful rea
 #########################################  #########################################
 #########################################  #########################################
 sub metaread {  sub metaread {
     my ($logfile,$fn)=@_;      my ($logfile,$fn,$prefix)=@_;
     unless (-e $fn) {      unless (-e $fn) {
  print($logfile 'No file '.$fn."\n");   print($logfile 'No file '.$fn."\n");
         return '<br /><b>No file:</b> <tt>'.$fn.'</tt>';          return '<br /><b>No file:</b> <tt>'.$fn.'</tt>';
Line 268  sub metaread { Line 267  sub metaread {
     print($logfile 'Processing '.$fn."\n");      print($logfile 'Processing '.$fn."\n");
     my $metastring;      my $metastring;
     {      {
      my $metafh=Apache::File->new($fn);   my $metafh=Apache::File->new($fn);
      $metastring=join('',<$metafh>);   $metastring=join('',<$metafh>);
     }      }
     &metaeval($metastring);      &metaeval($metastring,$prefix);
     return '<br /><b>Processed file:</b> <tt>'.$fn.'</tt>';      return '<br /><b>Processed file:</b> <tt>'.$fn.'</tt>';
 }  }
   
Line 325  string which presents the form field (fo Line 324  string which presents the form field (fo
 #########################################  #########################################
 sub textfield {  sub textfield {
     my ($title,$name,$value)=@_;      my ($title,$name,$value)=@_;
       $value=~s/^\s+//gs;
       $value=~s/\s+$//gs;
       $value=~s/\s+/ /gs;
     $title=&mt($title);      $title=&mt($title);
     my $uctitle=uc($title);      my $uctitle=uc($title);
     return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".      return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".
Line 808  sub store_metadata { Line 810  sub store_metadata {
     return (undef,$status);      return (undef,$status);
 }  }
   
   
   # ============================================== Parse file itself for metadata
   
   
   sub parseformeta {
       my ($source,$style)=@_;
       my $allmeta='';
       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);
       }
       return $allmeta;
   }
   
 #########################################  #########################################
 #########################################  #########################################
   
Line 945  sub publish { Line 966  sub publish {
                                  $ENV{'user.domain'};                                   $ENV{'user.domain'};
  $metadatafields{'authorspace'}=$cuname.'@'.$cudom;   $metadatafields{'authorspace'}=$cuname.'@'.$cudom;
   
   # ----------------------------------------------------------- Parse file itself
   
    &parseformeta($source,$style);
 # ------------------------------------------------ Check out directory hierachy  # ------------------------------------------------ Check out directory hierachy
   
         my $thisdisfn=$source;          my $thisdisfn=$source;
Line 955  sub publish { Line 979  sub publish {
   
         my $currentpath='/home/'.$cuname.'/';          my $currentpath='/home/'.$cuname.'/';
   
    my $prefix='../'x($#urlparts);
         foreach (@urlparts) {          foreach (@urlparts) {
     $currentpath.=$_.'/';      $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)  # ------------------- Clear out parameters and stores (there should not be any)
Line 981  sub publish { Line 1007  sub publish {
         }          }
                   
     }      }
   # ------------------------------------------ See if anything new in file itself
    
       $allmeta=&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  # ---------------- Find and document discrepancies in the parameters and stores
   
     my $chparms='';      my $chparms='';

Removed from v.1.139  
changed lines
  Added in v.1.143


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>