X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=last.pl;h=3576ba9a30744991165e46c9440c9bf238874ee0;hb=HEAD;hp=99ee2f5ac082cec37afc8165e99f241e93063d59;hpb=07ea12f5301c50d4c6595be5cba8544658ddc7f6;p=webpdf diff --git a/last.pl b/last.pl index 99ee2f5..3576ba9 100755 --- a/last.pl +++ b/last.pl @@ -14,6 +14,18 @@ if ($real_show_last > $pdfweb::config::show_last) { $real_show_last = $pdfweb::config::show_last; } +# This is probably the simplest place to clean up files that we no longer +# need having around. +for my $t (@thumbnails[$pdfweb::config::show_last..$#thumbnails]) { + if (-M $t > $pdfweb::config::minimum_age) { + (my $base = $t) =~ s/\.png$//; + my @to_delete = <$base*>; + + warn "Deleting " . join(', ', @to_delete); + unlink @to_delete; + } +} + # Sorry, no HTML templating. I didn't want to pull in yet another # dependency :-) @@ -46,9 +58,13 @@ for my $t (@thumbnails[0..$pdfweb::config::show_last-1]) { close DESC; if (length($desc) > 30) { - $desc = substr($desc, 0, 30) . " ..."; + # Is this abuse? + $desc = HTML::Entities::encode_entities(substr($desc, 0, 30)) . " ..."; + } else { + $desc = HTML::Entities::encode_entities($desc); } - $desc = HTML::Entities::encode_entities($desc); my $time = (stat($t))[9]; my $date = POSIX::strftime("%Y-%m-%d %H:%M", localtime($time));