Develop and Download Open Source Software

Browse CVS Repository

Annotation of /tombo/htdocs/pagegen.pl

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


Revision 1.3 - (hide annotations) (download) (as text)
Thu Mar 18 13:46:03 2004 UTC (20 years ago) by hirami
Branch: MAIN
CVS Tags: V20040318
Changes since 1.2: +1 -0 lines
File MIME type: text/x-perl
Release Tombo 1.8 beta 1

1 hirami 1.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 hirami 1.2 Copyright (C) 2000-2003, Tomohisa Hirami All rights reserved.<br>
106 hirami 1.3 Copyright (C) 2004, TOMBO maintainers All rights reserved.<br>
107 hirami 1.1 Last-Update: $lastupd
108     </table>
109     </body>
110     </html>
111     HTML_FOOTER
112     }

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