===================================================================
RCS file: /cvs/cvsweb/cvsweb.cgi,v
retrieving revision 3.28
retrieving revision 3.35
diff -u -p -r3.28 -r3.35
--- cvsweb/cvsweb.cgi 2000/09/30 18:27:16 3.28
+++ cvsweb/cvsweb.cgi 2000/10/10 21:14:05 3.35
@@ -43,7 +43,7 @@
# SUCH DAMAGE.
#
# $zId: cvsweb.cgi,v 1.103 2000/09/20 17:02:29 jumager Exp $
-# $Id: cvsweb.cgi,v 3.28 2000/09/30 18:27:16 knu Exp $
+# $Id: cvsweb.cgi,v 3.35 2000/10/10 21:14:05 knu Exp $
#
###
@@ -59,7 +59,7 @@ use vars qw (
$checkoutMagic $doCheckout $scriptname $scriptwhere
$where $pathinfo $Browser $nofilelinks $maycompress @stickyvars
%funcline_regexp $is_mod_perl
- $is_lynx $is_w3m $is_msie $is_mozilla3 $is_textbased
+ $is_links $is_lynx $is_w3m $is_msie $is_mozilla3 $is_textbased
%input $query $barequery $sortby $bydate $byrev $byauthor
$bylog $byfile $hr_default $logsort $cvstree $cvsroot
$mimetype $defaultTextPlain $defaultViewable $allow_compress
@@ -74,11 +74,12 @@ use vars qw (
$difffontsize $inputTextSize $mime_types $allow_annotate
$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
+ $show_subdir_lastmod $show_log_in_markup $v
$navigationHeaderColor $tableBorderColor $markupLogColor
$tabstop $state $annTable $sel $curbranch @HideModules
$module $use_descriptions %descriptions @mytz $dwhere $moddate
$use_moddate $has_zlib $gzip_open
+ $LOG_FILESEPARATOR $LOG_REVSEPARATOR
);
sub printDiffSelect($);
@@ -115,6 +116,7 @@ sub download_url($$;$);
sub download_link($$$;$);
sub toggleQuery($$);
sub urlencode($);
+sub htmlquote($);
sub http_header(;$);
sub html_header($);
sub html_footer();
@@ -155,10 +157,13 @@ $diffcolorChange = $diffcolorAdd = $diffcolorDarkChang
$difffontsize = $inputTextSize = $mime_types = $allow_annotate =
$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 =
+$show_subdir_lastmod = $show_log_in_markup = $v =
$navigationHeaderColor = $tableBorderColor = $markupLogColor =
$tabstop = $use_moddate = $moddate = $gzip_open = undef;
+$LOG_FILESEPARATOR = q/^={77}$/;
+$LOG_REVSEPARATOR = q/^-{28}$/;
+
##### End of configuration variables #####
use Time::Local;
@@ -192,12 +197,13 @@ $is_mod_perl = defined($ENV{MOD_PERL});
# per file, so disable the link at the icon
# in this case:
$Browser = $ENV{HTTP_USER_AGENT};
+$is_links = ($Browser =~ m`^Links `);
$is_lynx = ($Browser =~ m`^Lynx/`i);
$is_w3m = ($Browser =~ m`^w3m/`i);
$is_msie = ($Browser =~ m`MSIE`);
$is_mozilla3 = ($Browser =~ m`^Mozilla/[3-9]`);
-$is_textbased = ($is_lynx || $is_w3m);
+$is_textbased = ($is_links || $is_lynx || $is_w3m);
$nofilelinks = $is_textbased;
@@ -279,25 +285,24 @@ foreach (keys %DEFAULTVALUE)
}
$barequery = "";
+my @barequery;
foreach (@stickyvars) {
# construct a query string with the sticky non default parameters set
if (defined($input{$_}) && $input{$_} ne '' &&
!(defined($DEFAULTVALUE{$_}) && $input{$_} eq $DEFAULTVALUE{$_})) {
- if ($barequery) {
- $barequery = $barequery . "&";
- }
- my $thisval = urlencode($_) . "=" . urlencode($input{$_});
- $barequery .= $thisval;
+ push @barequery, join('=', urlencode($_), urlencode($input{$_}));
}
}
# is there any query ?
-if ($barequery) {
+if (@barequery) {
+ $barequery = join('&', @barequery);
$query = "?$barequery";
- $barequery = "&" . $barequery;
+ $barequery = "&$barequery";
}
else {
$query = "";
}
+undef @barequery;
# get actual parameters
$sortby = $input{"sortby"};
@@ -345,16 +350,19 @@ if ($input{'cvsroot'} && $CVSROOT{$input{'cvsroot'}})
$cvsroot = $CVSROOT{$cvstree};
# create icons out of description
-foreach my $k (keys %ICONS) {
+my $k;
+foreach $k (keys %ICONS) {
no strict 'refs';
my ($itxt,$ipath,$iwidth,$iheight) = @{$ICONS{$k}};
if ($ipath) {
- ${"${k}icon"} = "";
+ ${"${k}icon"} = sprintf('',
+ htmlquote($ipath), htmlquote($itxt), $iwidth, $iheight)
}
else {
${"${k}icon"} = $itxt;
}
}
+undef $k;
my $config_cvstree = "$config-$cvstree";
@@ -365,6 +373,7 @@ if (-f $config_cvstree) {
sprintf('Error in loading configuration file: %s
%s
',
$config_cvstree, &htmlify($@)));
}
+undef $config_cvstree;
$prcategories = '(?:' . join('|', @prcategories) . ')';
$prcgi .= '%s' if defined($prcgi) && $prcgi !~ /%s/;
@@ -476,10 +485,12 @@ elsif (-d $fullname) {
print "
";
- print "" if (!$byfile);
- print "File";
- print "" if (!$byfile);
+ if ($byfile) {
+ print 'File';
+ } else {
+ print &link('File', sprintf('./%s#dirlist',
+ &toggleQuery("sortby", "file")));
+ }
print " | ";
# do not display the other column-headers, if we do not have any files
# with revision information:
@@ -488,38 +499,47 @@ elsif (-d $fullname) {
print "";
- print "" if (!$byrev);
- print "Rev.";
- print "" if (!$byrev);
+ if ($byrev) {
+ print 'Rev.';
+ } else {
+ print &link('Rev.', sprintf('./%s#dirlist',
+ &toggleQuery("sortby", "rev")));
+ }
print " | ";
$infocols++;
print "";
- print "" if (!$bydate);
- print "Age";
- print "" if (!$bydate);
+ if ($bydate) {
+ print 'Age';
+ } else {
+ print &link('Age', sprintf('./%s#dirlist',
+ &toggleQuery("sortby", "date")));
+ }
print " | ";
if ($show_author) {
$infocols++;
print "";
- print "" if (!$byauthor);
- print "Author";
- print "" if (!$byauthor);
+ if ($byauthor) {
+ print 'Author';
+ } else {
+ print &link('Author', sprintf('./%s#dirlist',
+ &toggleQuery("sortby", "author")));
+ }
print " | ";
}
$infocols++;
print "";
- print "" if (!$bylog);
- print "Last log entry";
- print "" if (!$bylog);
+ if ($bylog) {
+ print 'Last log entry';
+ } else {
+ print &link('Last log entry', sprintf('./%s#dirlist',
+ &toggleQuery("sortby", "log")));
+ }
print " | ";
}
elsif ($use_descriptions) {
@@ -548,9 +568,9 @@ elsif (-d $fullname) {
closedir($dh);
}
- my $hideAtticToggleLink = "[Hide]" if (!$input{'hideattic'});
+ my $hideAtticToggleLink = $input{'hideattic'} ? '' :
+ &link('[Hide]', sprintf('./%s#dirlist',
+ &toggleQuery ("hideattic")));
# Sort without the Attic/ pathname.
# place directories first
@@ -595,9 +615,9 @@ elsif (-d $fullname) {
print $backicon;
}
else {
- print &link($backicon,$url);
+ print &link($backicon, $url);
}
- print " ", &link("Previous Directory",$url);
+ print " ", &link("Previous Directory", $url);
}
else {
$url = urlencode($_) . '/' . $query;
@@ -606,13 +626,13 @@ elsif (-d $fullname) {
print $diricon;
}
else {
- print &link($diricon,$url);
+ print &link($diricon, $url);
}
- print " ", &link($_ . "/", $url), $attic;
+ print " ", &link("$_/", $url), $attic;
if ($_ eq "Attic") {
- print " [Don't hide]";
+ print " ";
+ print &link("[Don't hide]", sprintf('./%s#dirlist',
+ &toggleQuery ("hideattic")));
}
}
# Show last change in dir
@@ -683,8 +703,8 @@ elsif (-d $fullname) {
print " ", &link($_, $url), $attic;
print " " if ($dirtable);
download_link($fileurl,
- $rev, $rev,
- $defaultViewable ? "text/x-cvsweb-markup" : undef);
+ $rev, $rev,
+ $defaultViewable ? "text/x-cvsweb-markup" : undef);
print " | " if ($dirtable);
if ($date) {
print " " . readableTime(time() - $date,0) . "";
@@ -914,33 +934,29 @@ sub findLastModifiedSubdirs(@) {
}
sub htmlify($;$) {
- my($string, $extra) = @_;
+ (local $_, my $extra) = @_;
- # Special Characters; RFC 1866
- $string =~ s/&/&/g;
- $string =~ s/\"/"/g;
- $string =~ s/</g;
- $string =~ s/>/>/g;
+ $_ = htmlquote($_);
- # get URL's as link ..
- $string =~ s`(http|ftp|https)(://[-a-zA-Z0-9%.~:_/]+)([?&]([-a-zA-Z0-9%.~:_]+)=([-a-zA-Z0-9%.~:_])+)*`$1$2$3`g; # `
+ # get URL's as link
+ s`(http|ftp|https)(://[-a-zA-Z0-9%.~:_/]+)([?&]([-a-zA-Z0-9%.~:_]+)=([-a-zA-Z0-9%.~:_])+)*`&link("$1$2$3", "$1$2$3")`ge; # `
# get e-mails as link
- $string =~ s`([-a-zA-Z0-9_.]+@([-a-zA-Z0-9]+\.)+[A-Za-z]{2,4})`$1`g; # `
+ s`[-a-zA-Z0-9_.]+@([-a-zA-Z0-9]+\.)+[A-Za-z]{2,4}`&link($&, "mailto:$&")`ge; # `
if ($extra) {
- # get PR #'s as link ..
+ # get PR #'s as link: "PR#nnnn" "PR: nnnn, ..." "PR nnnn, ..." "bin/nnnn"
if (defined($prcgi)) {
- 1 while $string =~ s`\b(pr[:#]?\s*(?:#?\d+[,\s]\s*)*#?)(\d+)\b`$1 . &link($2, sprintf($prcgi, $2))`ie; # `
- $string =~ s`\b${prcategories}/(\d+)\b`&link($&, sprintf($prcgi, $1))`igeo; # `
+ 1 while s`\b(pr[:#]?\s*(?:#?\d+[,\s]\s*)*#?)(\d+)\b`$1 . &link($2, sprintf($prcgi, $2))`ie; # `;
+ s`\b${prcategories}/(\d+)\b`&link($&, sprintf($prcgi, $1))`igeo; # `;
}
- # get manpage specs as link ..
+ # get manpage specs as link: "foo.1" "foo(1)"
if (defined($mancgi)) {
- $string =~ s`\b([a-zA-Z]\w+)\(([0-9n])\)\B`&link($&, sprintf($mancgi, $2, $1))`ge; # `
+ s`\b([a-zA-Z]\w+)(?:\(([0-9n])\)\B|\.([0-9n])\b)`&link($&, sprintf($mancgi, $2 ne '' ? $2 : $3, $1))`ge; # `x;
}
}
- return $string;
+ $_;
}
sub spacedHtmlText($;$) {
@@ -976,7 +992,7 @@ sub spacedHtmlText($;$) {
sub link($$) {
my($name, $where) = @_;
- return "$name\n";
+ sprintf '%s', htmlquote($where), $name;
}
sub revcmp($$) {
@@ -1024,7 +1040,7 @@ sub redirect($) {
print "Location: $url\r\n";
}
html_header("Moved");
- print "This document is located here.\n";
+ print "This document is located ", &link('here', $url), "\n";
print &html_footer;
exit(1);
}
@@ -1141,11 +1157,6 @@ sub doAnnotate($$) {
($pathname = $where) =~ s/(Attic\/)?[^\/]*$//;
($filename = $where) =~ s/^.*\///;
- http_header();
-
- navigateHeader($scriptwhere,$pathname,$filename,$rev, "annotate");
- print "Annotation of $pathname$filename, Revision $rev\n";
-
# this seems to be necessary
$| = 1; $| = 0; # Flush
@@ -1155,7 +1166,7 @@ sub doAnnotate($$) {
# the public domain.
# we could abandon the use of rlog, rcsdiff and co using
# the cvsserver in a similiar way one day (..after rewrite)
- $pid = open2($reader, $writer, "cvs server") || fatal ("500 Internal Error",
+ $pid = open2($reader, $writer, "cvs -Rl server") || fatal ("500 Internal Error",
"Fatal Error - unable to open cvs for annotation");
# OK, first send the request to the server. A simplified example is:
@@ -1207,6 +1218,11 @@ sub doAnnotate($$) {
# were nicer about buffering, then we could just leave it open, I think.
close ($writer) || die "cannot close: $!";
+ http_header();
+
+ navigateHeader($scriptwhere,$pathname,$filename,$rev, "annotate");
+ print "Annotation of $pathname$filename, Revision $rev\n";
+
# Ready to get the responses from the server.
# For example:
# E Annotations for foo/xx
@@ -1239,33 +1255,41 @@ sub doAnnotate($$) {
}
elsif ($words[0] eq "M") {
$lineNr++;
- my $lrev = substr ($_, 2, 13);
- my $lusr = substr ($_, 16, 9);
- my $line = substr ($_, 36);
+ (my $lrev = substr($_, 2, 13)) =~ y/ //d;
+ (my $lusr = substr($_, 16, 9)) =~ y/ //d;
+ my $line = substr($_, 36);
+ my $isCurrentRev = ($rev eq $lrev);
# we should parse the date here ..
if ($lrev eq $oldLrev) {
- $revprint = " ";
+ $revprint = sprintf('%-8s', '');
}
else {
- $revprint = $lrev; $oldLusr = "";
- $revprint =~ s`^(\S+)`$1`; # `
+ $revprint = sprintf('%-8s', $lrev);
+ $revprint =~ s`\S+`&link($&, "$scriptwhere$barequery#rev$&")`e; # `
+ $oldLusr = '';
}
if ($lusr eq $oldLusr) {
- $usrprint = " ";
+ $usrprint = '';
}
else {
$usrprint = $lusr;
}
$oldLrev = $lrev;
$oldLusr = $lusr;
- # is there a less timeconsuming way to strip spaces ?
- ($lrev = $lrev) =~ s/\s+//g;
- my $isCurrentRev = ($rev eq $lrev);
- print "" if ($isCurrentRev);
- printf ("%8s%s%8s %4d:", $revprint, ($isCurrentRev ? "|" : " "), $usrprint, $lineNr);
+ # Set bold for text-based browsers only - graphical
+ # browsers show bold fonts a bit wider than regular fonts,
+ # so it looks irregular.
+ print "" if ($isCurrentRev && $is_textbased);
+
+ printf "%s%s %-8s %4d:",
+ $revprint,
+ $isCurrentRev ? '!' : ' ',
+ $usrprint,
+ $lineNr;
print spacedHtmlText($line, $d{'tabstop'});
- print "" if ($isCurrentRev);
+
+ print "" if ($isCurrentRev && $is_textbased);
}
elsif ($words[0] eq "ok") {
# We could complain about any text received after this, like the
@@ -1389,12 +1413,14 @@ sub cvswebMarkup($$$) {
print " ";
print "";
print "File: ", &clickablePath($where, 1);
- print " ";
- &download_link(urlencode($fileurl), $revision, "(download)");
+ print " (";
+ &download_link($fileurl, $revision, "download");
+ print ")";
if (!$defaultTextPlain) {
- print " ";
- &download_link(urlencode($fileurl), $revision, "(as text)",
+ print " (";
+ &download_link($fileurl, $revision, "as text",
"text/plain");
+ print ")";
}
print " \n";
if ($show_log_in_markup) {
@@ -1410,10 +1436,10 @@ sub cvswebMarkup($$$) {
my $url = download_url($fileurl, $revision, $mimetype);
print " ";
if ($mimetype =~ /^image/) {
- print " ";
+ printf ' ', htmlquote("$url$barequery");
}
elsif ($mimetype =~ m%^application/pdf%) {
- print " |
|
---|