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

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',
        !            35: );
        !            36: 
        !            37: $d=~/\<\!\-\- button (.*?) \-\-\>/;
        !            38: my $buttonv=$1;
        !            39: while (1) {
        !            40:     if ($t=~/\<BUTTON NAME=\'(.*?)\' \/\>/) {
        !            41: 	my $bname=$1;
        !            42: 	my $button;
        !            43: 	my $bh=$bhash{$bname};
        !            44: 	if ($buttonv eq $bname) {
        !            45: 	    $button=<<END;
        !            46: <table cellpadding='5' cellspacing='0' border='3'><tr><td>
        !            47: <a href='$bh'>
        !            48: <font face='helvetica'>
        !            49: <font color='#009900'>
        !            50: $bname
        !            51: </font>
        !            52: </font>
        !            53: </a>
        !            54: </td></tr></table>
        !            55: END
        !            56:         }
        !            57: 	else {
        !            58: 	    $button=<<END;
        !            59: <table cellpadding='5' cellspacing='0' border='1'><tr><td>
        !            60: <a href='$bh'>
        !            61: <strong><font face='helvetica'>
        !            62: <font color='#009900'>$bname</font>
        !            63: </font></strong></a>
        !            64: </td></tr></table>
        !            65: END
        !            66: 	}
        !            67: 	$t=~s/\<BUTTON NAME=\'$bname\' \/\>/$button/g;
        !            68:     }
        !            69:     else {
        !            70: 	last;
        !            71:     }
        !            72: }
        !            73: $d=~/\<\!\-\- preamble start \-\-\>(.*?)\<\!\-\- preamble end \-\-\>/s;
        !            74: my $preamble=$1;
        !            75: $t=~s/\<PREAMBLE \/\>/$preamble/g;
        !            76: $d=~/\<\!\-\- maintext start \-\-\>(.*?)\<\!\-\- maintext end \-\-\>/s;
        !            77: my $maintext=$1;
        !            78: $t=~s/\<MAINTEXT \/\>/$maintext/g;
        !            79: print $t;

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