Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Jun 2003 21:26:31 +0200
From:      "Paul Gelderblom" <paulgelderblom@bigfoot.com>
To:        <freebsd-cvsweb@FreeBSD.org>
Cc:        =?iso-8859-1?Q?Ville_Skytt=E4?= <scop@FreeBSD.org>
Subject:   Contribution: show different icon for icon for binary (-kb) files and show keyword expansion mode on the log page
Message-ID:  <001001c338f4$2f831000$0b00000a@a2000.nl>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Hi all,

Attached is a patch that makes cvsweb display a different icon for files that are -according to the cvs server- binary files.
Until now, cvsweb merely ignored keyword expansion lines in the (r)log, but after this patch it uses them as follows:
- in the directory page binary files get a different icon
- in the log page, the keyword expansion type is shown, with an additional note if it's a binary file.

Of course, you need an icon for this; my 'artwork' is included  (put it in the cvsweb/icons folder) (based on the other icons already present there; am I not infringing anyone's copyright?)
For those who use the Apache icons ( in /icons by default on an apache server) it will use the binary.gif already present there.

The patch file included is a context diff against the current head revision in the freebsd repository.

Ville: It's a relatively small change so I hope it can be included there ....

Greetings,
Paul Gelderblom
paulgelderblom@bigfoot.com







[-- Attachment #2 --]
Index: cvsweb.cgi
===================================================================
RCS file: /home/ncvs/projects/cvsweb/cvsweb.cgi,v
retrieving revision 1.149
diff -c -r1.149 cvsweb.cgi
*** cvsweb.cgi	4 May 2003 10:42:20 -0000	1.149
--- cvsweb.cgi	22 Jun 2003 08:00:03 -0000
***************
*** 62,68 ****
    %MIRRORS %DEFAULTVALUE %ICONS %MTYPES
    @DIFFTYPES %DIFFTYPES @LOGSORTKEYS %LOGSORTKEYS
    %alltags %fileinfo %tags @branchnames %nameprinted
!   %symrev %revsym @allrevisions %date %author @revdisplayorder
    @revisions %state %difflines %log %branchpoint @revorder
    $prcgi @prcategories $re_prcategories $prkeyword $re_prkeyword $mancgi
    $checkoutMagic $doCheckout $scriptname $scriptwhere
--- 62,68 ----
    %MIRRORS %DEFAULTVALUE %ICONS %MTYPES
    @DIFFTYPES %DIFFTYPES @LOGSORTKEYS %LOGSORTKEYS
    %alltags %fileinfo %tags @branchnames %nameprinted
!   %symrev %revsym @allrevisions %date %author @revdisplayorder $keywordsubstitution
    @revisions %state %difflines %log %branchpoint @revorder
    $prcgi @prcategories $re_prcategories $prkeyword $re_prkeyword $mancgi
    $checkoutMagic $doCheckout $scriptname $scriptwhere
***************
*** 72,78 ****
    %input $query $barequery $sortby $bydate $byrev $byauthor
    $bylog $byfile $defaultDiffType $logsort $cvstree $cvsroot
    $mimetype $charset $output_filter $defaultTextPlain $defaultViewable
!   $command_path %CMD $allow_compress $backicon $diricon $fileicon $graphicon
    $fullname $newname $cvstreedefault $logo $defaulttitle $address
    $long_intro $short_instruction $shortLogLen $show_author
    $tablepadding $hr_breakable $showfunc $hr_ignwhite $hr_ignkeysubst
--- 72,78 ----
    %input $query $barequery $sortby $bydate $byrev $byauthor
    $bylog $byfile $defaultDiffType $logsort $cvstree $cvsroot
    $mimetype $charset $output_filter $defaultTextPlain $defaultViewable
!   $command_path %CMD $allow_compress $backicon $diricon $fileicon $graphicon $binfileicon
    $fullname $newname $cvstreedefault $logo $defaulttitle $address
    $long_intro $short_instruction $shortLogLen $show_author
    $tablepadding $hr_breakable $showfunc $hr_ignwhite $hr_ignkeysubst
***************
*** 793,799 ****
  
      if ($file eq '..' || -d "$fullname/$file") {
        next if ($file eq '..' && $where eq '/');
!       my ($rev, $date, $log, $author, $filename) = @{$fileinfo{$file}}
          if (defined($fileinfo{$file}));
        printf "<tr class=\"dir-row-%s\">\n<td colspan=\"2\">",
          ($dirrow % 2) ? 'even' : 'odd';
--- 793,799 ----
  
      if ($file eq '..' || -d "$fullname/$file") {
        next if ($file eq '..' && $where eq '/');
!       my ($rev, $date, $log, $author, $filename, $keywordsubst) = @{$fileinfo{$file}}
          if (defined($fileinfo{$file}));
        printf "<tr class=\"dir-row-%s\">\n<td colspan=\"2\">",
          ($dirrow % 2) ? 'even' : 'odd';
***************
*** 878,892 ****
        $url       = './' . $fileurl . $query;
        $filesexists++;
        next if (!defined($fileinfo{$file}));
!       my ($rev, $date, $log, $author) = @{$fileinfo{$file}};
        $filesfound++;
        printf "<tr class=\"dir-row-%s\">\n", ($dirrow % 2) ? 'even' : 'odd';
        printf '<td%s>', $allow_cvsgraph ? '' : ' colspan="2"';
  
        if ($nofilelinks) {
!         print $fileicon;
        } else {
!         print &link($fileicon, $url);
        }
        print '&nbsp;', &link(htmlquote($file), $url), $attic;
        if ($allow_cvsgraph) {
--- 878,893 ----
        $url       = './' . $fileurl . $query;
        $filesexists++;
        next if (!defined($fileinfo{$file}));
!       my ($rev, $date, $log, $author, $filename, $keywordsubst) = @{$fileinfo{$file}};
        $filesfound++;
        printf "<tr class=\"dir-row-%s\">\n", ($dirrow % 2) ? 'even' : 'odd';
        printf '<td%s>', $allow_cvsgraph ? '' : ' colspan="2"';
  
+       my $icon=($keywordsubst eq "b" ? $binfileicon:$fileicon);
        if ($nofilelinks) {
!         print $icon;
        } else {
!         print &link($icon, $url);
        }
        print '&nbsp;', &link(htmlquote($file), $url), $attic;
        if ($allow_cvsgraph) {
***************
*** 2149,2154 ****
--- 2150,2156 ----
    my $state = 'start';
    my ($date, $branchpoint, $branch, $log, @filetags);
    my ($rev, $revision, $revwanted, $filename, $head, $author);
+   my ($keywordsubst);
  
    while (<$fh>) {
      if ($state eq "start") {
***************
*** 2163,2168 ****
--- 2165,2171 ----
        $revision    = '';
        %symrev      = ();
        @filetags    = ();
+       $keywordsubst= '';
  
        #jump to head state
        $state = "head";
***************
*** 2180,2185 ****
--- 2183,2190 ----
          $head = $1;
        } elsif (/^branch: (.+)$/) {
          $branch = $1;
+       } elsif (/^keyword substitution: (.+)$/) {
+         $keywordsubst = $1;
        } elsif (/^symbolic names:/) {
          $state = "tags";
          ($branch = $head) =~ s/\.\d+$//
***************
*** 2250,2256 ****
                : 0
              && ($rev eq $head))
          {    # Don't think head is needed here..
!           my @finfo = ($rev, $date, $log, $author, $filename);
            my ($name);
            ($name = $filename) =~ s%/.*%%;
            $fileinfo{$name} = [@finfo];
--- 2255,2261 ----
                : 0
              && ($rev eq $head))
          {    # Don't think head is needed here..
!           my @finfo = ($rev, $date, $log, $author, $filename, $keywordsubst);
            my ($name);
            ($name = $filename) =~ s%/.*%%;
            $fileinfo{$name} = [@finfo];
***************
*** 2313,2318 ****
--- 2318,2324 ----
    undef %state;
    undef %difflines;
    undef %log;
+   $keywordsubstitution="";
  
    if (!open($fh, "-|")) {    # child
      if ($revision ne '') {
***************
*** 2331,2342 ****
        } else {
          $symnames = 0;
        }
!     } elsif (/^head:\s+([\d\.]+)/) {
        $head = $1;
      } elsif (/^branch:\s+([\d\.]+)/) {
        $curbranch = $1;
      } elsif (/^symbolic names/) {
        $symnames = 1;
      } elsif (/^-----/) {
        last;
      }
--- 2337,2351 ----
        } else {
          $symnames = 0;
        }
!     }
!     if (/^head:\s+([\d\.]+)/) {
        $head = $1;
      } elsif (/^branch:\s+([\d\.]+)/) {
        $curbranch = $1;
      } elsif (/^symbolic names/) {
        $symnames = 1;
+     } elsif (/^keyword substitution: (.+)$/) {
+         $keywordsubstitution = $1;
      } elsif (/^-----/) {
        last;
      }
***************
*** 2852,2857 ****
--- 2861,2869 ----
    print "\n</p>\n<hr noshade>\n";
  
    print "<p>\n";
+ 
+   my $explain=($keywordsubstitution =~ /b/) ? " (i.e.: CVS considers this a binary file)":"";
+   print "Keyword substitution: $keywordsubstitution $explain<br>\n";
    print $curbranch
      ? ("Default branch: ", ($revsym{$curbranch} || $curbranch))
      : "No default branch";
Index: cvsweb.conf
===================================================================
RCS file: /home/ncvs/projects/cvsweb/cvsweb.conf,v
retrieving revision 1.49
diff -c -r1.49 cvsweb.conf
*** cvsweb.conf	4 May 2003 10:54:39 -0000	1.49
--- cvsweb.conf	22 Jun 2003 08:00:05 -0000
***************
*** 203,208 ****
--- 203,209 ----
            back  => [('[BACK]',  "$iconsdir/back.gif",      20,   22)],
            dir   => [('[DIR]',   "$iconsdir/dir.gif",       20,   22)],
            file  => [('[TXT]',   "$iconsdir/text.gif",      20,   22)],
+           binfile  => [('[BINARY]',"$iconsdir/binary.gif", 20,   22)],
            graph => [('[GRAPH]', "$iconsdir/minigraph.png", 16,   16)],
  );
  undef $iconsdir;

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?001001c338f4$2f831000$0b00000a>