#!/usr/local/bin/perl -w
#
#  converted from info (/bin/csh script) originally written by Glenn Flierl
#  modified to read from .info files by Christine Hammond, May 1996
#
# NOTE: /images/dir.gif and /images/datadisp.gif are used by this script 
#  if you do not have these buttons, you can get them on anonymous ftp at
#  dataone.whoi.edu (128.128.80.28) in /pub/images
#
# No customizing necessary if used with a standard JGOFS system, i.e.,
#   JGOFSDIR/objects, and JGOFSDIR/htmlbin exist.
#
################################################################
#
# tell browser to display as html
#
print "Content-type: text/html\n";
print "\n";
$backto="";
$datalink="";
#
# save the return-to link value, i.e., previous page was ...
# so that if we are returning to data, we return to exact same level.
#
 $backto = $ENV{'HTTP_REFERER'};
#
# get the argv, use tail only - should be objectname[+params]
#
 $qs = $ENV{'QUERY_STRING'};
 $var = substr($qs,rindex($qs,"/")+1);
#
# argv's head is the path from top of object tree
#
 $ddir = substr($qs,0,index($qs,$var));
#
# set the href text for linking to data, by default at level 0
#
 $datalink = "/jg/serv$ddir$var.html0";
#
# test which process requested this script - if serv, it's a data display
#
if ($backto) {
 if ( $backto =~ /serv/ ) {
   $datalink=$backto;
   $var=substr($var,0,index($var,".htm"));
 }
}
#
# show the buttons for directory, data at top of screen
#
 print "<a href=\"/jg/dir?$ddir\"><img alt=\"[Directory]\" border=0 src=\"/images/dir.gif\"></a> \n";
 print " <a href=\"$datalink\"><img alt=\"[Data...]\" border=0 src=\"/images/datadisp.gif\"></a>\n";
#
# go to top of objects tree, plus current dir
# NOTE:  this assumes a standard jgofs structure with directories
#         htmlbin/ and objects/ at the first level subdirs of jgofsdir
#
 chdir("../objects$ddir");
#
# display the name of the object for which we have a .info file
#
 print "<h1> $var </h1>\n";
 print "<pre>\n";
#
# display contents of objectname.info file in current dir
#
 open (INFILE, "$var.info");
 while (<INFILE>) {
    print $_;
 }
 close(INFILE);
#
# turn off pre tag set above 
#
 print "</pre>\n";
 print "<hr>\n";

