#!/usr/bin/perl -w
-use CGI;
+use CGI qw/:standard/;
$query=new CGI;
my($period)=$query->param('period');
$period = "today" unless defined $period;
$modulelist =~ s/[\r\n]/ /gm;
my($cvs2clpath) = "/usr/local/bin/cvs2cl";
-my($cvs2clargs) = "--stdout --no-wrap --no-common-dir -r -t -w -S -U $cvsroot/CVSROOT/users -l \"-d'$firstdate'\" -g \"-d$cvsroot\" -g \"-Q\"";
+my($cvs2clargs) = "--stdout --no-wrap --no-common-dir -r -t -w -S -U $cvsroot/CVSROOT/users -l \"-d$firstdate\" -g \"-d$cvsroot\" -g \"-Q\"";
my($updatecmd) = "/home/iscream/bin/fullcvsupdate.sh $modulelist";
my($logcmd) = "cd /tmp/i-scream/cvstmp && $cvs2clpath $cvs2clargs";
-my ($left) = "../htdocs/left.inc" ;
-my ($title) = "../htdocs/title.inc";
-my ($bottom) = "../htdocs/bottom.inc";
+my ($incdir) = "../htdocs";
-print "Content-type: text/html\n\n";
+# Include files
+my ($doctype) = "$incdir/doctype.inc";
+my ($style) = "$incdir/style.inc";
+my ($header) = "$incdir/header.inc";
+my ($footer) = "$incdir/footer.inc";
+my ($menu) = "$incdir/menu-static.inc" ;
-print <<"END";
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+# Section markers
+my ($secwho) = 1;
+my ($secfiles) = 2;
+my ($seclog) = 3;
-<html>
+# This should be application/xhtml+xml
+print "Content-type: text/html\n\n";
-<head>
- <title>The i-scream Project Commit Log</title>
-</head>
+&print_html($doctype);
-<body bgcolor="#ffffff" link="#0000ff" alink="#3333cc" vlink="#3333cc" text="#000066">
+print <<"END";
-<table border="0" cellpadding="2" cellspacing="2">
- <tr>
- <td valign="top">
+ <head>
+ <title>
+ i-scream CVS Commit Logs
+ </title>
END
-&print_html($left);
+&print_html($style);
print <<"END";
- </td>
- <td valign="top">
+
+ </head>
+ <body>
+ <div id="container">
+ <div id="main">
END
-&print_html($title);
+&print_html($header);
print <<"END";
-<h2>$heading</h2>
+
+ <div id="contents">
+ <h1 class="top">
+ i-scream CVS Commit Logs
+ </h1>
+ <h2>
+ $heading
+ </h2>
+ <div id="cvslog">
END
print `$updatecmd >/dev/null 2>&1`;
my(@modules) = split (/\s+/, $modulelist);
foreach my $module (@modules) {
-
- print "<table border=\"0\" bgcolor=\"#000066\" cellpadding=\"5\" width=\"100%\">\n\n";
- print "<tr><td>\n<font size=\"4\"><b><a href=\"http://cvs.i-scream.org/$module\" style=\"color: white\">$module module</a></b></font>\n</td></tr>\n\n";
- print "<tr><td bgcolor=\"white\">\n";
+ my($firstentry) = 1;
+ my($sec) = 0;
+ print <<"END";
+ <div>
+ <h3>
+ <a href="http://cvs.i-scream.org/$module/" class="cvsloghead">$module module</a>
+ </h3>
+END
my(@lines) = `$logcmd $module 2>&1`;
if(@lines == 0) {
- print "There have been no commits in this module during this period.\n";
+ print <<"END";
+ <p>
+ There have been no commits in this module during this period.
+ </p>
+END
}
else {
+ my(@log) = ();
foreach my $line (@lines) {
- if ($line =~ /^([0-9]{4}-[0-9]{2}-[0-9]{2}.*?)\s+([^\s]+)\s+<([^\s]+)>$/) {
- print "\n<font color=\"blue\">\n<b>";
- print HTML_encode($1);
- print "</b>\n<i>";
- print " committed by <a href=\"mailto:$3\" style=\"text-decoration: none;\">";
- print HTML_encode("$2");
- print "</a></i>\n</font>\n"
- }
- elsif ($line =~ /^([0-9]{4}-[0-9]{2}-[0-9]{2}.*?)\s+([^\s]+)$/) {
- print "\n<font color=\"blue\">\n<b>";
- print HTML_encode($1);
- print "</b>\n<i>";
- print " committed by ";
- print HTML_encode("$2");
- print "</i>\n</font>\n"
+ if ($line =~ /^([0-9]{4}-[0-9]{2}-[0-9]{2}.*?)\s+([^\s]+)(\s+<([^\s]+)>)?$/) {
+ my($datetime) = escapeHTML($1);
+ my($committer) = escapeHTML($2);
+ my($email) = $4;
+
+ if($sec != $secwho) {
+ if($sec == $seclog) {
+ @log = &trim_array(@log);
+ foreach my $logline (@log) {
+ $logline =~ s/^\t//;
+ print escapeHTML("$logline\n");
+ }
+ @log = ();
+ print <<"END";
+</pre>
+ </div>
+END
+ }
+ if($firstentry) {
+ $firstentry = 0;
+ print <<"END";
+ <div class="logitemfirst">
+END
+ }
+ else {
+ print <<"END";
+ <div class="logitem">
+END
+ }
+ $sec = $secwho;
+ }
+
+ print <<"END";
+ <p>
+ <b>
+ $datetime
+ </b>
+ committed by
+END
+ if(defined $email) {
+ print <<"END";
+ <a href="mailto:$email">$committer</a>
+END
+ }
+ else {
+ print <<"END";
+ $committer
+END
+ }
+ print <<"END";
+ </p>
+END
}
elsif($line =~ /([^\s]+) (\([^,^\)]+(,[^\)]+)?\))([,:])/) {
my ($file, $rev, $tags, $ext) = ($1, $2, $3, $4);
- print "<code>";
- print "<a href=\"http://cvs.i-scream.org/$file\" style=\"text-decoration: none;\">";
- print HTML_encode($file);
- print "</a> ";
+ $ext = escapeHTML($ext);
+ if($sec != $secfiles) {
+ $sec = $secfiles;
+ print <<"END";
+ <p>
+END
+ }
+ $file = escapeHTML($file);
+ print <<"END";
+ <a href="http://cvs.i-scream.org/$file">$file</a>
+END
if($rev =~ /\(([^\s]+)\.(\d+)(.*)\)/) {
my $start = $1;
my $end = $2;
chop $oldrev;
}
if(defined $oldrev) {
- my $diff = ".diff?r1=$oldrev&r2=$newrev";
- print "(<a href=\"http://cvs.i-scream.org/$file$diff\" style=\"text-decoration: none;\">";
- print HTML_encode("$start.$end");
- print "</a>";
- print HTML_encode("$other)");
+ my $diff = ".diff?r1=$oldrev&r2=$newrev";
+ my $startend = escapeHTML("$start.$end");
+ $other = escapeHTML($other);
+ chomp $other;
+ print <<"END";
+ (<a href="http://cvs.i-scream.org/$file$diff">$startend</a>$other)$ext
+END
}
else {
- print HTML_encode($rev);
+ $rev = escapeHTML($rev);
+ print <<"END";
+ $rev$ext
+END
}
}
else {
- print HTML_encode($rev);
+ $rev = escapeHTML($rev);
+ print <<"END";
+ $rev$ext
+END
+ }
+ if($ext !~ /:$/) {
+ print <<"END";
+ <br />
+END
}
- print HTML_encode($ext);
- print "</code><br>\n"
}
else {
+ next if $sec == $secwho; # not done secfiles yet
+ if($sec != $seclog) {
+ $sec = $seclog;
+ print <<"END";
+ </p>
+ <pre>
+END
+ }
chomp $line;
- print "<code>";
- print HTML_encode($line);
- print "</code><br>\n"
+ push(@log, $line);
}
}
+ if($sec == $seclog) {
+ @log = &trim_array(@log);
+ foreach my $logline (@log) {
+ $logline =~ s/^\t//;
+ print escapeHTML("$logline\n");
+ }
+ @log = ();
+ print <<"END";
+</pre>
+ </div>
+END
+ }
}
- print "</td></tr>\n";
-
- print "</table><p>\n\n";
+ print <<"END";
+ </div>
+END
}
-&print_html($bottom);
+print <<"END";
+ </div>
+ </div>
+END
+
+&print_html($footer);
print <<"END";
- </td>
- </tr>
-</table>
+ </div>
+END
+
+&print_html($menu);
-</body>
+print <<"END";
+ </div>
+ </body>
</html>
END
exit 0;
-#------------------------------------------------------
-# sub HTML_encode
-#
-# escape HTML characters that may cause problems when
-# shown either in the <body> or within text fields.
-#------------------------------------------------------
-sub HTML_encode ($){
- my ($encoded) = @_;
- $encoded =~ s/&/&/g;
- $encoded =~ s/"/"/g;
- $encoded =~ s/</</g;
- $encoded =~ s/>/>/g;
- return $encoded;
+# Print the contents of a file containing html
+sub print_html {
+ my ($filename) = @_;
+ open(FILE, $filename);
+ while(<FILE>) {
+ print;
+ }
+ close FILE;
}
-# Print a file without escaping HTML: -
-sub print_html ($) {
- my ($filename) = @_;
- print `cat $filename 2>&1`;
+# Trim an array (remove beginning and end emptry entries)
+sub trim_array {
+ my (@array) = @_;
+ for(my $i = 0; $i < scalar @array; $i++) {
+ if($array[$i] ne "") {
+ splice @array, 0, $i;
+ last;
+ }
+ }
+ for(my $i = scalar @array - 1; $i >= 0; $i--) {
+ if($array[$i] ne "") {
+ splice @array, $i+1;
+ last;
+ }
+ }
+ return @array;
}