Fix open/close state for panel.html and express=1. Encapsulate it a little better.

This commit is contained in:
slamm%netscape.com 2000-04-27 22:56:17 +00:00
Родитель 7069f3aa9e
Коммит 441ab8aac5
2 изменённых файлов: 104 добавлений и 82 удалений

Просмотреть файл

@ -57,14 +57,14 @@ else {
star => 'star.gif' star => 'star.gif'
); );
$tree = $form{tree}; $::tree = $form{tree};
# $rel_path is the relative path to webtools/tinderbox used for links. # $rel_path is the relative path to webtools/tinderbox used for links.
# It changes to "../" if the page is generated statically, because then # It changes to "../" if the page is generated statically, because then
# it is placed in tinderbox/$tree. # it is placed in tinderbox/$::tree.
$rel_path = ''; $rel_path = '';
&show_tree_selector, exit if $form{tree} eq ''; &show_tree_selector, exit if $::tree eq '';
&do_quickparse, exit if $form{quickparse}; &do_quickparse, exit if $form{quickparse};
&do_express, exit if $form{express}; &do_express, exit if $form{express};
&do_rdf, exit if $form{rdf}; &do_rdf, exit if $form{rdf};
@ -136,7 +136,7 @@ sub do_static {
foreach $pair (@pages) { foreach $pair (@pages) {
my ($page, $call) = @{$pair}; my ($page, $call) = @{$pair};
my $outfile = "$form{tree}/$page"; my $outfile = "$::tree/$page";
open(OUT,">$outfile.$$"); open(OUT,">$outfile.$$");
select OUT; select OUT;
@ -164,14 +164,14 @@ sub print_page_head {
# Print time in format, "HH:MM timezone" # Print time in format, "HH:MM timezone"
my $now = strftime("%H:%M %Z", localtime); my $now = strftime("%H:%M %Z", localtime);
EmitHtmlTitleAndHeader("tinderbox: $tree", "tinderbox", EmitHtmlTitleAndHeader("tinderbox: $::tree", "tinderbox",
"tree: $tree ($now)"); "tree: $::tree ($now)");
&print_javascript; &print_javascript;
# Get the message of the day only on the first pageful # Get the message of the day only on the first pageful
do "$tree/mod.pl" if $nowdate eq $maxdate; do "$::tree/mod.pl" if $nowdate eq $maxdate;
print "$message_of_day\n"; # from $tree/mod.pl print "$message_of_day\n"; # from $::tree/mod.pl
# Quote and Lengend # Quote and Lengend
# #
@ -218,10 +218,10 @@ sub print_page_head {
</table> </table>
}; };
} }
if ($bonsai_tree) { if (is_tree_state_available()) {
print "<a NAME=\"status\"></a>"; print "<a NAME=\"status\"></a>";
print "The tree is currently <font size=+2>"; print "The tree is <font size=+2>";
print (&tree_open ? 'OPEN' : 'CLOSED'); print (is_tree_open() ? 'open' : 'closed');
print "</font>\n"; print "</font>\n";
} }
} }
@ -265,12 +265,12 @@ BEGIN {
# #
my $query_link = ''; my $query_link = '';
my $end_query = ''; my $end_query = '';
my $pretty_time = &print_time($build_time_times->[$tt]); my $pretty_time = print_time($build_time_times->[$tt]);
($hour) = $pretty_time =~ /(\d\d):/; ($hour) = $pretty_time =~ /(\d\d):/;
if ($lasthour ne $hour or &has_who_list($tt)) { if ($lasthour ne $hour or has_who_list($tt)) {
$query_link = &query_ref($td, $build_time_times->[$tt]); $query_link = query_ref($td, $build_time_times->[$tt]);
$end_query = '</a>'; $end_query = '</a>';
} }
if ($lasthour eq $hour) { if ($lasthour eq $hour) {
@ -300,11 +300,11 @@ BEGIN {
# #
for (my $build_index=0; $build_index < $name_count; $build_index++) { for (my $build_index=0; $build_index < $name_count; $build_index++) {
if (not defined($br = $build_table->[$tt][$build_index])) { if (not defined($br = $build_table->[$tt][$build_index])) {
# No build data for this time # No build data for this time (e.g. no build after this time).
print "<td></td>\n"; print "<td></td>\n";
next; next;
} }
next if $br == -1; # rowspan has covered this row next if $br == -1; # Covered by rowspan
my $rowspan = $br->{rowspan}; my $rowspan = $br->{rowspan};
$rowspan = $mindate_time_count - $tt + 1 $rowspan = $mindate_time_count - $tt + 1
@ -338,14 +338,14 @@ BEGIN {
# What Changed # What Changed
# #
# Only add the "C" link if there have been changes since the last build. # Only add the "C" link if there have been changes since the last build.
if ($br->{previousbuildtime}) { if ($br->{previousstarttime}) {
my $previous_br = $build_table->[$tt+$rowspan][$build_index]; my $previous_br = $build_table->[$tt+$rowspan][$build_index];
my $previous_rowspan = $previous_br->{rowspan}; my $previous_rowspan = $previous_br->{rowspan};
if (&has_who_list($tt+$rowspan, if (&has_who_list($tt+$rowspan,
$tt+$rowspan+$previous_rowspan-1)) { $tt+$rowspan+$previous_rowspan-1)) {
print "\n", &query_ref($br->{td}, print "\n", &query_ref($br->{td},
$br->{previousbuildtime}, $br->{previousstarttime},
$br->{buildtime} - 1); $br->{starttime} - 1);
print "C</a>"; print "C</a>";
} }
} }
@ -369,7 +369,7 @@ BEGIN {
# Warnings # Warnings
if (defined $td->{warnings}{$logfile}) { if (defined $td->{warnings}{$logfile}) {
my ($warning_count) = $td->{warnings}{$logfile}; my ($warning_count) = $td->{warnings}{$logfile};
my $warn_file = "$tree/warn$logfile"; my $warn_file = "$::tree/warn$logfile";
$warn_file =~ s/\.gz$/.html/; $warn_file =~ s/\.gz$/.html/;
print "<br><br><a href='${rel_path}$warn_file'>Warn:$warning_count</a>"; print "<br><br><a href='${rel_path}$warn_file'>Warn:$warning_count</a>";
} }
@ -411,7 +411,7 @@ sub print_table_header {
print "</tr><tr>\n"; print "</tr><tr>\n";
print "<td rowspan=1><font size=-1>Click time to <br>see changes <br>", print "<td rowspan=1><font size=-1>Click time to <br>see changes <br>",
"since time</font></td>"; "since then</font></td>";
print "<td><font size=-1>", print "<td><font size=-1>",
"Click name to see what they did</font></td>"; "Click name to see what they did</font></td>";
@ -431,7 +431,7 @@ sub print_table_footer {
."Show previous 24 hours</a>"; ."Show previous 24 hours</a>";
$hours = $save_hours; $hours = $save_hours;
} }
print "<p><a href='${rel_path}admintree.cgi?tree=$tree'>", print "<p><a href='${rel_path}admintree.cgi?tree=$::tree'>",
"Administrate Tinderbox Trees</a><br>\n"; "Administrate Tinderbox Trees</a><br>\n";
} }
@ -441,7 +441,7 @@ sub open_showbuilds_url {
@_ @_
); );
my $url = "${rel_path}showbuilds.cgi?tree=$form{tree}"; my $url = "${rel_path}showbuilds.cgi?tree=$::tree";
$url .= "&hours=$hours" if $hours ne $default_hours; $url .= "&hours=$hours" if $hours ne $default_hours;
while (my ($key, $value) = each %args) { while (my ($key, $value) = each %args) {
$url .= "&$key=$value" if $value ne ''; $url .= "&$key=$value" if $value ne '';
@ -500,27 +500,47 @@ sub has_who_list {
} }
} }
sub tree_open { BEGIN {
my ($line, $treestate); # Check bonsai tree for open/close state
open(BID, "<../bonsai/data/$bonsai_tree/batchid.pl")
or print "can't open batchid<br>"; my $treestate = undef;
$line = <BID>; my $checked_state = 0;
close(BID);
if ($line =~ m/'(\d+)'/) { sub _check_tree_state {
$bid = $1; $checked_state = 1;
} else { tb_load_treedata();
return 0; return unless defined $bonsai_tree and $bonsai_tree ne '';
}
open(BATCH, "<../bonsai/data/$bonsai_tree/batch-${bid}.pl") local $_;
or print "can't open batch-${bid}.pl<br>"; $::BatchID='';
while ($line = <BATCH>){ eval qq(require "../bonsai/data/$bonsai_tree/batchid.pl");
if ($line =~ /^\$::TreeOpen = '(\d+)';/) { if ($::BatchID eq '') {
warn "No BatchID in ../bonsai/data/$bonsai_tree/batchid.pl\n";
return;
}
open(BATCH, "<../bonsai/data/$bonsai_tree/batch-$::BatchID.pl")
or print "can't open batch-$::BatchID.pl<br>";
while (<BATCH>) {
if (/^\$::TreeOpen = '(\d+)';/) {
$treestate = $1; $treestate = $1;
last; last;
}
} }
return;
}
sub is_tree_state_available {
return 1 if defined $treestate;
return 0 if $checked_state;
_check_tree_state();
return is_tree_state_available();
}
sub is_tree_open {
_check_tree_state() unless $checked_state;
return $treestate;
} }
close(BATCH);
return $treestate;
} }
sub print_javascript { sub print_javascript {
@ -707,12 +727,12 @@ __ENDJS
print "\"$ss\";\n"; print "\"$ss\";\n";
} }
for ($ii=0; $ii < $name_count; $ii++) { for ($ii=0; $ii < $name_count; $ii++) {
if (defined($br = $build_table->[0][$ii]) and $br != -1) { if (defined($br = $build_table->[0][$ii])) {
my $bn = $build_names->[$ii]; my $bn = $build_names->[$ii];
print "builds[$ii]='$bn';\n"; print "builds[$ii]='$bn';\n";
} }
} }
print "buildtree = '$form{tree}';\n"; print "buildtree = '$::tree';\n";
# Use JavaScript to refresh the page every 15 minutes # Use JavaScript to refresh the page every 15 minutes
print "setTimeout('location.reload()',900000);\n" if $nowdate eq $maxdate; print "setTimeout('location.reload()',900000);\n" if $nowdate eq $maxdate;
@ -735,14 +755,18 @@ sub do_express {
print "Content-type: text/html\nRefresh: 900\n\n<HTML>\n"; print "Content-type: text/html\nRefresh: 900\n\n<HTML>\n";
my (%build, %times); my (%build, %times);
tb_loadquickparseinfo($form{tree}, \%build, \%times); tb_loadquickparseinfo($::tree, \%build, \%times);
my @keys = sort keys %build; my @keys = sort keys %build;
my $keycount = @keys; my $keycount = @keys;
my $tm = &print_time(time); my $tm = &print_time(time);
print "<table border=1 cellpadding=1 cellspacing=1><tr>"; print "<table border=1 cellpadding=1 cellspacing=1><tr>";
print "<th align=left colspan=$keycount>"; print "<th align=left colspan=$keycount>";
print &open_showbuilds_href."$tree as of $tm</a></tr><tr>\n"; print &open_showbuilds_href."$::tree";
if (is_tree_state_available()) {
print (is_tree_open() ? ' is open' : ' is closed');
}
print ", $tm</a></tr><tr>\n";
foreach my $buildname (@keys) { foreach my $buildname (@keys) {
print "<td bgcolor='$colormap{$build{$buildname}}'>$buildname</td>"; print "<td bgcolor='$colormap{$build{$buildname}}'>$buildname</td>";
} }
@ -754,7 +778,7 @@ sub do_panel {
print "Content-type: text/html\n\n<HTML>\n" unless $form{static}; print "Content-type: text/html\n\n<HTML>\n" unless $form{static};
my (%build, %times); my (%build, %times);
tb_loadquickparseinfo($form{tree}, \%build, \%times); tb_loadquickparseinfo($::tree, \%build, \%times);
print q( print q(
<head> <head>
@ -770,17 +794,15 @@ sub do_panel {
LINK="#0000EE" VLINK="#551A8B" ALINK="#FF0000"> LINK="#0000EE" VLINK="#551A8B" ALINK="#FF0000">
); );
# Hack the panel link for now. # Hack the panel link for now.
print "<a target='_content' href='http://tinderbox.mozilla.org/seamonkey/'>$tree"; print "<a target='_content' href='http://tinderbox.mozilla.org/seamonkey/'>$::tree";
$bonsai_tree = ''; if (is_tree_state_available()) {
require "$tree/treedata.pl"; print " is ", is_tree_open() ? 'open' : 'closed';
if ($bonsai_tree ne '') {
print " is ", tree_open() ? "OPEN" : "CLOSED";
} }
# Add the current time # Add the current time
my ($minute,$hour,$mday,$mon) = (localtime)[1..4]; my ($minute,$hour,$mday,$mon) = (localtime)[1..4];
my $tm = sprintf("%d/%d&nbsp;%d:%02d",$mon+1,$mday,$hour,$minute); my $tm = sprintf("%d/%d&nbsp;%d:%02d",$mon+1,$mday,$hour,$minute);
print " as of $tm</a><br>"; print ", $tm</a><br>";
print "<table border=0 cellpadding=1 cellspacing=1>"; print "<table border=0 cellpadding=1 cellspacing=1>";
while (my ($name, $status) = each %build) { while (my ($name, $status) = each %build) {
@ -793,7 +815,7 @@ sub do_flash {
print "Content-type: text/rdf\n\n" unless $form{static}; print "Content-type: text/rdf\n\n" unless $form{static};
my (%build, %times); my (%build, %times);
tb_loadquickparseinfo($form{tree}, \%build, \%times); tb_loadquickparseinfo($::tree, \%build, \%times);
my ($mac,$unix,$win) = (0,0,0); my ($mac,$unix,$win) = (0,0,0);
@ -840,7 +862,7 @@ sub do_flash {
<NC:child> <NC:child>
<RDF:Description ID='flash'> <RDF:Description ID='flash'>
<NC:type resource='http://www.mozilla.org/RDF#TinderboxFlash' /> <NC:type resource='http://www.mozilla.org/RDF#TinderboxFlash' />
<NC:source>$tree</NC:source> <NC:source>$::tree</NC:source>
<NC:description>$text</NC:description> <NC:description>$text</NC:description>
<NC:timestamp>$tm</NC:timestamp> <NC:timestamp>$tm</NC:timestamp>
</RDF:Description> </RDF:Description>
@ -856,12 +878,10 @@ sub do_flash {
sub do_quickparse { sub do_quickparse {
print "Content-type: text/plain\n\n"; print "Content-type: text/plain\n\n";
my @treelist = split /,/, $tree; my @treelist = split /,/, $::tree;
foreach my $t (@treelist) { foreach my $t (@treelist) {
$bonsai_tree = ""; if (is_tree_state_available()) {
require "$t/treedata.pl"; my $state = is_tree_open() ? 'open' : 'close';
if ($bonsai_tree ne "") {
my $state = tree_open() ? "Open" : "Close";
print "State|$t|$bonsai_tree|$state\n"; print "State|$t|$bonsai_tree|$state\n";
} }
my (%build, %times); my (%build, %times);
@ -876,13 +896,13 @@ sub do_quickparse {
sub do_rdf { sub do_rdf {
print "Content-type: text/plain\n\n"; print "Content-type: text/plain\n\n";
my $mainurl = "http://$ENV{SERVER_NAME}$ENV{SCRIPT_NAME}?tree=$tree"; my $mainurl = "http://$ENV{SERVER_NAME}$ENV{SCRIPT_NAME}?tree=$::tree";
my $dirurl = $mainurl; my $dirurl = $mainurl;
$dirurl =~ s@/[^/]*$@@; $dirurl =~ s@/[^/]*$@@;
my (%build, %times); my (%build, %times);
tb_loadquickparseinfo($tree, \%build, \%times); tb_loadquickparseinfo($::tree, \%build, \%times);
my $image = "channelok.gif"; my $image = "channelok.gif";
my $imagetitle = "OK"; my $imagetitle = "OK";
@ -898,8 +918,8 @@ sub do_rdf {
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://my.netscape.com/rdf/simple/0.9/"> xmlns="http://my.netscape.com/rdf/simple/0.9/">
<channel> <channel>
<title>Tinderbox - $tree</title> <title>Tinderbox - $::tree</title>
<description>Build bustages for $tree</description> <description>Build bustages for $::tree</description>
<link>$mainurl</link> <link>$mainurl</link>
</channel> </channel>
<image> <image>
@ -909,10 +929,8 @@ sub do_rdf {
</image> </image>
}; };
$bonsai_tree = ''; if (is_tree_state_available()) {
require "$tree/treedata.pl"; my $state = is_tree_open() ? 'open' : 'closed';
if ($bonsai_tree ne '') {
my $state = tree_open() ? "OPEN" : "CLOSED";
print "<item><title>The tree is currently $state</title>", print "<item><title>The tree is currently $state</title>",
"<link>$mainurl</link></item>\n"; "<link>$mainurl</link></item>\n";
} }
@ -936,23 +954,17 @@ sub do_hdml {
}; };
%state_symbols = (success=>'+',busted=>'!',testfailed=>'~'); %state_symbols = (success=>'+',busted=>'!',testfailed=>'~');
my @treelist = split /,/, $tree; if (is_tree_state_available()) {
foreach my $t (@treelist) { print "<LINE>$::tree is " . (is_tree_open() ? 'open' : 'closed');
$bonsai_tree = ""; }
require "$t/treedata.pl"; my (%build, %times);
if ($bonsai_tree ne "") { tb_loadquickparseinfo($::tree, \%build, \%times);
my $state = tree_open() ? "Open" : "Close";
print "<LINE>$t is $state"; foreach my $buildname (sort keys %build) {
} print "<LINE>$state_symbols{$build{$buildname}} $buildname\n";
my (%build, %times);
tb_loadquickparseinfo($t, \%build, \%times);
foreach my $buildname (sort keys %build) {
print "<LINE>$state_symbols{$build{$buildname}} $buildname\n";
}
} }
print q{ print q{
</display> </display>
<DISPLAY NAME=help> <DISPLAY NAME=help>
Legend:<BR> Legend:<BR>

Просмотреть файл

@ -101,12 +101,22 @@ sub value_encode {
} }
BEGIN {
my $have_loaded_treedata = 0;
sub tb_load_treedata {
return if $have_loaded_treedata;
$have_loaded_treedata = 1;
require "$tree/treedata.pl" if -r "$tree/treedata.pl";
}
}
sub tb_load_data { sub tb_load_data {
$tree = $form{'tree'}; $tree = $form{'tree'};
return undef unless $tree; return undef unless $tree;
require "$tree/treedata.pl" if -r "$tree/treedata.pl"; tb_load_treedata();
$ignore_builds = {}; $ignore_builds = {};