Optionally decode title

This commit is contained in:
Peter J. Holzer 2024-07-19 09:30:27 +02:00
parent 12db194723
commit a157f9e8e4
2 changed files with 15 additions and 2 deletions

View File

@ -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;
} }

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 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);