#!/usr/bin/perl -w # # use syntax to include contents of in # output file in output dierctory. # # Usage: formhtml filename1 ... filenameN # # last revision aug 99 # use strict; #use Time::gmtime; ###################################################################### # variables my $navfile='nav2.html'; my $counter; my $indextxt; my $file; my $fileout; my $OUTDIR = $ENV{HOME}.'/html/upload/ftm/'; my $font = 'Arial,Helvetica'; my $include; my $maincolor = '#303030'; my $navcolor = '#2f2f4f'; my $headcolor = '#2f4f4f'; my $rest; my $stats; my $h2; my @h2; my @tmp; ###################################################################### # blocks of text my $head = ' '; my $body = ' '; my $Xbody = ''; my $tail = '

bestviewed with any browser created with emacs graphics by the gimp

'; my $Xtail = ''; ###################################################################### # start processing for (@ARGV) { next if $_ eq $navfile; $file = $_; $fileout = $OUTDIR . $file; open(INPUT,"<$file"); open(OUTPUT,">$fileout"); select(OUTPUT); #make this standard output while () { # global stuff $_ = &global($_); ###################################################################### # structural stuff, and start printing output # header stuff: if(//i) { print $head; } # replace plain tag with standard, and any top-of-the-page stuff elsif(//) { print $body; } # if ($file !~ /index\.html|links\.html/) { # print $Xbody; } #colourful headings elsif(($h2) = /

(.*)/) { while($h2 !~ /<\/h2>/) { chomp($h2); $h2 .= ; } $h2 =~ s/<\/h2>//i; @h2 = split /\s*&;\s*/, $h2; $h2 = shift @h2; $h2 =~ tr/[a-z]/[A-Z]/; print '' . '
' . "$h2" . '
'; while ($#h2>0) { $tmp[0] = shift @h2; $tmp[1] = shift @h2; print "[ $tmp[1] ]"; } print '
'; } # hidden commands/comments elsif ( //; next if $entry =~ /<\!--/; ($line,$text,$desc) = split /\n/, $entry; ($ftm,$country,$link,$date) = split / +/, $line.' .'; if ($date =~ /a/) { $date =~ s#a=(.*)#$1#i; } elsif ($date =~ /u/) { $date =~ s#u=(.*)#$1#i; } else { $date = ''; } if ($ftm =~ /ftm/) { $ftm = 'FTM'; } elsif ($ftm =~ /mtf/) { $ftm = 'MTF'; } elsif ($ftm =~ /so/) { $ftm = 'SO' } else { $ftm = 'N/A'; } $country = ''.
	  $country.''; $link = ''.$text.''; print "$country $ftm     $link     $date
"; print "$desc\n

\n"; } } ###################################################################### sub commands { # included files if(($include) = /^<\!-- INCLUDE (.*) -->/) { &include($include); } elsif( /<\!-- LATEST -->/ ) { &latest(); } # indexes elsif( /<\!-- START INDEX -->/ ) { $counter=1; #initialise counter &include("java.js"); print "

    \n"; while () { &latest() if //; last if /<\!-- END INDEX -->/; $indextxt = 'onMouseOver="oneon(i'. $counter.')" onMouseOut="oneoff(i'.$counter.')">'. ':'; s#<(a href.*)>(.*)#<$1$indextxt$2#gi && $counter++; $_ = &global($_); print; } print "<\/ul>\n"; } elsif( /<\!--LINKS-->/ ) { &links; } # remove other commented stuff to make pages smaller, and allow me to place # draft text on the local file. else { until( /-->/ ) { $_ .= ' '.; } if (! /-->/) { $_ .= ' ' . ; } s///sg; if (/\S/) { print; } } } ###################################################################### sub moddate { my $file=shift; my $mtime=(stat($file))[9]; my ($sec, $min, $hr, $day, $month, $yr, $wdy, $ydy, $isdst) = gmtime($mtime); my @months = ("January","February","March","April","May","June", "July", "August", "September", "October", "November", "December"); my $datestr = join(' ',$day,$months[$month],$yr+1900); return($datestr); } sub shift2 { my @tmp = splice(@{$_[0]},0,2); $tmp[0] =~ s/ +$//; $tmp[0] =~ s/^ +//; $tmp[1] =~ s/ +$//; $tmp[1] =~ s/^ +//; return @tmp; } sub latest { my $line; my $count=0; my $dfile=$ENV{HOME}.'/html/ftm/diary'; open(LATEST,"<$dfile") or die "can't open $dfile: $!\n"; while($line=) { if($line=~/\d\d\.\d\d\.\d\d/) { $count++; last if $count>5; chomp($line); print "$line - "; } elsif( $line =~ /^\s*$/ ) { print "

    \n"; } else { print $line; } } print '

    Read more...

    '; }