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.4 - (hide annotations) (download) (as text)
Tue Apr 27 14:25:17 2004 UTC (19 years, 11 months ago) by hirami
Branch: MAIN
CVS Tags: V20040427, V20040526
Changes since 1.3: +6 -0 lines
File MIME type: text/x-perl
for releasing TOMBO 1.8

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

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