# story page
$r->get('/story/:sid/' => [sid => qr|\d\d/\d\d/\d\d/\d+|])
- ->to('story#story');
+ ->to('story#single');
# comment page
$r->get('/comment/:cid/')->to('comment#single');
# journal page
$r->get('/journal/new')->to('journal#create', seclev => 1);
- $r->get('/journal/:id/')->to('journal#journal');
+ $r->get('/journal/:id/')->to('journal#single');
# submission page
$r->get('/submission/new')->to('submission#create');
- $r->get('/submission/:id/')->to('submission#submission');
+ $r->get('/submission/:id/')->to('submission#single');
#$r->post('/submission')->to('submission#create');
# polls page
}
$year = $year + 2000;
- my $property = { year => $year,
- month => $month,
- day => $day,
- type => 'archive',
- target => $type,
- title => $params->{title},
- };
-
my $offset_sec = $user->{config}->{offset_sec} || 0;
my $q_params = { year => $year,
month => $month,
$next = Newslash::Util::Items->get_date_string_from_item($next_items->[0], $offset_sec, $unit);
}
+ my $page = { content_type => $type,
+ type => "archive",
+ year => $year,
+ month => $month,
+ day => $day,
+ };
+
$c->render(template => 'archive/index',
- items => $items,
+ contents => $items,
counts => $counts,
- page_property => $property,
+ page => $page,
prev => $prev,
next => $next,
- archive_type => $type,
);
if (@$items == 0) {
# }
#}
- $c->render(comment => $comment,
+ my $page = { content_type => "comment",
+ type => "single" };
+
+ $c->render(template => "common/single",
+ content => $comment,
parent => $parent,
discussion => $discuss,
+ page => $page,
);
}
use Data::Dumper;
use List::Util qw(any);
-sub journal {
+sub single {
my $c = shift;
my $users = $c->model('users');
my $user = $c->stash('user');
}
- $c->render(story => $journal,
+ my $page = { content_type => "journal",
+ type => "single" };
+
+ $c->render(template => "common/single",
+ content => $journal,
discussion => $discuss,
comments => $comments,
the_user => $the_user,
+ page => $page,
use_captcha => 1,
comment_allowed => $comment_allowed,
);
$poll->{active} = _is_poll_active($c, $poll);
my $related_polls = $c->model('polls')->select(limit => 10, order_by => {create_time => "DESC"});
- $c->render(story => $poll,
+
+ my $page = { content_type => "poll",
+ type => "single" };
+
+ $c->render(template => "common/single",
+ content => $poll,
+ page => $page,
discussion => $discuss,
related => $related_polls,
);
use Mojo::Base 'Mojolicious::Controller';
use Mojo::Util qw(dumper);
-sub story {
+sub single {
my $c = shift;
my $session = $c->session('session');
my $sid = $c->stash('sid');
my $mod_reasons = $c->model('moderations')->reasons;
$c->stash(moderate_reasons => $mod_reasons);
- $c->render(story => $story,
+ my $page = { type => "single",
+ content_type => "story",
+ };
+ $c->render(template => "common/single",
+ content => $story,
discussion => $discuss,
comments => $comments,
related => $related,
params => $params,
authors => $authors,
use_captcha => 1,
- comment_allowed => 1,
+ page => $page,
);
}
use Mojo::Base 'Mojolicious::Controller';
use Data::Dumper;
-sub submission {
+sub single {
my $c = shift;
my $subid = $c->stash('id');
my $user = $c->stash('user');
$comment_allowed = $discussions->is_comment_allowed(discussion => $discuss,
uid => $user->{uid});
}
- $c->render(story => $submission,
+
+ my $page = { content_type => "submission",
+ type => "single" };
+
+ $c->render(template => "common/single",
+ content => $submission,
discussion => $discuss,
comments => $comments,
+ page => $page,
use_captcha => 1,
comment_allowed => $comment_allowed,
);
$prev = $self->_make_navitem($prev_item);
}
+ my $page = { type => "timeline",
+ content_type => $params->{content_type},
+ };
+
$self->render("timeline/base",
- items => $items,
+ contents => $items,
prev => $prev,
title => $params->{title},
- timeline => 1);
+ page => $page,
+ );
}
sub stories {
);
$c->_render_timeline(items => $items,
+ content_type => "story",
limit => $limit);
}
limit => $limit);
$c->_render_timeline(items => $items,
+ content_type => "recent",
limit => $limit,
title => "最新");
};
%$popular_period);
$c->_render_timeline(items => $items,
+ content_type => "popular",
limit => $limit,
title => "人気");
}
$c->_render_timeline(items => $items,
limit => $limit,
+ content_type => "comment",
title => "日記");
}
$c->_render_timeline(items => $items,
limit => $limit,
+ content_type => "submission",
title => "タレコミ");
}
$c->_render_timeline(items => $items,
limit => $limit,
+ content_type => "poll",
title => "国民投票");
}
}
}
+ my $page = { type => "user" };
+ my $content_type_table = { home => "recent",
+ comments => "comment",
+ journals => "journal",
+ submissions => "submission"
+ };
+ $page->{content_type} = $content_type_table->{$tab} || "user";
+
$c->render(template => "user/base",
- page_property => { type => "user" },
+ page => $page,
user_tab => $tab,
- items => $items,
+ contents => $items,
the_user => $the_user,
relation => $relation
);
<div class="main-column">
- <div class="index main-contents">
+ <div class="archive [% page.content_type %] index main-contents">
[%- INCLUDE archive/index_header.html.tt2 -%]
[%- IF items.size == 0 -%]
</div>
[%- END -%]
- [%- FOREACH story IN items -%]
+ [%- FOREACH content IN contents -%]
[%- INCLUDE common/article/article %]
[%- END -%]
[%-
USE cal = MicroCalendar;
-last_day = cal.last_day_of_month(page_property.year, page_property.month);
-dow = cal.day_of_week(page_property.year, page_property.month, 1);
+last_day = cal.last_day_of_month(page.year, page.month);
+dow = cal.day_of_week(page.year, page.month, 1);
days = ['日', '月','火','水','木','金','土','日'];
classes = ['sunday', 'monday','tuesday','wednesday','thursday','friday','saturday','sunday'];
-yyyy = page_property.year;
-yy = page_property.year.substr(2, 2);
-mm = page_property.month;
+yyyy = page.year;
+yy = page.year.substr(2, 2);
+mm = page.month;
m = mm + 0;
-dd = page_property.day;
+dd = page.day;
d = dd + 0;
-ctype = page_property.target;
+ctype = page.target;
p_yy = cal.year_of_previous_month(yyyy, m).substr(2, 2);
p_mm = cal.previous_month(yyyy, m);
[%-
USE dtf = DateTimeFormatter;
-IF story.content_type == 'story'; content_id = story.sid; END;
-IF story.content_type == 'journal'; content_id = story.id; END;
-IF story.content_type == 'submission'; content_id = story.subid; END;
-IF story.content_type == 'poll'; content_id = story.qid; END;
-IF story.content_type == 'vote'; content_id = story.qid; END;
+IF content.content_type == 'story'; content_id = content.sid; END;
+IF content.content_type == 'journal'; content_id = content.id; END;
+IF content.content_type == 'submission'; content_id = content.subid; END;
+IF content.content_type == 'poll'; content_id = content.qid; END;
+IF content.content_type == 'vote'; content_id = content.qid; END;
-IF story.content_type == 'story'; url = "/story/" _ story.sid _ "/"; END;
-IF story.content_type == 'journal'; url = "/journal/" _ story.id _ "/"; END;
-IF story.content_type == 'submission'; url = "/submission/" _ story.id _ "/"; END;
-IF story.content_type == 'comment'; url = "/comment/" _ story.id _ "/"; END;
-IF story.content_type == 'poll'; url = "/poll/" _ story.id _ "/"; END;
+IF content.content_type == 'story'; url = "/story/" _ content.sid _ "/"; END;
+IF content.content_type == 'journal'; url = "/journal/" _ content.id _ "/"; END;
+IF content.content_type == 'submission'; url = "/submission/" _ content.id _ "/"; END;
+IF content.content_type == 'comment'; url = "/comment/" _ content.id _ "/"; END;
+IF content.content_type == 'poll'; url = "/poll/" _ content.id _ "/"; END;
-%]
-<article id="[% story.id %]" type="[% story.content_type %]" item-id="[% content_id %]"
+<article id="[% content.id %]" type="[% content.content_type %]" item-id="[% content_id %]"
[% IF !x_template %]v-if="0"[% ELSE %]v-if="mode != 'editing' || enableAutoPreview"[% END %]>
<header>
<h1>
- [%- IF story.primary_topic.image.length || x_template -%]
- <img [% IF story.primary_topic.image %]src="[% Site.topic_icon_base_url %]/[% story.primary_topic.image %]"[% END %]
+ [%- IF content.primary_topic.image.length || x_template -%]
+ <img [% IF content.primary_topic.image %]src="[% Site.topic_icon_base_url %]/[% content.primary_topic.image %]"[% END %]
:src="primaryTopicIconURL" v-if="primaryTopicIconURL" />
[%- END -%]
[%- IF url -%]
- <a href="[% url %]" v-html="item.title">[% story.title %]</a>
+ <a href="[% url %]" v-html="content.title">[% content.title %]</a>
[%- ELSE -%]
- <span v-html="item.title">[% story.title %]</span>
+ <span v-html="content.title">[% content.title %]</span>
[%- END -%]
</h1>
<div class="property">
<span class="content-type">
- [%- IF story.content_type == 'story' -%]ストーリー[%- END -%]
- [%- IF story.content_type == 'feed' -%]フィード[%- END -%]
- [%- IF story.content_type == 'journal' -%]日記[%- END -%]
- [%- IF story.content_type == 'submission' -%]タレコミ[%- END -%]
- [%- IF story.content_type == 'comment' -%]コメント[%- END -%]
- [%- IF story.content_type == 'poll' -%]国民投票[%- END -%]
+ [%- IF content.content_type == 'story' -%]ストーリー[%- END -%]
+ [%- IF content.content_type == 'feed' -%]フィード[%- END -%]
+ [%- IF content.content_type == 'journal' -%]日記[%- END -%]
+ [%- IF content.content_type == 'submission' -%]タレコミ[%- END -%]
+ [%- IF content.content_type == 'comment' -%]コメント[%- END -%]
+ [%- IF content.content_type == 'poll' -%]国民投票[%- END -%]
</span>
<span class="author">
- by <span v-text="item.author"><a href="/~[% story.author %]/">[% story.author %]</a></span>
+ by <span v-text="content.author"><a href="/~[% content.author %]/">[% content.author %]</a></span>
</span>
- <span class="create-time" v-text="item.create_time">[% dtf.mysql_to_user(story.create_time, user.config.offset_sec, user.config.time_format) %]</span>
- [% IF story.content_type == 'story' %]<span class="dept"><span v-text="item.dept" v-if="item.dept">[% story.dept %]</span> 部門より</span>[% END %]
+ <span class="create-time" v-text="content.create_time">[% dtf.mysql_to_user(content.create_time, user.config.offset_sec, user.config.time_format) %]</span>
+ [% IF content.content_type == 'story' %]<span class="dept"><span v-text="content.dept" v-if="content.dept">[% content.dept %]</span> 部門より</span>[% END %]
</div>
<div class="toolbar" v-if="mode == ''">
- [%- IF story.content_type == 'journal' && story.uid == user.uid || x_template -%]
+ [%- IF content.content_type == 'journal' && content.uid == user.uid || x_template -%]
<button type="button" class="btn btn-default btn-sm"
area-label="編集" v-show="editable" v-on:click="editItem(item)">
<span class="glyphicon glyphicon-pencil"></span>
</button>
[%- END -%]
- [%- IF story.content_type == 'story' && user.is_admin || user.editor || x_template -%]
+ [%- IF content.content_type == 'story' && user.is_admin || user.editor || x_template -%]
<button type="button" class="btn btn-default btn-sm" id="activate-editor"
area-label="編集" title="編集" v-on:click="editItem(item)"
v-if="editable">
<span class="glyphicon glyphicon-cog"></span>
</button>
[%- END -%]
- [%- IF story.content_type == 'submission' && (user.author || x_template) -%]
- [<a href="/admin/story/edit?subid=[% story.submission_id %]">accept</a>]
+ [%- IF content.content_type == 'submission' && (user.author || x_template) -%]
+ [<a href="/admin/story/edit?subid=[% content.submission_id %]">accept</a>]
[%- END -%]
</div>
</header>
<div class="body contents-text">
- [%- IF story.content_type == 'poll' -%]
+ [%- IF content.content_type == 'poll' -%]
[% INCLUDE common/poll/poll_body %]
- [%- ELSIF story.content_type == 'vote' -%]
+ [%- ELSIF content.content_type == 'vote' -%]
[% INCLUDE common/poll/vote_body %]
[%- END -%]
</div>
- [%- IF story.introtext || x_template -%]
- <div class="body contents-text" v-html="item.introtext">[% story.introtext %]</div>
+ [%- IF content.introtext || x_template -%]
+ <div class="body contents-text" v-html="content.introtext">[% content.introtext %]</div>
[%- END -%]
- [% IF story.content_type != "journal" && story.bodytext && !hide_bodytext %]
- <div class="body contents-text" v-html="item.bodytext">[% story.bodytext %]</div>
+ [% IF content.content_type != "journal" && content.bodytext && !hide_bodytext %]
+ <div class="body contents-text" v-html="content.bodytext">[% content.bodytext %]</div>
[% END %]
[%- IF x_template -%]
- <div class="body contents-text" v-if="item.url"><p><a :href="item.url">情報元へのリンク</a></p></div>
- [%- ELSIF story.url -%]
- <div class="body contents-text"><p><a href="[% story.url %]">情報元へのリンク</a></p></div>
+ <div class="body contents-text" v-if="content.url"><p><a :href="content.url">情報元へのリンク</a></p></div>
+ [%- ELSIF content.url -%]
+ <div class="body contents-text"><p><a href="[% content.url %]">情報元へのリンク</a></p></div>
[%- END -%]
<footer>
[%- IF !hide_more_link -%]
- [%- IF story.content_type != "feed" -%]
+ [%- IF content.content_type != "feed" -%]
<div class="link-to-story" v-if="mode == ''"><a href="[% url %]" :href="url">
- [%- IF story.content_type == "poll" -%]
- [%- IF story.commentcount || x_template -%]
- <span v-if="item.commentcount > 0">投票結果と<span v-text="item.commentcount">[% story.commentcount %]</span>件のコメントを見る</span>
+ [%- IF content.content_type == "poll" -%]
+ [%- IF content.commentcount || x_template -%]
+ <span v-if="content.commentcount > 0">投票結果と<span v-text="content.commentcount">[% content.commentcount %]</span>件のコメントを見る</span>
[%- END -%]
- [%- IF !story.commentcount || x_template -%]<span v-if="item.commentcount == 0">投票結果を見る</span>[%- END -%]
+ [%- IF !content.commentcount || x_template -%]<span v-if="content.commentcount == 0">投票結果を見る</span>[%- END -%]
[%- ELSE -%]
[%- link_target = "記事" -%]
- [%- IF story.commentcount || x_template -%]
- <span v-if="item.commentcount > 0">[% link_target %]と<span v-text="item.commentcount">[% story.commentcount %]</span>件のコメントを読む</span>
+ [%- IF content.commentcount || x_template -%]
+ <span v-if="content.commentcount > 0">[% link_target %]と<span v-text="content.commentcount">[% content.commentcount %]</span>件のコメントを読む</span>
[%- END -%]
- [%- IF !story.commentcount || x_template -%]
- <span v-if="item.commentcount == 0">[% link_target %]を読む</span>
+ [%- IF !content.commentcount || x_template -%]
+ <span v-if="content.commentcount == 0">[% link_target %]を読む</span>
[%- END -%]
[%- END -%]
</a></div>
[%- END -%]
[%- ELSE -%]
<div class="comment-counter">
- [%- IF story.discussion_id -%]
- <a href="#comments"><span class="counter" v-text="item.commentcount">[% story.commentcount %]</span>コメント</a>
+ [%- IF content.discussion_id -%]
+ <a href="#comments"><span class="counter" v-text="content.commentcount">[% content.commentcount %]</span>コメント</a>
[%- END -%]
</div>
[%- END -%]
<div class="tag-bar">
<ul class="tags">
- [%- FOREACH tag IN story.tags -%]
- [%- IF tag.private == "no" && tag.tagname != "mainpage" && tag.uid == story.uid -%]
+ [%- FOREACH tag IN content.tags -%]
+ [%- IF tag.private == "no" && tag.tagname != "mainpage" && tag.uid == content.uid -%]
<li>[% tag.tagname %]</li>
[%- END -%]
[%- END -%]
<script type="text/x-template" id="article-item-template">
<div class="article">
<div class="preview-header" v-if="mode == 'editing' && enableAutoPreview">投稿プレビュー:</div>
- [% INCLUDE common/article/article story={content_type => type} x_template=1 hide_more_link = 0 %]
- [% INCLUDE common/article/editor story={content_type => type} x_template=1 %]
+ [% INCLUDE common/article/article content={content_type => type} x_template=1 hide_more_link = 0 %]
+ [% INCLUDE common/article/editor content={content_type => type} x_template=1 %]
</div>
</script>
<div id="poll-body">
[%- IF timeline -%]
<div class="poll">
- <p class="poll-title">[% story.title %]</p>
+ <p class="poll-title">[% content.title %]</p>
<ol class="poll-answers">
- [%- FOREACH answer IN story.answers -%]
+ [%- FOREACH answer IN content.answers -%]
<li>[% answer.answer %]</li>
[%- END -%]
</ol>
</div>
[%- ELSE -%]
<div class="poll-results">
- [%- FOREACH answer IN story.answers -%]
+ [%- FOREACH answer IN content.answers -%]
<div class="poll-answer">
<div class="answer-text">[% answer.answer %]</div>
<div class="poll-graph-wrapper">
</div>
[%- END -%]
</div>
- <div class="total">合計 [% story.voters %]票</div>
+ <div class="total">合計 [% content.voters %]票</div>
[%- END %]
</div>
<div class="sidebar">
- [%- IF mode == "story" -%]
+ [%- IF page.type == "timeline" || page.type == "archive" -%]
+ [%- INCLUDE common/ads/main_rectangle -%]
+ [%- FOREACH box IN NS.sidebar_items() -%]
+ <div class="sidebar-item contents-text [% box.type %] [% box.name %]">
+ [%- box.contents -%]
+ </div>
+ [%- END -%]
+
+ [%- ELSIF page.content_type == "story" -%]
[% INCLUDE common/ads/main_rectangle %]
<div class="sidebar-item related">
<h2>関連リンク</h2>
[%- END -%]
</div>
- [%- ELSIF mode == "comment" -%]
+ [%- ELSIF page.content_type == "comment" -%]
[% INCLUDE common/ads/main_rectangle %]
- [%- ELSIF mode == "poll" -%]
+ [%- ELSIF page.content_type == "poll" -%]
[% INCLUDE common/ads/main_rectangle %]
<div class="sidebar-item related">
<h2>最近の国民投票</h2>
</ul>
</div>
- [%- ELSIF mode == "journal" -%]
+ [%- ELSIF page.content_type == "journal" -%]
<div class="abbrevable">
[% INCLUDE common/user %]
</div>
+
[%- ELSE -%]
[% INCLUDE common/ads/main_rectangle %]
- [%- FOREACH box IN NS.sidebar_items() -%]
- <div class="sidebar-item contents-text [% box.type %] [% box.name %]">
- [%- box.contents -%]
- </div>
- [%- END -%]
+
[%- END -%]
</div>
--- /dev/null
+[% WRAPPER common/layout enable_sidebar=1 short_header=1 %]
+
+[% INCLUDE common/components/comment_tree %]
+[% IF user.editor || user.is_admin -%]
+[% INCLUDE common/components/article_item %]
+[% END -%]
+
+<div class="main-column">
+ <div class="[% page.type %] [% page.content_type %] main-contents">
+
+ [%- IF page.content_type == "comment" && page.type == "single" -%]
+ <div class="content-notice alert alert-info">
+ <p>このコンテンツは、
+ [%- IF discussion.kind == "story" -%]
+ 「<span><a href="/story/[% discussion.sid %]">[% discussion.title %]</a></span>」記事
+ [%- ELSE -%]
+ 「<span>[% discussion.title %]</span>」記事
+ [%- END -%]に対するコメントです。</p>
+
+ [%- IF comment.parent_id != 0 -%]
+ <p>親コメントは「<span><a href="/comment/[% parent.cid %]">[% parent.title %]</a></span>」です。</p>
+ [%- END -%]
+ </div>
+ [%- END -%]
+
+ <div id="content-body">
+ [%- INCLUDE common/article/article hide_more_link=1 -%]
+ <article-item></article-item>
+ </div>
+
+ [%- IF page.type == "single" && page.content_type == "story" -%]
+ <div class="next-prev-story">
+ [%- IF params.prev_stoid && params.prev_stoid.story -%]
+ <div class="prev"><a href="/story/[% params.prev_stoid.story.sid %]">
+ [% params.prev_stoid.story.title %]
+ </a></div>
+ [%- END -%]
+ [%- IF params.next_stoid && params.next_stoid.story -%]
+ <div class="next"><a href="/story/[% params.next_stoid.story.sid %]">
+ [% params.next_stoid.story.title %]
+ </a></div>
+ [%- END -%]
+ </div>
+ <div class="related">
+ <div id="story-ads-native-contents" class="ads-native-contents">
+ [%- INCLUDE ads/native_contents -%]
+ </div>
+ </div>
+ [%- END -%]
+
+ [%- IF !discussion -%]
+ <div class="alert alert-info">
+ この投稿に対するコメントは設定により無効にされています。
+ </div>
+ [%- ELSIF discussion.commentstatus == "disabled" -%]
+ <div class="alert alert-info">
+ この投稿に対するコメントは設定により無効にされています。
+ </div>
+ [%- ELSIF discussion.commentstatus == "logged_in" -%]
+ <div class="alert alert-info">
+ この投稿に対するコメントはログインユーザーにのみ許可されています。
+ </div>
+ [%- ELSIF discussion.commentstatus != "enabled" -%]
+ <div class="alert alert-info clear">
+ この投稿に対するコメントは一部のユーザーのみに許可されています。
+ </div>
+ [%- END -%]
+
+ </div><!-- .story -->
+</div><!-- .main-column -->
+
+[%- INCLUDE common/sidebar -%]
+
+[%#- INCLUDE common/comment/comments_nojs -%]
+[%#- INCLUDE common/comment/comments -%]
+<div id="comments">
+ <comment-tree></comment-tree>
+</div>
+<script>commentTree.run({el:'#comments'});</script>
+
+[%- IF user.editor || user.is_admin -%]
+<script>articleItem.addTrigger('#activate-editor', {el: '#content-body'});</script>
+[%- END -%]
+
+[% END %]
<div class="main-column">
<div class="index main-contents">
- [%- FOREACH story IN items -%]
+ [%- FOREACH content IN contents -%]
[%- INCLUDE common/article/article %]
[%- END -%]
</nav>
</div>
- [%- SWITCH user_tab %]
- [%- CASE ['friends', 'foes', 'fans', 'freaks' ] -%]
- <div class="index main-contents">
- [%- FOREACH item IN items -%]
- [% INCLUDE common/user the_user=item no_form=1 %]
- [%- END -%]
- </div>
- [%- CASE DEFAULT -%]
- <div class="index main-contents">
- [%- FOREACH item IN items -%]
+ <div class="user [%- page.content_type -%] main-contents">
+ [%- SWITCH user_tab %]
+ [%- CASE ['friends', 'foes', 'fans', 'freaks' ] -%]
+ [%- FOREACH user IN contents -%]
+ [% INCLUDE common/user the_user=user no_form=1 %]
+ [%- END -%]
+
+ [%- CASE DEFAULT -%]
+ [%- FOREACH content IN contents -%]
[%- INCLUDE common/article/article story=item %]
[%- END -%]
</div><!-- .index -->
[%- END -%]
</div>
-<div class="sidebar">
-</div>
+[%- INCLUDE common/sidebar -%]
[%- IF user.uid != the_user.uid && user.is_login -%]
<script src="/js/user-profile.js"></script>