Browse CVS Repository
Contents of /tombo/htdocs/pagegen.pl
Parent Directory
| Revision Log
| Revision Graph
Revision 1.2 -
( show annotations)
( download)
( as text)
Wed Jan 8 16:37:58 2003 UTC
(21 years, 3 months ago)
by hirami
Branch: MAIN
CVS Tags: V20030125, V20030109, V20030322, V20030322_2, V20030428, V20030117, V20030528, V20030413, V20030724, V20030322_3, Tombo_1_7, V20030415_2, Tombo_1_7b5, V20030415, V20030515, V20030516
Changes since 1.1: +1 -1 lines
File MIME type: text/x-perl
update footer copyright
| 1 |
#! /usr/bin/perl |
| 2 |
|
| 3 |
$menufile = "menu.txt"; |
| 4 |
$topfile = "title.txt"; |
| 5 |
$headerfile = "header.txt"; |
| 6 |
|
| 7 |
|
| 8 |
if ($#ARGV != 1 || !-d $ARGV[0] || !-d $ARGV[1]) { |
| 9 |
print "Usage : pagegen.pl <TMPLDIR> <OUTDIR>\n"; |
| 10 |
exit 1; |
| 11 |
} |
| 12 |
|
| 13 |
$srcdir = $ARGV[0]; |
| 14 |
$dstdir = $ARGV[1]; |
| 15 |
|
| 16 |
opendir(DIR_S, $srcdir) || die; |
| 17 |
while($file = readdir(DIR_S)) { |
| 18 |
next unless ($file =~ /\.tmpl/); |
| 19 |
pagegen($file); |
| 20 |
} |
| 21 |
closedir(DIR_S); |
| 22 |
|
| 23 |
exit 0; |
| 24 |
|
| 25 |
sub pagegen() { |
| 26 |
my ($file) = @_; |
| 27 |
|
| 28 |
my ($outfile) = $file; |
| 29 |
|
| 30 |
$outfile =~ s/\.tmpl$/\.html/; |
| 31 |
|
| 32 |
open(OUT, ">$dstdir/$outfile") || die "$dstdir/$outfile : $!"; |
| 33 |
|
| 34 |
open(BODY, "$srcdir/$file") || die; |
| 35 |
while(<BODY>) { |
| 36 |
chop; |
| 37 |
if (/^<!-- TOP -->$/) { |
| 38 |
include_top(OUT); |
| 39 |
next; |
| 40 |
} |
| 41 |
if (/^<!-- MENU -->$/) { |
| 42 |
include_menu(OUT); |
| 43 |
next; |
| 44 |
} |
| 45 |
if (/^<!-- HEADER -->$/) { |
| 46 |
include_header(OUT); |
| 47 |
next; |
| 48 |
} |
| 49 |
if (/^<!-- FOOTER +(\$.+\$) +-->$/) { |
| 50 |
include_footer(OUT, $1); |
| 51 |
next; |
| 52 |
} |
| 53 |
print OUT "$_\n"; |
| 54 |
} |
| 55 |
close(BODY); |
| 56 |
close(OUT); |
| 57 |
} |
| 58 |
|
| 59 |
sub include_top() |
| 60 |
{ |
| 61 |
my ($stream) = @_; |
| 62 |
open(TOP, "$srcdir/$topfile") || die; |
| 63 |
while(<TOP>) { |
| 64 |
print $stream $_; |
| 65 |
} |
| 66 |
close(TOP); |
| 67 |
} |
| 68 |
|
| 69 |
sub include_header() |
| 70 |
{ |
| 71 |
my($stream) = @_; |
| 72 |
open(HEADER, "$srcdir/$headerfile") || die; |
| 73 |
while(<HEADER>) { |
| 74 |
print $stream $_; |
| 75 |
} |
| 76 |
close(HEADER); |
| 77 |
} |
| 78 |
|
| 79 |
sub include_menu() |
| 80 |
{ |
| 81 |
my($stream) = @_; |
| 82 |
print $stream '<table width="100%"><tr valign="top">'."\n"; |
| 83 |
print $stream '<td width="20%" bgcolor="#FAF0E6"'."\n"; |
| 84 |
|
| 85 |
open(MENU, "$srcdir/$menufile") || die; |
| 86 |
while(<MENU>) { |
| 87 |
print $stream $_; |
| 88 |
} |
| 89 |
close(MENU); |
| 90 |
|
| 91 |
print $stream '</td>'."\n"; |
| 92 |
print $stream '<td width="2%">'."\n"; |
| 93 |
print $stream '<td width="78%" bgcolor="#FFFFFF">'."\n"; |
| 94 |
} |
| 95 |
|
| 96 |
sub include_footer() |
| 97 |
{ |
| 98 |
my($stream, $lastupd) = @_; |
| 99 |
print $stream <<"HTML_FOOTER"; |
| 100 |
</td> |
| 101 |
</tr> |
| 102 |
</table> |
| 103 |
<hr> |
| 104 |
<table width="100%"> |
| 105 |
Copyright (C) 2000-2003, Tomohisa Hirami All rights reserved.<br> |
| 106 |
Last-Update: $lastupd |
| 107 |
</table> |
| 108 |
</body> |
| 109 |
</html> |
| 110 |
HTML_FOOTER |
| 111 |
} |
| |