]> i-scream Git - www.i-scream.org.git/blob - cgi-bin/cvslog.cgi
Added option to show commits since a given date:
[www.i-scream.org.git] / cgi-bin / cvslog.cgi
1 #!/usr/bin/perl -w
2
3 use CGI;
4 $query=new CGI;
5 my($period)=$query->param('period');
6 $period = "today" unless defined $period;
7 my($modulelist)=$query->param('module');
8 my $moduleext=""; $moduleext=":$modulelist" if defined $modulelist;
9
10 my($firstdate);
11 if($period eq "days") {
12     my($days)=$query->param('days');
13     $days = 1 unless defined $days;
14     if ($days < 1) {$days = 1};
15     $heading = "i-scream CVS$moduleext commits in the past $days day(s)";
16     $days--;
17     $firstdate = ">" . `date --date \"$days days ago\" \"+%Y/%m/%d\"`;
18 }
19 elsif($period eq "date") {
20     my($date)=$query->param('date');
21     $date = `/bin/date \"+%Y/%m/%d\"` unless defined $date;
22     $heading = "i-scream CVS$moduleext commits on $date";
23     $firstdate = "$date 00:00<$date 23:59"
24 }
25 elsif($period eq "since") {
26     my($date)=$query->param('date');
27     $date = `/bin/date \"+%Y/%m/%d\"` unless defined $date;
28     $heading = "i-scream CVS$moduleext commits since $date";
29     $firstdate = ">$date";
30 }
31 elsif($period eq "thisweek") {
32     $firstdate = ">last Sunday";
33     $heading = "i-scream CVS$moduleext commits this week";
34 }
35 else {
36     # default to "today only"
37     $firstdate = ">" . `/bin/date \"+%Y/%m/%d\"`;
38     $heading = "Today's i-scream CVS$moduleext commits";
39 }
40
41 my($cvsroot) = "/cvs/i-scream";
42
43 $modulelist = `ls $cvsroot` unless defined $modulelist;
44 $modulelist =~ s/[\r\n]/ /gm;
45
46 my($cvs2clpath) = "/home/sites/www.i-scream.org.uk/bin/cvs2cl2.pl";
47 my($cvs2clargs) = "--stdout --no-wrap -r -b -t -w -S -U $cvsroot/CVSROOT/users -l \"-d'$firstdate'\" -g \"-d$cvsroot\" -g \"-Q\"";
48 my($updatecmd) = "/home/sites/www.i-scream.org.uk/bin/fullcvsupdate.sh $modulelist";
49 my($logcmd) = "cd /home/sites/www.i-scream.org.uk/cvsscripttemp && $cvs2clpath $cvs2clargs";
50
51 my ($left) = "../left.inc" ;
52 my ($title) = "../title.inc";
53 my ($bottom) = "../bottom.inc";
54
55 print "Content-type: text/html\n\n";
56
57 print <<"END";
58 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
59
60 <html>
61
62 <head>
63  <title>The i-scream Project Commit Log</title>
64 </head>
65
66 <body bgcolor="#ffffff" link="#0000ff" alink="#3333cc" vlink="#3333cc" text="#000066">
67
68 <table border="0" cellpadding="2" cellspacing="2">
69  <tr>
70   <td valign="top">
71 END
72
73 &print_html($left);
74
75 print <<"END";
76   </td>
77   <td valign="top">
78 END
79
80 &print_html($title);
81
82 print <<"END";
83 <h2>$heading</h2>
84 END
85
86 print `$updatecmd`;
87
88 my(@modules) = split (/\s+/, $modulelist);
89
90 foreach my $module (@modules) {
91
92     print "<table border=\"0\" bgcolor=\"#000066\" cellpadding=\"5\" width=\"100%\">\n\n";
93     print "<tr><td>\n<font size=\"4\"><b><a href=\"/cgi-bin/cvs/viewcvs.cgi/$module\" style=\"color: white\">$module module</a></b></font>\n</td></tr>\n\n";
94     print "<tr><td bgcolor=\"white\">\n";
95
96     my(@lines) = `$logcmd $module 2>&1`;
97     if(@lines == 0) {
98         print "There have been no commits in this module during this period.\n";
99     }
100     else {
101         foreach my $line (@lines) {
102
103             if ($line =~ /^([0-9]{4}-[0-9]{2}-[0-9]{2}.*?)\s+([^\s]+)\s+<([^\s]+)>$/) {
104                 print "\n<font color=\"blue\">\n<b>";
105                 print HTML_encode($1);
106                 print "</b>\n<i>";
107                 print " commited by <a href=\"mailto:$3\" style=\"text-decoration: none;\">";
108                 print HTML_encode("$2");
109                 print "</a></i>\n</font>\n"
110             }
111             elsif($line =~ /(\S+) (\(\S+\))([,:])/) {
112                 #chop $line;
113                 my ($file, $rest, $ext) = ($1, $2, $3);
114                 print "<code>";
115                 print "<a href=\"/cgi-bin/cvs/viewcvs.cgi/$file\" style=\"text-decoration: none;\">";
116                 print HTML_encode($file);
117                 print "</a> ";
118                 if($rest =~ /\((\S).(\S+)\)/) {
119                     my $newrev = "$1.$2";
120                     my $oldminver = $2-1;
121                     my $oldrev = "$1.$oldminver";
122                     if(!($1==1 && $2==1)) {
123                         my $diff = ".diff?r1=$oldrev&r2=$newrev";
124                         print "<a href=\"/cgi-bin/cvs/viewcvs.cgi/$file$diff\" style=\"text-decoration: none;\">";
125                         print HTML_encode($rest);
126                         print "</a>";
127                     }
128                     else {
129                         print HTML_encode($rest);
130                     }
131                 }
132                 else {
133                     print HTML_encode($rest);
134                 }
135                 print HTML_encode($ext);
136                 print "</code><br>\n"
137             }
138             else {
139                 chop $line;
140                 print "<code>";
141                 print HTML_encode($line);
142                 print "</code><br>\n"
143             }
144         }
145     }
146     print "</td></tr>\n";
147
148     print "</table><p>\n\n";
149 }
150
151 &print_html($bottom);
152
153 print <<"END";
154
155   </td>
156  </tr>
157 </table>
158
159 </body>
160
161 </html>
162 END
163
164 exit 0;
165
166 #------------------------------------------------------
167 # sub HTML_encode
168 #
169 # escape HTML characters that may cause problems when
170 # shown either in the <body> or within text fields.
171 #------------------------------------------------------
172 sub HTML_encode ($){
173     my ($encoded) = @_;
174     $encoded =~ s/&/&amp;/g;
175     $encoded =~ s/"/&quot;/g;
176     $encoded =~ s/</&lt;/g;
177     $encoded =~ s/>/&gt;/g;
178     return $encoded;
179 }
180
181 # Print a file without escaping HTML: -
182 sub print_html ($) {
183     my ($filename) = @_;
184     print `cat $filename 2>&1`;
185 }