ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/web/cgi-bin/cvslog.cgi
Revision: 1.35
Committed: Thu Mar 25 22:48:47 2004 UTC (20 years, 7 months ago) by tdb
Branch: MAIN
Changes since 1.34: +1 -1 lines
Log Message:
Update CGI's to know about new site.

File Contents

# User Rev Content
1 tdb 1.5 #!/usr/bin/perl -w
2    
3 tdb 1.31 use CGI qw/:standard/;
4 tdb 1.5 $query=new CGI;
5     my($period)=$query->param('period');
6     $period = "today" unless defined $period;
7 tdb 1.16 my($modulelist)=$query->param('module');
8     my $moduleext=""; $moduleext=":$modulelist" if defined $modulelist;
9 tdb 1.5
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 tdb 1.16 $heading = "i-scream CVS$moduleext commits in the past $days day(s)";
16 tdb 1.5 $days--;
17 tdb 1.26 $firstdate = ">" . `/bin/date -v-${days}d +%Y/%m/%d`;
18 tdb 1.16 }
19     elsif($period eq "date") {
20     my($date)=$query->param('date');
21 tdb 1.25 $date = `/bin/date +%Y/%m/%d` unless defined $date;
22 tdb 1.16 $heading = "i-scream CVS$moduleext commits on $date";
23     $firstdate = "$date 00:00<$date 23:59"
24 tdb 1.5 }
25 tdb 1.18 elsif($period eq "since") {
26     my($date)=$query->param('date');
27 tdb 1.25 $date = `/bin/date +%Y/%m/%d` unless defined $date;
28 tdb 1.18 $heading = "i-scream CVS$moduleext commits since $date";
29     $firstdate = ">$date";
30     }
31 tdb 1.5 elsif($period eq "thisweek") {
32 tdb 1.16 $firstdate = ">last Sunday";
33     $heading = "i-scream CVS$moduleext commits this week";
34 tdb 1.5 }
35     else {
36 tdb 1.16 # default to "today only"
37 tdb 1.25 $firstdate = ">" . `/bin/date +%Y/%m/%d`;
38 tdb 1.16 $heading = "Today's i-scream CVS$moduleext commits";
39 tdb 1.5 }
40 tdb 1.1
41 tdb 1.10 my($cvsroot) = "/cvs/i-scream";
42    
43     $modulelist = `ls $cvsroot` unless defined $modulelist;
44 tdb 1.17 $modulelist =~ s/[\r\n]/ /gm;
45 tdb 1.1
46 tdb 1.25 my($cvs2clpath) = "/usr/local/bin/cvs2cl";
47 tdb 1.28 my($cvs2clargs) = "--stdout --no-wrap --no-common-dir -r -t -w -S -U $cvsroot/CVSROOT/users -l \"-d'$firstdate'\" -g \"-d$cvsroot\" -g \"-Q\"";
48 tdb 1.25 my($updatecmd) = "/home/iscream/bin/fullcvsupdate.sh $modulelist";
49     my($logcmd) = "cd /tmp/i-scream/cvstmp && $cvs2clpath $cvs2clargs";
50 tdb 1.13
51 tdb 1.35 my ($incdir) = "../htdocs";
52 tdb 1.31
53     # Include files
54     my ($doctype) = "$incdir/doctype.inc";
55     my ($style) = "$incdir/style.inc";
56     my ($header) = "$incdir/header.inc";
57     my ($footer) = "$incdir/footer.inc";
58 tdb 1.34 my ($menu) = "$incdir/menu-static.inc" ;
59 tdb 1.31
60     # Section markers
61     my ($secwho) = 1;
62     my ($secfiles) = 2;
63     my ($seclog) = 3;
64 tdb 1.1
65 tdb 1.31 # This should be application/xhtml+xml
66 tdb 1.10 print "Content-type: text/html\n\n";
67    
68 tdb 1.31 &print_html($doctype);
69    
70 tdb 1.1 print <<"END";
71    
72 tdb 1.31 <head>
73     <title>
74     i-scream CVS Commit Logs
75     </title>
76 tdb 1.30 END
77    
78     &print_html($style);
79    
80     print <<"END";
81 tdb 1.1
82 tdb 1.31 </head>
83     <body>
84     <div id="container">
85     <div id="main">
86 tdb 1.13 END
87    
88 tdb 1.30 &print_html($header);
89 tdb 1.12
90     print <<"END";
91    
92 tdb 1.31 <div id="contents">
93     <h1 class="top">
94     i-scream CVS Commit Logs
95     </h1>
96     <h2>
97     $heading
98     </h2>
99     <div id="cvslog">
100 tdb 1.5 END
101 tdb 1.1
102 tdb 1.22 print `$updatecmd >/dev/null 2>&1`;
103 tdb 1.9
104 tdb 1.5 my(@modules) = split (/\s+/, $modulelist);
105    
106     foreach my $module (@modules) {
107 tdb 1.31 my($firstentry) = 1;
108 tdb 1.32 my($sec) = 0;
109 tdb 1.31 print <<"END";
110     <div>
111     <h3>
112     <a href="http://cvs.i-scream.org/$module/" class="cvsloghead">$module module</a>
113     </h3>
114     END
115 tdb 1.5
116     my(@lines) = `$logcmd $module 2>&1`;
117     if(@lines == 0) {
118 tdb 1.31 print <<"END";
119     <p>
120     There have been no commits in this module during this period.
121     </p>
122     END
123 tdb 1.5 }
124     else {
125 tdb 1.31 my(@log) = ();
126 tdb 1.5 foreach my $line (@lines) {
127 tdb 1.7
128 tdb 1.31 if ($line =~ /^([0-9]{4}-[0-9]{2}-[0-9]{2}.*?)\s+([^\s]+)(\s+<([^\s]+)>)?$/) {
129     my($datetime) = escapeHTML($1);
130     my($committer) = escapeHTML($2);
131     my($email) = $4;
132    
133     if($sec != $secwho) {
134     if($sec == $seclog) {
135     @log = &trim_array(@log);
136     foreach my $logline (@log) {
137     $logline =~ s/^\t//;
138 tdb 1.32 print escapeHTML("$logline\n");
139 tdb 1.31 }
140     @log = ();
141     print <<"END";
142     </pre>
143     </div>
144     END
145     }
146     if($firstentry) {
147     $firstentry = 0;
148     print <<"END";
149     <div class="logitemfirst">
150     END
151     }
152     else {
153     print <<"END";
154     <div class="logitem">
155     END
156     }
157     $sec = $secwho;
158     }
159    
160     print <<"END";
161     <p>
162     <b>
163     $datetime
164     </b>
165     committed by
166     END
167     if(defined $email) {
168     print <<"END";
169     <a href="mailto:$email">$committer</a>
170     END
171     }
172     else {
173     print <<"END";
174     $committer
175     END
176     }
177     print <<"END";
178     </p>
179     END
180 tdb 1.20 }
181 tdb 1.29 elsif($line =~ /([^\s]+) (\([^,^\)]+(,[^\)]+)?\))([,:])/) {
182     my ($file, $rev, $tags, $ext) = ($1, $2, $3, $4);
183 tdb 1.31 $ext = escapeHTML($ext);
184     if($sec != $secfiles) {
185     $sec = $secfiles;
186     print <<"END";
187     <p>
188     END
189     }
190     $file = escapeHTML($file);
191     print <<"END";
192     <a href="http://cvs.i-scream.org/$file">$file</a>
193     END
194 tdb 1.29 if($rev =~ /\(([^\s]+)\.(\d+)(.*)\)/) {
195 tdb 1.25 my $start = $1;
196     my $end = $2;
197     my $other = $3;
198     my $newrev = "$start.$end";
199     my $oldrev;
200     if($end != 1) {
201     my $oldminver = $end-1;
202     $oldrev = "$start.$oldminver";
203     }
204     elsif($start =~ /^((\d+\.)+)(\d+)$/) {
205     $oldrev = $1;
206     # take trailing . off old revision
207     chop $oldrev;
208     }
209     if(defined $oldrev) {
210 tdb 1.31 my $diff = ".diff?r1=$oldrev&amp;r2=$newrev";
211     my $startend = escapeHTML("$start.$end");
212     $other = escapeHTML($other);
213     chomp $other;
214     print <<"END";
215     (<a href="http://cvs.i-scream.org/$file$diff">$startend</a>$other)$ext
216     END
217 tdb 1.16 }
218     else {
219 tdb 1.31 $rev = escapeHTML($rev);
220     print <<"END";
221     $rev$ext
222     END
223 tdb 1.16 }
224     }
225     else {
226 tdb 1.31 $rev = escapeHTML($rev);
227     print <<"END";
228     $rev$ext
229     END
230     }
231     if($ext !~ /:$/) {
232     print <<"END";
233     <br />
234     END
235 tdb 1.16 }
236 tdb 1.7 }
237     else {
238 tdb 1.31 next if $sec == $secwho; # not done secfiles yet
239     if($sec != $seclog) {
240     $sec = $seclog;
241     print <<"END";
242     </p>
243     <pre>
244     END
245     }
246 tdb 1.29 chomp $line;
247 tdb 1.31 push(@log, $line);
248     }
249     }
250     if($sec == $seclog) {
251     @log = &trim_array(@log);
252     foreach my $logline (@log) {
253     $logline =~ s/^\t//;
254 tdb 1.32 print escapeHTML("$logline\n");
255 tdb 1.7 }
256 tdb 1.31 @log = ();
257     print <<"END";
258     </pre>
259     </div>
260     END
261 tdb 1.5 }
262     }
263 tdb 1.31 print <<"END";
264     </div>
265     END
266 tdb 1.1 }
267    
268 tdb 1.31 print <<"END";
269     </div>
270     </div>
271     END
272 tdb 1.30
273     &print_html($footer);
274    
275 tdb 1.31 print <<"END";
276    
277     </div>
278     END
279 tdb 1.30
280     &print_html($menu);
281 tdb 1.13
282 tdb 1.1 print <<"END";
283 tdb 1.7
284 tdb 1.31 </div>
285     </body>
286 tdb 1.1 </html>
287     END
288    
289     exit 0;
290    
291 tdb 1.31 # Print the contents of a file containing html
292     sub print_html {
293     my ($filename) = @_;
294     open(FILE, $filename);
295     while(<FILE>) {
296     print;
297     }
298     close FILE;
299 tdb 1.13 }
300    
301 tdb 1.31 # Trim an array (remove beginning and end emptry entries)
302     sub trim_array {
303     my (@array) = @_;
304     for(my $i = 0; $i < scalar @array; $i++) {
305     if($array[$i] ne "") {
306     splice @array, 0, $i;
307     last;
308     }
309     }
310     for(my $i = scalar @array - 1; $i >= 0; $i--) {
311     if($array[$i] ne "") {
312     splice @array, $i+1;
313     last;
314     }
315     }
316     return @array;
317 tdb 1.1 }