From b34523803090be6bf4bc1c359b7f22a5e7869551 Mon Sep 17 00:00:00 2001 From: hylom Date: Thu, 23 Mar 2017 21:40:36 +0900 Subject: [PATCH] Web: implement /comments, /submissions --- src/newslash_web/lib/Newslash/Web.pm | 5 ++++- src/newslash_web/lib/Newslash/Web/Controller/Index.pm | 12 ++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/newslash_web/lib/Newslash/Web.pm b/src/newslash_web/lib/Newslash/Web.pm index 402dad41..a6563097 100644 --- a/src/newslash_web/lib/Newslash/Web.pm +++ b/src/newslash_web/lib/Newslash/Web.pm @@ -101,12 +101,15 @@ sub startup { # index page $r->get('/')->to('index#root'); $r->get('/recent')->to('timeline#recent'); + $r->get('/journals')->to('index#journals'); + $r->get('/comments')->to('index#comments'); + $r->get('/submissions')->to('index#submissions'); + # archive page $r->get('/story/:year/:month/:day/' => [year => qr/[0-9]{2}/, month => qr/[0-9]{2}/, day => qr/[0-9]{2}/])->to('index#story_archive'); - $r->get('/journals')->to('index#journals'); # Login / Logout $r->get('/login')->to('login#login'); diff --git a/src/newslash_web/lib/Newslash/Web/Controller/Index.pm b/src/newslash_web/lib/Newslash/Web/Controller/Index.pm index 7d97cbe9..6889e309 100644 --- a/src/newslash_web/lib/Newslash/Web/Controller/Index.pm +++ b/src/newslash_web/lib/Newslash/Web/Controller/Index.pm @@ -16,6 +16,18 @@ sub journals { $c->render(journals => $journals); } +sub comments { + my $c = shift; + my $comments = $c->model('comments')->select(limit => 10, order_by => {timestamp => 'DESC'}); + $c->render(template => "timeline/base", items => $comments); +} + +sub submissions { + my $c = shift; + my $submissions = $c->model('submissions')->select(limit => 10, order_by => {timestamp => 'DESC'}); + $c->render(template => "timeline/base", items => $submissions); +} + sub story_archive { my $c = shift; my $year = $c->stash('year'); -- 2.11.0