]> git.sesse.net Git - webpdf/blob - last.pl
Move the ���show_last��� parameter part of config.pm.
[webpdf] / last.pl
1 #! /usr/bin/perl
2 use CGI;
3 use HTML::Entities;
4 use POSIX;
5 use strict;
6 use warnings;
7 require './config.pm';
8
9 # Find the latest N PNG thumbnails. Somewhat ineffective, but I assume 
10 # we'll get to that later :-)
11 my @thumbnails = (sort { -M $a <=> -M $b } <$pdfweb::config::outputdir/*.png>);
12 my $real_show_last = scalar @thumbnails;
13 if ($real_show_last > $pdfweb::config::show_last) {
14         $real_show_last = $pdfweb::config::show_last;
15 }
16
17 # Sorry, no HTML templating. I didn't want to pull in yet another
18 # dependency :-)
19
20 print <<"EOF";
21 Content-type: text/html; charset=utf-8
22
23 <?xml version="1.0" encoding="UTF-8" ?>
24 <!DOCTYPE
25   html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
26   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
27 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
28   <head>
29     <title>PDF converter : sesse.net</title>
30     <link rel="stylesheet" href="http://www.sesse.net/sesse.css" type="text/css" />
31     <link rel="stylesheet" href="pdfweb.css" type="text/css" />
32     <link rev="made" href="mailto:sgunderson\@bigfoot.com" />
33     <meta name="MSSmartTagsPreventParsing" content="TRUE" />
34   </head>
35   <body>
36     <h1>Last $real_show_last uploads</h1>
37     
38     <p><a href="http://pdf.sesse.net/">Back to the converter</a></p>
39 EOF
40
41 for my $t (@thumbnails[0..$pdfweb::config::show_last-1]) {
42         (my $descname = $t) =~ s/\.png$/.desc/;
43         open DESC, "<$descname"
44                 or next;
45         chomp (my $desc = <DESC>);
46         close DESC;
47
48         if (length($desc) > 30) {
49                 $desc = substr($desc, 0, 30) . " ...";
50         }
51         $desc = HTML::Entities::encode_entities($desc);
52
53         my $time = (stat($t))[9];
54         my $date = POSIX::strftime("%Y-%m-%d %H:%M", localtime($time));
55         $t =~ s#^.*/##;
56         (my $pdfname = $t) =~ s/\.png$//;
57
58         print <<"EOF";
59 <div class="pdfthumbnail">
60   <p class="thumb"><a href="output/$pdfname"><img src="output/$t" alt="PDF thumbnail" /></a></p>
61   <p class="desc">$desc</p>
62   <p class="date">$date</p>
63 </div>
64 EOF
65 }
66
67 print <<"EOF";
68
69     <p class="copyright">Web PDF converter, &copy; 2005 <a href="http://www.sesse.net/">Steinar H. Gunderson</a>.</p>
70   </body>
71 </html> 
72 EOF