head 1.2; access; symbols; locks ploi:1.2; strict; comment @# @;1.2 date 2002.08.20.15.24.21; author ploi; state Exp; branches; next 1.1;
1.1 date 2002.08.20.15.04.05; author ploi; state Exp; branches; next ;
desc @Script to convert user doc files to html files and move them to the www directory @
1.2 log @consolidated html code to subroutines filtered bak directory @ text @#!/usr/bin/perl # $Id$ # Nasty hack to convert online docs to webpages # by Tyr # first version: 15 Aug 2002 # this script really needs to be cleaned up # TODO: # - consolidate here docs to single subroutine Done 20 Aug 2002 # - filter out the 'bak' directory Done 20 Aug 2002 # # - rewrite to allow dynamic update by passing arg
use File::Find; use File::Basename;
sub convert_file { #print $File::Find::name, -d && '/', "\n"; if (-d $File::Find::name) { &handle_dir($File::Find::name); return; } return if ($File::Find::name =~ /pl$/); open FILE, $File::Find::name or die "Can't open file: $!\n"; $name = basename($File::Find::name); open OUT, ">/home/ploi/www/docs/$name.html" or die "Can't open to write: $!\n"; &start_html($name); while (
) { See Also: if(//){ See Also: s/?//; s/[' .]//g; @@words = split /[,]/; for $word (@@words) { print OUT " $word"; } } elsif (/^$/) { print OUT " "; } else { print OUT; } } &end_html; close OUT; }
sub handle_dir { $dir = shift; opendir DIR, $dir or die "Can't opendir $dir: $!\n"; @@allfiles = grep !/^\.|bak/, readdir DIR; closedir DIR; $name = basename($File::Find::name); open OUT, ">/home/ploi/www/docs/$name.html" or die "Can't open to write: $!\n"; &start_html($dir); foreach $file (@@allfiles) { print OUT "$file
"; } &end_html; close OUT; }sub all_names { if (-f $File::Find::name) {push @@names, basename($File::Find::name);} }
sub print_all{ open OUT, ">/home/ploi/www/docs/all.html" or die "Can't open to write: $!\n"; &start_html; print OUT "
\n
\n"; &end_html; close OUT; }"; @@snames = sort @@names; foreach $name (@@snames) { next if $name =~ /\./; print OUT " $name"; $i++; if ($i ==5 ){ print OUT "\n "; $i = 0; } } print OUT " sub start_html { my $page = ""; if (@@_) { $page = shift; } else { $page = "all"; } print OUT <<"EOF";
$page Player documentation for Frontier
Sections: all basic communication race manipulation other
EOF }EOF }sub end_html { print OUT <<"EOF";
my @@names = ""; find (\&all_names, ('/home/ploi/mud/lib/doc/helpdir/')); &print_all; find (\&convert_file, ('/home/ploi/mud/lib/doc/helpdir/')); @
1.1 log @Initial revision @ text @d2 1 a2 1
d8 3 a10 1 # - consolidate here docs to single subroutine a11 1 # - filter out the 'bak' directory d26 13 a38 26 print OUT <<"EOF";
$name Player documentation for Frontier
Sections: all basic communication race manipulation other
EOF while (EOF close OUT; a46 1 #print "$dir\n"; d48 1 a48 1 @@allfiles = grep !/^\./, readdir DIR; d52 1 a52 19 print OUT <<"EOF";) { See Also: if(//){ See Also: s/?//; s/[' .]//g; @@words = split /[,]/; for $word (@@words) { print OUT " $word"; a39 4 } elsif (/^$/) { print OUT " "; } else { print OUT; d41 2 a42 7 } print OUT <<"EOF";
$dir Player documentation for Frontier
Sections: all basic communication race manipulation other
EOF a53 1EOF close OUT; d65 17 d83 8 a90 2 open OUT, ">/home/ploi/www/docs/all.html" or die "Can't open to write: $!\n"; print OUT <<"EOF"; d93 1 a93 1d55 3 a57 7 } print OUT <<"EOF";
all a107 2a116 1 close OUT; @
a108 9 @@snames = sort @@names; foreach $name (@@snames) { next if $name =~ /\./; print OUT " $name"; $i++; if ($i ==5 ){ print OUT "\n "; $i = 0; } d110 3 a112 2 print OUT <<"EOF";