X-Git-Url: https://git.sesse.net/?p=webpdf;a=blobdiff_plain;f=last.pl;fp=last.pl;h=e668edfb799a4ab85a41a10dd19661e2531646b5;hp=0000000000000000000000000000000000000000;hb=b943073892273418899c8187f9055d7faede1a0d;hpb=07e40b2b0a31439e2697b08f27d51b2dea31b615 diff --git a/last.pl b/last.pl new file mode 100755 index 0000000..e668edf --- /dev/null +++ b/last.pl @@ -0,0 +1,74 @@ +#! /usr/bin/perl +use CGI; +use HTML::Entities; +use POSIX; +use strict; +use warnings; +require './config.pm'; + +my $num_last = 20; + +# Find the latest N PNG thumbnails. Somewhat ineffective, but I assume +# we'll get to that later :-) +my @thumbnails = (sort { -M $a <=> -M $b } <$pdfweb::config::outputdir/*.png>); +my $real_num_last = scalar @thumbnails; +if ($real_num_last > $num_last) { + $real_num_last = $num_last; +} + +# Sorry, no HTML templating. I didn't want to pull in yet another +# dependency :-) + +print <<"EOF"; +Content-type: text/html; charset=utf-8 + + + + + + PDF converter : sesse.net + + + + + + +

Last $real_num_last uploads

+ +

Back to the converter

+EOF + +for my $t (@thumbnails[0..$num_last-1]) { + (my $descname = $t) =~ s/\.png$/.desc/; + open DESC, "<$descname" + or next; + chomp (my $desc = ); + close DESC; + + if (length($desc) > 30) { + $desc = substr $desc, 0, 30; + } + $desc = HTML::Entities::encode_entities($desc); + + my $time = (stat($t))[9]; + my $date = POSIX::strftime("%Y-%m-%d %H:%M", localtime($time)); + $t =~ s#^.*/##; + (my $pdfname = $t) =~ s/\.png$//; + + print <<"EOF"; +
+

PDF thumbnail

+

$desc

+

$date

+
+EOF +} + +print <<"EOF"; + + + + +EOF