=================================================================== RCS file: /home/cvs/CVSROOT/Attic/cvsweb.cgi,v retrieving revision 1.2 retrieving revision 1.3 diff -u -p -r1.2 -r1.3 --- CVSROOT/Attic/cvsweb.cgi 1999/12/27 20:23:26 1.2 +++ CVSROOT/Attic/cvsweb.cgi 2000/07/11 08:20:53 1.3 @@ -7,6 +7,7 @@ # extended by Henner Zeller , # Henrik Nordström # Ken Coar +# Dick Balaska # # Based on: # * Bill Fenners cvsweb.cgi revision 1.28 available from: @@ -38,7 +39,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $Id: cvsweb.cgi,v 1.2 1999/12/27 20:23:26 maekawa Exp $ +# $Id: cvsweb.cgi,v 1.3 2000/07/11 08:20:53 maekawa Exp $ # ### @@ -67,8 +68,9 @@ use vars qw ( $extern_window_width $extern_window_height $edit_option_form $checkout_magic $show_subdir_lastmod $show_log_in_markup $v $navigationHeaderColor $tableBorderColor $markupLogColor - $tabstop $state $annTable $sel $curbranch $HideModules @HideModules - $module + $tabstop $state $annTable $sel $curbranch @HideModules + $module $use_descriptions %descriptions @mytz $dwhere $moddate + $use_moddate ); ##### Start of Configuration Area ######## @@ -98,7 +100,7 @@ $allow_markup = $use_java_script = $open_extern_window $extern_window_width = $extern_window_height = $edit_option_form = $checkout_magic = $show_subdir_lastmod = $show_log_in_markup = $v = $navigationHeaderColor = $tableBorderColor = $markupLogColor = -$tabstop = undef; +$tabstop = $use_moddate = $moddate = undef; ##### End of configuration variables ##### @@ -150,7 +152,6 @@ $maycompress =(($ENV{'HTTP_ACCEPT_ENCODING'} =~ m|gzip if (-f $config) { do "$config"; - $HideModules = "§" . join("§", @HideModules) . "§"; } else { &fatal("500 Internal Error", @@ -204,7 +205,7 @@ foreach (@stickyvars) { # construct a query string with the sticky non default parameters set if (defined($input{$_}) && $input{$_} ne "" && $input{$_} ne $DEFAULTVALUE{$_}) { if ($barequery) { - $barequery = $barequery . "&"; + $barequery = $barequery . "&"; } my $thisval = urlencode($_) . "=" . urlencode($input{$_}); $barequery .= $thisval; @@ -213,7 +214,7 @@ foreach (@stickyvars) { # is there any query ? if ($barequery) { $query = "?$barequery"; - $barequery = "&" . $barequery; + $barequery = "&" . $barequery; } else { $query = ""; @@ -346,8 +347,17 @@ elsif (-d $fullname) { html_header("$where"); print $short_instruction; } - - print "

\n"; + + my $descriptions; + if (($use_descriptions) && open (DESC, "<$cvsroot/CVSROOT/descriptions")) { + while () { + chomp; + my ($dir,$description) = /(\S+)\s+(.*)/; + $descriptions{$dir} = $description; + } + } + + print "

\n"; # give direct access to dirs if ($where eq '/') { chooseMirror(); @@ -362,7 +372,7 @@ elsif (-d $fullname) { } - print "


\n"; + print "
\n"; # Using in this manner violates the HTML2.0 spec but # provides the results that I want in most browsers. Another # case of layout spooging up HTML. @@ -375,9 +385,9 @@ elsif (-d $fullname) { } print "\n"; $infocols++; - print ""; $infocols++; - print ""; if ($show_author) { $infocols++; - print ""; } $infocols++; - print ""; } + elsif ($use_descriptions) { + print "\n"; } else { @@ -498,7 +513,7 @@ elsif (-d $fullname) { } else { $url = urlencode($_) . '/' . $query; - print ""; + print ""; if ($nofilelinks) { print $diricon; } @@ -514,7 +529,7 @@ elsif (-d $fullname) { } # Show last change in dir if ($filename) { - print ""; + my ($dwhere) = ($where ne "/" ? $where : "") . $_; + if ($use_descriptions && defined $descriptions{$dwhere}) { + print ""; + print "
"; + $columnHeaderColorDefault) . "\">"; print "" if (!$byfile); print "File"; @@ -387,18 +397,18 @@ elsif (-d $fullname) { # with revision information: if (scalar(%fileinfo)) { $infocols++; - print ""; + $columnHeaderColorDefault) . "\">"; print "" if (!$byrev); print "Rev."; print "" if (!$byrev); print ""; + $columnHeaderColorDefault) . "\">"; print "" if (!$bydate); print "Age"; @@ -406,9 +416,9 @@ elsif (-d $fullname) { print ""; + $columnHeaderColorDefault) . "\">"; print "" if (!$byauthor); print "Author"; @@ -416,14 +426,19 @@ elsif (-d $fullname) { print ""; + $columnHeaderColorDefault) . "\">"; print "" if (!$bylog); print "Last log entry"; print "" if (!$bylog); print ""; + print "Description"; + $infocols++; + } print "
  " if ($dirtable); + print "  " if ($dirtable); if ($date) { print " " . readableTime(time() - $date,0) . ""; } @@ -536,14 +551,16 @@ elsif (-d $fullname) { } } else { - # if there are any files (which require infocols), close the - # row with the appropriate number of columns, so that the - # vertical seperators are visible - if ($dirtable && scalar(%fileinfo)) { - print " " if $dirtable; + print $descriptions{$dwhere}; + } elsif ($dirtable && $infocols > 1) { + # close the row with the appropriate number of + # columns, so that the vertical seperators are visible my($cols) = $infocols; while ($cols > 1) { - print "  "; $cols--; } } @@ -568,7 +585,7 @@ elsif (-d $fullname) { ($rev,$date,$log,$author) = @{$fileinfo{$_}}; $filesfound++; print "
" if ($dirtable); - print ""; + print ""; if ($nofilelinks) { print $fileicon; } @@ -1146,23 +1163,30 @@ sub doCheckout { } if (defined($rev)) { - $revopt = "-r'$rev'"; + $revopt = "-r$rev"; + if ($use_moddate) { + readLog($fullname,$rev); + $moddate=$date{$rev}; + } } else { $revopt = ""; + if ($use_moddate) { + readLog($fullname); + $moddate=$date{$symrev{HEAD}}; + } } - # this may not be quoted with single quotes - # in windows .. but should in U*nx. there - # is a function which allows for quoting `evil` - # characters somewhere, I know (buried in the Perl-manpage) - ## ### just for the record: ### 'cvs co' seems to have a bug regarding single checkout of ### directories/files having spaces in it; ### this is an issue that should be resolved on cvs's side - open($fh, "cvs -d'$cvsroot' co -p $revopt '$where' 2>&1 |") || - &fatal("500 Internal Error", "Couldn't co: $!"); + # + # Safely for a child process to read from. + if (! open($fh, "-|")) { # child + open(STDERR, ">&STDOUT"); # Redirect stderr to stdout + exec("cvs", "-d$cvsroot", "co", "-p", $revopt, $where); + } #=================================================================== #Checking out squid/src/ftp.c #RCS: /usr/src/CVS/squid/src/ftp.c,v @@ -1175,6 +1199,7 @@ sub doCheckout { last if (/^\*\*\*\*/); $revision = $1 if (/^VERS: (.*)$/); $filename = $1 if (/^Checking out (.*)$/); + $filename =~ s/^\.\/*//; $cvsheader .= $_; } if ($filename ne $where) { @@ -1211,7 +1236,7 @@ sub cvswebMarkup { navigateHeader ($scriptwhere, $pathname, $filename, $revision, "view"); print "
"; print "
"; - print "File: ", &clickablePath($where, 1), ""; + print "File: ", &clickablePath($where, 1); print " "; &download_link(urlencode($fileurl), $revision, "(download)"); if (!$defaultTextPlain) { @@ -1239,7 +1264,7 @@ sub cvswebMarkup { else { print "
";
 	foreach (@content) {
-	    print htmlify($_);
+	    print spacedHtmlText($_);
 	}
 	print "
"; } @@ -1259,7 +1284,7 @@ sub viewable($) { sub doDiff { my($fullname, $r1, $tr1, $r2, $tr2, $f) = @_; my $fh = do {local(*FH);}; - my ($rev1, $rev2, $sym1, $sym2, $difftype, $diffname, $f1, $f2); + my ($rev1, $rev2, $sym1, $sym2, @difftype, $diffname, $f1, $f2); if ($r1 =~ /([^:]+)(:(.+))?/) { $rev1 = $1; @@ -1294,25 +1319,25 @@ sub doDiff { } my $human_readable = 0; if ($f eq 'c') { - $difftype = '-c'; + @difftype = qw{-c}; $diffname = "Context diff"; } elsif ($f eq 's') { - $difftype = '--side-by-side --width=164'; + @difftype = qw{--side-by-side --width=164}; $diffname = "Side by Side"; } elsif ($f eq 'H') { $human_readable = 1; - $difftype = '--unified=15'; + @difftype = qw{--unified=15}; $diffname = "Long Human readable"; } elsif ($f eq 'h') { - $difftype = '-u'; + @difftype =qw{-u}; $human_readable = 1; $diffname = "Human readable"; } elsif ($f eq 'u') { - $difftype = '-u'; + @difftype = qw{-u}; $diffname = "Unidiff"; } else { @@ -1322,22 +1347,19 @@ sub doDiff { # apply special options if ($human_readable) { if ($hr_funout) { - $difftype = $difftype . ' -p'; + push @difftype, '-p'; } if ($hr_ignwhite) { - $difftype = $difftype . ' -w'; + push @difftype, '-w'; } if ($hr_ignkeysubst) { - $difftype = $difftype . ' -kk'; + push @difftype, '-kk'; } } -## cvs rdiff doesn't support '-p' and '-w' option .. sad -# open($fh, "cvs -d $cvsroot rdiff $difftype " . -# "-r$rev1 -r$rev2 '$where' 2>&1 |") -# || &fatal("500 Internal Error", "Couldn't cvs rdiff: $!"); -### - open($fh, "rcsdiff $difftype -r$rev1 -r$rev2 '$fullname' 2>&1 |") - || &fatal("500 Internal Error", "Couldn't GNU rcsdiff: $!"); + if (! open($fh, "-|")) { # child + open(STDERR, ">&STDOUT"); # Redirect stderr to stdout + exec("rcsdiff",@difftype,"-r$rev1","-r$rev2",$fullname); + } if ($human_readable) { http_header(); &human_readable_diff($fh, $rev2); @@ -1363,7 +1385,7 @@ sub doDiff { #--- src/sys/netinet/tcp_output.c 1995/12/05 17:46:35 1.17 RELENG_2_1_0 # (bogus example, but...) # - if ($difftype eq '-u') { + if (grep { $_ eq '-u'} @difftype) { $f1 = '---'; $f2 = '\+\+\+'; } @@ -1416,15 +1438,19 @@ sub getDirLogs { return; } - my ($filenames) = join("' '",@files); if ($tag) { #can't use -r as - is allowed in tagnames, but misinterpreated by rlog.. - open($fh, "rlog '$filenames' 2>/dev/null |") - || &fatal("500 Internal Error", "Failed to spawn GNU rlog"); + if (! open($fh, "-|")) { + close(STDERR); # rlog may complain; ignore. + exec("rlog",@files); + } } else { - open($fh, "rlog -r '$filenames' 2>/dev/null |") - || &fatal("500 Internal Error", "Failed to spawn GNU rlog"); + my $kidpid = open($fh, "-|"); + if (! $kidpid) { + close(STDERR); # rlog may complain; ignore. + exec("rlog","-r",@files); + } } $state = "start"; while (<$fh>) { @@ -1493,7 +1519,7 @@ again: $date = undef; $log = ""; # Try to reconstruct the relative filename if RCS spits out a full path - $filename =~ s%^$DirName/%%; + $filename =~ s%^\Q$DirName\E/%%; next; } if ($state eq "log") { @@ -1552,7 +1578,7 @@ again: } if ($. == 0) { fatal("500 Internal Error", - "Failed to spawn GNU rlog on '$filenames'

did you set the \$ENV{PATH} in your configuration file correctly ?"); + "Failed to spawn GNU rlog on '".join(", ", @files)."'

did you set the \$ENV{PATH} in your configuration file correctly ?"); } close($fh); } @@ -1579,9 +1605,14 @@ sub readLog { undef %log; print("Going to rlog '$fullname'\n") if ($verbose); - open($fh, "rlog $revision '$fullname'|") - || &fatal("500 Internal Error", "Failed to spawn rlog"); - + if (! open($fh, "-|")) { # child + if ($revision ne '') { + exec("rlog",$revision,$fullname); + } + else { + exec("rlog",$fullname); + } + } while (<$fh>) { print if ($verbose); if ($symnames) { @@ -1843,7 +1874,12 @@ sub printLog($;$) { if (/^1\.1\.1\.\d+$/) { print " (vendor branch)"; } - print ", " . scalar gmtime($date{$_}) . " UTC ("; + if (defined @mytz) { + my ($est) = $mytz[(localtime($date{$_}))[8]]; + print ", " . scalar localtime($date{$_}) . " $est ("; + } else { + print ", " . scalar gmtime($date{$_}) . " UTC ("; + } print readableTime(time() - $date{$_},1) . " ago)"; print " by "; print "" . $author{$_} . "\n"; @@ -1881,10 +1917,10 @@ sub printLog($;$) { if ($prev) { $diffrev{$prev} = 1; print " to previous $prev\n"; + print "&r2=$_" . $barequery . "\">$prev\n"; if (!$hr_default) { # offer a human readable version if not default print "(colored)\n"; + print "&r2=$_" . $barequery . "&f=h\">colored)\n"; } } # @@ -1892,10 +1928,10 @@ sub printLog($;$) { # offer a diff with the branch point. if ($revsym{$brp} && !/^1\.1\.1\.\d+$/ && !defined($diffrev{$brp})) { print " to branchpoint $brp\n"; + print "&r2=$_" . $barequery . "\">$brp\n"; if (!$hr_default) { # offer a human readable version if not default print "(colored)\n"; + print "&r2=$_" . $barequery . "&f=h\">colored)\n"; } } # @@ -1922,12 +1958,12 @@ sub printLog($;$) { if (!defined($diffrev{$nextmain})) { $diffrev{$nextmain} = 1; print " next main $nextmain\n"; if (!$hr_default) { # offer a human readable version if not default print "(colored)\n"; + print "&r2=$_" . $barequery . + "&f=h\">colored)\n"; } } } @@ -1936,12 +1972,12 @@ sub printLog($;$) { if (defined($input{"r1"}) && !defined($diffrev{$input{"r1"}})) { $diffrev{$input{"r1"}} = 1; print " to selected $input{'r1'}\n"; if (!$hr_default) { # offer a human readable version if not default print "(colored)\n"; + print "&r2=$_" . $barequery . + "&f=h\">colored)\n"; } } @@ -1984,8 +2020,8 @@ sub doLog { printLog($revdisplayorder[$i]); } - print "\n"; print "


"; + print "\n"; print "This form allows you to request diff's between any two\n"; print "revisions of a file. You may select a symbolic revision\n"; print "name using the selection box or you may type in a numeric\n"; @@ -2019,7 +2055,7 @@ sub doLog { print "\n"; print "
\n"; if (@branchnames) { - print "
\n"; + print "\n"; print "
\n"; foreach (@stickyvars) { next if ($_ eq "only_with_tag"); @@ -2045,9 +2081,8 @@ sub doLog { print "\n"; print "\n"; print "
\n"; - print "\n"; } - print "\n"; + print "\n"; print "
\n"; foreach (@stickyvars) { next if ($_ eq "only_with_tag"); @@ -2066,7 +2101,6 @@ sub doLog { print "\n"; print "\n"; print "
\n"; - print ""; print &html_footer; print "\n"; } @@ -2136,8 +2170,8 @@ sub human_readable_diff($){ print "

Diff for /$where_nd between version $rev1 and $rev2

\n"; - print "\n"; - print "\n"; + print "
\n"; + print "\n"; print "
"; print "version $rev1"; print ", $date1" if (defined($date1)); @@ -2167,12 +2201,12 @@ sub human_readable_diff($){ if ($difftxt =~ /^@@/) { ($oldline,$newline,$funname) = $difftxt =~ /@@ \-([0-9]+).*\+([0-9]+).*@@(.*)/; print "
"; - print "
Line $oldline"; + print "
Line $oldline"; print " $funname
"; print "
"; - print "\n"; + print "\n"; $state = "dump"; $leftRow = 0; $rightRow = 0; @@ -2226,7 +2260,7 @@ sub human_readable_diff($){ print "
Line $newline"; + print "
Line $newline"; print " $funname
"; - print "
"; close($fh); - print "

\n"; + print "

\n"; print ""; @@ -2238,7 +2272,6 @@ sub human_readable_diff($){ print ""; print ""; print "
changed lines
 Added in v.$rev2
\n"; - print "\n\n"; print "
"; # Print format selector @@ -2262,8 +2295,9 @@ sub navigateHeader ($$$$$) { my ($swhere,$path,$filename,$rev,$title) = @_; $swhere = "" if ($swhere eq $scriptwhere); $swhere = urlencode($filename) if ($swhere eq ""); + print "<\!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"; print "\n\n"; - print ''; + print ''; print "\n$path$filename - $title - $rev\n"; print "\n"; print ""; @@ -2476,7 +2510,7 @@ sub download_url { $url = "$scriptname/$checkoutMagic/${path}$url"; } $url .= "?rev=$revision"; - $url .= "&content-type=$mimetype" if (defined($mimetype)); + $url .= "&content-type=$mimetype" if (defined($mimetype)); return $url; } @@ -2545,7 +2579,7 @@ sub toggleQuery($$) { my ($value) = defined($vars{$var}) ? $vars{$var} : ""; my ($default) = defined($DEFAULTVALUE{$var}) ? $DEFAULTVALUE{$var} : ""; if ($value ne $default) { - $newquery .= "&" if ($newquery ne ""); + $newquery .= "&" if ($newquery ne ""); $newquery .= urlencode($var) . "=" . urlencode($value); } } @@ -2565,6 +2599,14 @@ sub urlencode { sub http_header { my $content_type = shift || "text/html"; my $is_mod_perl = defined($ENV{'MOD_PERL'}); + if (defined($moddate)) { + if ($is_mod_perl) { + Apache->request->header_out(Last_modified => scalar gmtime($moddate) . " GMT"); + } + else { + print "Last-Modified: " . scalar gmtime($moddate) . " GMT\n"; + } + } if ($is_mod_perl) { Apache->request->content_type($content_type); } @@ -2610,13 +2652,14 @@ sub http_header { sub html_header($) { my ($title) = @_; + my $version = '$Revision: 1.3 $'; http_header(); print < $title - + $body_tag $logo

$title

@@ -2649,6 +2692,10 @@ sub link_tags # sub forbidden_module { my($module) = @_; + + for (my $i=0; $i < @HideModules; $i++) { + return 1 if $module eq $HideModules[$i]; + } - return ("§$module§" =~ /$HideModules/); + return 0; }