[BACK]Return to cvsweb.cgi CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / cvsweb

Diff for /cvsweb/cvsweb.cgi between version 3.2 and 3.3

version 3.2, 2000/07/20 11:52:05 version 3.3, 2000/07/27 16:16:41
Line 55  use vars qw (
Line 55  use vars qw (
     @revisions %state %difflines %log %branchpoint @revorder $prcgi      @revisions %state %difflines %log %branchpoint @revorder $prcgi
     @prcategories $prcategories      @prcategories $prcategories
     $checkoutMagic $doCheckout $scriptname $scriptwhere      $checkoutMagic $doCheckout $scriptname $scriptwhere
     $where $Browser $nofilelinks $maycompress @stickyvars      $where $pathinfo $Browser $nofilelinks $maycompress @stickyvars
     %functionlineregexp      %funcline_regexp $is_mod_perl
       $is_lynx $is_msie $is_mozilla3
     %input $query $barequery $sortby $bydate $byrev $byauthor      %input $query $barequery $sortby $bydate $byrev $byauthor
     $bylog $byfile $hr_default $logsort $cvstree $cvsroot      $bylog $byfile $hr_default $logsort $cvstree $cvsroot
     $mimetype $defaultTextPlain $defaultViewable $allow_compress      $mimetype $defaultTextPlain $defaultViewable $allow_compress
Line 64  use vars qw (
Line 65  use vars qw (
     $cvstreedefault $body_tag $logo $defaulttitle $address      $cvstreedefault $body_tag $logo $defaulttitle $address
     $backcolor $long_intro $short_instruction $shortLogLen      $backcolor $long_intro $short_instruction $shortLogLen
     $show_author $dirtable $tablepadding $columnHeaderColorDefault      $show_author $dirtable $tablepadding $columnHeaderColorDefault
     $columnHeaderColorSorted $hr_breakable $hr_funout $hr_ignwhite      $columnHeaderColorSorted $hr_breakable $showfunc $hr_ignwhite
     $hr_ignkeysubst $diffcolorHeading $diffcolorEmpty $diffcolorRemove      $hr_ignkeysubst $diffcolorHeading $diffcolorEmpty $diffcolorRemove
     $diffcolorChange $diffcolorAdd $diffcolorDarkChange $difffontface      $diffcolorChange $diffcolorAdd $diffcolorDarkChange $difffontface
     $difffontsize $inputTextSize $mime_types $allow_annotate      $difffontsize $inputTextSize $mime_types $allow_annotate
Line 80  use vars qw (
Line 81  use vars qw (
 ##### Start of Configuration Area ########  ##### Start of Configuration Area ########
 # == EDIT this ==  # == EDIT this ==
 # User configuration is stored in  # User configuration is stored in
 $config = $ENV{'CVSWEB_CONFIG'} || '/usr/local/etc/cvsweb.conf';  $config = defined($ENV{CVSWEB_CONFIG}) ? $ENV{CVSWEB_CONFIG} : '/usr/local/etc/cvsweb.conf';
   
 # == Configuration defaults ==  # == Configuration defaults ==
 # Defaults for configuration variables that shouldn't need  # Defaults for configuration variables that shouldn't need
Line 96  $allow_version_select = 1;
Line 97  $allow_version_select = 1;
 $cvstreedefault = $body_tag = $logo = $defaulttitle = $address =  $cvstreedefault = $body_tag = $logo = $defaulttitle = $address =
 $backcolor = $long_intro = $short_instruction = $shortLogLen =  $backcolor = $long_intro = $short_instruction = $shortLogLen =
 $show_author = $dirtable = $tablepadding = $columnHeaderColorDefault =  $show_author = $dirtable = $tablepadding = $columnHeaderColorDefault =
 $columnHeaderColorSorted = $hr_breakable = $hr_funout = $hr_ignwhite =  $columnHeaderColorSorted = $hr_breakable = $showfunc = $hr_ignwhite =
 $hr_ignkeysubst = $diffcolorHeading = $diffcolorEmpty = $diffcolorRemove =  $hr_ignkeysubst = $diffcolorHeading = $diffcolorEmpty = $diffcolorRemove =
 $diffcolorChange = $diffcolorAdd = $diffcolorDarkChange = $difffontface =  $diffcolorChange = $diffcolorAdd = $diffcolorDarkChange = $difffontface =
 $difffontsize = $inputTextSize = $mime_types = $allow_annotate =  $difffontsize = $inputTextSize = $mime_types = $allow_annotate =
Line 113  use IPC::Open2;
Line 114  use IPC::Open2;
   
 $verbose = $v;  $verbose = $v;
 $checkoutMagic = "~checkout~";  $checkoutMagic = "~checkout~";
 $where = defined($ENV{'PATH_INFO'}) ? $ENV{'PATH_INFO'} : "";  $pathinfo = defined($ENV{PATH_INFO}) ? $ENV{PATH_INFO} : '';
   $where = $pathinfo;
 $doCheckout = ($where =~ /^\/$checkoutMagic/);  $doCheckout = ($where =~ /^\/$checkoutMagic/);
 $where =~ s|^/($checkoutMagic)?||;  $where =~ s|^/($checkoutMagic)?||;
 $where =~ s|/+$||;  $where =~ s|/+$||;
 ($scriptname = $ENV{'SCRIPT_NAME'}) =~ s|^/?|/|;  $scriptname = defined($ENV{SCRIPT_NAME}) ? $ENV{SCRIPT_NAME} : '';
   $scriptname =~ s|^/?|/|;
 $scriptname =~ s|/+$||;  $scriptname =~ s|/+$||;
   $scriptwhere = $scriptname;
 if ($where) {  if ($where) {
     $scriptwhere = $scriptname . '/' . urlencode($where);      $scriptwhere .= '/' . urlencode($where);
 }  }
 else {  
     $scriptwhere = $scriptname;  
 }  
 $scriptwhere =~ s|/+$||;  
   
   $is_mod_perl = defined($ENV{MOD_PERL});
   
 # in lynx, it it very annoying to have two links  # in lynx, it it very annoying to have two links
 # per file, so disable the link at the icon  # per file, so disable the link at the icon
 # in this case:  # in this case:
 $Browser = $ENV{'HTTP_USER_AGENT'};  $Browser = $ENV{HTTP_USER_AGENT} || '';
 $nofilelinks = ($Browser =~ m'^Lynx/');  $is_lynx = ($Browser =~ m`^Lynx/`);
   $is_msie = ($Browser =~ m`MSIE`);
   $is_mozilla3 = ($Browser =~ m`^Mozilla/[3456789]`);
   
   $nofilelinks = $is_lynx;
   
 # newer browsers accept gzip content encoding  # newer browsers accept gzip content encoding
 # and state this in a header  # and state this in a header
 # (netscape did always but didn't state it)  # (netscape did always but didn't state it)
Line 143  $nofilelinks = ($Browser =~ m'^Lynx/');
Line 149  $nofilelinks = ($Browser =~ m'^Lynx/');
 # Turn off gzip if running under mod_perl. piping does  # Turn off gzip if running under mod_perl. piping does
 # not work as expected inside the server. One can probably  # not work as expected inside the server. One can probably
 # achieve the same result using Apache::GZIPFilter.  # achieve the same result using Apache::GZIPFilter.
 $maycompress =(($ENV{'HTTP_ACCEPT_ENCODING'} =~ m|gzip|  $maycompress =(($ENV{HTTP_ACCEPT_ENCODING} =~ m`gzip`
                 || $Browser =~ m%^Mozilla/3%)                  || $is_mozilla3)
                && ($Browser !~ m/MSIE/)                 && !$is_msie
                && !defined($ENV{'MOD_PERL'}));                 && !$is_mod_perl);
   
 # put here the variables we need in order  # put here the variables we need in order
 # to hold our state - they will be added (with  # to hold our state - they will be added (with
 # their current value) to any link/query string  # their current value) to any link/query string
 # you construct  # you construct
 @stickyvars = ('cvsroot','hideattic','sortby','logsort','f','only_with_tag');  @stickyvars = qw(cvsroot hideattic sortby logsort fonly_with_tag);
   
 if (-f $config) {  if (-f $config) {
     do "$config";      do $config;
 }  }
 else {  else {
    &fatal("500 Internal Error",     &fatal("500 Internal Error",
Line 166  else {
Line 172  else {
 }  }
   
 undef %input;  undef %input;
 if ($query = $ENV{'QUERY_STRING'}) {  $query = $ENV{QUERY_STRING};
   
   if ($query ne '') {
     foreach (split(/&/, $query)) {      foreach (split(/&/, $query)) {
         s/%(..)/sprintf("%c", hex($1))/ge;      # unquote %-quoted          s/%(..)/sprintf("%c", hex($1))/ge;      # unquote %-quoted
         if (/(\S+)=(.*)/) {          if (/(\S+)=(.*)/) {
Line 251  else {
Line 259  else {
   
 $hr_default = $input{'f'} eq 'h';  $hr_default = $input{'f'} eq 'h';
   
 $logsort = $input{"logsort"};  $logsort = $input{'logsort'};
   
   
 ## Default CVS-Tree  ## Default CVS-Tree
Line 276  foreach my $k (keys %ICONS) {
Line 284  foreach my $k (keys %ICONS) {
     no strict 'refs';      no strict 'refs';
     my ($itxt,$ipath,$iwidth,$iheight) = @{$ICONS{$k}};      my ($itxt,$ipath,$iwidth,$iheight) = @{$ICONS{$k}};
     if ($ipath) {      if ($ipath) {
         $ {"${k}icon"} = "<IMG SRC=\"$ipath\" ALT=\"$itxt\" BORDER=\"0\" WIDTH=\"$iwidth\" HEIGHT=\"$iheight\">";          ${"${k}icon"} = "<IMG SRC=\"$ipath\" ALT=\"$itxt\" BORDER=\"0\" WIDTH=\"$iwidth\" HEIGHT=\"$iheight\">";
     }      }
     else {      else {
         $ {"${k}icon"} = $itxt;          ${"${k}icon"} = $itxt;
     }      }
 }  }
   
Line 312  if (-d $fullname) {
Line 320  if (-d $fullname) {
     # ensure, that directories always end with (exactly) one '/'      # ensure, that directories always end with (exactly) one '/'
     # to allow relative URL's. If they're not, make a redirect.      # to allow relative URL's. If they're not, make a redirect.
     ##      ##
     my $pathinfo = defined($ENV{'PATH_INFO'}) ? $ENV{'PATH_INFO'} : "";  
     if (!($pathinfo =~ m|/$|) || ($pathinfo =~ m |/{2,}$|)) {      if (!($pathinfo =~ m|/$|) || ($pathinfo =~ m |/{2,}$|)) {
         redirect ($scriptwhere . '/' . $query);          redirect ($scriptwhere . '/' . $query);
     }      }
Line 347  elsif (-d $fullname) {
Line 354  elsif (-d $fullname) {
         getDirLogs($cvsroot,$where,@subLevelFiles);          getDirLogs($cvsroot,$where,@subLevelFiles);
   
         if ($where eq '/') {          if ($where eq '/') {
             html_header("$defaulttitle");              html_header($defaulttitle);
             $long_intro =~ s/!!CVSROOTdescr!!/$CVSROOTdescr{$cvstree}/g;              $long_intro =~ s/!!CVSROOTdescr!!/$CVSROOTdescr{$cvstree}/g;
             print $long_intro;              print $long_intro;
         }          }
         else {          else {
             html_header("$where");              html_header($where);
             print $short_instruction;              print $short_instruction;
         }          }
   
Line 907  sub revcmp {
Line 914  sub revcmp {
   
 sub fatal {  sub fatal {
         my($errcode, $errmsg) = @_;          my($errcode, $errmsg) = @_;
         if (defined($ENV{'MOD_PERL'})) {          if ($is_mod_perl) {
                 Apache->request->status((split(/ /, $errcode))[0]);                  Apache->request->status((split(/ /, $errcode))[0]);
         }          }
         else {          else {
Line 921  sub fatal {
Line 928  sub fatal {
   
 sub redirect {  sub redirect {
         my($url) = @_;          my($url) = @_;
         if (defined($ENV{'MOD_PERL'})) {          if ($is_mod_perl) {
                 Apache->request->status(301);                  Apache->request->status(301);
                 Apache->request->header_out(Location => $url);                  Apache->request->header_out(Location => $url);
         }          }
Line 1007  sub doAnnotate ($$) {
Line 1014  sub doAnnotate ($$) {
     # reasons ..      # reasons ..
     if (!($rev =~ /^[\d\.]+$/)) {      if (!($rev =~ /^[\d\.]+$/)) {
         &fatal("404 Not Found",          &fatal("404 Not Found",
                 "Malformed query \"$ENV{'QUERY_STRING'}\"");                  "Malformed query \"$ENV{QUERY_STRING}\"");
     }      }
   
     ($pathname = $where) =~ s/(Attic\/)?[^\/]*$//;      ($pathname = $where) =~ s/(Attic\/)?[^\/]*$//;
Line 1053  sub doAnnotate ($$) {
Line 1060  sub doAnnotate ($$) {
     # least to the point of including the directories down to the one      # least to the point of including the directories down to the one
     # containing the file in question).      # containing the file in question).
     # So if $where is "dir/sdir/file", then @dirs will be ("dir","sdir","file")      # So if $where is "dir/sdir/file", then @dirs will be ("dir","sdir","file")
     my @dirs = split (/\//, $where);      my @dirs = split('/', $where);
     my $path = "";      my $path = "";
     foreach (@dirs) {      foreach (@dirs) {
         if ($path eq "") {          if ($path eq "") {
Line 1061  sub doAnnotate ($$) {
Line 1068  sub doAnnotate ($$) {
             $path = $_;              $path = $_;
         }          }
         else {          else {
             print $writer "Directory " . $path . "\n";              print $writer "Directory $path\n";
             print $writer "$cvsroot/" . $path ."\n";              print $writer "$cvsroot/$path\n";
             # In our example, $_ is "sdir" and $path becomes "dir/sdir"              # In our example, $_ is "sdir" and $path becomes "dir/sdir"
             # And the next time, "file" and "dir/sdir/file" (which then gets              # And the next time, "file" and "dir/sdir/file" (which then gets
             # ignored, because we don't need to send Directory for the file).              # ignored, because we don't need to send Directory for the file).
             $path = $path . "/" . $_;              $path .= "/$_";
         }          }
     }      }
     # And the last "Directory" before "annotate" is the top level.      # And the last "Directory" before "annotate" is the top level.
Line 1123  sub doAnnotate ($$) {
Line 1130  sub doAnnotate ($$) {
             $oldLusr = $lusr;              $oldLusr = $lusr;
             # is there a less timeconsuming way to strip spaces ?              # is there a less timeconsuming way to strip spaces ?
             ($lrev = $lrev) =~ s/\s+//g;              ($lrev = $lrev) =~ s/\s+//g;
             my $isCurrentRev = ("$rev" eq "$lrev");              my $isCurrentRev = ($rev eq $lrev);
   
             print "<b>" if ($isCurrentRev);              print "<b>" if ($isCurrentRev);
             printf ("%8s%s%8s %4d:", $revprint, ($isCurrentRev ? "|" : " "), $usrprint, $lineNr);              printf ("%8s%s%8s %4d:", $revprint, ($isCurrentRev ? "|" : " "), $usrprint, $lineNr);
Line 1160  sub doCheckout {
Line 1167  sub doCheckout {
     # reasons ..      # reasons ..
     if (defined($rev) && !($rev =~ /^[\d\.]+$/)) {      if (defined($rev) && !($rev =~ /^[\d\.]+$/)) {
         &fatal("404 Not Found",          &fatal("404 Not Found",
                 "Malformed query \"$ENV{'QUERY_STRING'}\"");                  "Malformed query \"$ENV{QUERY_STRING}\"");
     }      }
   
     # get mimetype      # get mimetype
Line 1194  sub doCheckout {
Line 1201  sub doCheckout {
     # Safely for a child process to read from.      # Safely for a child process to read from.
     if (! open($fh, "-|")) { # child      if (! open($fh, "-|")) { # child
       open(STDERR, ">&STDOUT"); # Redirect stderr to stdout        open(STDERR, ">&STDOUT"); # Redirect stderr to stdout
       exec("cvs", "-d", "$cvsroot", "co", "-p", "$revopt", "$where");        exec("cvs", "-d", $cvsroot, "co", "-p", $revopt, $where);
     }      }
 #===================================================================  #===================================================================
 #Checking out squid/src/ftp.c  #Checking out squid/src/ftp.c
Line 1317  sub doDiff {
Line 1324  sub doDiff {
         # reasons ..          # reasons ..
         if (!($rev1 =~ /^[\d\.]+$/) || !($rev2 =~ /^[\d\.]+$/)) {          if (!($rev1 =~ /^[\d\.]+$/) || !($rev2 =~ /^[\d\.]+$/)) {
             &fatal("404 Not Found",              &fatal("404 Not Found",
                     "Malformed query \"$ENV{'QUERY_STRING'}\"");                      "Malformed query \"$ENV{QUERY_STRING}\"");
         }          }
 #  #
 # rev1 and rev2 are now both numeric revisions.  # rev1 and rev2 are now both numeric revisions.
Line 1356  sub doDiff {
Line 1363  sub doDiff {
         }          }
   
         # apply special options          # apply special options
         if ($human_readable) {          if ($showfunc) {
             if ($hr_funout) {              push @difftype, '-p';
                 push @difftype, '-p';  
   
                 my($re1, $re2);              my($re1, $re2);
   
                 while (($re1, $re2) = each %functionlineregexp) {              while (($re1, $re2) = each %funcline_regexp) {
                     if ($fullname =~ /$re1/) {                  if ($fullname =~ /$re1/) {
                         push @difftype, '-F', '$re2';                      push @difftype, '-F', '$re2';
                         last;                      last;
                     }  
                 }                  }
             }              }
           }
           if ($human_readable) {
             if ($hr_ignwhite) {              if ($hr_ignwhite) {
                 push @difftype, '-w';                  push @difftype, '-w';
             }              }
Line 1377  sub doDiff {
Line 1384  sub doDiff {
             }              }
         }          }
         if (! open($fh, "-|")) { # child          if (! open($fh, "-|")) { # child
                 open(STDERR, ">&STDOUT"); # Redirect stderr to stdout              open(STDERR, ">&STDOUT"); # Redirect stderr to stdout
                 exec("rcsdiff",@difftype,"-r$rev1","-r$rev2",$fullname);              exec("rcsdiff",@difftype,"-r$rev1","-r$rev2",$fullname);
         }          }
         if ($human_readable) {          if ($human_readable) {
             http_header();              http_header();
Line 2019  sub doLog {
Line 2026  sub doLog {
         $backurl = $scriptname . "/" . urlencode($upwhere) . $query;          $backurl = $scriptname . "/" . urlencode($upwhere) . $query;
         print &link($backicon, "$backurl#$filename"),          print &link($backicon, "$backurl#$filename"),
               " <b>Up to ", &clickablePath($upwhere, 1), "</b><p>\n";                " <b>Up to ", &clickablePath($upwhere, 1), "</b><p>\n";
         print "<A HREF=\"#diff\">Request diff between arbitrary revisions</A>\n";          print <<EOF;
         print "<HR NOSHADE>\n";  <A HREF="#diff">Request diff between arbitrary revisions</A>
   <HR NOSHADE>
   EOF
         if ($curbranch) {          if ($curbranch) {
             print "Default branch: ";              print "Default branch: ", ($revsym{$curbranch} || $curbranch);
             print ($revsym{$curbranch} || $curbranch);  
         }          }
         else {          else {
             print "No default branch";              print "No default branch";
Line 2373  sub readableTime ($$)
Line 2381  sub readableTime ($$)
     }      }
     $i--;      $i--;
     $break = $breaks[$i];      $break = $breaks[$i];
     $retval = plural_write(int ($secs / $break), $desc{"$break"});      $retval = plural_write(int ($secs / $break), $desc{$break});
   
     if ($long == 1 && $i > 0) {      if ($long == 1 && $i > 0) {
         my $rest = $secs % $break;          my $rest = $secs % $break;
         $i--;          $i--;
         $break = $breaks[$i];          $break = $breaks[$i];
         my $resttime = plural_write(int ($rest / $break),          my $resttime = plural_write(int ($rest / $break),
                                 $desc{"$break"});                                  $desc{$break});
         if ($resttime) {          if ($resttime) {
             $retval = $retval . ", " . $resttime;              $retval = $retval . ", " . $resttime;
         }          }
Line 2413  sub clickablePath($$) {
Line 2421  sub clickablePath($$) {
             $retval = $retval . " / ";              $retval = $retval . " / ";
             $wherepath = $wherepath . '/' . $_;              $wherepath = $wherepath . '/' . $_;
             my ($last) = "$wherepath/" eq "/$pathname"              my ($last) = "$wherepath/" eq "/$pathname"
                 || "$wherepath" eq "/$pathname";                  || $wherepath eq "/$pathname";
             if ($clickLast || !$last) {              if ($clickLast || !$last) {
                 $retval = $retval . "<a href=\"${scriptname}"                  $retval = $retval . "<a href=\"${scriptname}"
                     . urlencode($wherepath)                      . urlencode($wherepath)
Line 2454  sub chooseCVSRoot() {
Line 2462  sub chooseCVSRoot() {
         print ">\n";          print ">\n";
         foreach $k (@foo) {          foreach $k (@foo) {
             print "<option value=\"$k\"";              print "<option value=\"$k\"";
             print " selected" if ("$k" eq "$cvstree");              print " selected" if ($k eq $cvstree);
             print ">" . ($CVSROOTdescr{"$k"} ? $CVSROOTdescr{"$k"} :              print ">" . ($CVSROOTdescr{$k} ? $CVSROOTdescr{$k} :
                         $k). "</option>\n";                          $k). "</option>\n";
         }          }
         print "</select>\n</td>";          print "</select>\n</td>";
Line 2618  sub urlencode {
Line 2626  sub urlencode {
   
 sub http_header {  sub http_header {
     my $content_type = shift || "text/html";      my $content_type = shift || "text/html";
     my $is_mod_perl = defined($ENV{'MOD_PERL'});  
     if (defined($moddate)) {      if (defined($moddate)) {
         if ($is_mod_perl) {          if ($is_mod_perl) {
             Apache->request->header_out(Last_modified => scalar gmtime($moddate) . " GMT");              Apache->request->header_out(Last_modified => scalar gmtime($moddate) . " GMT");
Line 2679  sub html_header($) {
Line 2686  sub html_header($) {
  "http://www.w3.org/TR/REC-html40/loose.dtd">   "http://www.w3.org/TR/REC-html40/loose.dtd">
 <html>  <html>
 <title>$title</title>  <title>$title</title>
 <!-- hennerik CVSweb $version -->  <!-- CVSweb $version -->
 </head>  </head>
 $body_tag  $body_tag
 $logo <h1 align="center">$title</h1>  $logo <h1 align="center">$title</h1>

Legend:
Removed from v.3.2  
changed lines
  Added in v.3.3

CVSweb