diff --git a/lib/Rss2Html/Feed.pm b/lib/Rss2Html/Feed.pm index a77d918..a1075f9 100644 --- a/lib/Rss2Html/Feed.pm +++ b/lib/Rss2Html/Feed.pm @@ -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; } diff --git a/rss2html.postgresql b/rss2html.postgresql index 732d809..48b2cd4 100644 --- a/rss2html.postgresql +++ b/rss2html.postgresql @@ -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);