mirror of
https://github.com/zhigang1992/tsemple.git
synced 2026-01-12 22:53:00 +08:00
Users comments page
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
5
app/controllers/users/comments_controller.rb
Normal file
5
app/controllers/users/comments_controller.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class Users::CommentsController < Users::ApplicationController
|
||||
def index
|
||||
@comments = @user.comments.order(id: :desc).page(params[:page])
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
|
||||
7
app/views/users/_sidebar.html.slim
Normal file
7
app/views/users/_sidebar.html.slim
Normal 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
|
||||
12
app/views/users/comments/comment/_topic.html.slim
Normal file
12
app/views/users/comments/comment/_topic.html.slim
Normal 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
|
||||
20
app/views/users/comments/index.html.slim
Normal file
20
app/views/users/comments/index.html.slim
Normal 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'
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
7
test/controllers/users/comments_controller_test.rb
Normal file
7
test/controllers/users/comments_controller_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class Users::CommentsControllerTest < ActionController::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user