#!/usr/bin/perl -w # vim: set sw=4 ts=4 si et ic ruler nowrapscan nowrap: # Copyright: Guido Socher # use strict; use vars qw($opt_o $opt_h); use Getopt::Std; sub help(); # getopts("ho:")||die "ERROR: No such option. -h for help\n"; help() if ($opt_h); my $imgdir = "../../common/images"; my $lang="en"; my %intdat=( 'en'=>{'chset'=>"iso-8859-1",'abstract'=>'Abstract'}, ); my $icon="$imgdir/dir_list_file.gif"; my $alt; my $ver="1.0"; my $dir="."; my $type; my @files; my $outfile ="index.shtml"; # delete $ENV{'IFS'}; delete $ENV{'CDPATH'}; delete $ENV{'ENV'}; delete $ENV{'BASH_ENV'}; $ENV{'PATH'}="/bin:/usr/bin"; # $outfile ="$opt_o" if ($opt_o); if ($ARGV[0]){ $dir=$ARGV[0]; $dir=~s/\/$//; $outfile="$dir/$outfile"; } # opendir(DIR,"$dir")||die "ERROR: can not read $dir\n"; @files=readdir(DIR); closedir DIR; my $issuename; if ($dir eq "."){ $issuename=`pwd`; }else{ $issuename=$dir; } $issuename=~s/^.*\///; # open (OUT,">$outfile")||die "ERROR: can not write to $outfile\n"; # print OUT "LinuxFocus $issuename\n"; print OUT "\n"; print OUT "\n"; print OUT "\n"; print OUT "

LinuxFocus $issuename

\n"; print OUT "\n"; foreach (reverse sort @files){ next if (/index/o); next if ($_ eq "."); next if ($_ eq ".."); next if ($_ eq "RCS"); if (-f "$dir/$_"){ next unless(/article\d+\.s?html/); $icon="$imgdir/dir_list_file.gif"; $type = "file"; $alt = "\"file\""; $type = "html file" if (/html$/); if (/article\d+\.s?html/){ $alt = "\"article $_\""; $type = "Linuxfocus article:
"; my $tmp=`grep \"=LF=TITLE_\" \"$dir/$_\"`; $tmp=~s/=LF=TITLE_://; $tmp=~s/\s+/ /g; $type .="$tmp"; $icon="$imgdir/dir_list_tux.gif"; } } print OUT "\n"; } $icon="$imgdir/dir_list_lftux.jpg"; $alt="\"LF home\""; print OUT "\n"; print OUT "
$alt $_ $type
$alt <-- LF Home Go to the front page of LinuxFocus
\n"; close OUT; # #------------- # sub help(){ print "webls -- genrate an article index file for the files in of a linuxfocus issue USAGE: webls [-h] [-o index.html] [directory] The output is written by default to index.shtml but may be overwritten with option -o. This program shall be used form October 2004 onwards to generate an index for available articles in a given month. There will be no more editorial everything goes to the front page therefore a new index.shtml file is needed for the directory where the articles are stored. did already exist. OPTIONS: -h this help -o write to a different html file (not index.shtml) \n"; exit 0; } __END__