# | Line 1 | Line 1 | |
---|---|---|
1 | #!/usr/bin/perl -w | |
2 | ||
3 | + | # TODO: remove tables, and use CSS instead |
4 | + | |
5 | use CGI; | |
6 | $query=new CGI; | |
7 | my($period)=$query->param('period'); | |
8 | $period = "today" unless defined $period; | |
9 | + | my($modulelist)=$query->param('module'); |
10 | + | my $moduleext=""; $moduleext=":$modulelist" if defined $modulelist; |
11 | ||
12 | my($firstdate); | |
13 | if($period eq "days") { | |
14 | my($days)=$query->param('days'); | |
15 | $days = 1 unless defined $days; | |
16 | if ($days < 1) {$days = 1}; | |
17 | < | $heading = "i-scream CVS commits in the past $days day(s)"; |
17 | > | $heading = "i-scream CVS$moduleext commits in the past $days day(s)"; |
18 | $days--; | |
19 | < | $firstdate = `date --date \"$days days ago\" \"+%Y/%m/%d\"`; |
19 | > | $firstdate = ">" . `/bin/date -v-${days}d +%Y/%m/%d`; |
20 | } | |
21 | + | elsif($period eq "date") { |
22 | + | my($date)=$query->param('date'); |
23 | + | $date = `/bin/date +%Y/%m/%d` unless defined $date; |
24 | + | $heading = "i-scream CVS$moduleext commits on $date"; |
25 | + | $firstdate = "$date 00:00<$date 23:59" |
26 | + | } |
27 | + | elsif($period eq "since") { |
28 | + | my($date)=$query->param('date'); |
29 | + | $date = `/bin/date +%Y/%m/%d` unless defined $date; |
30 | + | $heading = "i-scream CVS$moduleext commits since $date"; |
31 | + | $firstdate = ">$date"; |
32 | + | } |
33 | elsif($period eq "thisweek") { | |
34 | < | $firstdate = "last Sunday"; |
35 | < | $heading = "i-scream CVS commits this week"; |
34 | > | $firstdate = ">last Sunday"; |
35 | > | $heading = "i-scream CVS$moduleext commits this week"; |
36 | } | |
37 | else { | |
38 | < | # default to "today only" |
39 | < | $firstdate = `/bin/date \"+%Y/%m/%d\"`; |
40 | < | $heading = "Today's i-scream CVS commits"; |
38 | > | # default to "today only" |
39 | > | $firstdate = ">" . `/bin/date +%Y/%m/%d`; |
40 | > | $heading = "Today's i-scream CVS$moduleext commits"; |
41 | } | |
42 | ||
27 | – | print "Content-type: text/html\n\n"; |
28 | – | |
29 | – | my($cvs2clpath) = "/home/sites/www.i-scream.org.uk/bin/cvs2cl.pl"; |
43 | my($cvsroot) = "/cvs/i-scream"; | |
31 | – | my($cvs2clargs) = "--stdout -r -b -t -w -U $cvsroot/CVSROOT/users -l \"-d'\>$firstdate'\" -g \"-d$cvsroot\" -g \"-Q\""; |
32 | – | my($updatecmd) = "/home/sites/www.i-scream.org.uk/bin/fullcvsupdate.sh"; |
33 | – | my($logcmd) = "cd /home/sites/www.i-scream.org.uk/cvsscripttemp && $cvs2clpath $cvs2clargs"; |
44 | ||
45 | + | $modulelist = `ls $cvsroot` unless defined $modulelist; |
46 | + | $modulelist =~ s/[\r\n]/ /gm; |
47 | + | |
48 | + | my($cvs2clpath) = "/usr/local/bin/cvs2cl"; |
49 | + | my($cvs2clargs) = "--stdout --no-wrap --no-common-dir -r -t -w -S -U $cvsroot/CVSROOT/users -l \"-d'$firstdate'\" -g \"-d$cvsroot\" -g \"-Q\""; |
50 | + | my($updatecmd) = "/home/iscream/bin/fullcvsupdate.sh $modulelist"; |
51 | + | my($logcmd) = "cd /tmp/i-scream/cvstmp && $cvs2clpath $cvs2clargs"; |
52 | + | |
53 | + | my ($menu) = "../nwww/menu.inc" ; |
54 | + | my ($header) = "../nwww/header.inc"; |
55 | + | my ($footer) = "../nwww/footer.inc"; |
56 | + | my ($style) = "../nwww/style.inc"; |
57 | + | |
58 | + | print "Content-type: text/html\n\n"; |
59 | + | |
60 | print <<"END"; | |
61 | < | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
61 | > | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
62 | > | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
63 | ||
64 | <html> | |
65 | ||
66 | <head> | |
67 | < | <title>The i-scream Project Commit Log</title> |
68 | < | </head> |
67 | > | <title>i-scream CVS Commit Logs</title> |
68 | > | END |
69 | ||
70 | < | <body bgcolor="#ffffff" link="#ffffff" alink="#ffffff" vlink="#ffffff" text="#000066"> |
70 | > | &print_html($style); |
71 | ||
72 | < | <a href="http://www.i-scream.org.uk"><img border="0" src="../i-scream.gif"></a> |
72 | > | print <<"END"; |
73 | > | </head> |
74 | ||
75 | < | <h2>$heading</h2> |
75 | > | <body> |
76 | ||
77 | + | <div id="container"> |
78 | + | |
79 | + | <div id="main"> |
80 | END | |
81 | ||
82 | < | print `$updatecmd`; |
82 | > | &print_html($header); |
83 | ||
84 | < | my($modulelist)=$query->param('module'); |
85 | < | $modulelist = `ls $cvsroot` unless defined $modulelist; |
84 | > | print <<"END"; |
85 | > | <div id="contents"> |
86 | > | <h1 class="top">i-scream CVS Commit Logs</h1> |
87 | ||
88 | + | <h2>$heading</h2> |
89 | + | END |
90 | + | |
91 | + | print `$updatecmd >/dev/null 2>&1`; |
92 | + | |
93 | my(@modules) = split (/\s+/, $modulelist); | |
94 | ||
95 | foreach my $module (@modules) { | |
96 | ||
97 | < | print "<table border=\"0\" bgcolor=\"#000066\" cellpadding=\"5\" width=\"100%\">"; |
98 | < | print "<tr><td><font size=\"4\"><b><a href=\"/cgi-bin/cvs/viewcvs.cgi/$module\">$module module</a></b></font></td></tr>"; |
97 | > | print "<table border=\"0\" bgcolor=\"#000066\" cellpadding=\"5\" width=\"100%\">\n\n"; |
98 | > | 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"; |
99 | print "<tr><td bgcolor=\"white\">\n"; | |
100 | ||
101 | my(@lines) = `$logcmd $module 2>&1`; | |
# | Line 69 | Line 105 | foreach my $module (@modules) { | |
105 | else { | |
106 | foreach my $line (@lines) { | |
107 | ||
108 | < | if ($line =~ /^([0-9]{4}-[0-9]{2}-[0-9]{2}.*?)([^\s]+)$/) { |
109 | < | print "<font color=\"blue\"><b>"; |
108 | > | if ($line =~ /^([0-9]{4}-[0-9]{2}-[0-9]{2}.*?)\s+([^\s]+)\s+<([^\s]+)>$/) { |
109 | > | print "\n<font color=\"blue\">\n<b>"; |
110 | print HTML_encode($1); | |
111 | < | print "</b><i>"; |
112 | < | print HTML_encode("by $2"); |
113 | < | print "</i></font>" |
111 | > | print "</b>\n<i>"; |
112 | > | print " committed by <a href=\"mailto:$3\" style=\"text-decoration: none;\">"; |
113 | > | print HTML_encode("$2"); |
114 | > | print "</a></i>\n</font>\n" |
115 | } | |
116 | + | elsif ($line =~ /^([0-9]{4}-[0-9]{2}-[0-9]{2}.*?)\s+([^\s]+)$/) { |
117 | + | print "\n<font color=\"blue\">\n<b>"; |
118 | + | print HTML_encode($1); |
119 | + | print "</b>\n<i>"; |
120 | + | print " committed by "; |
121 | + | print HTML_encode("$2"); |
122 | + | print "</i>\n</font>\n" |
123 | + | } |
124 | + | elsif($line =~ /([^\s]+) (\([^,^\)]+(,[^\)]+)?\))([,:])/) { |
125 | + | my ($file, $rev, $tags, $ext) = ($1, $2, $3, $4); |
126 | + | print "<code>"; |
127 | + | print "<a href=\"http://cvs.i-scream.org/$file\" style=\"text-decoration: none;\">"; |
128 | + | print HTML_encode($file); |
129 | + | print "</a> "; |
130 | + | if($rev =~ /\(([^\s]+)\.(\d+)(.*)\)/) { |
131 | + | my $start = $1; |
132 | + | my $end = $2; |
133 | + | my $other = $3; |
134 | + | my $newrev = "$start.$end"; |
135 | + | my $oldrev; |
136 | + | if($end != 1) { |
137 | + | my $oldminver = $end-1; |
138 | + | $oldrev = "$start.$oldminver"; |
139 | + | } |
140 | + | elsif($start =~ /^((\d+\.)+)(\d+)$/) { |
141 | + | $oldrev = $1; |
142 | + | # take trailing . off old revision |
143 | + | chop $oldrev; |
144 | + | } |
145 | + | if(defined $oldrev) { |
146 | + | my $diff = ".diff?r1=$oldrev&r2=$newrev"; |
147 | + | print "(<a href=\"http://cvs.i-scream.org/$file$diff\" style=\"text-decoration: none;\">"; |
148 | + | print HTML_encode("$start.$end"); |
149 | + | print "</a>"; |
150 | + | print HTML_encode("$other)"); |
151 | + | } |
152 | + | else { |
153 | + | print HTML_encode($rev); |
154 | + | } |
155 | + | } |
156 | + | else { |
157 | + | print HTML_encode($rev); |
158 | + | } |
159 | + | print HTML_encode($ext); |
160 | + | print "</code><br/>\n" |
161 | + | } |
162 | else { | |
163 | < | chop $line; |
163 | > | chomp $line; |
164 | print "<code>"; | |
165 | print HTML_encode($line); | |
166 | < | print "</code><br>" |
166 | > | print "</code><br/>\n" |
167 | } | |
168 | } | |
169 | } | |
# | Line 89 | Line 172 | foreach my $module (@modules) { | |
172 | print "</table><p>\n\n"; | |
173 | } | |
174 | ||
175 | + | print "</div>"; |
176 | + | |
177 | + | &print_html($footer); |
178 | + | |
179 | + | print "</div>"; |
180 | + | |
181 | + | &print_html($menu); |
182 | + | |
183 | print <<"END"; | |
184 | + | </div> |
185 | ||
186 | </body> | |
95 | – | |
187 | </html> | |
188 | END | |
189 | ||
# | Line 111 | Line 202 | sub HTML_encode ($){ | |
202 | $encoded =~ s/</</g; | |
203 | $encoded =~ s/>/>/g; | |
204 | return $encoded; | |
205 | + | } |
206 | + | |
207 | + | # Print a file without escaping HTML: - |
208 | + | sub print_html ($) { |
209 | + | my ($filename) = @_; |
210 | + | print `cat $filename 2>&1`; |
211 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |