}
sub latest {
- my ($self, $limit) = @_;
+ my $self = shift;
+ my $args = {@_};
my $c = $self->c;
my $user = $c->stash('user');
- $limit ||= $c->_get_config("item_per_page", 10);
+ my $limit = $args->{limit} || $c->_get_config("item_per_page", 10);
my $show_future = $user->{is_admin} ? 1 : 0;
my $show_nonpublic = $user->{is_admin} ? 1 : 0;
package Newslash::Web::Controller::Rss;
use Mojo::Base 'Newslash::Web::Controller';
use Mojo::Util qw(dumper);
+use List::Util qw(any);
use DateTime;
use DateTime::Format::MySQL;
use Newslash::Util::Items;
use constant CACHE_SEC => 30;
-
+use constant SUB_SECTIONS => qw(
+ apple askslashdot developers hardware idle interview
+ it linux mobile opensource review science security slash yro
+ );
sub timeline {
my $c = shift;
my $type = $c->stash("rss_type") || "";
limit => $limit,
order_by => {create_time => 'desc'},
);
+ } elsif (any { $type eq $_} (SUB_SECTIONS)) {
+ # get tid
+ my $topic = $c->model("topics")->select(keyword => $type);
+ my $stories = $c->ezcache->model('stories', { expire => CACHE_SEC });
+ $items = $stories->select(hide_future => 1,
+ public_only => 1,
+ limit => $limit,
+ tid => $topic->{tid},
+ order_by => {create_time => 'desc'},
+ );
} else {
+ # select by tag
$c->rendered(404);
return;
}