OSDN Git Service

implement comment single page
authorhylom <hylom@users.sourceforge.jp>
Fri, 22 Sep 2017 12:16:06 +0000 (21:16 +0900)
committerhylom <hylom@users.sourceforge.jp>
Fri, 22 Sep 2017 12:16:06 +0000 (21:16 +0900)
src/newslash_web/css/main/comment.less
src/newslash_web/css/main/main.less
src/newslash_web/css/main/story.less
src/newslash_web/lib/Newslash/Web.pm
src/newslash_web/lib/Newslash/Web/Controller/Comment.pm
src/newslash_web/templates/comment/single.html.tt2 [new file with mode: 0644]

index 6d5392f..5cf3168 100644 (file)
     border: 1px solid @border-color-inactive;
     font-size: 94%;
 
+    .body {
+        margin-top: 0.8em;
+        margin-bottom: 0.8em;
+    }
     header {
        h1 {
            background: @article-header-background;
index 43a6301..6dc1b24 100644 (file)
@@ -15,6 +15,11 @@ ul, ol {
     margin: 0;
 }
 
+p {
+    margin: 0;
+    margin-bottom: 1em;
+}
+
 a {
     text-decoration: none;
     color: @anchor-color;
index f19863d..a427f85 100644 (file)
@@ -3,6 +3,9 @@
 @import "colors.less";
 
 .story {
+    .content-notice {
+        margin: 4px 0;
+    }
     .next-prev-story {
         padding: 0 6px;
         margin: 0;
index 25008d4..e861b80 100644 (file)
@@ -162,6 +162,9 @@ sub startup {
     $r->get('/story/:sid/' => [sid => qr|\d\d/\d\d/\d\d/\d+|])
       ->to('story#story');
 
+    # 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');
@@ -180,21 +183,17 @@ sub startup {
     # archive page
     $r->get('/story/:year/:month/:day/')->to('archive#story');
     $r->get('/story/:year/:month/')->to('archive#story');
-    $r->get('/story/:year/')->to('archive#story');
     $r->get('/story/')->to('archive#story');
 
     $r->get('/journal/:year/:month/:day/')->to('archive#journal');
     $r->get('/journal/:year/:month/')->to('archive#journal');
-    $r->get('/journal/:year/')->to('archive#journal');
     $r->get('/journal/')->to('archive#journal');
 
     $r->get('/submission/:year/:month/:day/')->to('archive#submission');
     $r->get('/submission/:year/:month/')->to('archive#submission');
-    $r->get('/submission/:year/')->to('archive#submission');
     $r->get('/submission/')->to('archive#submission');
 
     $r->get('/poll/:year/:month/')->to('archive#poll');
-    $r->get('/poll/:year/')->to('archive#poll');
     $r->get('/poll/')->to('archive#poll');
 
     # my page
index 5ad1652..4ba15e2 100644 (file)
@@ -4,13 +4,37 @@ use Mojo::Util qw(dumper);
 
 sub single {
     my $c = shift;
-}
 
-sub index {
-    my $c = shift;
-    my $comments = $c->model('comments')->select(limit => 10, order_by => {create_time => 'DESC'});
-    $c->render(template => "timeline/base", items => $comments);
+    my $cid = $c->stash('cid');
+    my $user = $c->stash('user');
+
+    my $comments = $c->model('comments');
+    my $comment = $comments->select(cid => $cid);
+
+    if (!$comment) {
+        $c->render('Not found', status => '404');
+        return;
+    }
+
+    if ($comment->{public} && $comment->{public} eq 'no' && !$user->{is_admin}) {
+        $c->render('Not found', status => '404');
+        return;
+    }
+
+    my $discuss = $c->model('discussions')->select(id => $comment->{sid});
+    my $story;
+    my $source_url;
+    if ($discuss) {
+        if ($discuss->{kind} == "story") {
+            $story = $c->model('stories')->select(stoid => $discuss->{stoid});
+        }
+    }
+
+    $c->render(comment => $comment,
+               discussion => $discuss,
+              );
 }
 
+
 1;
 
diff --git a/src/newslash_web/templates/comment/single.html.tt2 b/src/newslash_web/templates/comment/single.html.tt2
new file mode 100644 (file)
index 0000000..e65bc34
--- /dev/null
@@ -0,0 +1,55 @@
+[% 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="story main-contents">
+    <div id="story">
+      <div class="content-notice alert alert-info">
+        このコンテンツは、
+        [%- IF discussion.kind == "story" -%]
+        「<span><a href="/story/[% discussion.sid %]">[% discussion.title %]</a></span>」記事
+        [%- ELSE -%]
+        「<span>[% discussion.title %]</span>」記事
+        [%- END -%]に対するコメントです。
+      </div>
+      [%- INCLUDE common/article/article story=comment hide_more_link=1 -%]
+      <article-item></article-item>
+    </div>
+    <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 class="ads-native-contents">
+        [%- INCLUDE ads/native_contents -%]
+      </div>
+    </div>
+  </div><!-- .story -->
+</div><!-- .main-column -->
+
+[%- INCLUDE common/sidebar mode="story" -%]
+
+[%#- 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: '#story'});</script>
+[%- END -%]
+
+[% END %]