/rss.fcgi
#!/usr/bin/perl
use CGI::Fast qw/:cgi/;
use Vector::RSS;
use Vector::Post;
use Vector::Channel;
use strict;
REQUEST:
while (my $q = new CGI::Fast) {
my (undef, $channel, $thread) = split(m'/', $ENV{PATH_INFO});
print header(-type => 'application/rss+xml');
if ($channel) {
if ($thread) {
my $head = load Vector::Post $thread;
my @children = map { load Vector::Post $_ } $head->replies;
print Vector::RSS::generate_rss({
type => 'thread',
description => $head->{data},
channel => $channel,
post_id => $thread,
items => \@children,
});
} else {
my @posts = map { load Vector::Post $_ } Vector::Channel::list_all($channel);
print Vector::RSS::generate_rss({
type => 'channel',
description => "All posts from $channel",
channel => $channel,
items => \@posts,
});
}
} else {
# channel list
my @channels = map {
{
type => 'channel_item',
channel => Vector::Channel::name($_)
}
} Vector::Channel::list_channels;
print Vector::RSS::generate_rss({
type => 'channels',
channels => \@channels
});
}
}