#!/usr/bin/perl5 if($#ARGV<0) { &usage(); } else { $notes = 0 ; if( !($ARGV[0] cmp "-n") ) { $notes = 1 ; $firstfile = 1 ; $notesfile = $ARGV[1] ; } $tmpfile = "./install.pl.tmp" ; $login = getlogin || (getpwuid($<))[0] || "no_email" ; system("/anfs/www/html/UoCCL/template/getrealname $login > $tmpfile") ; open(TMP,"<$tmpfile") or die "Unable to open $tmpfile\n" ; $name = ; close(TMP) ; if( $name eq "" ) { $name = "Somebody" ; } system("date > $tmpfile") ; open(TMP,"<$tmpfile") or die "Unable to open $tmpfile\n" ; $date = ; close(TMP) ; if( $notes ) { open(HTML,">$notesfile.note") or die "Unable to open $notesfile.note\n" ; } foreach $ag (@ARGV) { if( $ag cmp "-n" && $ag cmp $notesfile ) { if( $ag =~ ".*tmpl" ) { $ag = substr( $ag, 0, length($ag) - 5 ) ; } if( $ag =~ "p.." ) { $pnum = substr( $ag, 1, 1 ) ; } open(TMPL,"<$ag.tmpl") or die "Unable to open $ag.tmpl\n" ; if( !$notes ) { open(HTML,">$ag.html") or die "Unable to open $ag.html\n" ; } if( !$notes || $firstfile ) { $firstfile = 0 ; $indexlines=""; if( open(INDX,") { $indexlines .= $_ ; } } $title= ; open(TOP,"<./top.def") or die "Unable to open top.def\n" ; while() { s/##TITLE##/$title/g ; s/##INDEX##/$indexlines/g ; print HTML $_ ; } close(TOP) ; } else { $title= ; print HTML "

", $title, "

\n" ; } $notesonly = 0 ; $webonly = 0 ; while() { /##WEBONLY##/ && ($webonly = 1) ; /##-WEBONLY##/ && ($webonly = 0) ; s/##-?WEBONLY##// ; /##NOTESONLY##/ && ($notesonly = 1) ; /##-NOTESONLY##/ && ($notesonly = 0) ; s/##-?NOTESONLY##// ; s/##LISTSTART##/
    /g ; s/##ITEMHEAD##/
  • /g ; s/##ITEMBODY##/
    /g ; s|##LISTEND##|
|g ; if( (!$notes && !$notesonly) || ( $notes && !$webonly) ) { print HTML $_ ; } } if( !$notes ) { open(BOTTOM,"<./bottom.def") or die "Unable to open bottom.def\n" ; while() { s/##FILENAME##/$ag.html/g ; s/##DATE##/$date/g ; s/##OWNERNAME##/$name/g ; s/##OWNEREMAIL##/$login\@cl.cam.ac.uk/g ; s/##INDEX##/$indexlines/g ; print HTML $_ ; } close(BOTTOM) ; close(HTML); } close(TMPL); } } if( $notes ) { print HTML "\n" ; print HTML "\n" ; close(HTML); } } sub usage { print "Usage: install.pl [-n ] []+\n"; print " Installs web page .html based on each .tmpl\n"; print " if -n specified then produces .note by\n"; print " concatenating all of the .tmpl files appropriately\n"; exit; }