Diff for /loncom/publisher/lonpubdir.pm between versions 1.17 and 1.21

version 1.17, 2001/12/15 20:48:47 version 1.21, 2002/02/05 12:54:46
Line 37 Line 37
 # 03/24,03/29 Gerd Kortemeyer)  # 03/24,03/29 Gerd Kortemeyer)
 # 03/31,04/03,05/09,06/23,08/18,08/20 Gerd Kortemeyer  # 03/31,04/03,05/09,06/23,08/18,08/20 Gerd Kortemeyer
 # 12/15 Scott Harrison  # 12/15 Scott Harrison
   # 12/28 Gerd Kortemeyer
 #  #
 ###  ###
   
Line 102  sub handler { Line 103  sub handler {
   $r->print('<h1>Construction Space Directory <tt>'.$thisdisfn.'/</tt></h1>');    $r->print('<h1>Construction Space Directory <tt>'.$thisdisfn.'/</tt></h1>');
       
   if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {    if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) {
           $r->print('<h3><font color=red>Co-Author: '.$uname.' at '.$udom.            $r->print('<h3>Co-Author: '.$uname.' at '.$udom.
                '</font></h3>');                 '</h3>');
   }    }
   
   
   my $docroot=$r->dir_config('lonDocRoot');    my $docroot=$r->dir_config('lonDocRoot');
   
   my $resdir=$docroot.'/res/'.$udom.'/'.$uname.$thisdisfn;    my $resdir=$docroot.'/res/'.$udom.'/'.$uname.$thisdisfn;
     my $targetdir=$udom.'/'.$uname.$thisdisfn;
   my $linkdir='/~'.$uname.$thisdisfn;    my $linkdir='/~'.$uname.$thisdisfn;
   
   $r->print('<table border=2>'.    $r->print('<table border=2>'.
  '<tr><th>Filename</th><th>Modified</th><th>Status</th><th>&nbsp;</th></tr>');   '<tr><th>Actions</th><th>Name</th><th>Title</th>'.
    '<th>Status</th><th>Last Modified</th></tr>');
   
   my $filename;    my $filename;
   my $dirptr=16384;    my $dirptr=16384;
Line 129  sub handler { Line 132  sub handler {
      my $extension='';       my $extension='';
      if ($filename=~/\.(\w+)$/) { $extension=$1; }       if ($filename=~/\.(\w+)$/) { $extension=$1; }
      if ($cmode&$dirptr) {       if ($cmode&$dirptr) {
          my $disfilename=$filename;   putdirectory($r, $thisdisfn, $linkdir, $filename, $cmtime);
          if ($filename eq '..') {  
      $disfilename='<i>Parent Directory</i>';  
          }  
          unless ((($filename eq '..') && ($thisdisfn eq '')) ||  
                  ($filename eq '.')) {  
            $r->print('<tr bgcolor=#BBBBFF'.  
            '><td><a href="'.$linkdir.'/'.$filename.'">'.$disfilename.  
  '</a></td><td>'.localtime($cmtime).'</td><td>&nbsp;</td><td>&nbsp;</td></tr>'  
            );  
          }  
      } elsif (&Apache::loncommon::fileembstyle($extension) ne 'hdn') {       } elsif (&Apache::loncommon::fileembstyle($extension) ne 'hdn') {
          my $status='Unpublished';           my $status='Unpublished';
          my $bgcol='#FFBBBB';           my $title='&nbsp;';
          if (-e $resdir.'/'.$filename) {           if (-e $resdir.'/'.$filename) {
             my ($rdev,$rino,$rmode,$rnlink,              my ($rdev,$rino,$rmode,$rnlink,
                 $ruid,$rgid,$rrdev,$rsize,                  $ruid,$rgid,$rrdev,$rsize,
Line 150  sub handler { Line 143  sub handler {
                 $rblksize,$rblocks)=stat($resdir.'/'.$filename);                  $rblksize,$rblocks)=stat($resdir.'/'.$filename);
             if ($rmtime>=$cmtime) {              if ($rmtime>=$cmtime) {
  $status='Published';   $status='Published';
                 $bgcol='#BBFFBB';                  $title=
    '<a href="/res/'.$targetdir.'/'.$filename.'.meta" target=cat>'.
    &Apache::lonnet::metadata($targetdir.'/'.$filename,'title').'</a>';
             } else {              } else {
                 $status='Modified';                  $status='Modified';
                 $bgcol='#FFFFBB';                  $title=
    '<a href="/res/'.$targetdir.'/'.$filename.'.meta" target=cat>'.
    &Apache::lonnet::metadata($targetdir.'/'.$filename,'title').'</a>';
                 if                   if 
          (&Apache::loncommon::fileembstyle(($filename=~/\.(\w+)$/)) eq 'ssi') {           (&Apache::loncommon::fileembstyle(($filename=~/\.(\w+)$/)) eq 'ssi') {
                    $status.='<br><a href="/adm/diff?filename=/~'.$uname.                     $status.='<br><a href="/adm/diff?filename=/~'.$uname.
Line 164  sub handler { Line 161  sub handler {
             $status.='<br><a href="/adm/retrieve?filename=/~'.$uname.              $status.='<br><a href="/adm/retrieve?filename=/~'.$uname.
               $thisdisfn.'/'.$filename.'" target=cat>Retrieve</a>';                $thisdisfn.'/'.$filename.'" target=cat>Retrieve</a>';
  }   }
          $r->print('<tr bgcolor='.$bgcol.   $r->print('<tr>'.
          '><td><a href="'.$linkdir.'/'.$filename.'">'.$filename.     '<td><a target="_parent" href="/adm/publish?filename=/~'.
          '</a></td><td>'.localtime($cmtime).'</td><td>'.$status.'</td>'.          $uname.$thisdisfn.'/'.$filename.'">'.'Publish</a>'.
      '<td><a target="_parent" href="/adm/publish?filename=/~'.$uname.     '</td>'.
                                       $thisdisfn.'/'.$filename.'">'.     '<td>'.
          'Publish</a></td></tr>');        '<a href="'.$linkdir.'/'.$filename.'">'.$filename.'</a>'.
      '</td>'.
      '<td>'.$title.'</td>'.
      '<td>'.$status.'</td>'.
      '<td>'.localtime($cmtime).'</td>'.
      '</tr>');
      } else {       } else {
  # "hidden" extension and not a directory, so hide it away.   # "hidden" extension and not a directory, so hide it away.
      }       }
Line 179  sub handler { Line 181  sub handler {
   $r->print('</table></body></html>');    $r->print('</table></body></html>');
   return OK;      return OK;  
 }  }
   #
   #  Put out a directory table row:
   #    putdirectory(r, base, here, dirname, modtime)
   #      r       - Apache request object.
   #      reqfile - File in request.
   #      here    - Where we are in directory tree.
   #      dirname - Name of directory special file.
   #      modtime - Encoded modification time.
   # 
   sub putdirectory {
       my ($r, $reqfile, $here, $dirname, $modtime) = @_;
     
       # construct the display filename: the directory name unless ..:
       
       my $disfilename = $dirname;
       if ($dirname eq '..') {
    $disfilename = '<i>Parent Directory</i>';
       }
       unless (( ($dirname eq '..') && ($reqfile eq '')) ||
       ($dirname eq '.')) {
    $r->print('<tr>'.
     '<td>Click to cwd</td>'.
     '<td><a href="'.$here.'/'.$dirname.'/">'.
     $disfilename.'</a></td>'.
           '<td>&nbsp;</td>'.
     '<td>&nbsp;</td>'.
     '<td>'.localtime($modtime).'</td>'.
     '</tr>');
       }
       return OK;
   }
 1;  1;
 __END__  __END__
   
Line 191  Apache::lonpubdir - Publication Handler Line 223  Apache::lonpubdir - Publication Handler
   
 Invoked (for various locations) by /etc/httpd/conf/srm.conf:  Invoked (for various locations) by /etc/httpd/conf/srm.conf:
   
 <LocationMatch "^/\~.*/$">   <LocationMatch "^/\~.*/$">
 PerlAccessHandler       Apache::loncacc   PerlAccessHandler       Apache::loncacc
 SetHandler perl-script   SetHandler perl-script
 PerlHandler Apache::lonpubdir   PerlHandler Apache::lonpubdir
 ErrorDocument     403 /adm/login   ErrorDocument     403 /adm/login
 ErrorDocument     404 /adm/notfound.html   ErrorDocument     404 /adm/notfound.html
 ErrorDocument     406 /adm/unauthorized.html   ErrorDocument     406 /adm/unauthorized.html
 ErrorDocument  500 /adm/errorhandler   ErrorDocument  500 /adm/errorhandler
 </LocationMatch>   </LocationMatch>
   
 <Location /adm/pubdir>   <Location /adm/pubdir>
 PerlAccessHandler       Apache::lonacc   PerlAccessHandler       Apache::lonacc
 SetHandler perl-script   SetHandler perl-script
 PerlHandler Apache::lonpubdir   PerlHandler Apache::lonpubdir
 ErrorDocument     403 /adm/login   ErrorDocument     403 /adm/login
 ErrorDocument     404 /adm/notfound.html   ErrorDocument     404 /adm/notfound.html
 ErrorDocument     406 /adm/unauthorized.html   ErrorDocument     406 /adm/unauthorized.html
 ErrorDocument  500 /adm/errorhandler   ErrorDocument  500 /adm/errorhandler
 </Location>   </Location>
   
 =head1 INTRODUCTION  =head1 INTRODUCTION
   
 This module enables cookie based authentication and is used  This module publishes a directory of files.
 to control access for many different LON-CAPA URIs.  
   
 Whenever the client sends the cookie back to the server,   
 this cookie is handled by either lonacc.pm or loncacc.pm  
 (see srm.conf for what is invoked when).  If  
 the cookie is missing or invalid, the user is re-challenged  
 for login information.  
   
 This is part of the LearningOnline Network with CAPA project  This is part of the LearningOnline Network with CAPA project
 described at http://www.lon-capa.org.  described at http://www.lon-capa.org.

Removed from v.1.17  
changed lines
  Added in v.1.21


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