=================================================================== RCS file: /cvs/cvsweb/cvsweb.cgi,v retrieving revision 3.36 retrieving revision 3.37 diff -u -p -r3.36 -r3.37 --- cvsweb/cvsweb.cgi 2000/10/20 12:28:45 3.36 +++ cvsweb/cvsweb.cgi 2000/10/20 15:46:01 3.37 @@ -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.36 2000/10/20 12:28:45 knu Exp $ +# $Id: cvsweb.cgi,v 3.37 2000/10/20 15:46:01 knu Exp $ # ### @@ -52,6 +52,7 @@ use strict; use vars qw ( $config $allow_version_select $verbose %CVSROOT %CVSROOTdescr %MIRRORS %DEFAULTVALUE %ICONS %MTYPES + @DIFFTYPES %DIFFTYPES @LOGSORTKEYS %LOGSORTKEYS %alltags @tabcolors %fileinfo %tags @branchnames %nameprinted %symrev %revsym @allrevisions %date %author @revdisplayorder @revisions %state %difflines %log %branchpoint @revorder @@ -61,7 +62,7 @@ use vars qw ( %funcline_regexp $is_mod_perl $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 + $bylog $byfile $defaultDiffType $logsort $cvstree $cvsroot $mimetype $defaultTextPlain $defaultViewable $allow_compress $GZIPBIN $backicon $diricon $fileicon $fullname $newname $cvstreedefault $body_tag $body_tag_for_src @@ -83,6 +84,8 @@ use vars qw ( ); sub printDiffSelect($); +sub printDiffLinks($$); +sub printLogSortSelect($); sub findLastModifiedSubdirs(@); sub htmlify_sub(&$); sub htmlify($;$); @@ -166,6 +169,49 @@ $tabstop = $use_moddate = $moddate = $gzip_open = unde $LOG_FILESEPARATOR = q/^={77}$/; $LOG_REVSEPARATOR = q/^-{28}$/; +@DIFFTYPES = qw(h H u c s); +@DIFFTYPES{@DIFFTYPES} = ( + { + 'descr' => 'colored', + 'opts' => [ '-u' ], + 'colored' => 1, + }, + { + 'descr' => 'long colored', + 'opts' => [ '--unified=15' ], + 'colored' => 1, + }, + { + 'descr' => 'unified', + 'opts' => [ '-u' ], + 'colored' => 0, + }, + { + 'descr' => 'context', + 'opts' => [ '-c' ], + 'colored' => 0, + }, + { + 'descr' => 'side by side', + 'opts' => [ '--side-by-side', '--width=164' ], + 'colored' => 0, + }, + ); + +@LOGSORTKEYS = qw(cvs date rev); +@LOGSORTKEYS{@LOGSORTKEYS} = ( + { + 'descr' => 'Not sorted', + }, + { + 'descr' => 'Commit date', + }, + { + 'descr' => 'Revision', + }, + ); + + ##### End of configuration variables ##### use Time::Local; @@ -329,7 +375,7 @@ else { $byfile = 1; } -$hr_default = ($input{'f'} eq 'h' || $input{'f'} eq 'H'); +$defaultDiffType = $input{'f'}; $logsort = $input{'logsort'}; @@ -785,12 +831,9 @@ elsif (-d $fullname) { print "Revision"; print "Log message"; print ""; - print "revisions by: \n"; - print "\n"; - print "Not sorted"; - print "Commit date"; - print "Revision"; - print ""; + print "Sort log by: "; + printLogSortSelect(0); + print ""; print "Diff format: "; printDiffSelect(0); print ""; @@ -884,18 +927,43 @@ gzipclose(); sub printDiffSelect($) { my ($use_java_script) = @_; - my ($f) = $input{'f'}; - print "\n"; - print "Colored Diff"; - print "Long Colored Diff"; - print "Unidiff"; - print "Context Diff"; - print "Side by Side"; + my $f = $input{'f'}; + + print ''; + + local $_; + for (@DIFFTYPES) { + printf('%s', + $_, + $f eq $_ ? ' SELECTED' : '', + "\u$DIFFTYPES{$_}{'descr'}" + ); + } + print ""; } +sub printLogSortSelect($) { + my ($use_java_script) = @_; + + print ''; + + local $_; + for (@LOGSORTKEYS) { + printf('%s', + $_, + $logsort eq $_ ? ' SELECTED' : '', + "\u$LOGSORTKEYS{$_}{'descr'}" + ); + } + + print ""; +} + sub findLastModifiedSubdirs(@) { my (@dirs) = @_; my ($dirname, @files); @@ -1529,7 +1597,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, $f1, $f2); if ($r1 =~ /([^:]+)(:(.+))?/) { $rev1 = $1; @@ -1563,36 +1631,18 @@ sub doDiff($$$$$$) { ($rev1, $sym1) = ($rev2, $sym2); ($rev2, $sym2) = ($tmp1, $tmp2); } - my $human_readable = 0; - if ($f eq 'c') { - @difftype = qw{-c}; - $diffname = "Context diff"; - } - elsif ($f eq 's') { - @difftype = qw{--side-by-side --width=164}; - $diffname = "Side by Side"; - } - elsif ($f eq 'H') { - $human_readable = 1; - @difftype = qw{--unified=15}; - $diffname = "Long Human readable"; - } - elsif ($f eq 'h') { - @difftype =qw{-u}; - $human_readable = 1; - $diffname = "Human readable"; - } - elsif ($f eq 'u') { - @difftype = qw{-u}; - $diffname = "Unidiff"; - } - else { + my $difftype = $DIFFTYPES{$f}; + + if (!$difftype) { fatal ("400 Bad arguments", "Diff format $f not understood"); } + my @difftype = @{$difftype->{'opts'}}; + my $human_readable = $difftype->{'colored'}; + # apply special options if ($showfunc) { - push @difftype, '-p' if $f =~ /^[cHhu]$/; + push @difftype, '-p' if $f ne 's'; my($re1, $re2); @@ -2066,6 +2116,20 @@ sub readLog($;$) { } +sub printDiffLinks($$) { + my($text, $url) = @_; + my @extra; + + local $_; + for ($DIFFTYPES{$defaultDiffType}{'colored'} ? qw(u) : qw(h)) { + my $f = $_ eq $defaultDiffType ? '' : $_; + + push @extra, &link(lc $DIFFTYPES{$_}{'descr'}, "$url&f=$f"); + } + + print &link($text, $url), ' (', join(', ', @extra), ')'; +} + sub printLog($;$) { my ($link, $br, $brp); ($_,$link) = @_; @@ -2190,10 +2254,7 @@ sub printLog($;$) { $barequery); print " to previous "; - print &link($prev, $url); - if (!$hr_default) { # offer a human readable version if not default - print ' (', &link('colored', "$url&f=h"), ')'; - } + printDiffLinks($prev, $url); } # # Plus, if it's on a branch, and it's not a vendor branch, @@ -2206,10 +2267,7 @@ sub printLog($;$) { $barequery); print " to branchpoint "; - print &link($brp, $url); - if (!$hr_default) { # offer a human readable version if not default - print ' (', &link('colored', "$url&f=h"), ')'; - } + printDiffLinks($brp, $url); } # # Plus, if it's on a branch, and it's not a vendor branch, @@ -2242,10 +2300,7 @@ sub printLog($;$) { $barequery); print " next main "; - print &link($nextmain, $url); - if (!$hr_default) { # offer a human readable version if not default - print ' (', &link('colored', "$url&f=h"), ')'; - } + printDiffLinks($nextmain, $url); } } # Plus if user has selected only r1, then present a link @@ -2260,10 +2315,7 @@ sub printLog($;$) { $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"), ')'; - } + printDiffLinks($input{'r1'}, $url); } } print "\n"; @@ -2343,8 +2395,8 @@ sub doLog($) { print "\n"; print ""; print "\n"; - print "Preferred Diff type:"; - print ""; + print "Preferred Diff type:"; + print ""; printDiffSelect($use_java_script); print "\n"; if (@branchnames) { @@ -2379,13 +2431,9 @@ sub doLog($) { print ""; print "\n"; print "Sort log by:"; - print "\n"; - print "Not sorted"; - print "Commit date"; - print "Revision"; - print ""; + print ""; + printLogSortSelect($use_java_script); + print ""; print ""; print "\n"; print ""; @@ -2589,7 +2637,7 @@ 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 ""; @@ -2972,7 +3020,7 @@ sub http_header(;$) { sub html_header($) { my ($title) = @_; - my $version = '$zRevision: 1.103 $ $Revision: 3.36 $'; #' + my $version = '$zRevision: 1.103 $ $Revision: 3.37 $'; #' http_header(); print <
\n"; @@ -2343,8 +2395,8 @@ sub doLog($) { print "\n"; print "