<html>
<head>
 <title><%$title%></title>
 <link href="styles.css" rel="stylesheet" type="text/css" />
 <!-- Changed by: Jim Mahoney, 09-Dec-2004 -->
 <!-- This is the outer HTML that's wrapped around     -->
 <!-- all the other page requests from this directory. -->
</head>
<body><table width="99%">
<tr>
 <td colspan="2" id="title"><%$title%></td>
</tr>
<tr>
 <td id="left-menu">
 &nbsp;<br />
% for my $page (@pages){
 <% menu_link($page) %><br />
% }
 &nbsp;<br />
 </td>
 <td id="body">

%# Insert the HTML from the page that was called (e.g. home.html) here.
% $m->call_next();

 </td>
</tr>
<tr>
 <td colspan="2" id="about">
 Jim Mahoney (mahoney@marlboro.edu)<br />
 November 2 2004
</td>
</tr>
</table></body>
</html>

%#
%#====================================================
%#

<%init>

 # Set the path where perl looks for packages to include
 # the directory where this autohandler is, if we don't already have it
 my $directory = $m->current_comp->source_dir;
 push @INC, $directory unless grep(/$directory/,@INC);
 # Load the RegistrarDB.pm file at run time.
 # (We can't say "use RegistrarDB" here; that happens at compile time.)
 require RegistrarDB;

 # Note that the Perl process which is doing all this is 
 # one of several that Apache has listening for requests,
 # and persists across many requests.  Therefore, changing
 # the perl code like Registrar.db and having Perl notice 
 # that it's changed can get a bit tricky.  If several students
 # have their own versions of Registrar.db elsewhere, then 
 # it can get even tricker.  
 #
 # To try to ensure that the right thing would happen, 
 # in this funky multi-developer-single-perl enviroment,
 # I tried the following kludge - but it didn't do what I expected,
 # so I commented it out.  The right thing is to restart apache 
 # if need be, but that takes root access, eh?
 # Check out the documentation about @INC, %INC, "use", and "require" 
 ## delete $INC{'RegistrarDB.pm'} if exists $INC{'RegistrarDB.pm'};   
 #

 my $title = "Registrar Database Demo";

 # These are the pages that show up in the menu on the left of the screen.
 # The URL for each is its name with .html appended.
 my @pages = qw( home add summary register search );

 # Given one of the entries in that @page list, 
 # return the HTML string that links to that page,
 # or a string that shows we're already visiting that page.
 sub menu_link {
   my ($page) = @_;
   return $m->base_comp->name =~ /$page/ ?
     qq{<span class="current-page">$page</span>} :
     qq{<a href="$page.html">$page</a>};
 }

</%init>

