From ef38efa8fedc8aa6ba327068c2c34fda417e4bd0 Mon Sep 17 00:00:00 2001 From: lime1024 Date: Tue, 5 Feb 2019 10:30:54 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=E6=97=A5=E5=A0=B1=E3=81=AA=E3=81=AE?= =?UTF-8?q?=E3=81=8B=E6=8F=90=E5=87=BA=E7=89=A9=E3=81=AA=E3=81=AE=E3=81=8B?= =?UTF-8?q?=E3=81=AE=E3=82=A2=E3=82=A4=E3=82=B3=E3=83=B3=E3=82=92=E5=87=BA?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/comments/_comment.html.slim | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/comments/_comment.html.slim b/app/views/comments/_comment.html.slim index 51e454859ae..a814d61d843 100644 --- a/app/views/comments/_comment.html.slim +++ b/app/views/comments/_comment.html.slim @@ -7,6 +7,7 @@ header.thread-comment__body-header - if user_comments_page? h2.thread-comment__title.is-user-comments + = t("activerecord.models.#{commentable.class.to_s.tableize.singularize}") = link_to commentable, class: "thread-comment__title-link" do = image_tag commentable.user.avatar.variant(resize: "40x40"), class: "thread-comment__title-icon" = truncate(comment_title(commentable), length: 50) From 7415092f211e31a6ef7672895a938b0687e1cf2c Mon Sep 17 00:00:00 2001 From: lime1024 Date: Wed, 6 Feb 2019 10:40:00 +0900 Subject: [PATCH 2/6] =?UTF-8?q?=E3=83=A6=E3=83=BC=E3=82=B6=E3=83=BC?= =?UTF-8?q?=E5=80=8B=E5=88=A5=E3=81=AE=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E4=B8=80=E8=A6=A7=E3=81=A7=E6=8F=90=E5=87=BA=E7=89=A9=E3=81=AE?= =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=88=E3=83=AB=E3=82=92=E5=87=BA=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/comments_helper.rb | 6 ------ app/views/comments/_comment.html.slim | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 79eaf23b5fd..47e931158c2 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -4,10 +4,4 @@ module CommentsHelper def user_comments_page? controller_path == "users/comments" && action_name == "index" end - - def comment_title(commentable) - if commentable.is_a?(Report) - commentable.title - end - end end diff --git a/app/views/comments/_comment.html.slim b/app/views/comments/_comment.html.slim index a814d61d843..918f5cf7a3e 100644 --- a/app/views/comments/_comment.html.slim +++ b/app/views/comments/_comment.html.slim @@ -10,7 +10,7 @@ = t("activerecord.models.#{commentable.class.to_s.tableize.singularize}") = link_to commentable, class: "thread-comment__title-link" do = image_tag commentable.user.avatar.variant(resize: "40x40"), class: "thread-comment__title-icon" - = truncate(comment_title(commentable), length: 50) + = truncate(commentable.title, length: 50) - else h2.thread-comment__title = link_to comment.user, itempro: "url", class: "thread-comment__title-link" do From b0181e86944696dd4d5c8da4bfa770dc7ea6aa0e Mon Sep 17 00:00:00 2001 From: teppei machida Date: Wed, 13 Feb 2019 10:49:45 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=E8=87=AA=E5=88=86=E3=81=AE=E3=82=B3?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E4=B8=80=E8=A6=A7=E3=81=AE=E3=83=87?= =?UTF-8?q?=E3=82=B6=E3=82=A4=E3=83=B3=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 1 + Gemfile.lock | 5 +++++ .../blocks/thread/_thread-list-item.sass | 3 ++- app/helpers/comments_helper.rb | 10 ++++++++++ app/views/searchables/_searchable.html.slim | 2 +- app/views/users/comments/_comment.html.slim | 19 +++++++++++++++++++ app/views/users/comments/_comments.html.slim | 3 +++ app/views/users/comments/index.html.slim | 3 ++- 8 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 app/views/users/comments/_comment.html.slim create mode 100644 app/views/users/comments/_comments.html.slim diff --git a/Gemfile b/Gemfile index 4aed2f34131..e4c296d0d20 100644 --- a/Gemfile +++ b/Gemfile @@ -49,6 +49,7 @@ gem "rails-i18n" gem "google-cloud-storage", "~> 1.3", require: false gem "mini_magick" gem "activestorage-validator" +gem "commonmarker" group :production, :staging do gem "newrelic_rpm" diff --git a/Gemfile.lock b/Gemfile.lock index 153e45fd199..402444ae256 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -86,6 +86,8 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) + commonmarker (0.18.2) + ruby-enum (~> 0.5) concurrent-ruby (1.1.4) crass (1.0.4) curb (0.8.8) @@ -274,6 +276,8 @@ GEM retriable (3.1.2) rollbar (2.18.0) multi_json + ruby-enum (0.7.2) + i18n ruby-graphviz (1.2.3) ruby_dep (1.5.0) rubyzip (1.2.2) @@ -381,6 +385,7 @@ DEPENDENCIES chromedriver-helper cocoon coffee-rails (~> 4.2) + commonmarker curb (~> 0.8.8) diffy dynamic_form diff --git a/app/assets/stylesheets/blocks/thread/_thread-list-item.sass b/app/assets/stylesheets/blocks/thread/_thread-list-item.sass index 86b6dad662c..1b4383e0127 100644 --- a/app/assets/stylesheets/blocks/thread/_thread-list-item.sass +++ b/app/assets/stylesheets/blocks/thread/_thread-list-item.sass @@ -63,6 +63,7 @@ display: flex align-items: center margin-bottom: .125rem + justify-content: space-between +media-breakpoint-down(sm) flex-direction: column align-items: flex-start @@ -119,7 +120,7 @@ +text-block(.75rem 1.4, block $muted-text inline-block) .thread-list-item__body - +text-block(.875rem 1.8) + +text-block(.875rem 1.6) .thread-list-item-meta__created-at +text-block(.75rem 1.4, $muted-text) diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index 47e931158c2..b6730f142fb 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -4,4 +4,14 @@ module CommentsHelper def user_comments_page? controller_path == "users/comments" && action_name == "index" end + + def md2html(text) + html = CommonMarker.render_html(text) + raw(html) + end + + def comment_summury(comment, word_count) + summury = strip_tags(md2html(comment)).gsub(/[\r\n]/,"") + simple_format(truncate(summury, length: word_count)) + end end diff --git a/app/views/searchables/_searchable.html.slim b/app/views/searchables/_searchable.html.slim index 2bf86ce85f1..273a9bf3e6f 100644 --- a/app/views/searchables/_searchable.html.slim +++ b/app/views/searchables/_searchable.html.slim @@ -6,4 +6,4 @@ .thread-list-item__title = link_to searchable.title, searchable, class: "thread-list-item__title-link" .thread-list-item__body - p = truncate searchable.description, length: 50 + = comment_summury(searchable.description, 90) diff --git a/app/views/users/comments/_comment.html.slim b/app/views/users/comments/_comment.html.slim new file mode 100644 index 00000000000..6c42337af3a --- /dev/null +++ b/app/views/users/comments/_comment.html.slim @@ -0,0 +1,19 @@ +- commentable = comment.commentable +.thread-list-item(class="is-#{commentable.class.to_s.tableize.singularize}") + .thread-list-item__inner + .thread-list-item__label + = t("activerecord.models.#{commentable.class.to_s.tableize.singularize}") + header.thread-list-item__header + - if user_comments_page? + h2.thread-list-item__title + = link_to commentable, class: "thread-list-item__title-link" do + = image_tag commentable.user.avatar.variant(resize: "40x40"), class: "thread-comment__title-icon" + = truncate(commentable.title, length: 50) + - else + h2.thread-list-item__title + = link_to comment.user, itempro: "url", class: "thread-list-item__title-link" do + = comment.user.login_name + time.thread-comment__created-at(datetime="#{commentable.created_at.to_datetime}" pubdate="pubdate") + = l comment.updated_at + .thread-list-item__body + = comment_summury(comment.description, 90) diff --git a/app/views/users/comments/_comments.html.slim b/app/views/users/comments/_comments.html.slim new file mode 100644 index 00000000000..24f95bb78b1 --- /dev/null +++ b/app/views/users/comments/_comments.html.slim @@ -0,0 +1,3 @@ +.thread-comments-container + .thread-comments + = render partial: "comment", collection: comments.order(:created_at), as: :comment diff --git a/app/views/users/comments/index.html.slim b/app/views/users/comments/index.html.slim index bb7e1681cf1..c7447a7f88e 100644 --- a/app/views/users/comments/index.html.slim +++ b/app/views/users/comments/index.html.slim @@ -14,5 +14,6 @@ header.page-header .page-body .container = paginate @comments, position: "top" - = render "comments/comments", comments: @comments + .thread-list.a-card + = render "comments", comments: @comments = paginate @comments, position: "bottom" From 8208119a42b084e6b5018ac8fbb25549a4568996 Mon Sep 17 00:00:00 2001 From: teppei machida Date: Wed, 13 Feb 2019 11:07:03 +0900 Subject: [PATCH 4/6] :cop: --- app/helpers/comments_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/comments_helper.rb b/app/helpers/comments_helper.rb index b6730f142fb..68a646842b3 100644 --- a/app/helpers/comments_helper.rb +++ b/app/helpers/comments_helper.rb @@ -11,7 +11,7 @@ def md2html(text) end def comment_summury(comment, word_count) - summury = strip_tags(md2html(comment)).gsub(/[\r\n]/,"") + summury = strip_tags(md2html(comment)).gsub(/[\r\n]/, "") simple_format(truncate(summury, length: word_count)) end end From 224807acb8d0eb0f59a6834ef777d036d2ad07c5 Mon Sep 17 00:00:00 2001 From: teppei machida Date: Wed, 13 Feb 2019 16:48:10 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=81=AAview=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/show.html.slim | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/views/users/show.html.slim b/app/views/users/show.html.slim index ae657007ec6..a25503e3056 100644 --- a/app/views/users/show.html.slim +++ b/app/views/users/show.html.slim @@ -38,6 +38,3 @@ header.page-header - if @user.github_account .a-card = render "users/github_grass", user: @user - - if @user.admin? - .a-card - = render "users/unchecked" From fe63a490afaa9b01ca6e7de2782addc710ca6759 Mon Sep 17 00:00:00 2001 From: teppei machida Date: Wed, 13 Feb 2019 17:35:06 +0900 Subject: [PATCH 6/6] =?UTF-8?q?dom=E5=A4=89=E6=9B=B4=E3=81=AB=E4=BC=B4?= =?UTF-8?q?=E3=81=86=E3=83=86=E3=82=B9=E3=83=88=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/system/page_tabs_test.rb | 2 +- test/system/users_test.rb | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/test/system/page_tabs_test.rb b/test/system/page_tabs_test.rb index 3e35e7f2938..66ef1bbcfc6 100644 --- a/test/system/page_tabs_test.rb +++ b/test/system/page_tabs_test.rb @@ -491,7 +491,7 @@ class PageTabsTest < ApplicationSystemTestCase assert_equal 1, all(".page-tabs__item-link.is-active").length assert_equal "コメント", first(".page-tabs__item-link.is-active").text expected_comment_counts = User.find(user_id).comments.where(commentable_type: "Report").size - actual_comment_counts = all(".thread-comment__title-link").size + actual_comment_counts = all(".thread-list-item__title-link").size assert_equal expected_comment_counts, actual_comment_counts end diff --git a/test/system/users_test.rb b/test/system/users_test.rb index 2ccf38f342d..66bd0c2e9ae 100644 --- a/test/system/users_test.rb +++ b/test/system/users_test.rb @@ -88,12 +88,6 @@ class UsersTest < ApplicationSystemTestCase assert_text "kensyu" end - test "admin user can see unchecked number table" do - login_user "komagata", "testtest" - visit "/users/#{users(:komagata).id}" - assert_equal 1, all(".admin-table").length - end - test "nomal user can't see unchecked number table" do login_user "hatsuno", "testtest" visit "/users/#{users(:hatsuno).id}"