$admin->get('/css')->to('admin-css#edit');
$admin->get('/story/edit')->to('admin-story#edit');
+ $admin->get('/story/list')->to('admin-story#list');
$admin->get('/users')->to('admin-users#index');
$c->render(authors => $authors, source => $source, page => $page);
}
+sub list {
+ my $c = shift;
+ my $page = $c->param('page') || 0;
+ my $users = $c->model('users');
+ my $stories = $c->model('stories');
+
+ my $items_per_page = 20;
+
+ my $items = $stories->select(limit => $items_per_page,
+ offset => $page * $items_per_page,
+ order_by => { create_time => "DESC" });
+
+ # convert submitter UID to user hash
+ my $user_cache = {};
+ for my $item (@$items) {
+ my $submitter = $item->{submitter};
+ if (!defined $user_cache->{$submitter}) {
+ my $u = $users->select(uid => $submitter);
+ $user_cache->{$submitter} = $u ? $u : {};
+ }
+ $item->{submitter} = $user_cache->{$submitter};
+ }
+
+ $c->render(items => $items, page_num => $page, );
+}
1;
<ul class="menu-bar">
<li><a href="[% Site.root %]">[% Site.name %]</a></li>
<li><a href="/admin/submissions">タレコミリスト</a></li>
+ <li><a href="/admin/story/list">記事リスト</a></li>
<!-- story -->
<li class="dropdown">
--- /dev/null
+[% WRAPPER common/layout %]
+
+<div class="app-frame" id="stories-manager">
+ <h3>Stories</h3>
+ <div v-text="message"></div>
+ <div>
+ <a href="/admin/story/list">[top]</a>
+ [%- IF page_num -%]
+ <a href="/admin/story/list?page=[% page_num - 1 %]">[prev]</a>
+ [%- END -%]
+ <a href="/admin/story/list?page=[% page_num + 1 %]">[next]</a>
+ </div>
+ <table class="table">
+ <thead>
+ <tr>
+ <th>date (GMT)</th>
+ <th></th>
+ <th>title</th>
+ <th>submit</th>
+ <th>author</th>
+ <th>hits</th>
+ <th>comments</th>
+ </tr>
+ </thead>
+ <tbody>
+ [%- FOREACH item IN items %]
+ <tr>
+ <td>[% item.create_time %]</td>
+ <td><a href="/admin/story/edit?stoid=[% item.stoid %]" target="_blank_">[編集]</a></td>
+ <td><a href="/story/[% item.sid %]">[% item.title %]</a></td>
+ <td>[% item.submitter.nickname %]</td>
+ <td>[% item.author %]</td>
+ <td>[% item.hits %]</td>
+ <td>[% item.commentcount %]</td>
+ </tr>
+ [%- END %]
+ </tbody>
+ </table>
+ <div>
+ <a href="/admin/story/list">[top]</a>
+ [%- IF page_num -%]
+ <a href="/admin/story/list?page=[% page_num - 1 %]">[prev]</a>
+ [%- END -%]
+ <a href="/admin/story/list?page=[% page_num + 1 %]">[next]</a>
+ </div>
+</div>
+
+
+[% END %]