0 ORDER BY ts DESC LIMIT 200)
AND +num > 0
GROUP BY tid
ORDER BY ds ASC
EOS
}
sub topics_i { pop @{$_[0]->{msgs}} }
sub topics_atom { # GET /$INBOX_NAME/topics_(new|active).atom
my ($ctx) = @_;
require PublicInbox::WwwAtomStream;
my ($hdr, $smsg, $val);
PublicInbox::WwwAtomStream->response($ctx, \&topics_i);
}
sub topics_html { # GET /$INBOX_NAME/topics_(new|active).html
my ($ctx) = @_;
require PublicInbox::WwwStream;
my $buf = '';
$ctx->{-html_more_links} = qq{\n- recent:[subjects (threaded)|};
if ($ctx->{topic_category} eq 'new') {
$ctx->{-html_more_links} .= qq{topics (new)|topics (active)]};
} else { # topic_category eq "active" - topics with recent replies
$ctx->{-html_more_links} .= qq{topics (new)|topics (active)]};
}
# can't use SQL to filter references since our schema wasn't designed
# for it, but our SQL sorts by ascending time to favor top-level
# messages while our final result (post-references filter) favors
# recent messages
my $msgs = delete $ctx->{msgs};
add_topic_html($buf, pop @$msgs) while scalar(@$msgs);
$buf .= '
';
PublicInbox::WwwStream::html_oneshot($ctx, 200, $buf);
}
sub response {
my ($ctx, $ibx_name, $category, $type) = @_;
my ($ret, $over);
$ret = PublicInbox::WWW::invalid_inbox($ctx, $ibx_name) and return $ret;
$over = $ctx->{ibx}->over or
return PublicInbox::WWW::need($ctx, 'Overview', './');
$ctx->{msgs} = $category eq 'new' ? topics_new($over) :
topics_active($over);
$ctx->{topic_category} = $category;
$type eq 'atom' ? topics_atom($ctx) : topics_html($ctx);
}
1;