Develop and Download Open Source Software

Browse CVS Repository

Contents of /tombo/htdocs/pagegen.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Sat Jul 3 07:18:08 2004 UTC (19 years, 9 months ago) by hirami
Branch: MAIN
CVS Tags: V20040822, V20040703, V20040911
Changes since 1.4: +4 -3 lines
File MIME type: text/x-perl
TOMBO 1.9 beta 1

1 #! /usr/bin/perl
2
3 #$base ="http://tombo.sourceforge.jp";
4 $pjhome="http://sourceforge.jp/projects/tombo";
5
6 $menufile = "menu.txt";
7 $topfile = "title.txt";
8 $headerfile = "header.txt";
9
10
11
12 if ($#ARGV != 2 || !-d $ARGV[0] || !-d $ARGV[1]) {
13 print "Usage : pagegen.pl <TMPLDIR> <OUTDIR> <BASE>\n";
14 exit 1;
15 }
16
17 $srcdir = $ARGV[0];
18 $dstdir = $ARGV[1];
19 $base = $ARGV[2];
20
21 opendir(DIR_S, $srcdir) || die;
22 while($file = readdir(DIR_S)) {
23 next unless ($file =~ /\.tmpl/);
24 pagegen($file);
25 }
26 closedir(DIR_S);
27
28 exit 0;
29
30 sub pagegen() {
31 my ($file) = @_;
32
33 my ($outfile) = $file;
34
35 $outfile =~ s/\.tmpl$/\.html/;
36
37 open(OUT, ">$dstdir/$outfile") || die "$dstdir/$outfile : $!";
38
39 open(BODY, "$srcdir/$file") || die;
40 while(<BODY>) {
41 chop;
42 if (/^<!-- TOP -->$/) {
43 include_top(OUT);
44 next;
45 }
46 if (/^<!-- MENU -->$/) {
47 include_menu(OUT);
48 next;
49 }
50 if (/^<!-- HEADER -->$/) {
51 include_header(OUT);
52 next;
53 }
54 if (/^<!-- FOOTER +(\$.+\$) +-->$/) {
55 include_footer(OUT, $1);
56 next;
57 }
58 print OUT "$_\n";
59 }
60 close(BODY);
61 close(OUT);
62 }
63
64 sub include_top()
65 {
66 my ($stream) = @_;
67 open(TOP, "$srcdir/$topfile") || die;
68 while(<TOP>) {
69 print $stream $_;
70 }
71 close(TOP);
72 }
73
74 sub include_header()
75 {
76 my($stream) = @_;
77 open(HEADER, "$srcdir/$headerfile") || die;
78 while(<HEADER>) {
79 print $stream $_;
80 }
81 close(HEADER);
82 }
83
84 sub include_menu()
85 {
86 my($stream) = @_;
87 print $stream '<table width="100%"><tr valign="top">'."\n";
88 print $stream '<td width="20%" bgcolor="#FAF0E6"'."\n";
89
90 open(MENU, "$srcdir/$menufile") || die;
91 while(<MENU>) {
92 s/_PJHOME_/$pjhome/g;
93 s/_BASE_/$base/g;
94 print $stream $_;
95 }
96 close(MENU);
97
98 print $stream '</td>'."\n";
99 print $stream '<td width="2%">'."\n";
100 print $stream '<td width="78%" bgcolor="#FFFFFF">'."\n";
101 }
102
103 sub include_footer()
104 {
105 my($stream, $lastupd) = @_;
106 print $stream <<"HTML_FOOTER";
107 </td>
108 </tr>
109 </table>
110 <hr>
111 <table width="100%">
112 Copyright (C) 2000-2003, Tomohisa Hirami All rights reserved.<br>
113 Copyright (C) 2004, TOMBO maintainers All rights reserved.<br>
114 Last-Update: $lastupd
115 </table>
116 </body>
117 </html>
118 HTML_FOOTER
119 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26