#!/usr/bin/perl -w
#makes a javascriptfile with one function in it: fortuneOfTheDay
#fortune command is executed and resuls end up in that function...

open(FORTUNE,"/c/bin/fortune |") || die "$!";

print "function fortuneOfTheDay() {\n";
print "document.write(\"\"\n";
while(<FORTUNE>) {
  chomp;
  s/\\/\\\\/g;
  s/\"/\\\"/g;
  print "  + \"".$_."\\n\"\n"; 
}
print "  )\;\n}";

close(FORTUNE);

#!/usr/bin/perl -w
#
# This scrip creates a primitive photo album from given photos.
# Few pointers...
# MAKE clean directory for photo album an GO there
# MAKE "photos" directory (or something) and move photos there
#  (and nothing else)
# MAKE $thumbsdir directory 
# RUN this script: thisscript.pl photos/*
#
# The script does following things:
#  makes thumbnails ($size) using 'convert' to the $thumbsdir
#  makes index.html which has thumbnails with links to all photos(rundir)
#  makes individual html files for each photo with prev/next links(rundir)
# Note that ANY existing old thumb or html files ARE OVERWRITTEN

$thumbsdir="thumbs";
$size="120x120";
$title="Photo Album";
$rowsize=5;

#make the terminology tables and convert thumbnails
for($i=0;$i<=$#ARGV;$i++) {
  $s=$ARGV[$i];
  $s =~ s/.*\///; $photo[$i]=$s;
  @a=split(/\./,$s);
  $t="";
  for($j=0;$j<=$#a;$j++) {
    $htmlfile[$i]=$t."html" if ($j==$#a);
    $t[$i]=$t."tn." if ($j==$#a);
    $t=$t.$a[$j];
    $t=$t."." if ($j!=$#a);
  }
  $thumbfile[$i]=$thumbsdir."/".$t;
  `convert -size $size $ARGV[$i] -resize $size $thumbfile[$i]`; 
}

#make the index.html
open(FILE,">index.html");
print FILE "<html><head><title>$title</title></head>\n<body>\n";
print FILE "<h1>$title</h1><hr>";
print FILE "\n<p align=\"center\"><table>";
$r=0;
for($i=0;$i<=$#ARGV;$i++) {
  if ($r==0) { print FILE "<tr>\n"; $r=$rowsize; }
  print FILE "<td align=\"center\"><a href=\"$htmlfile[$i]\">";
  print FILE "<img src=\"$thumbfile[$i]\" alt=\"$ARGV[$i]\"></a>";
  print FILE "<br>$photo[$i]</td>\n";
  $r--;
  print FILE "</tr>\n" if (($r==0)||($#ARGV==$i));
}
print FILE "</p></table></body></html>\n";
close FILE;

#make the other html files
for($i=0;$i<=$#ARGV;$i++) {
  open(FILE,">$htmlfile[$i]");
  print FILE "<html><head><title>$title - $photo[$i]</title></head>\n<body>\n";
  print FILE "<a href=\"index.html\">index</a>:\n";
  print FILE "<a href=\"$htmlfile[$i-1]\">prev</a>\n" if ($i>0);
  print FILE "<a href=\"$htmlfile[$i+1]\">next</a>\n" if ($i<$#ARGV);
  print FILE "<img src=\"$ARGV[$i]\" alt=\"$ARGV[$i]\">\n";
  print FILE "</body></html>\n";
  close FILE;
}

#!/usr/bin/perl -w
#This scripst makes a html page, which holds
#given files (scripts) inside <pre></pre> tags...
#last parameter is the title of html-page
#...and yes... this produces a warning...
#usage: script.pl [file1] [file2] ... title

$title = $ARGV[$#ARGV];

print "<html>\n";
print "<head>\n";
print "<title>$title</title>\n";
print "</head>\n";
print "<body>\n";

$first=1;
$history="";

while (<>) {
    print $history;
    if (m/^#!/) {
	if ($first) { $first=0; print "<pre>\n"; } 
	else {
	    print "</pre>\n";
	    print "<hr>\n";
	    print "<pre>\n";
	}
    }
    s/&/&#38/g;
    s/</&lt\;/g;
    s/>/&gt\;/g;
    $history=$_;	 
}

print "</pre>\n";
print "</body>\n";
print "</html>\n";