Diff for /loncom/publisher/lonpublisher.pm between versions 1.121 and 1.132

version 1.121, 2003/04/02 02:17:10 version 1.132, 2003/09/16 21:30:28
Line 82  invocation by F<loncapa_apache.conf>: Line 82  invocation by F<loncapa_apache.conf>:
   ErrorDocument     500 /adm/errorhandler    ErrorDocument     500 /adm/errorhandler
   </Location>    </Location>
   
   =head1 OVERVIEW
   
   Authors can only write-access the C</~authorname/> space. They can
   copy resources into the resource area through the publication step,
   and move them back through a recover step. Authors do not have direct
   write-access to their resource space.
   
   During the publication step, several events will be
   triggered. Metadata is gathered, where a wizard manages default
   entries on a hierarchical per-directory base: The wizard imports the
   metadata (including access privileges and royalty information) from
   the most recent published resource in the current directory, and if
   that is not available, from the next directory above, etc. The Network
   keeps all previous versions of a resource and makes them available by
   an explicit version number, which is inserted between the file name
   and extension, for example C<foo.2.html>, while the most recent
   version does not carry a version number (C<foo.html>). Servers
   subscribing to a changed resource are notified that a new version is
   available.
   
 =head1 DESCRIPTION  =head1 DESCRIPTION
   
 B<lonpublisher> takes the proper steps to add resources to the LON-CAPA  B<lonpublisher> takes the proper steps to add resources to the LON-CAPA
Line 190  sub metaeval { Line 210  sub metaeval {
               }                }
               if ($metadatafields{$unikey}) {                if ($metadatafields{$unikey}) {
   my $newentry=$parser->get_text('/'.$entry);    my $newentry=$parser->get_text('/'.$entry);
                   unless (($metadatafields{$unikey}=~/$newentry/) ||                    unless (($metadatafields{$unikey}=~/\Q$newentry\E/) ||
                           ($newentry eq '')) {                            ($newentry eq '')) {
                      $metadatafields{$unikey}.=', '.$newentry;                       $metadatafields{$unikey}.=', '.$newentry;
   }    }
Line 304  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)=@_;
     return "\n<p><b>$title:</b></p><br />".      my $uctitle=uc($title);
       return "\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".
              "</b></font></p><br />".
            '<input type="text" name="'.$name.'" size=80 value="'.$value.'" />';             '<input type="text" name="'.$name.'" size=80 value="'.$value.'" />';
 }  }
   
Line 316  sub hiddenfield { Line 338  sub hiddenfield {
 sub selectbox {  sub selectbox {
     my ($title,$name,$value,$functionref,@idlist)=@_;      my ($title,$name,$value,$functionref,@idlist)=@_;
     my $uctitle=uc($title);      my $uctitle=uc($title);
       $value=(split(/\s*,\s*/,$value))[-1];
     my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".      my $selout="\n<p><font color=\"#800000\" face=\"helvetica\"><b>$uctitle:".
  "</b></font></p><br />".'<select name="'.$name.'">';   '</b></font></p><br /><select name="'.$name.'">';
     foreach (@idlist) {      foreach (@idlist) {
         $selout.='<option value=\''.$_.'\'';          $selout.='<option value=\''.$_.'\'';
         if ($_ eq $value) {          if ($_ eq $value) {
Line 695  sub fix_ids_and_indices { Line 718  sub fix_ids_and_indices {
  }   }
  if (!$endtag) { if ($token->[4]=~m:/>$:) { $endtag=' /'; }; }   if (!$endtag) { if ($token->[4]=~m:/>$:) { $endtag=' /'; }; }
  $outstring.='<'.$tag.$newparmstring.$endtag.'>';   $outstring.='<'.$tag.$newparmstring.$endtag.'>';
  if ($lctag eq 'm') {   if ($lctag eq 'm' || $lctag eq 'script' 
     $outstring.=&get_all_text_unbalanced('/m',\@parser);                      || $lctag eq 'display' || $lctag eq 'tex') {
       $outstring.=&get_all_text_unbalanced('/'.$lctag,\@parser);
  }   }
     } elsif ($token->[0] eq 'E') {      } elsif ($token->[0] eq 'E') {
  if ($token->[2]) {   if ($token->[2]) {
Line 812  sub publish { Line 836  sub publish {
  return ('<font color="red">No write permission to user directory, FAIL</font>',1);   return ('<font color="red">No write permission to user directory, FAIL</font>',1);
     }      }
     print $logfile       print $logfile 
 "\n\n================= Publish ".localtime()." Phase One  ================\n";  "\n\n================= Publish ".localtime()." Phase One  ================\n".$ENV{'user.name'}.'@'.$ENV{'user.domain'}."\n";
   
     if (($style eq 'ssi') || ($style eq 'rat') || ($style eq 'prv')) {      if (($style eq 'ssi') || ($style eq 'rat') || ($style eq 'prv')) {
 # ------------------------------------------------------- This needs processing  # ------------------------------------------------------- This needs processing
Line 907  sub publish { Line 931  sub publish {
         $metadatafields{'author'}=~s/\s+/ /g;          $metadatafields{'author'}=~s/\s+/ /g;
         $metadatafields{'author'}=~s/\s+$//;          $metadatafields{'author'}=~s/\s+$//;
         $metadatafields{'owner'}=$cuname.'@'.$cudom;          $metadatafields{'owner'}=$cuname.'@'.$cudom;
    $metadatafields{'modifyinguser'}=$ENV{'user.name'}.'@'.
                                    $ENV{'user.domain'};
    $metadatafields{'authorspace'}=$cuname.'@'.$cudom;
   
 # ------------------------------------------------ Check out directory hierachy  # ------------------------------------------------ Check out directory hierachy
   
         my $thisdisfn=$source;          my $thisdisfn=$source;
         $thisdisfn=~s/^\/home\/$cuname\///;          $thisdisfn=~s/^\/home\/\Q$cuname\E\///;
   
         my @urlparts=split(/\//,$thisdisfn);          my @urlparts=split(/\//,$thisdisfn);
         $#urlparts--;          $#urlparts--;
Line 1042  function uncheckAll(field) { Line 1069  function uncheckAll(field) {
         field[i].checked = false ;          field[i].checked = false ;
 }  }
 </script>  </script>
 <p><b>Keywords: $keywords_help</b>   <p><font color="#800000" face="helvetica"><b>KEYWORDS:</b></font>
    $keywords_help</b>
 <input type="button" value="check all" onclick="javascript:checkAll(document.pubform.keywords)" />   <input type="button" value="check all" onclick="javascript:checkAll(document.pubform.keywords)" /> 
 <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.pubform.keywords)" />   <input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.pubform.keywords)" /> 
 </p>  </p>
Line 1054  END Line 1082  END
  foreach (sort keys %keywords) {   foreach (sort keys %keywords) {
     $keywordout.='<td><input type="checkbox" name="keywords" value="'.$_.'"';      $keywordout.='<td><input type="checkbox" name="keywords" value="'.$_.'"';
     if ($metadatafields{'keywords'}) {      if ($metadatafields{'keywords'}) {
  if ($metadatafields{'keywords'}=~/$_/) {   if ($metadatafields{'keywords'}=~/\Q$_\E/) {
     $keywordout.=' checked="on"';      $keywordout.=' checked="on"';
  }   }
     } elsif (&Apache::loncommon::keyword($_)) {      } elsif (&Apache::loncommon::keyword($_)) {
Line 1077  END Line 1105  END
  $scrout.=&textfield('Notes','notes',$metadatafields{'notes'});   $scrout.=&textfield('Notes','notes',$metadatafields{'notes'});
   
  $scrout.=   $scrout.=
     '<p><b>Abstract:</b><br /><textarea cols="80" rows="5" name="abstract">'.      "\n<p><font color=\"#800000\" face=\"helvetica\"><b>ABSTRACT:".
       "</b></font></p><br />".
       '<textarea cols="80" rows="5" name="abstract">'.
     $metadatafields{'abstract'}.'</textarea></p>';      $metadatafields{'abstract'}.'</textarea></p>';
   
  $source=~/\.(\w+)$/;   $source=~/\.(\w+)$/;
   
  $scrout.=&hiddenfield('mime',$1);   $scrout.=&hiddenfield('mime',$1);
   
    my $defaultlanguage=$metadatafields{'language'};
    $defaultlanguage =~ s/\s*notset\s*//g;
    $defaultlanguage =~ s/^,\s*//g;
    $defaultlanguage =~ s/,\s*$//g;
   
  $scrout.=&selectbox('Language','language',   $scrout.=&selectbox('Language','language',
     $metadatafields{'language'},      $defaultlanguage,
     \&Apache::loncommon::languagedescription,      \&Apache::loncommon::languagedescription,
     (&Apache::loncommon::languageids),      (&Apache::loncommon::languageids),
    );     );
Line 1144  END Line 1179  END
  $ENV{'form.keywords'}='';   $ENV{'form.keywords'}='';
  foreach (keys %keywords) {   foreach (keys %keywords) {
     if ($metadatafields{'keywords'}) {      if ($metadatafields{'keywords'}) {
  if ($metadatafields{'keywords'}=~/$_/) {    if ($metadatafields{'keywords'}=~/\Q$_\E/) { 
     $ENV{'form.keywords'}.=$_.',';       $ENV{'form.keywords'}.=$_.','; 
  }   }
     } elsif (&Apache::loncommon::keyword($_)) {      } elsif (&Apache::loncommon::keyword($_)) {
Line 1220  sub phasetwo { Line 1255  sub phasetwo {
         return 0;          return 0;
     }      }
     print $logfile       print $logfile 
         "\n================= Publish ".localtime()." Phase Two  ================\n";          "\n================= Publish ".localtime()." Phase Two  ================\n".$ENV{'user.name'}.'@'.$ENV{'user.domain'}."\n";
           
     %metadatafields=();      %metadatafields=();
     %metadatakeys=();      %metadatakeys=();
Line 1327  sub phasetwo { Line 1362  sub phasetwo {
         closedir(DIR);          closedir(DIR);
         $maxversion++;          $maxversion++;
         $r->print('<p>Creating old version '.$maxversion.'</p>');          $r->print('<p>Creating old version '.$maxversion.'</p>');
         print $logfile "\nCreating old version ".$maxversion;          print $logfile "\nCreating old version ".$maxversion."\n";
                   
         my $copyfile=$srcd.'/'.$srcf.'.'.$maxversion.'.'.$srct;          my $copyfile=$srcd.'/'.$srcf.'.'.$maxversion.'.'.$srct;
                   
Line 1435  sub phasetwo { Line 1470  sub phasetwo {
 # ------------------------------------------------ Provide link to new resource  # ------------------------------------------------ Provide link to new resource
     unless ($batch) {      unless ($batch) {
         my $thisdistarget=$target;          my $thisdistarget=$target;
         $thisdistarget=~s/^$docroot//;          $thisdistarget=~s/^\Q$docroot\E//;
                   
         my $thissrc=$source;          my $thissrc=$source;
         $thissrc=~s/^\/home\/(\w+)\/public_html/\/priv\/$1/;          $thissrc=~s/^\/home\/(\w+)\/public_html/\/priv\/$1/;
Line 1457  sub phasetwo { Line 1492  sub phasetwo {
   
 sub batchpublish {  sub batchpublish {
     my ($r,$srcfile,$targetfile)=@_;      my ($r,$srcfile,$targetfile)=@_;
       #publication pollutes %ENV with form.* values
       my %oldENV=%ENV;
     $srcfile=~s/\/+/\//g;      $srcfile=~s/\/+/\//g;
     $targetfile=~s/\/+/\//g;      $targetfile=~s/\/+/\//g;
     my $thisdisfn=$srcfile;      my $thisdisfn=$srcfile;
Line 1465  sub batchpublish { Line 1502  sub batchpublish {
   
     my $docroot=$r->dir_config('lonDocRoot');      my $docroot=$r->dir_config('lonDocRoot');
     my $thisdistarget=$targetfile;      my $thisdistarget=$targetfile;
     $thisdistarget=~s/^$docroot//;      $thisdistarget=~s/^\Q$docroot\E//;
   
   
     undef %metadatafields;      undef %metadatafields;
Line 1492  sub batchpublish { Line 1529  sub batchpublish {
  &phasetwo($r,$srcfile,$targetfile,$thisembstyle,$thisdistarget,1);   &phasetwo($r,$srcfile,$targetfile,$thisembstyle,$thisdistarget,1);
  $r->print('</p>');   $r->print('</p>');
     }      }
       %ENV=%oldENV;
     return '';      return '';
 }  }
   
Line 1532  sub publishdirectory { Line 1570  sub publishdirectory {
         $ruid,$rgid,$rrdev,$rsize,          $ruid,$rgid,$rrdev,$rsize,
         $ratime,$rmtime,$rctime,          $ratime,$rmtime,$rctime,
         $rblksize,$rblocks)=stat($resdir.'/'.$filename);          $rblksize,$rblocks)=stat($resdir.'/'.$filename);
         if ($rmtime<$cmtime) {          if (($rmtime<$cmtime) || ($ENV{'form.forcerepub'})) {
 # previously published, modified now  # previously published, modified now
     $publishthis=1;      $publishthis=1;
                 }                  }
Line 1702  unless ($ENV{'form.phase'} eq 'two') { Line 1740  unless ($ENV{'form.phase'} eq 'two') {
   $thistarget=~s/\/public\_html//;    $thistarget=~s/\/public\_html//;
   
   my $thisdistarget=$thistarget;    my $thisdistarget=$thistarget;
   $thisdistarget=~s/^$docroot//;    $thisdistarget=~s/^\Q$docroot\E//;
   
   my $thisdisfn=$thisfn;    my $thisdisfn=$thisfn;
   $thisdisfn=~s/^\/home\/$cuname\/public_html\///;    $thisdisfn=~s/^\/home\/\Q$cuname\E\/public_html\///;
   
   if ($fn=~/\/$/) {    if ($fn=~/\/$/) {
 # -------------------------------------------------------- This is a directory  # -------------------------------------------------------- This is a directory
       &publishdirectory($r,$fn,$thisdisfn);        &publishdirectory($r,$fn,$thisdisfn);
         $r->print('<hr><font size="+2">Done</font><br><a href="/priv/'
    .$cuname.'/'.$thisdisfn
    .'">Return to Directory</a>');
   
   
   } else {    } else {
 # ---------------------- Evaluate individual file, and then output information.  # ---------------------- Evaluate individual file, and then output information.
       $thisfn=~/\.(\w+)$/;        $thisfn=~/\.(\w+)$/;
       my $thistype=$1;        my $thistype=$1;
       my $thisembstyle=&Apache::loncommon::fileembstyle($thistype);        my $thisembstyle=&Apache::loncommon::fileembstyle($thistype);
   
       $r->print('<h2>Publishing '.        $r->print('<h2>Publishing '.
         &Apache::loncommon::filedescription($thistype).' <tt>'.   &Apache::loncommon::filedescription($thistype).' <tt>');
         '<a href="/~'.$cuname.'/'.$thisdisfn.'" target="cat">'.$thisdisfn.  
         '</a></tt></h2><b>Target:</b> <tt>'.$thisdistarget.'</tt><br />');        $r->print(<<ENDCAPTION);
   <a href='javascript:void(window.open("/~$cuname/$thisdisfn","cat","height=300,width=500,scrollbars=1,resizable=1,menubar=0,location=1"))'>
   $thisdisfn</a>
   ENDCAPTION
         $r->print(
           '</tt></h2><b>Target:</b> <tt>'.$thisdistarget.'</tt><br />');
         
       if (($cuname ne $ENV{'user.name'}) || ($cudom ne $ENV{'user.domain'})) {        if (($cuname ne $ENV{'user.name'}) || ($cudom ne $ENV{'user.domain'})) {
           $r->print('<h3><font color="red">Co-Author: '.$cuname.' at '.$cudom.            $r->print('<h3><font color="red">Co-Author: '.$cuname.' at '.$cudom.
Line 1728  unless ($ENV{'form.phase'} eq 'two') { Line 1774  unless ($ENV{'form.phase'} eq 'two') {
       }        }
   
       if (&Apache::loncommon::fileembstyle($thistype) eq 'ssi') {        if (&Apache::loncommon::fileembstyle($thistype) eq 'ssi') {
           $r->print('<br /><a href="/adm/diff?filename=/~'.$cuname.'/'.            $r->print(<<ENDDIFF);
                     $thisdisfn.  <br />
    '&versiontwo=priv" target="cat">Diffs with Current Version</a><br />');  <a href='javascript:void(window.open("/adm/diff?filename=/~$cuname/$thisdisfn&versiontwo=priv","cat","height=300,width=500,scrollbars=1,resizable=1,menubar=0,location=1"))'>Diffs with Current Version</a><br />
   ENDDIFF
       }        }
       
 # ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.  # ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.
Line 1755  __END__ Line 1802  __END__
   
 =back  =back
   
   =back
   
 =cut  =cut
   

Removed from v.1.121  
changed lines
  Added in v.1.132


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