diff --git a/app/assets/stylesheets/comments.css.scss b/app/assets/stylesheets/comments.css.scss index 51d92ce..71765f4 100644 --- a/app/assets/stylesheets/comments.css.scss +++ b/app/assets/stylesheets/comments.css.scss @@ -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; + } +} + diff --git a/app/controllers/users/comments_controller.rb b/app/controllers/users/comments_controller.rb new file mode 100644 index 0000000..a191e85 --- /dev/null +++ b/app/controllers/users/comments_controller.rb @@ -0,0 +1,5 @@ +class Users::CommentsController < Users::ApplicationController + def index + @comments = @user.comments.order(id: :desc).page(params[:page]) + end +end diff --git a/app/views/topics/_topic.html.slim b/app/views/topics/_topic.html.slim index 155ba57..b843605 100644 --- a/app/views/topics/_topic.html.slim +++ b/app/views/topics/_topic.html.slim @@ -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 diff --git a/app/views/users/_sidebar.html.slim b/app/views/users/_sidebar.html.slim new file mode 100644 index 0000000..f0cdf33 --- /dev/null +++ b/app/views/users/_sidebar.html.slim @@ -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 diff --git a/app/views/users/comments/comment/_topic.html.slim b/app/views/users/comments/comment/_topic.html.slim new file mode 100644 index 0000000..b1c19e3 --- /dev/null +++ b/app/views/users/comments/comment/_topic.html.slim @@ -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 diff --git a/app/views/users/comments/index.html.slim b/app/views/users/comments/index.html.slim new file mode 100644 index 0000000..35de1d4 --- /dev/null +++ b/app/views/users/comments/index.html.slim @@ -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' diff --git a/app/views/users/topics/index.html.slim b/app/views/users/topics/index.html.slim index 7edc1cb..bcdc10a 100644 --- a/app/views/users/topics/index.html.slim +++ b/app/views/users/topics/index.html.slim @@ -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' diff --git a/config/routes.rb b/config/routes.rb index 9783ac7..42954cc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/test/controllers/users/comments_controller_test.rb b/test/controllers/users/comments_controller_test.rb new file mode 100644 index 0000000..0f856cd --- /dev/null +++ b/test/controllers/users/comments_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class Users::CommentsControllerTest < ActionController::TestCase + # test "the truth" do + # assert true + # end +end