2 use CGI::Fast qw/:cgi/;
5 use POSIX qw/strftime/;
8 my $baseurl = Blerg::Database::constant('BASEURL');
19 print header(-type => 'text/html',
20 -status => '404 Not Found');
23 <h1>404 Not Found</h1>
29 my ($type, $name, @items) = @_;
32 if ($type eq 'user') {
33 $title = "${name}'s blërg";
34 $link = "${baseurl}#$name";
35 } elsif ($type eq 'tag' || $type eq 'ref') {
39 $link = "${baseurl}#/$type/$basename";
43 <?xml version="1.0" encoding="utf-8" ?>
48 <description>Textual vomit</description>
52 my $data = xml_escape($i->{data});
53 my $post_time = strftime("%a, %d %b %Y %H:%M:%S %Z", localtime($i->{timestamp}));
54 my $author = defined $i->{author} ? $i->{author} : $name;
57 <pubDate>$post_time</pubDate>
58 <guid>${baseurl}get/$author/$i->{record}</guid>
59 <description>$data</description>
71 while (my $q = new CGI::Fast) {
72 my @path = split('/', $ENV{PATH_INFO});
76 # Assume this is a username; redirect to /user/<username>
77 my $username = $path[0];
78 my $b = Blerg::Database->open_existing($username);
83 print header(-type => 'application/rss+xml',
85 -status => '301 Moved Permanently',
86 -location => "${baseurl}rss/user/$username");
87 # And present the content in case their client is broken
89 record => '?failed_redirect',
91 data => qq{Your RSS aggregator is dumb and isn't following 301 redirects. Please manually redirect it here: ${baseurl}rss/user/$username}
93 print_rss(user => $username, $i);
94 } elsif ($path[0] eq 'user') {
95 my $username = $path[1];
96 my $b = Blerg::Database->open_existing($username);
101 print header(-type => 'application/rss+xml');
102 my $n = $b->record_count - 1;
103 my @list = reverse map {
106 data => $b->fetch($_),
107 timestamp => $b->timestamp($_),
109 } ($n > 50 ? $n - 50 : 0)..$n;
111 print_rss(user => $username, @list);
112 } elsif ($path[0] eq 'tag') {
115 my @list = Blerg::Database::tag_list($tag, 0, -1);
117 my $b = Blerg::Database->open_existing($_->{author});
118 my $data = $b->fetch($_->{record});
119 my $timestamp = $b->timestamp($_->{record});
122 author => $_->{author},
123 record => $_->{record},
125 timestamp => $timestamp,
128 print header(-type => 'application/rss+xml');
129 if (substr($tag, 0, 1) eq '#') {
130 print_rss(tag => $tag, @list);
132 print_rss(ref => $tag, @list);
134 } elsif ($path[0] eq 'ref') {
135 } elsif ($path[0] eq 'feed') {