Ignore:
Timestamp:
07/28/10 10:56:09 (14 years ago)
Author:
Kris Deugau
Message:

/branches/htmlform

Added missing index and footer templates
Update default CSS with definitions for footer, alternate-row colours
Have main.cgi look for a template matching $webvar{action}
Convert main summary page content to template
See #3.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/htmlform/cgi-bin/main.cgi

    r449 r450  
    6060        ));
    6161
    62 
    6362# Set up the CGI object...
    6463my $q = new CGI::Simple;
     
    7473
    7574if(!defined($webvar{action})) {
    76   $webvar{action} = "<NULL>";   #shuts up the warnings.
    77 }
     75  $webvar{action} = "index";    #shuts up the warnings.
     76}
     77
     78my $page = HTML::Template->new(filename => "$webvar{action}.tmpl");
    7879
    7980if($webvar{action} eq 'index') {
     
    182183#       if $IPDBacl{$authuser} =~ /A/;
    183184
     185print $page->output;
     186
    184187# We print the footer here, so we don't have to do it elsewhere.
    185188my $footer = HTML::Template->new(filename => "footer.tmpl");
     
    233236# Initial display:  Show master blocks with total allocated subnets, total free subnets
    234237sub showSummary {
    235 
    236   startTable('Master netblock', 'Routed netblocks', 'Allocated netblocks',
    237         'Free netblocks', 'Largest free block');
    238 
    239238  my %allocated;
    240239  my %free;
     
    276275  }
    277276
    278   # Print the data.
    279   my $count=0;
     277  # Assemble the data to stuff into the template.
     278  my @masterlist;
     279  my $rowclass=0;
    280280  foreach my $master (@masterblocks) {
    281     my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=showmaster&block=$master\">$master</a>",
    282         $routed{"$master"}, $allocated{"$master"}, $free{"$master"},
    283         ( ($bigfree{"$master"} eq '') ? ("&lt;NONE&gt;") : ("/".$bigfree{"$master"}) )
     281    my %row = (rowclass => "row$rowclass",
     282        master => "$master",
     283        routed => $routed{"$master"},
     284        allocated => $allocated{"$master"},
     285        free => $free{"$master"},
     286        bigfree => ( ($bigfree{"$master"} eq '') ? ("&lt;NONE&gt;") : ("/".$bigfree{"$master"}) )
    284287        );
    285 
    286     printRow(\@row, 'color1' ) if($count%2==0);
    287     printRow(\@row, 'color2' ) if($count%2!=0);
    288     $count++;
    289   }
    290   print "</table>\n";
    291   if ($IPDBacl{$authuser} =~ /a/) {
    292     print qq(<a href="/ip/cgi-bin/main.cgi?action=addmaster">Add new master block</a><br><br>\n);
    293   }
    294   print "Note:  Free blocks noted here include both routed and unrouted blocks.\n";
     288    push (@masterlist, \%row);
     289    $rowclass++;  $rowclass = $rowclass % 2;
     290  }
     291  $page->param(masterlist => \@masterlist);
     292
     293  $page->param(addmaster => ($IPDBacl{$authuser} =~ /a/) );
    295294
    296295} # showSummary
Note: See TracChangeset for help on using the changeset viewer.