Develop and Download Open Source Software

Browse CVS Repository

Diff of /tombo/htdocs/pagegen.pl

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

revision 1.5 by hirami, Sat Jul 3 07:18:08 2004 UTC revision 1.6 by hirami, Sat Aug 28 12:23:08 2004 UTC
# Line 6  $pjhome="http://sourceforge.jp/projects/ Line 6  $pjhome="http://sourceforge.jp/projects/
6  $menufile = "menu.txt";  $menufile = "menu.txt";
7  $topfile = "title.txt";  $topfile = "title.txt";
8  $headerfile = "header.txt";  $headerfile = "header.txt";
9    $num_headlines = 5;
   
10    
11  if ($#ARGV != 2 || !-d $ARGV[0] || !-d $ARGV[1]) {  if ($#ARGV != 2 || !-d $ARGV[0] || !-d $ARGV[1]) {
12          print "Usage : pagegen.pl <TMPLDIR> <OUTDIR> <BASE>\n";          print "Usage : pagegen.pl <TMPLDIR> <OUTDIR> <BASE>\n";
# Line 24  while($file = readdir(DIR_S)) { Line 23  while($file = readdir(DIR_S)) {
23          pagegen($file);          pagegen($file);
24  }  }
25  closedir(DIR_S);  closedir(DIR_S);
   
26  exit 0;  exit 0;
27    
28  sub pagegen() {  sub pagegen() {
# Line 55  sub pagegen() { Line 53  sub pagegen() {
53                          include_footer(OUT, $1);                          include_footer(OUT, $1);
54                          next;                          next;
55                  }                  }
56                    if (/^<!-- HISTORY -->$/) {
57                            include_history(OUT);
58                    }
59                    if (/^<!-- HEADLINE -->$/) {
60                        include_headline(OUT);
61                    }
62                  print OUT "$_\n";                  print OUT "$_\n";
63          }          }
64          close(BODY);          close(BODY);
# Line 117  Last-Update: $lastupd Line 121  Last-Update: $lastupd
121  </html>  </html>
122  HTML_FOOTER  HTML_FOOTER
123  }  }
124    
125    sub include_headline()
126    {
127        my ($stream) = @_;
128        opendir(DIR, "$srcdir/news") || die;
129        my @l = sort({$b <=> $a } readdir(DIR));
130        closedir(DIR);
131    
132        my $f, $d, $t, $sec, $headline, $dum;
133        $i = 0;
134        foreach $f(@l) {
135            next if ($f eq "." || $f eq "..");
136            next unless ($f =~ /^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})\.txt$/);
137            last if ($i > $num_headlines);
138            $d = "$1/$2/$3";
139            $t = "$4:$5";
140            $sec = "$1$2$3$4$5";
141    
142            open(F, "$srcdir/news/$f") || die;
143    
144            $headline = <F>;
145            chop($headline);
146    
147            print $stream "  <li><a href=\"history.html#$sec\">$headline</a> ($d)</li>\n";
148    
149            close(F);
150            $i++;
151        }
152    }
153    
154    sub include_history()
155    {
156        my ($stream) = @_;
157        opendir(DIR, "$srcdir/news") || die;
158        my @l = sort( { $b <=> $a } readdir(DIR));
159        closedir(DIR);
160    
161        my $f, $d, $t, $sec, $headline, $dum;
162        foreach $f (@l) {
163            next if ($f eq "." || $f eq "..");
164            next unless ($f =~ /^([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})\.txt$/);
165            $d = "$1-$2-$3";
166            $t = "$4:$5";
167            $sec = "$1$2$3$4$5";
168    
169            open(F, "$srcdir/news/$f") || die;
170    
171            $headline = <F>;
172            chop($headline);
173    
174            $dum = <F>; # skip blank line
175    
176            print $stream "<a name=\"$sec\" />\n";
177            print $stream "<h3>$d $headline</h3>\n";
178            while(<F>) {
179                print $stream $_;
180            }
181            close(F);
182        }
183    
184    }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

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