#!/bin/csh
# a script to display an object's documentation as contained
# in a file named 'objectname.info'
#
# modified:  April 26, 1996 to print objectname as an HTML H1 header
#                 before cat'ing the objectname.info file.  clh
#            May 10, 1996 to use buttons at top of display for linking
#                 to the directory page, to the data display
#
# 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
#
################################################################
#
#
# tell browser to display as html
#
echo "Content-type: text/html"
echo ""
# 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.
#
if ( ${?HTTP_REFERER} ) then
  set backto="${HTTP_REFERER}"
else
  set backto=""
endif
#
# get the argv, use tail only - should be objectname[+params]
#
set var=$1:t
#
# argv's head is the path from top of object tree
#
set ddir=$1:h
#
# set the href text for linking to data, by default at level 0
#
set datalink="/jg/serv${ddir}/${var}.html0"
#
# test which process requested this script - if serv, it's a data display
#
set isobj=`echo "${backto}" | grep serv | wc -c`

if ( ${isobj} > 3 ) then
  set datalink="${backto}"
  set var=$var:r
endif
#
# show the buttons for directory, data at top of screen
#
echo "<a href="\""/jg/dir?${ddir}/"\""><img alt="\""[Directory]"\"" border=0 src="\""/images/dir.gif"\""></a> "
echo " <a href="\""${datalink}"\""><img alt="\""[Data...]"\"" border=0 src="\""/images/datadisp.gif"\""></a>"
#
# 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
#
cd ../objects/${ddir}
#
# show the object for which we have info 
#
echo "<h1> ${var}</h1>"
echo "<pre>"
#
# display contents of objectname.info file in current dir
#
cat ${var}.info
#
# turn off pre tag set above 
#
echo "</pre>"
echo "<hr>"
