#! /bin/csh 
#
#  html_wrap:  
#     Wrap the standard header and trailer elements around an html file
#     with only a body part (without <body> </body> tags)
#     to create a standards-conforming and identifiable html file
#
#   Usage:
#      html_wrap -title "My Title" <foo >foo.html
##
##  To do:  support other META information, including
##	derivation, expiration date, keywords
##
# 

## 
## Configuration: begin here 
##
set title = "Untitled"        ## Default title if none specified
set today = `/bin/date -u`    ##  must return Greenwich Meridian Time
set bgcolor = "ffffff"	      ## White background
##
## End of configuration 
##

##


getarg:
  if ($#argv < 1) then
     goto argsdone
  endif

  switch ($1:q)
  	
     case -title: 
     case -Title:
     case -t: 
         if ($#argv < 2  ||  $2:q =~ -*) then
            echo  $1:q option must have argument
            exit 1
         else
	    set  title = "$2:q "
            shift 
            breaksw
         endif

     case -derived: 
     case -Derived:
     case -d: 
         if ($#argv < 2  ||  $2:q =~ -*) then
            echo  $1:q option must have argument
            exit 1
         else
	    set  derived = "$2:q "
            shift 
            breaksw
         endif

      default:
	echo "Usage: html_wrap [options] <infile >! outfile"
	echo "Options: "
	echo "-title YOURTITLE  ## DO include this"
	echo "-derived FromWhat ## If automatically generated"
	echo "Parameter $1:q ignored"
   endsw

   shift
   goto getarg

argsdone: 

cat <<xxEOFxx
<HTML>
<HEAD>
<!-- Generated by src2www -->
<!-- See http://www.cs.purdue.edu/homes/young/software/src2www.html -->
<META HTTP-EQUIV="Created" CONTENT="${today}">
<TITLE>${title}</TITLE>
</HEAD>
<BODY bgcolor="$bgcolor">
<H1>${title}</H1>
xxEOFxx
#
cat ## Stdin to Stdout
#
cat <<xxEOFxx
</BODY>
</HTML>
xxEOFxx


