CVS-Metrics

 view release on metacpan or  search on metacpan

bin/cgi_cvs_evolr  view on Meta::CPAN

    }
    GenerateError($title, "Unknown tag_to '$tag_to'.")
            unless ($found);

    my @tags2 = @tags;
    while ($tag_from ne $tags2[0]) {
        shift @tags2;
    }
    shift @tags2;
    $found = 0;
    foreach (@tags2) {
        if ($_ eq $tag_to) {
            $found = 1;
            last;
        }
    }
    GenerateError($title, "'$tag_from' >= '$tag_to'.")
            unless ($found);

    GenerateHTML($cvs_log, \@tags, $title, $path, $tag_from, $tag_to, $start_date);
}

sub FindCvs {
    my $cvs;
    if ($^O eq 'MSWin32') {
        eval 'use File::Which';
        $cvs = which('cvs');
        unless (defined $cvs) {
            eval 'use Win32::TieRegistry(Delimiter => "/")';
            my $cvs_setting;
            my $hkey = 'HKEY_CURRENT_USER/Software/WinCvs/wincvs/CVS settings';
            eval '$cvs_setting = $Registry->{$hkey}';
            $cvs = $cvs_setting->{'/P_WhichCvs'};
            if (defined $cvs) {
                $cvs =~ s/[\000\001]//g;
                $cvs =~ s/wincvs\.exe\@$//;
                if ( -e "${cvs}CVSNT\\\\cvs.exe") {
                    $cvs .= "CVSNT\\\\cvs.exe";
                }
                else {
                    $cvs .= 'cvs.exe';
                }
            }
        }
        die "cvs not found !\n" unless (defined $cvs);
        warn "Using CVS : $cvs\n";
        return q{"} . $cvs . q{"};
    }
    else {
        return 'cvs';
    }
}

#######################################################################

sub GenerateHTML {
    my ($cvs_log, $tags, $title, $path, $tag_from, $tag_to, $start_date) = @_;

my $html = q{
<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
  <head>
    <meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1' />
    <meta name='generator' content='<TMPL_VAR NAME=generator>' />
    <meta name='date' content='<TMPL_VAR NAME=date>' />
    <meta name='robots' content='nofollow' />
    <title>cvs_evol <!-- TMPL_VAR NAME=title --></title>
    <style type='text/css'>
      <!-- TMPL_VAR NAME=style -->
    </style>
  </head>
  <body>
  <h1>Evolution Report</h1>
  <h1><!-- TMPL_VAR NAME=title --></h1>
  <hr />
  <h2>Activity</h2>
  <img src='<TMPL_VAR NAME=a_img>' />
  <h2>Context</h2>
  <table class='layout'>
    <tr>
      <td valign='top'><img src='<TMPL_VAR NAME=e_img>' /></td>
      <td valign='top'>
        <table border='1' cellpadding='5'>
          <tr>
            <th>Tag</th>
            <th>Date</th>
          </tr>
        <!-- TMPL_LOOP NAME=timed_tag -->
          <tr>
            <td><!-- TMPL_VAR NAME=tag --></td>
            <td><!-- TMPL_VAR NAME=timed --></td>
          </tr>
        <!-- /TMPL_LOOP -->
        </table>
      </td>
    </tr>
  </table>
  <hr />
  <h2>Evolution Report Summary</h2>
  <table border='1' cellpadding='5'>
    <tr>
      <th width='40%'>Directories</th>
      <th width='20%'>Added files</th>
      <th width='20%'>Modified files</th>
      <th width='20%'>Deleted files</th>
    </tr>
  <!-- TMPL_LOOP NAME=summary -->
    <tr>
      <td><a href='#<TMPL_VAR NAME=dir>'><!-- TMPL_VAR NAME=dir --></a></td>
      <td><!-- TMPL_VAR NAME=added --></td>
      <td><!-- TMPL_VAR NAME=modified --></td>
      <td><!-- TMPL_VAR NAME=deleted --></td>
    </tr>
  <!-- /TMPL_LOOP -->
    <tr class='total'>
      <td>TOTAL</td>
      <td><!-- TMPL_VAR NAME=total_added --></td>
      <td><!-- TMPL_VAR NAME=total_modified --></td>
      <td><!-- TMPL_VAR NAME=total_deleted --></td>
    </tr>

bin/cgi_cvs_evolr  view on Meta::CPAN

                if ($file->{state} eq 'dead') {
                    $filename = basename($file->{filename});
                }
                else {
                    $filename = "<a class='filename' href='" . $viewcvs . $module . $file->{filename} . "?rev=" . $file->{revision} . "\&content-type=text\%2Fplain\&root=cvs:" . $repository . "'>" . basename($file->{filename}) . "</a>";
                }
                push @files, {
                    filename    => $filename,
                    revision    => $file->{revision},
                    date        => $file->{date},
                    author      => $file->{author},
                    action      => $action,
                    tags        => \@tags,
                };
                $rowspan1 ++;
                $rowspan2 ++;
            }
            $message =~ s/&/&amp;/g;
            $message =~ s/</&lt;/g;
            $message =~ s/>/&gt;/g;
            $message =~ s/\n/<br \/>/g;
            push @comments, {
                rowspan     => $rowspan2,
                comment     => $message,
                files       => \@files,
            };
        }
        push @dirs, {
            rowspan     => $rowspan1,
            dir         => $dirname,
            comments    => \@comments,
        }
    }

    $template->param(
            style           => $style,
            generator       => $generator,
            date            => $now,
            title           => $title_full,
            e_img           => $base . $e_img,
            a_img           => $base . $a_img,
            timed_tag       => \@timed_tag,
            summary         => \@summary,
            total_added     => $total_added,
            total_modified  => $total_modified,
            total_deleted   => $total_deleted,
            dirs            => \@dirs,
    );

    print header(
            -type  =>  'text/html',
    );
    print $template->output();
}

sub GenerateError {
    my ($title, $message) = @_;

my $error = q{
<?xml version='1.0' encoding='ISO-8859-1'?>
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
  <head>
    <meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1' />
    <meta name='generator' content='<TMPL_VAR NAME=generator>' />
    <meta name='date' content='<TMPL_VAR NAME=date>' />
    <title>cvs_evol <!-- TMPL_VAR NAME=title --></title>
    <style type='text/css'>
      <!-- TMPL_VAR NAME=style -->
    </style>
  </head>
  <body>
    <h1><!-- TMPL_VAR NAME=title --></h1>
    <hr />
    <h2>Error</h2>
    <blockquote><em><!-- TMPL_VAR NAME=message --></em></blockquote>
    <hr />
    <cite>Generated by cgi_cvs_evolr (<!-- TMPL_VAR NAME=date -->)</cite>
  </body>
</html>
};

my $style = q{
      body  { background-color: #CCFFFF }
      h1    { text-align: center }
      h2    { color: red }
};

    $error =~ s/^\s+//gm;
    my $template = HTML::Template->new(
            scalarref           => \$error,
    );
    die "can't create template ($!).\n"
            unless (defined $template);

    my $now = localtime();
    my $generator = 'cgi_cvs_evolr ' . $CVS::Metrics::VERSION . ' (Perl ' . $] . ')';

    $template->param(
            style       => $style,
            generator   => $generator,
            date        => $now,
            title       => $title,
            message     => $message,
    );

    print header(
            -type  =>  'text/html',
    );
    print $template->output();
    exit;
}



( run in 0.506 second using v1.01-cache-2.11-cpan-39bf76dae61 )