#!/usr/bin/perl use strict; use warnings; use v5.14; use XML::RAI; use XML::Atom::Client; use DBI; use CGI; use Rss2Html::Scrubber; use Time::HiRes qw(time); use POSIX qw(strftime); $| = 1; my $q = CGI->new(); binmode STDOUT, ":encoding(UTF-8)"; my $feed_id = $q->param('id'); my $dbh = DBI->connect("dbi:SQLite:dbname=rss2html.sqlite", "", ""); $dbh->{sqlite_unicode} = 1; print "Content-Type: text/html; charset=utf-8\n"; print "Refresh: 600\n"; print "\n"; print "\n"; print "

RSS 2 HTML

\n"; print "

", strftime("%Y-%m-%d %H:%M:%S%z", localtime()), "

\n"; my $feed = $dbh->selectrow_hashref("select * from feeds where id=?", {}, $feed_id); print "\n"; print "", $q->escapeHTML($feed->{id}), "\n"; print "", $q->escapeHTML($feed->{title}), "\n"; print "", $q->escapeHTML($feed->{type}), "\n"; print "\n"; my $now = time(); my $seconds_per_week = 86400 * 7; my $start = $now - 4 * $seconds_per_week; my $items = $dbh->selectall_arrayref("select * from items where feed_id=? and issued >= ? order by issued", { Slice => {} }, $feed->{id}, $start, ); for my $item (@$items) { my $t = $item->{issued}; my $dt1 = $now - $t; my $dt2 = $dt1 % $seconds_per_week; $item->{dt2} = $dt2; } $items = [ sort { $a->{dt2} <=> $b->{dt2} } @$items ]; print "\n"; for my $item (@$items) { my $t = $now - $item->{dt2}; print"\n"; print"\n"; print"\n"; print"\n"; print"\n"; } print "
", $item->{dt2}, "", strftime("%a %H:%M:%S", localtime($t)), "", "", $q->escapeHTML($item->{title}), "", "
\n"; # vim: expandtab