Compare commits

..

2 Commits

Author SHA1 Message Date
Peter J. Holzer a157f9e8e4 Optionally decode title 2024-07-19 09:30:27 +02:00
Peter J. Holzer 12db194723 Port to Perl 5.32 2021-08-29 09:24:59 +02:00
2 changed files with 16 additions and 3 deletions

View File

@ -21,10 +21,12 @@ use Try::Tiny;
use Cache::Memcached;
use Encode qw(decode_utf8);
use HTML::Entities;
use HTTP::Date;
use XML::Atom::Client;
use XML::RAI;
with 'MooseX::Log::Log4perl';
has 'id' => (
@ -116,10 +118,16 @@ sub update {
$issued = $guess_issued;
}
my $title = $item->title;
$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(?, ?, ?, ?, ?, ?)",
{},
$item->title, $item->link, $item->content, $issued, $now, $self->{id}
$title, $item->link, $item->content, $issued, $now, $self->{id}
);
$self->invalidate_item_info;
}
@ -135,7 +143,7 @@ sub update {
$atomfeed = $api->getFeed($self->{url});
} catch {
$self->log->error("error fetching $self->{url}: $@");
}
};
if ($atomfeed) {
my @items = $atomfeed->entries;
for my $item (@items) {

View File

@ -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 read(item_id integer, username varchar, foreign key (item_id) references items(id));
CREATE INDEX on items(link);