Revert r147, as planned.
authorSteinar H. Gunderson <sesse@debian.org>
Fri, 22 Jun 2007 21:35:41 +0000 (23:35 +0200)
committerSteinar H. Gunderson <sesse@debian.org>
Fri, 22 Jun 2007 21:35:41 +0000 (23:35 +0200)
perl/Sesse/pr0n/Listing.pm
perl/Sesse/pr0n/Templates.pm
templates/default/listing.xml [deleted file]

index 0d63c6d004a25e3ffe9292154d6ce8f1dcfeccd5..02ac273cfac7e7a99157661d0cbdd83c0bcd9033 100644 (file)
@@ -16,27 +16,30 @@ sub handler {
                }
        }
 
-
+#      my $q = $dbh->prepare('SELECT t1.id,t1.date,t1.name FROM events t1 LEFT JOIN images t2 ON t1.id=t2.event WHERE t1.vhost=? GROUP BY t1.id,t1.date,t1.name ORDER BY COALESCE(MAX(t2.date),\'1970-01-01 00:00:00\'),t1.id') or
+#              dberror($r, "Couldn't list events");
        my $q = $dbh->prepare('SELECT event,date,name FROM events e JOIN last_picture_cache c USING (vhost,event) WHERE vhost=? ORDER BY last_picture DESC')
                or dberror($r, "Couldn't list events");
        $q->execute($r->get_server_name)
                or dberror($r, "Couldn't get events");
 
-       my @events = ();
+       $r->content_type('text/html; charset=utf-8');
+
+       Sesse::pr0n::Common::header($r, Sesse::pr0n::Templates::fetch_template($r, 'event-listing'));
+       $r->print("    <ul>\n");
+
        while (my $ref = $q->fetchrow_hashref()) {
                my $id = $ref->{'event'};
-               my $date = Encode::decode_utf8($ref->{'date'});
-               my $name = Encode::decode_utf8($ref->{'name'});
-       
-               push @events, {
-                       'a' => $name,
-                       'a/href' => "$id/",
-                       'date' => $date
-               };
+               my $date = HTML::Entities::encode_entities(Encode::decode_utf8($ref->{'date'}));
+               my $name = HTML::Entities::encode_entities(Encode::decode_utf8($ref->{'name'}));
+               
+               $r->print("      <li><a href=\"$id/\">$name</a> ($date)</li>\n");
        }
-       $q->finish();
 
-       Sesse::pr0n::Templates::output_page($r, 'listing.xml', { 'ul' => \@events });
+       $r->print("    </ul>\n");
+       Sesse::pr0n::Common::footer($r);
+
+       $q->finish();
        return Apache2::Const::OK;
 }
 
index 8aa0134650784b83c1243b9d91ee4d83db9e338c..8ff1e0353457360b2cc69dd3356610f23a8d4d79 100644 (file)
@@ -3,11 +3,6 @@ use strict;
 use warnings;
 
 use Sesse::pr0n::Common qw(error dberror);
-use XML::SAX::Expat;
-use XML::SAX::Writer;
-use XML::TemplateSAX::Buffer;
-use XML::TemplateSAX::Cleaner;
-use XML::TemplateSAX::Handler;
 
 BEGIN {
        use Exporter ();
@@ -89,36 +84,5 @@ sub print_template {
        $r->print($text);
 }
 
-sub output_page {
-       my ($r, $page, $params) = @_;
-
-       $r->content_type('text/html; charset=utf-8');
-       $params->{'version'} = $Sesse::pr0n::Common::VERSION;
-
-       # build up the XML chain
-       my $consumer = ModPerlConsumer->new($r);
-       my $writer = XML::SAX::Writer->new(Output => $consumer);
-       my $cleaner = XML::TemplateSAX::Cleaner->new(Handler => $writer);
-       my $filter = XML::TemplateSAX::Handler->new(Handler => $cleaner, Content => $params);
-       my $parser = XML::SAX::Expat->new(Handler => $filter);
-
-       # kick off the parsing
-       $parser->parse_string(fetch_template($r, $page));
-}
-
-# XML consumer for Apache2::Request
-package ModPerlConsumer;
-
-our @ISA = qw( XML::SAX::Writer::ConsumerInterface );
-sub new {
-       my ($base, $r) = @_;
-       return $base->SUPER::new($r);
-}
-
-sub output {
-       my ($self, $text) = @_;
-       $$self->print($text);
-}
-
 1;
 
diff --git a/templates/default/listing.xml b/templates/default/listing.xml
deleted file mode 100644 (file)
index 6ad6d76..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
-<!DOCTYPE
-  html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
-  "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:t="http://template.sesse.net/">
-  <head>
-    <title>Event listing</title>
-    <link rel="stylesheet" href="/pr0n.css" type="text/css" />
-  </head>
-
-  <body>
-    <h1>Event listing</h1>
-
-    <ul t:id="events">
-      <li><a /> (<t:date />)</li>
-    </ul>
-
-    <hr />
-    <p class="footer">
-      pr0n <t:version />, Copyright 2004-2007 <a href="http://www.sesse.net/">Steinar
-      H. Gunderson</a>. All images are copyright their respective owners; please see
-      the <a href="/faq.html" accesskey="5">FAQ</a> for more information.
-    </p>
-  </body>
-</html>