Changeset 478 for branches/htmlform


Ignore:
Timestamp:
08/27/10 17:56:58 (14 years ago)
Author:
Kris Deugau
Message:

/branches/htmlfrom

Set a global variable so we can move the site to any level of
web directory. See #17 - note this is an internal autoconfiguration
that shouldn't need to be exposed.
Make code/template structure for setting row colours in tables more
consistent - also tweak search.cgi so it spits out live colour
classes. See #3.

Location:
branches/htmlform
Files:
3 edited

Legend:

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

    r477 r478  
    2929openlog "IPDB","pid","$IPDB::syslog_facility";
    3030
     31## Environment.  Collect some things, process some things, set some things...
     32
    3133# Collect the username from HTTP auth.  If undefined, we're in
    3234# a test environment, or called without a username.
     
    3739  $authuser = $ENV{'REMOTE_USER'};
    3840}
     41
     42# anyone got a better name?  :P
     43my $thingroot = $ENV{SCRIPT_FILENAME};
     44$thingroot =~ s|cgi-bin/main.cgi||;
    3945
    4046syslog "debug", "$authuser active, $ENV{'REMOTE_ADDR'}";
     
    5258
    5359# Set up some globals
    54 ##fixme - need to autofill this somehow
    55 $ENV{HTML_TEMPLATE_ROOT} = '/home/kdeugau/dev/ipdb/trunk/templates';
     60$ENV{HTML_TEMPLATE_ROOT} = $thingroot."templates";
    5661
    5762my $header = HTML::Template->new(filename => "header.tmpl");
     
    272277  my $rowclass=0;
    273278  foreach my $master (@masterblocks) {
    274     my %row = (rowclass => "row$rowclass",
     279    my %row = (
     280        rowclass => $rowclass++ % 2,
    275281        master => "$master",
    276282        routed => $routed{"$master"},
     
    280286        );
    281287    push (@masterlist, \%row);
    282     $rowclass++;  $rowclass = $rowclass % 2;
    283288  }
    284289  $page->param(masterlist => \@masterlist);
     
    354359    foreach my $master (@localmasters) {
    355360      my %row = (
    356         rowclass => $rowclass % 2,
     361        rowclass => $rowclass++ % 2,
    357362        block => "$master",
    358363        city => $cities{"$master"},
     
    362367        );
    363368      push @routed, \%row;
    364       $rowclass++;
    365369    }
    366370    $page->param(routedlist => \@routed);
     
    380384    my $cidr = new NetAddr::IP $data[0];
    381385    my %row = (
    382         rowclass => $rowclass % 2,
     386        rowclass => $rowclass++ % 2,
    383387        fblock => "$cidr",
    384388        frange => $cidr->range
    385389        );
    386390    push @unrouted, \%row;
    387     $rowclass++;
    388391  }
    389392  $page->param(unrouted => \@unrouted);
  • branches/htmlform/cgi-bin/search.cgi

    r468 r478  
    470470        "&pool=$data[0]\">List IPs</a>";
    471471    }
    472     printRow(\@row, 'color1', 1) if ($count%2==0);
    473     printRow(\@row, 'color2', 1) if ($count%2!=0);
    474     $count++;
     472    printRow(\@row, "row".($count++ % 2), 1);
    475473  }
    476474
  • branches/htmlform/templates/index.tmpl

    r466 r478  
    1010</tr>
    1111<TMPL_LOOP NAME=masterlist>
    12 <tr class="<TMPL_VAR name=rowclass>">
     12<tr class="row<TMPL_VAR name=rowclass>">
    1313<td><a href="/ip/cgi-bin/main.cgi?action=showmaster&amp;block=<TMPL_VAR NAME=master>"><TMPL_VAR NAME=master></a></td>
    1414<td><TMPL_VAR NAME=routed></td>
Note: See TracChangeset for help on using the changeset viewer.