File:  [LON-CAPA] / loncom / build / doc_template.pl
Revision 1.9: download - view: text, annotated - select for diffs
Wed Jul 31 19:01:52 2002 UTC (21 years, 9 months ago) by harris41
Branches: MAIN
CVS tags: version_0_6_2, version_0_6, version_0_5_1, version_0_5, HEAD
this is the cvs date of when the contents were updated; thus
"last updated" is preferably to "automatically updated"

    1: # doc_template.pl - A perl script for beautifying doc/build/*.html files
    2: 
    3: # (Quick and dirty xml reading and substitution.)
    4: 
    5: # Scott Harrison
    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");
   14: @lines=<IN>; close IN;
   15: my $d=join('',@lines);
   16: open IN,"<$template" or die("no file $data");
   17: @lines=<IN>; close IN;
   18: my $t=join('',@lines);
   19: 
   20: # ------- read in values from data
   21: $d=~/\<title.*?\>(.*?)\<\/title.*?\>/s;
   22: my $title=$1;
   23: $t=~s/\<TITLE \/\>/$title/g;
   24: $d=~/\$(.*?)\$/;
   25: my $e=$1;
   26: $e=~s/\S*\s\S*\s+\S*$/ last updated/;
   27: my $cvsdate="<p align=\"left\"><font size=\"-2\"><i>CVS $e</i></font></p>";
   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',
   41:     'LICENSE' => '/docs/license/index.html',
   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;
   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;
   86: $t=~s/\<PREAMBLE \/\>/$preamble/g;
   87: $d=~/\<\!\-\- maintext start \-\-\>(.*?)\<\!\-\- maintext end \-\-\>/s;
   88: my $maintext=$1;
   89: $t=~s/\<MAINTEXT \/\>/$maintext/g;
   90: my $v=(<<END);
   91: <p align="right">
   92:  <a href="http://validator.w3.org/check/referer"><img
   93:         src="/loncapa_doc_icons/valid-xhtml10"
   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: }
  103: print $t;

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