1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#! /usr/bin/perl
#
# Last modification: Sun, 2 Feb 1997 01:39:23 +0200
#
# j_mkindex - Copyright (c) 1996 by Fabrizio Polacco <fpolacco@debian.org>.
# All rights reserved. This program is free software; you can redistribute it
# and/or modify it under the same terms as Perl itself.
# This script is intended to be used to build the debian package of the html
# on-line magazine Pluto Journal, but can be used to easily build also other
# online magazines.
# Usage: j_mkindex <journal-dir>
# the script executes in the source dir where it looks for a subdir .indexes
# which should contain the files index.{foot,head} and at least one file named
# idx_n??.{blind,full} (where ?? is a number in the range 00-99). It builds an
# index.html file in the current directory adding to index.head, the files
# idx_n??.{full|blind} and index.foot
sub copy_file
{
local( *IN ); ($IN) = @_; # my() can't use filehandles
open(IN, $IN) or die "Cannot open input file $IN\n";
print OUT <IN>;
close IN;
}
# script starts here
my $oldpwd = `pwd`;
my $index_dir = ".";
$index_dir = $ARGV[0] if scalar(@ARGV) == 1;
chdir $index_dir or die "Cannot chdir to $index_dir: $!\n";
die ".indexes dir doesn't exist\n" if ! -d "./.indexes";
die ".indexes/index.head doesn't exist\n" if ! -r "./.indexes/index.head";
die ".indexes/index.foot doesn't exist\n" if ! -r "./.indexes/index.foot";
open( OUT, "> index.html") or die "Cannot open output file index.html\n";
©_file(".indexes/index.head");
# can be very faster using readdir, but ... any need to?
for $j (reverse(('00','01','02','03','04','05','06','07','08','09', 10 .. 99 )))
{
if ( -r "./.indexes/idx_n${j}.full" )
{
©_file(".indexes/idx_n${j}.full");
}
elsif ( -r "./.indexes/idx_n${j}.blind" )
{
©_file(".indexes/idx_n${j}.blind");
}
}
©_file(".indexes/index.foot");
close OUT;
END { chdir $oldpwd; }
|