Annotation of loncom/build/doc_template.pl, revision 1.2

1.1       harris41    1: # perl script
                      2: 
                      3: # a quick and dirty xml reading and substitution
                      4: 
                      5: # --------------------------------------- slurp in information
                      6: unless (scalar(@ARGV)==2) {
                      7:     die("invalid invocation of doc_template.pl");
                      8: }
                      9: my $template=shift @ARGV; my $data=shift @ARGV;
                     10: my @lines;
                     11: open IN,"<$data" or die("no file $data");
                     12: @lines=<IN>; close IN; $d=join('',@lines);
                     13: open IN,"<$template" or die("no file $data");
                     14: @lines=<IN>; close IN; $t=join('',@lines);
                     15: 
                     16: # ------- read in values from data
                     17: $d=~/\<title.*?\>(.*?)\<\/title.*?\>/s;
                     18: my $title=$1;
                     19: $t=~s/\<TITLE \/\>/$title/g;
                     20: $d=~/\$(.*?)\$/;
                     21: my $cvsdate="<i>CVS: $1</i>";
                     22: $t=~s/\<DATE \/\>/$cvsdate/g;
                     23: $d=~/\<\!\-\- pdfahref (.*?) \-\-\>/;
                     24: my $pdfahref="<a href='$1'>";
                     25: $t=~s/\<PDFAHREF \/\>/$pdfahref/g;
                     26: 
                     27: my %bhash=(
                     28:     'CONFIGURE' => '/docs/reconfig/index.html',
                     29:     'INSTALL' => '/docs/install/index.html',
                     30:     'UPGRADE' => '/docs/upgrade/index.html',
                     31:     'FAQ' => '/docs/faq/index.html',
                     32:     'DOWNLOADS' => '/docs/downloads/index.html',
                     33:     'CONTACT' => '/docs/contact/index.html',
                     34:     'MAIN-SITE' => 'http://install.lon-capa.org',
1.2     ! harris41   35:     'LICENSE' => '/docs/license/index.html',
1.1       harris41   36: );
                     37: 
                     38: $d=~/\<\!\-\- button (.*?) \-\-\>/;
                     39: my $buttonv=$1;
                     40: while (1) {
                     41:     if ($t=~/\<BUTTON NAME=\'(.*?)\' \/\>/) {
                     42: 	my $bname=$1;
                     43: 	my $button;
                     44: 	my $bh=$bhash{$bname};
                     45: 	if ($buttonv eq $bname) {
                     46: 	    $button=<<END;
                     47: <table cellpadding='5' cellspacing='0' border='3'><tr><td>
                     48: <a href='$bh'>
                     49: <font face='helvetica'>
                     50: <font color='#009900'>
                     51: $bname
                     52: </font>
                     53: </font>
                     54: </a>
                     55: </td></tr></table>
                     56: END
                     57:         }
                     58: 	else {
                     59: 	    $button=<<END;
                     60: <table cellpadding='5' cellspacing='0' border='1'><tr><td>
                     61: <a href='$bh'>
                     62: <strong><font face='helvetica'>
                     63: <font color='#009900'>$bname</font>
                     64: </font></strong></a>
                     65: </td></tr></table>
                     66: END
                     67: 	}
                     68: 	$t=~s/\<BUTTON NAME=\'$bname\' \/\>/$button/g;
                     69:     }
                     70:     else {
                     71: 	last;
                     72:     }
                     73: }
                     74: $d=~/\<\!\-\- preamble start \-\-\>(.*?)\<\!\-\- preamble end \-\-\>/s;
                     75: my $preamble=$1;
                     76: $t=~s/\<PREAMBLE \/\>/$preamble/g;
                     77: $d=~/\<\!\-\- maintext start \-\-\>(.*?)\<\!\-\- maintext end \-\-\>/s;
                     78: my $maintext=$1;
                     79: $t=~s/\<MAINTEXT \/\>/$maintext/g;
                     80: print $t;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>