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

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=~/\$(.*?)\$/;
1.3     ! harris41   21: my $e=$1;
        !            22: $e=~s/\S*\s\S*\s+\S*$/ created by Scott Harrison/;
        !            23: my $cvsdate="<i>CVS: $e</i>";
1.1       harris41   24: $t=~s/\<DATE \/\>/$cvsdate/g;
                     25: $d=~/\<\!\-\- pdfahref (.*?) \-\-\>/;
                     26: my $pdfahref="<a href='$1'>";
                     27: $t=~s/\<PDFAHREF \/\>/$pdfahref/g;
                     28: 
                     29: my %bhash=(
                     30:     'CONFIGURE' => '/docs/reconfig/index.html',
                     31:     'INSTALL' => '/docs/install/index.html',
                     32:     'UPGRADE' => '/docs/upgrade/index.html',
                     33:     'FAQ' => '/docs/faq/index.html',
                     34:     'DOWNLOADS' => '/docs/downloads/index.html',
                     35:     'CONTACT' => '/docs/contact/index.html',
                     36:     'MAIN-SITE' => 'http://install.lon-capa.org',
1.2       harris41   37:     'LICENSE' => '/docs/license/index.html',
1.1       harris41   38: );
                     39: 
                     40: $d=~/\<\!\-\- button (.*?) \-\-\>/;
                     41: my $buttonv=$1;
                     42: while (1) {
                     43:     if ($t=~/\<BUTTON NAME=\'(.*?)\' \/\>/) {
                     44: 	my $bname=$1;
                     45: 	my $button;
                     46: 	my $bh=$bhash{$bname};
                     47: 	if ($buttonv eq $bname) {
                     48: 	    $button=<<END;
                     49: <table cellpadding='5' cellspacing='0' border='3'><tr><td>
                     50: <a href='$bh'>
                     51: <font face='helvetica'>
                     52: <font color='#009900'>
                     53: $bname
                     54: </font>
                     55: </font>
                     56: </a>
                     57: </td></tr></table>
                     58: END
                     59:         }
                     60: 	else {
                     61: 	    $button=<<END;
                     62: <table cellpadding='5' cellspacing='0' border='1'><tr><td>
                     63: <a href='$bh'>
                     64: <strong><font face='helvetica'>
                     65: <font color='#009900'>$bname</font>
                     66: </font></strong></a>
                     67: </td></tr></table>
                     68: END
                     69: 	}
                     70: 	$t=~s/\<BUTTON NAME=\'$bname\' \/\>/$button/g;
                     71:     }
                     72:     else {
                     73: 	last;
                     74:     }
                     75: }
                     76: $d=~/\<\!\-\- preamble start \-\-\>(.*?)\<\!\-\- preamble end \-\-\>/s;
                     77: my $preamble=$1;
                     78: $t=~s/\<PREAMBLE \/\>/$preamble/g;
                     79: $d=~/\<\!\-\- maintext start \-\-\>(.*?)\<\!\-\- maintext end \-\-\>/s;
                     80: my $maintext=$1;
                     81: $t=~s/\<MAINTEXT \/\>/$maintext/g;
                     82: print $t;

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