3 # zeitungen-rdf - Build RDF file for www.zeitungsliste.de
4 # Copyright (c) 2008 Joey Schulze <joey@infodrom.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
27 my %cfg = ('home' => 'http://www.zeitungsliste.de/',
28 'webdir' => '/var/www/www.zeitungsliste.de');
30 my $dsn = 'dbi:Pg:dbname=zlist';
32 my $dbh = DBI->connect('dbi:Pg:dbname=zlist') or die "Can't connect to database\n";
36 my $query = q{SELECT id,name,description FROM zeitungen
37 WHERE deleted IS false AND changed > now() - interval'3 months'
38 ORDER BY changed DESC};
40 my $sth = $dbh->prepare ($query) or die "Can't prepare Query: $DBI::errstr\n";
41 my $rv = $sth->execute or die "Can't execute query: $DBI::errstr\n";
44 push @ret, [$_->{id},$_->{name},$_->{description}] while ($_ = $sth->fetchrow_hashref);
52 my $papers = fetchnew();
54 my $rss = new XML::RSS (version => '1.0', encoding => 'utf-8');
56 title => 'Zeitungsliste',
57 description => 'Zeitungen im Netz',
61 foreach my $paper (@$papers) {
62 # printf "%d: %s\n%s\n", $paper->[0], $paper->[1], $paper->[2];
66 description => $paper->[2],
67 link => sprintf('%szeitung/%d.html', $cfg{'home'}, $paper->[0]),
72 my @new = split (/\n/, $rss->as_string);
77 my @diff = Algorithm::Diff::diff (\@old, \@new);
78 $rss->save ($fname) if (@diff);
84 rdf_new($cfg{webdir} . '/zeitungen.rdf');