Annotation of loncom/build/doc_template.pl, revision 1.8
1.8 ! harris41 1: # doc_template.pl - A perl script for beautifying doc/build/*.html files
1.1 harris41 2:
1.8 ! harris41 3: # (Quick and dirty xml reading and substitution.)
! 4:
! 5: # Scott Harrison
1.1 harris41 6:
7: # --------------------------------------- slurp in information
8: unless (scalar(@ARGV)==2) {
9: die("invalid invocation of doc_template.pl");
10: }
11: my $template=shift @ARGV; my $data=shift @ARGV;
12: my @lines;
13: open IN,"<$data" or die("no file $data");
1.6 harris41 14: @lines=<IN>; close IN;
15: my $d=join('',@lines);
1.1 harris41 16: open IN,"<$template" or die("no file $data");
1.6 harris41 17: @lines=<IN>; close IN;
18: my $t=join('',@lines);
1.1 harris41 19:
20: # ------- read in values from data
21: $d=~/\<title.*?\>(.*?)\<\/title.*?\>/s;
22: my $title=$1;
23: $t=~s/\<TITLE \/\>/$title/g;
24: $d=~/\$(.*?)\$/;
1.3 harris41 25: my $e=$1;
1.8 ! harris41 26: $e=~s/\S*\s\S*\s+\S*$/ automatically updated/;
1.7 harris41 27: my $cvsdate="<p align=\"left\"><font size=\"-2\"><i>CVS $e</i></font></p>";
1.1 harris41 28: $t=~s/\<DATE \/\>/$cvsdate/g;
29: $d=~/\<\!\-\- pdfahref (.*?) \-\-\>/;
30: my $pdfahref="<a href='$1'>";
31: $t=~s/\<PDFAHREF \/\>/$pdfahref/g;
32:
33: my %bhash=(
34: 'CONFIGURE' => '/docs/reconfig/index.html',
35: 'INSTALL' => '/docs/install/index.html',
36: 'UPGRADE' => '/docs/upgrade/index.html',
37: 'FAQ' => '/docs/faq/index.html',
38: 'DOWNLOADS' => '/docs/downloads/index.html',
39: 'CONTACT' => '/docs/contact/index.html',
40: 'MAIN-SITE' => 'http://install.lon-capa.org',
1.2 harris41 41: 'LICENSE' => '/docs/license/index.html',
1.1 harris41 42: );
43:
44: $d=~/\<\!\-\- button (.*?) \-\-\>/;
45: my $buttonv=$1;
46: while (1) {
47: if ($t=~/\<BUTTON NAME=\'(.*?)\' \/\>/) {
48: my $bname=$1;
49: my $button;
50: my $bh=$bhash{$bname};
51: if ($buttonv eq $bname) {
52: $button=<<END;
53: <table cellpadding='5' cellspacing='0' border='3'><tr><td>
54: <a href='$bh'>
55: <font face='helvetica'>
56: <font color='#009900'>
57: $bname
58: </font>
59: </font>
60: </a>
61: </td></tr></table>
62: END
63: }
64: else {
65: $button=<<END;
66: <table cellpadding='5' cellspacing='0' border='1'><tr><td>
67: <a href='$bh'>
68: <strong><font face='helvetica'>
69: <font color='#009900'>$bname</font>
70: </font></strong></a>
71: </td></tr></table>
72: END
73: }
74: $t=~s/\<BUTTON NAME=\'$bname\' \/\>/$button/g;
75: }
76: else {
77: last;
78: }
79: }
80: $d=~/\<\!\-\- preamble start \-\-\>(.*?)\<\!\-\- preamble end \-\-\>/s;
81: my $preamble=$1;
1.6 harris41 82: $preamble=~s/\<p([^\>]*)\>/<p$1><font face="helvetica">/g;
83: $preamble=~s/\<\/p([^\>]*)\>/<\/font><\/p$1>/g;
84: $preamble=~s/\<li([^\>]*)\>/<li$1><font face="helvetica">/g;
85: $preamble=~s/\<\/li([^\>]*)\>/<\/font><\/li$1>/g;
1.1 harris41 86: $t=~s/\<PREAMBLE \/\>/$preamble/g;
87: $d=~/\<\!\-\- maintext start \-\-\>(.*?)\<\!\-\- maintext end \-\-\>/s;
88: my $maintext=$1;
89: $t=~s/\<MAINTEXT \/\>/$maintext/g;
1.6 harris41 90: my $v=(<<END);
1.7 harris41 91: <p align="right">
1.6 harris41 92: <a href="http://validator.w3.org/check/referer"><img
1.7 harris41 93: src="/loncapa_doc_icons/valid-xhtml10"
1.6 harris41 94: alt="Valid XHTML 1.0!" height="31" width="88" /></a>
95: </p>
96: END
97: if ($d=~/\<\!\-\- validated \-\-\>/) {
98: $t=~s/\<VALIDATED \/\>/$v/g;
99: }
100: else {
101: $t=~s/\<VALIDATED \/\>//g;
102: }
1.1 harris41 103: print $t;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>