File: write_frames.pl

package info (click to toggle)
nwchem 6.1-6
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 622,036 kB
  • sloc: fortran: 3,947,551; ansic: 381,558; python: 18,041; cpp: 17,375; sh: 13,366; java: 12,311; f90: 11,218; perl: 6,527; csh: 5,151; makefile: 4,032; asm: 1,093; sed: 246; awk: 158; exp: 111
file content (158 lines) | stat: -rwxr-xr-x 5,210 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/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: write_frames.pl 19708 2010-10-29 18:04:21Z d3y133 $
#
# 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 = "<BODY BGCOLOR=\"#FFFFFF\">\n";
}
elsif ($document eq "prog") {
    $bodystring = "<BODY BGCOLOR=\"#FFFFFF\">\n";
}
else{
    $bodystring = "<BODY>\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 "<HTML>\n<HEAD>\n<TITLE> $title </TITLE>\n</HEAD>\n";
print FINDEX "<FRAMESET COLS=\"2*,5*\">\n";
print FINDEX "    <FRAMESET ROWS=\"3*,5*\">\n";
print FINDEX "        <FRAME SRC=\"$document.search.html\">\n";
print FINDEX "        <FRAME SRC=\"contents.html\">\n";
print FINDEX "    </FRAMESET>\n";
#-noban#print FINDEX "    <FRAMESET ROWS=\"2*,10*\">\n";
#-noban#print FINDEX "        <FRAME SRC=\"banner.html\">\n";
print FINDEX "    <FRAMESET>\n";
print FINDEX "        <FRAME SRC=\"$document.html\" NAME=\"main\">\n";
print FINDEX "    </FRAMESET>\n";
print FINDEX "</FRAMESET>\n";
print FINDEX "</HTML>\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 "<HTML>\n<HEAD>\n<TITLE> NWChem logo </TITLE>\n</HEAD>\n";
#-noban#print FBAN "<BODY BGCOLOR=\"aqua\">\n<CENTER>\n<P>\n";
#-noban#print FBAN "<IMG SRC=\"/docs/nwchem/nwchem_logo.gif\" ";
#-noban#print FBAN " ALT=\"NWChem - computational chemistry on parallel computers\"> \n";
#-noban#print FBAN "</P>\n<HR>\n</CENTER>\n</BODY>\n</HTML>\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 "<HTML>\n<HEAD>\n<TITLE> $title Search Window</TITLE>\n";
print FHTMLSEARCH "<BASE TARGET=\"main\">\n";
print FHTMLSEARCH "</HEAD>\n";
print FHTMLSEARCH "$bodystring";
while (<FSEARCH>){
    print FHTMLSEARCH $_;
}
print FHTMLSEARCH "<A TARGET=\"_TOP\" HREF=\"$document.html\"> No Frames Version </A><HR>";
print FHTMLSEARCH "\n</BODY>\n</HTML>\n";
close(FHTMLSEARCH);
close(FSEARCH);
# write contents.html  (Contents are in a block that 
#  starts with: <!--Table of Contents--> and 
#  ends with  : <!--End of Table of Contents-->
# 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 "<HTML>\n<HEAD>\n<TITLE><B>Contents of $title </B></TITLE>\n";
print FHTMLCONT "<BASE TARGET=\"main\">\n</HEAD>\n";
print FHTMLCONT "<BR>\n<B>Contents of<br>&nbsp;&nbsp;&nbsp; $title </B><BR>\n";
print FHTMLCONT "$bodystring";
$printit = 0;
$printdone = 0;
while(<FCONT>){
    if (!($printdone)){
	if (/<!--Table of Contents-->/) {$printit = 1;}
	if (/<!--End of Table of Contents-->/) {$printit = 0;$printdone=1;}
	if ($printit) {print FHTMLCONT $_;}
    }
}
print FHTMLCONT "</BODY>\n</HTML>\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 (<FI>) {
	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);