Users comments page

This commit is contained in:
Rei
2014-02-12 16:02:42 +08:00
parent 19ff77fb79
commit 004f7adc36
9 changed files with 72 additions and 7 deletions

View File

@@ -69,3 +69,22 @@
}
}
}
.commentable {
.commentable-heading {
margin-top: 0;
margin-bottom: 5px;
font-size: 1em;
line-height: inherit;
}
.commentable-icon {
float: left;
color: #999;
}
.commentable-content {
margin-left: 24px;
}
}

View File

@@ -0,0 +1,5 @@
class Users::CommentsController < Users::ApplicationController
def index
@comments = @user.comments.order(id: :desc).page(params[:page])
end
end

View File

@@ -9,8 +9,6 @@ a.list-group-item.topic href=topic_path(topic)
span.label.label-default
= topic.category.name
= ' · '
| by
'
= topic.user.name
= ' · '
= time_ago_in_words topic.created_at

View File

@@ -0,0 +1,7 @@
.panel.panel-campo
.panel-body
ul.nav.nav-pills.nav-stacked
li class=('active' if controller_name == 'topics')
a href=user_topics_path(username: @user.username) Topics
li class=('active' if controller_name == 'comments')
a href=user_comments_path(username: @user.username) Comments

View File

@@ -0,0 +1,12 @@
- topic = comment.commentable
a.list-group-item.commentable href=comment_permalink(comment)
.commentable-icon
i.fa.fa-comments-o
.commentable-content
.commentable-heading
b = comment.commentable.title
span.text-muted
= ' · '
= time_ago_in_words comment.created_at
= truncate comment.body, length: 140

View File

@@ -0,0 +1,20 @@
.row
.col-md-9
.panel.panel-campo
.panel-body
| profile
#comments.panel.panel-campo
.panel-heading.clearfix
.pull-right
= paginate @comments, theme: 'campo', params: { anchor: 'comments' }
h3.panel-title Comments
.panel-body
.list-group.list-group-campo
- @comments.each do |comment|
= render "users/comments/comment/#{comment.commentable_type.downcase}", comment: comment
.panel-footer.clearfix
.pull-right
= paginate @comments, theme: 'campo', params: { anchor: 'comments' }, placement: 'top'
.col-md-3
= render 'users/sidebar'

View File

@@ -16,8 +16,4 @@
= paginate @topics, theme: 'campo', params: { anchor: 'topics' }, placement: 'top'
.col-md-3
.panel.panel-campo
.panel-body
ul.nav.nav-pills.nav-stacked
li class=('active' if controller_name == 'topics')
a href=user_topics_path(username: @user.username) Topics
= render 'users/sidebar'

View File

@@ -50,6 +50,7 @@ Rails.application.routes.draw do
scope path: '~:username', module: 'users', as: 'user' do
resources :topics, only: [:index]
resources :comments, only: [:index]
root to: 'topics#index'
end

View File

@@ -0,0 +1,7 @@
require 'test_helper'
class Users::CommentsControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end