#!/usr/bin/perl #########!/msrc/apps/bin/perl # # New frames code to eat latex2html output and write a frames document # # Ricky A. Kendall # # 3/19/98 # # $Id$ # # remove nwchem banner stuff 3/23/98 # ###@INC = ("/msrc/apps/perl-5.005/lib/5.00502","/usr/lib/perl5"); require File::Copy; if (($ARGV[0] eq "") || ($ARGV[1] eq "")) { print "Usage: write_frames.pl document_name title_string\n"; exit(1); } else { $document = $ARGV[0]; $title = $ARGV[1]; } # figure_out where directory is: # $okay = 0; if (-d "$document") {$okay++;} if (-e "$document/index.html"){$okay++;} if (-e "$document/$document.html"){$okay++;} #print "okay is $okay \n"; if ($okay != 3) { print "write_frames.pl: you must be running in the latex source directory\n"; print " where the latex2html directory $document exists\n\n"; exit(1); } if ($document eq "user") { $bodystring = "\n"; } elsif ($document eq "prog") { $bodystring = "\n"; } else{ $bodystring = "\n"; } # write index.html (frames document) if (!(open(FINDEX,">$document/index.html"))){ die "write_frames.pl: could not open index.html for writing\n"; } print FINDEX "\n\n $title \n\n"; print FINDEX "\n"; print FINDEX " \n"; print FINDEX " \n"; print FINDEX " \n"; print FINDEX " \n"; #-noban#print FINDEX " \n"; #-noban#print FINDEX " \n"; print FINDEX " \n"; print FINDEX " \n"; print FINDEX " \n"; print FINDEX "\n"; print FINDEX "\n"; close(FINDEX); #-noban## write banner.html #-noban#if (!(open(FBAN,">$document/banner.html"))){ #-noban# die "write_frames.pl: could not open banner.html for writing\n"; #-noban#} #-noban#print FBAN "\n\n NWChem logo \n\n"; #-noban#print FBAN "\n
\n

\n"; #-noban#print FBAN "\"NWChem \n"; #-noban#print FBAN "

\n
\n
\n\n\n"; #-noban#close(FBAN); # # write $document_search.html if (!(open(FHTMLSEARCH,">$document/$document.search.html"))){ die "write_frames.pl: could not open $document/$document.search.html for writing\n"; } if (!(open(FSEARCH,"$document.search"))){ die "write_frames.pl: could not open $document.search for reading(1)\n"; } print FHTMLSEARCH "\n\n $title Search Window\n"; print FHTMLSEARCH "\n"; print FHTMLSEARCH "\n"; print FHTMLSEARCH "$bodystring"; while (){ print FHTMLSEARCH $_; } print FHTMLSEARCH " No Frames Version
"; print FHTMLSEARCH "\n\n\n"; close(FHTMLSEARCH); close(FSEARCH); # write contents.html (Contents are in a block that # starts with: and # ends with : # this is usually in node2.html. This is assumed # if (!(open(FHTMLCONT,">$document/contents.html"))){ die "write_frames.pl: could not open $document/contents.html for writing\n"; } if ($document eq "user") { if (!(open(FCONT,"$document/node2.html"))){ die "write_frames.pl: could not open $document/node2.html for reading(2)\n"; } } if ($document eq "prog") { if (!(open(FCONT,"$document/node4.html"))){ die "write_frames.pl: could not open $document/node2.html for reading(2)\n"; } } print FHTMLCONT "\n\n<B>Contents of $title </B>\n"; print FHTMLCONT "\n\n"; print FHTMLCONT "
\nContents of
    $title

\n"; print FHTMLCONT "$bodystring"; $printit = 0; $printdone = 0; while(){ if (!($printdone)){ if (//) {$printit = 1;} if (//) {$printit = 0;$printdone=1;} if ($printit) {print FHTMLCONT $_;} } } print FHTMLCONT "\n\n"; close(FHTMLCONT); close(FCONT); # fix No Title chdir $document; $tmp = "tmp_$$"; #print "tmp is $tmp \n"; foreach $file (`ls -1 *.html`) { chop($file); if (-e "$tmp") {unlink $tmp || die "could not delete $tmp\n";} # print "file: <: $file :>\n"; # print "tmp is <: $tmp :> \n"; $result_cp = ` /bin/cp $file $tmp `; # perl copy seems to be broke ?? # copy($file,$tmp); # $result_ls = `ls -l $tmp `; # print $result_ls; # exit; $Ofile = '>' . $file; open(FO,$Ofile) || die " could not open $Ofile for writting \n"; open(FI,$tmp) || die " could not open $tmp for reading(3) \n"; while () { if (/No Title/) { $line = chop(); $line =~ s/No Title/$title/; print FO "$line \n"; } else{ print FO $_; } } close(FO);close(FI); } if (-e "$tmp") {unlink $tmp || die "could not delete $tmp\n";} exit(0);