3 #$base ="http://tombo.sourceforge.jp";
4 $pjhome="http://sourceforge.jp/projects/tombo";
6 $menufile = "menu.txt";
7 $topfile = "title.txt";
8 $headerfile = "header.txt";
11 if ($#ARGV != 2 || !-d $ARGV[0] || !-d $ARGV[1]) {
12 print "Usage : pagegen.pl <TMPLDIR> <OUTDIR> <BASE>\n";
20 opendir(DIR_S, $srcdir) || die;
21 while($file = readdir(DIR_S)) {
22 next unless ($file =~ /\.tmpl$/);
31 my ($outfile) = $file;
33 $outfile =~ s/\.tmpl$/\.html/;
35 open(OUT, ">$dstdir/$outfile") || die "$dstdir/$outfile : $!";
37 open(BODY, "$srcdir/$file") || die;
40 if (/^<!-- TOP -->$/) {
44 if (/^<!-- MENU -->$/) {
48 if (/^<!-- HEADER -->$/) {
52 if (/^<!-- FOOTER +(\$.+\$) +-->$/) {
53 include_footer(OUT, $1);
56 if (/^<!-- HISTORY -->$/) {
59 if (/^<!-- HEADLINE -->$/) {
60 include_headline(OUT);
62 # if (/^<!-- DL\(([0-9a-zA-Z_]+), +([0-9]+)\) -->$/) {
63 if (/^<!-- DL\(([0-9a-zA-Z_]+), *([0-9]+)\) -->$/) {
64 expand_dl(OUT, $1, $2);
74 my ($stream, $prefix, $dlid) = @_;
75 my ($rs, $disp, $arch, $suffix);
76 open(DL, "$srcdir/download.conf") || die;
80 ($rs, $disp, $arch, $suffix, $path, $cmt) = split(/ /);
82 print $stream "<tr><td>$disp<td>$arch<td><a href=\"http://prdownloads.sourceforge.jp/tombo/$dlid/$prefix"."_$suffix.zip\">$prefix"."_$suffix.zip</a><td>$path<td>$cmt\n"
83 } elsif ($rs ne "c") {
84 print $stream "<tr><td rowspan=\"$rs\">$disp<td>$arch<td><a href=\"http://prdownloads.sourceforge.jp/tombo/$dlid/$prefix"."_$suffix.zip\">$prefix"."_$suffix.zip</a><td>$path<td>$cmt\n";
86 print $stream "<tr><td>$arch<td><a href=\"http://prdownloads.sourceforge.jp/tombo/$dlid/$prefix"."_$suffix.zip\">$prefix"."_$suffix.zip</a><td>$path<td>$cmt\n";
95 open(TOP, "$srcdir/$topfile") || die;
105 open(HEADER, "$srcdir/$headerfile") || die;
115 print $stream '<table width="100%"><tr valign="top">'."\n";
116 print $stream '<td width="20%" bgcolor="#FAF0E6"'."\n";
118 open(MENU, "$srcdir/$menufile") || die;
120 s/_PJHOME_/$pjhome/g;
126 print $stream '</td>'."\n";
127 print $stream '<td width="2%">'."\n";
128 print $stream '<td width="78%" bgcolor="#FFFFFF">'."\n";
133 my($stream, $lastupd) = @_;
134 print $stream <<"HTML_FOOTER";
140 Copyright (C) 2000-2003, Tomohisa Hirami All rights reserved.<br>
141 Copyright (C) 2004-2006, TOMBO maintainers All rights reserved.<br>
142 Last-Update: $lastupd
149 sub include_headline()
152 opendir(DIR, "$srcdir/news") || die;
153 my @l = sort({$b <=> $a } readdir(DIR));
156 my $f, $d, $t, $sec, $headline, $dum;
159 next if ($f eq "." || $f eq "..");
160 next unless ($f =~ /^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})\.txt$/);
161 last if ($i > $num_headlines);
166 open(F, "$srcdir/news/$f") || die;
171 print $stream " <li><a href=\"history.html#$sec\">$headline</a> ($d)</li>\n";
178 sub include_history()
181 opendir(DIR, "$srcdir/news") || die;
182 my @l = sort( { $b <=> $a } readdir(DIR));
185 my $f, $d, $t, $sec, $headline, $dum;
187 next if ($f eq "." || $f eq "..");
188 next unless ($f =~ /^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})\.txt$/);
193 open(F, "$srcdir/news/$f") || die;
198 $dum = <F>; # skip blank line
200 print $stream "<a name=\"$sec\" />\n";
201 print $stream "<h3>$d $headline</h3>\n";