Compare commits
2 Commits
41380bb04f
...
a157f9e8e4
Author | SHA1 | Date |
---|---|---|
Peter J. Holzer | a157f9e8e4 | |
Peter J. Holzer | 12db194723 |
|
@ -21,10 +21,12 @@ use Try::Tiny;
|
||||||
|
|
||||||
use Cache::Memcached;
|
use Cache::Memcached;
|
||||||
use Encode qw(decode_utf8);
|
use Encode qw(decode_utf8);
|
||||||
|
use HTML::Entities;
|
||||||
use HTTP::Date;
|
use HTTP::Date;
|
||||||
use XML::Atom::Client;
|
use XML::Atom::Client;
|
||||||
use XML::RAI;
|
use XML::RAI;
|
||||||
|
|
||||||
|
|
||||||
with 'MooseX::Log::Log4perl';
|
with 'MooseX::Log::Log4perl';
|
||||||
|
|
||||||
has 'id' => (
|
has 'id' => (
|
||||||
|
@ -116,10 +118,16 @@ sub update {
|
||||||
$issued = $guess_issued;
|
$issued = $guess_issued;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $title = $item->title;
|
||||||
$self->log->info("item " . $item->link . " new");
|
$self->log->info("item " . $item->link . " new");
|
||||||
|
if ($self->{decode_title}) {
|
||||||
|
$self->log->debug("decoding title $title");
|
||||||
|
$title = decode_entities($title);
|
||||||
|
$self->log->debug("decoded title $title");
|
||||||
|
}
|
||||||
$dbh->do("insert into items(title, link, content, issued, seen, feed_id) values(?, ?, ?, ?, ?, ?)",
|
$dbh->do("insert into items(title, link, content, issued, seen, feed_id) values(?, ?, ?, ?, ?, ?)",
|
||||||
{},
|
{},
|
||||||
$item->title, $item->link, $item->content, $issued, $now, $self->{id}
|
$title, $item->link, $item->content, $issued, $now, $self->{id}
|
||||||
);
|
);
|
||||||
$self->invalidate_item_info;
|
$self->invalidate_item_info;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +143,7 @@ sub update {
|
||||||
$atomfeed = $api->getFeed($self->{url});
|
$atomfeed = $api->getFeed($self->{url});
|
||||||
} catch {
|
} catch {
|
||||||
$self->log->error("error fetching $self->{url}: $@");
|
$self->log->error("error fetching $self->{url}: $@");
|
||||||
}
|
};
|
||||||
if ($atomfeed) {
|
if ($atomfeed) {
|
||||||
my @items = $atomfeed->entries;
|
my @items = $atomfeed->entries;
|
||||||
for my $item (@items) {
|
for my $item (@items) {
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
CREATE TABLE feeds (id serial primary key, url varchar, active boolean, last_update int, title varchar, type varchar, allow_img boolean, expire int, lang varchar);
|
CREATE TABLE feeds (
|
||||||
|
id serial primary key, url varchar, active boolean,
|
||||||
|
last_update int, title varchar, type varchar, allow_img boolean,
|
||||||
|
expire int, lang varchar,
|
||||||
|
decode_title boolean
|
||||||
|
);
|
||||||
CREATE TABLE items (id serial primary key, title varchar, link varchar, content varchar, issued int, seen int, feed_id integer, old int);
|
CREATE TABLE items (id serial primary key, title varchar, link varchar, content varchar, issued int, seen int, feed_id integer, old int);
|
||||||
CREATE TABLE read(item_id integer, username varchar, foreign key (item_id) references items(id));
|
CREATE TABLE read(item_id integer, username varchar, foreign key (item_id) references items(id));
|
||||||
CREATE INDEX on items(link);
|
CREATE INDEX on items(link);
|
||||||
|
|
Loading…
Reference in New Issue