=================================================================== RCS file: /cvs/cvsweb/cvsweb.cgi,v retrieving revision 3.34 retrieving revision 3.35 diff -u -p -r3.34 -r3.35 --- cvsweb/cvsweb.cgi 2000/10/10 18:48:59 3.34 +++ 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.34 2000/10/10 18:48:59 knu Exp $ +# $Id: cvsweb.cgi,v 3.35 2000/10/10 21:14:05 knu Exp $ # ### @@ -74,7 +74,7 @@ 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 @@ -116,6 +116,7 @@ sub download_url($$;$); sub download_link($$$;$); sub toggleQuery($$); sub urlencode($); +sub htmlquote($); sub http_header(;$); sub html_header($); sub html_footer(); @@ -156,7 +157,7 @@ $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; @@ -294,9 +295,9 @@ foreach (@stickyvars) { } # is there any query ? if (@barequery) { - $barequery = join('&', @barequery); + $barequery = join('&', @barequery); $query = "?$barequery"; - $barequery = "&$barequery"; + $barequery = "&$barequery"; } else { $query = ""; @@ -354,7 +355,8 @@ foreach $k (keys %ICONS) { no strict 'refs'; my ($itxt,$ipath,$iwidth,$iheight) = @{$ICONS{$k}}; if ($ipath) { - ${"${k}icon"} = "\"$itxt\""; + ${"${k}icon"} = sprintf('%s', + htmlquote($ipath), htmlquote($itxt), $iwidth, $iheight) } else { ${"${k}icon"} = $itxt; @@ -483,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: @@ -495,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) { @@ -555,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 @@ -602,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; @@ -613,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 @@ -690,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) . ""; @@ -921,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; + $_ = 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|\.([0-9n])\b)`&link($&, sprintf($mancgi, $2 ne '' ? $2 : $3, $1))`ge; # `x; + 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($;$) { @@ -983,7 +992,7 @@ sub spacedHtmlText($;$) { sub link($$) { my($name, $where) = @_; - return "$name"; + sprintf '%s', htmlquote($where), $name; } sub revcmp($$) { @@ -1031,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); } @@ -1256,7 +1265,7 @@ sub doAnnotate($$) { } else { $revprint = sprintf('%-8s', $lrev); - $revprint =~ s`\S+`$&`; # ` + $revprint =~ s`\S+`&link($&, "$scriptwhere$barequery#rev$&")`e; # ` $oldLusr = ''; } if ($lusr eq $oldLusr) { @@ -1404,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) { @@ -1425,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 "
"; + printf '
', htmlquote("$url$barequery"); } else { print "
";
@@ -2024,29 +2035,40 @@ sub printLog($;$) {
 	    }
 	    print "\n Revision ";
 	    &download_link($fileurl, $_, $_,
-		$defaultViewable ? "text/x-cvsweb-markup" : undef);
+			   $defaultViewable ? "text/x-cvsweb-markup" : undef);
 	    if ($defaultViewable) {
-		print " / ";
-		&download_link($fileurl, $_, "(download)", $mimetype);
+		print " / (";
+		&download_link($fileurl, $_, "download", $mimetype);
+		print ")";
 	    }
 	    if (not $defaultTextPlain) {
-		print " / ";
-		&download_link($fileurl, $_, "(as text)",
-			   "text/plain");
+		print " / (";
+		&download_link($fileurl, $_, "as text", "text/plain");
+		print ")";
 	    }
 	    if (!$defaultViewable) {
-		print " / ";
-		&download_link($fileurl, $_, "(view)", "text/x-cvsweb-markup");
+		print " / (";
+		&download_link($fileurl, $_, "view", "text/x-cvsweb-markup");
+		print ")";
 	    }
 	    if ($allow_annotate) {
-		print " - ";
-		print "annotate";
+		print " - ";
+		print &link('annotate',
+			    sprintf('%s/%s?annotate=%s%s',
+				    $scriptname,
+				    urlencode($where),
+				    $_,
+				    $barequery));
 	    }
 	    # Plus a select link if enabled, and this version isn't selected
 	    if ($allow_version_select) {
 		if ((!defined($input{"r1"}) || $input{"r1"} ne $_)) {
-		    print " - [select for diffs]\n";
+		    print " - ";
+		    print &link('[select for diffs]',
+				sprintf('%s?r1=%s%s',
+					$scriptwhere,
+					$_,
+					$barequery));
 		}
 		else {
 		    print " - [selected]";
@@ -2101,22 +2123,33 @@ sub printLog($;$) {
 	    # Offer diff to previous revision
 	    if ($prev) {
 		$diffrev{$prev} = 1;
-		print " to previous $prev\n";
+
+		my $url = sprintf('%s.diff?r1=%s&r2=%s%s',
+				  $scriptwhere,
+				  $prev,
+				  $_,
+				  $barequery);
+
+		print " to previous ";
+		print &link($prev, $url);
 		if (!$hr_default) { # offer a human readable version if not default
-		    print "(colored)\n";
+		    print &link('colored', "$url&f=h");
 		}
 	    }
 	    #
 	    # Plus, if it's on a branch, and it's not a vendor branch,
 	    # offer a diff with the branch point.
 	    if ($revsym{$brp} && !/^1\.1\.1\.\d+$/ && !defined($diffrev{$brp})) {
-		print " to branchpoint $brp\n";
+		my $url = sprintf('%s.diff?r1=%s&r2=%s%s',
+				  $scriptwhere,
+				  $brp,
+				  $_,
+				  $barequery);
+
+		print " to branchpoint ";
+		print &link($brp, $url);
 		if (!$hr_default) { # offer a human readable version if not default
-		print "(colored)\n";
+		    print &link('colored', "$url&f=h");
 		}
 	    }
 	    #
@@ -2142,13 +2175,17 @@ sub printLog($;$) {
 		}
 		if (!defined($diffrev{$nextmain})) {
 		    $diffrev{$nextmain} = 1;
-		    print " next main $nextmain\n";
+
+		    my $url = sprintf('%s.diff?r1=%s&r2=%s%s',
+				      $scriptwhere,
+				      $nextmain,
+				      $_,
+				      $barequery);
+
+		    print " next main ";
+		    print &link($nextmain, $url);
 		    if (!$hr_default) { # offer a human readable version if not default
-			print "(colored)\n";
+			print &link('colored', "$url&f=h");
 		    }
 		}
 	    }
@@ -2156,14 +2193,17 @@ sub printLog($;$) {
 	    # to make a diff to that revision
 	    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";
 
+		my $url = sprintf('%s.diff?r1=%s&r2=%s%s',
+				  $scriptwhere,
+				  $input{'r1'},
+				  $_,
+				  $barequery);
+
+		print " to selected ";
+		print &link($input{'r1'}, $url);
+		if (!$hr_default) { # offer a human readable version if not default
+		    print &link('colored', "$url&f=h");
 		}
 	    }
 	}
@@ -2183,11 +2223,10 @@ sub doLog($) {
         ($filename = $where) =~ s|^.*/||;
         $backurl = $scriptname . "/" . urlencode($upwhere) . $query;
 	print &link($backicon, "$backurl#$filename"),
-              " Up to ", &clickablePath($upwhere, 1), "

\n"; - print <Request diff between arbitrary revisions -


-EOF + " Up to ", &clickablePath($upwhere, 1), "

\n"; + print &link('Request diff between arbitrary revisions', '#diff'); + print '


'; + if ($curbranch) { print "Default branch: ", ($revsym{$curbranch} || $curbranch); } @@ -2215,7 +2254,7 @@ EOF print "

\n"; print "

\n"; foreach (@stickyvars) { - print "\n" + printf('', $_, $input{$_}) if (defined($input{$_}) && ((!defined($DEFAULTVALUE{$_}) || $input{$_} ne $DEFAULTVALUE{$_}) @@ -2492,12 +2531,12 @@ sub navigateHeader($$$$$) { $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 "$body_tag_for_src\n"; print ""; print ""; @@ -2579,7 +2618,9 @@ sub clickablePath($$) { $retval = "[$cvstree]"; } else { - $retval = $retval . " [$cvstree]"; + $retval .= ' ' . &link("[$cvstree]", sprintf('%s/%s#dirlist', + $scriptname, + $query)); my $wherepath = ''; my ($lastslash) = $pathname =~ m|/$|; foreach (split(/\//, $pathname)) { @@ -2588,15 +2629,15 @@ sub clickablePath($$) { my ($last) = "$wherepath/" eq "/$pathname" || $wherepath eq "/$pathname"; if ($clickLast || !$last) { - $retval = $retval . "$_"; + $retval .= &link($_, join('', + $scriptname, + urlencode($wherepath), + (!$last || $lastslash ? '/' : ''), + $query, + (!$last || $lastslash ? "#dirlist" : ""))); } else { # do not make a link to the current dir - $retval = $retval . $_; + $retval .= $_; } } } @@ -2653,7 +2694,7 @@ sub chooseMirror() { print "\nThis cvsweb is mirrored in:\n"; foreach $mirror (keys %MIRRORS) { print ", " if ($moremirrors); - print qq($mirror\n); + print &link(htmlquote($mirror),$MIRRORS{$mirror}); $moremirrors = 1; } print "

\n"; @@ -2696,32 +2737,28 @@ sub download_url($$;$) { $revision =~ s/\b0\.//; - if (defined($checkout_magic) + if (defined($checkoutMagic) && (!defined($mimetype) || $mimetype ne "text/x-cvsweb-markup")) { - my ($path); - ($path = $where) =~ s|/[^/]*$|/|; + my $path = $where; + $path =~ s|/[^/]*$|/|; $url = "$scriptname/$checkoutMagic/${path}$url"; } $url .= "?rev=$revision"; - $url .= "&content-type=$mimetype" if (defined($mimetype)); + $url .= '&content-type=' . urlencode($mimetype) if (defined($mimetype)); - return $url; + $url; } # Presents a link to download the # selected revision sub download_link($$$;$) { - my ($url,$revision,$textlink,$mimetype) = @_; - my ($fullurl) = download_url($url,$revision,$mimetype); - my ($paren) = $textlink =~ /^\(/; - $textlink =~ s/^\(// if ($paren); - $textlink =~ s/\)$// if ($paren); - print "(" if ($paren); - print "$textlink"; - print ")" if ($paren); } # Returns a Query string with the @@ -2772,7 +2814,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); } } @@ -2783,12 +2825,26 @@ sub toggleQuery($$) { } sub urlencode($) { - my ($in) = @_; - my ($out); - ($out = $in) =~ s/([\000-+{-\377])/sprintf("%%%02x", ord($1))/ge; - return $out; + local($_) = @_; + + s/[\000-+{-\377]/sprintf("%%%02x", ord($&))/ge; + + + $_; } +sub htmlquote($) { + local($_) = @_; + + # Special Characters; RFC 1866 + s/&/&/g; + s/\"/"/g; + s//>/g; + + $_; +} + sub http_header(;$) { my $content_type = shift || "text/html"; if (defined($moddate)) { @@ -2847,7 +2903,7 @@ sub http_header(;$) { sub html_header($) { my ($title) = @_; - my $version = '$zRevision: 1.103 $ $Revision: 3.34 $'; #' + my $version = '$zRevision: 1.103 $ $Revision: 3.35 $'; #' http_header(); print <$sym"; + $ret .= &link($sym, $fileurl . toggleQuery('only_with_tag',$sym)); } - return $ret."\n"; + return "$ret\n"; } #

"; - print "$backicon"; + print &link($backicon, "$swhere$query#rev$rev"); print " Return to ", &link("$filename","$swhere$query#rev$rev")," CVS log"; print " $fileicon