1#!/msrc/apps/bin/perl5
2###########################
3# latex2HTML wrapper script
4# Pawel Wolinski
5# pwolinsk@comp.uark.edu
6# 5/21/97
7###########################
8
9#
10# This script takes the output of htmlize (munged latex2html)
11# and adds the frame based indexing
12#
13
14
15$input_dir =".";
16$output_dir=".";
17$title="NWChem User Documentation";
18
19if ($ARGV[0] eq "") {&print_usage;exit(0);} else {$start_file=$ARGV[0];}
20if ($ARGV[1] ne "") {$title=$ARGV[1];}
21
22&make_contents_cover($input_dir,$output_dir,$start_file);
23&make_manuals($output_dir,$title);
24
25
26
27
28
29#-----------------------subroutines-------------------
30sub make_contents_cover {
31local ($in_dir,$out_dir,$start_f)=@_;
32$r1=<<EOT;
33.*<IMG ALIGN=BOTTOM ALT="next".*
34<B>.*Next:</B>.*
35<B>.*Up:</B>.*
36<B>.*Previous:</B>.*</A>*.
37EOT
38
39$r2=<<EOT2;
40<script>
41var ontop=true;
42function focus_me() {
43   if (ontop) {self.focus();}
44}
45function toggle_ontop() {
46   if (ontop==true) ontop=false;
47   else ontop=true;
48   focus_me();
49}
50function index() {
51   if (self.name=="contentsWin") {
52      self.opener.location="index.html";
53      self.close();
54   }
55}
56function windows_man() {
57   if (self.name=="contents_frame") {
58      top.location="windows_man.html";
59   }
60}
61</script>
62EOT2
63
64$r3=<<EOT5;
65<table>
66<tr>
67<td><font size=-1><i><input type=\"button\" value=\"frames\" onClick=\"index()\"></i></font></td>
68<td><font size=-1><i><input type=\"button\" value=\"windows\" onClick=\"windows_man()\"></i></font></td>
69<td width=100%></td>
70<td><font size=-1><i><input type=\"button\" value=\"on top\" onClick=\"toggle_ontop()\"></i></font></td>
71</tr>
72</table>
73EOT5
74   if (!(open(F,"$in_dir/node2.html"))) {
75      print stderr "make_manual: Cannot find the contents file \"node2.html\" - terminating!\n\n";
76      exit(0);
77   }
78   close(F);
79
80   if (!(open(F,"$in_dir/$start_f"))) {
81      print stderr "make_manual: Cannot find the start file \"$start_f\" - terminating!\n\n";
82      exit(0);
83   }
84   close(F);
85
86   $contents=`cat $in_dir/node2.html`;
87   $cover   =`cat $in_dir/$start_f`;
88
89   $contents=~s/$r1//g;
90   $contents=~s/<HR>//g;
91   $contents=~s/<BR>  <P>//ig;
92
93   $cover   =~s/<H2>*.<\/H2>//g;
94   $cover   =~s/<UL>.*<\/UL>//gs;
95   $cover   =~s/<HR>//g;
96
97   if ($cover=~/<A HREF.*>\s*Compressed postscript<\/A>/i)
98      {$comp_postscript=$&;}
99   if ($cover=~/<A HREF.*>\s*Postscript<\/A>/i)
100      {$postscript=$&;}
101   if ($cover=~/<ISINDEX.*>/i)
102      {$search=$&;}
103
104   $cover   =~s/<P>.*Compressed Postscript<\/A>//ig;
105   $cover   =~s/<P>.*Postscript<\/A>//ig;
106   $cover   =~s/<ISINDEX.*>//gi;
107
108   $contents=~s/<\/HEAD>/<base target=\"main\">\n$r2<\/HEAD>/g;
109   $contents=~s/<BODY/<BODY onBlur=\"focus_me()\"/;
110   $contents=~s/<H2>/<font size=-1><i><form>$r3$comp_postscript $postscript<\/form><\/i><\/font>\n$search\n<H2>/g;
111
112   open(F,">$out_dir/contents.html");
113   print F $contents;
114   close(F);
115
116   open(F,">$out_dir/cover.html");
117   print F $cover;
118   close(F);
119}
120
121
122
123
124sub print_usage {
125print <<EOT2;
126usage: make_manual.pl [start file] ["title"]
127
128    start file:     root file of the latex2html tree
129    title     :     (optional) title displayed in browser's
130                    header bar; default="NWChem User Documentation"
131EOT2
132}
133
134
135
136sub make_manuals {
137local($out_dir,$tit)=@_;
138
139$frames_index=<<EOT3;
140<html>
141<head>
142<title>$tit</title>
143<script>
144<!--
145window.name="something";
146//-->
147</script>
148</head>
149<frameset cols="300,*" border=1>
150   <frame name="contents_frame" scrolling="yes" src="contents.html">
151   <frame name="main" src="cover.html">
152</frameset>
153</html>
154EOT3
155
156
157$cover=`cat cover.html`;
158if ($cover=~/<body.*<\/body>/is) {
159   $cover=$&;
160   $cover=~s/<body/<body onLoad=\"show_contents()\"/i;
161}
162
163$windows_index=<<EOT4;
164<html>
165<head>
166<title>$tit</title>
167<script>
168<!--
169var toolkit=java.awt.Toolkit.getDefaultToolkit();
170var screen_size=toolkit.getScreenSize();
171screen_h=screen_size.height;
172function show_contents() {
173   win_features="toolbar=no,scrollbars=yes,status=no,dircetories=no,resizable=yes,width=300,height="+screen_h;
174   contents=window.open
175      ("contents.html","contentsWin",win_features);
176}
177window.name="main";
178//-->
179</script>
180</head>
181$cover
182</html>
183EOT4
184
185   open(F,">$out_dir/index.html");
186   print F $frames_index;
187   close(F);
188
189   open(F,">$out_dir/windows_man.html");
190   print F $windows_index;
191   close(F);
192}
193