#!/usr/bin/perl -w

use strict;
use CGI qw/:standard/;
my $cgi = new CGI;

my $file = $cgi->param('file');

# grab base date
$file =~ m/(.*).txt/;
my $date = $1;

my @images = <Images/$date/*.jpg>;
my @audio = <Audio/$date/*.mp3>;


print "Content-type: text/html\n\n";

print "<html><head>";


print <<EOD;
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-38045415-3', 'auto');
  ga('send', 'pageview');

</script>

EOD

print "</head><body>";

print "<!-- generated by a script Chucs wrote in 2 minutes in Jackson Hole,
WY -->";

open(INPUT, "<$file");
while (<INPUT>) {
	# add breaks...
	if (/^$/) {
		print "<br /><br />";
	}
	print;
}
close(INPUT);

print "<br />";

foreach (@images) {
	print "<img src='$_'><br /><br />";
}

print "<br />";

print "<h3>Sound Bites</h3> (amusing/short/dumb excerpts from dictaphone)<br /><br />";

foreach (@audio) {
	print "<a href='$_'>$_</a><br /><br />";
}



print "</body></html>";


