skip "mode is 'test'", 4 if ($t->app->mode eq 'test');
test_path("/tag/");
test_path("/tag/linux/");
+ test_path("/tag/linux/2");
test_path("/tag/linux/story/");
- test_path("/tag/linux/story/?page=2");
+ test_path("/tag/linux/story/2/");
}
# user
# tag page
$r->get('/tag/:tagname/:type/:page/')->to('tag#list_tagged_items');
- $r->get('/tag/:tagname/:page/')->to('tag#list_tagged_items');
+ $r->get('/tag/:tagname/:page/' => [page => qr/\d+/])->to('tag#list_tagged_items');
+ $r->get('/tag/:tagname/:type/')->to('tag#list_tagged_items');
$r->get('/tag/:tagname/')->to('tag#list_tagged_items');
$r->get('/tag/')->to('tag#list_tags');
my $type = $c->stash('type');
# check parameter
- my $page_num = $c->param('page') || 1;
+ my $page_num = $c->stash('page') || 1;
my $config = $c->app->config("Timeline") || {};
my $limit = $config->{item_per_page} || 10;
my $offset = $limit * ($page_num - 1);
- my $show_future = $user->{is_admin} ? 1 : 0;
- my $show_nonpublic = $user->{is_admin} ? 1 : 0;
-
- if ($page_num < 1 || $type && !any { $_ eq $type } qw(story journal submission)) {
+ if ($page_num !~ m/^\d+$/
+ || $page_num < 1
+ || $type && !any { $_ eq $type } qw(story journal submission)) {
$c->rendered(404);
return;
}
+
# get tagname id
my $tagname_ids = [];
my $tags = $c->model('tags');
}
push @$tagname_ids, $rs->[0]->{tagnameid};
- my $show_future = $user->{is_admin} || $user->{author} || 0;
+ my $show_future = $user->{is_admin} ? 1 : 0;
+ my $show_nonpublic = $user->{is_admin} ? 1 : 0;
my $items = $c->model('firehose')->select(type => $type,
tag_name_id => $tagname_ids,
limit => $limit + 1,
offset => $offset,
hide_future => !$show_future,
- public_only => !$show_future,
+ public_only => !$show_nonpublic,
);
if (!$items) {
$c->rendered(500);