From 850a0d758eb481b28a0008a6f8a6710bcc3f46de Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Sun, 17 Nov 2019 15:37:01 -0500 Subject: [PATCH] use comment listing with images --- .../controllers/comment_controller.ex | 2 +- .../controllers/post_controller.ex | 7 +++++++ .../templates/comment/_comment.html.slime | 19 +++++-------------- .../comment/_comment_with_image.html.slime | 17 +++++++++++++++++ .../templates/comment/index.html.slime | 2 +- 5 files changed, 31 insertions(+), 16 deletions(-) create mode 100644 lib/philomena_web/controllers/post_controller.ex create mode 100644 lib/philomena_web/templates/comment/_comment_with_image.html.slime diff --git a/lib/philomena_web/controllers/comment_controller.ex b/lib/philomena_web/controllers/comment_controller.ex index 5a7a666e..0d14ce6c 100644 --- a/lib/philomena_web/controllers/comment_controller.ex +++ b/lib/philomena_web/controllers/comment_controller.ex @@ -19,7 +19,7 @@ defmodule PhilomenaWeb.CommentController do sort: %{posted_at: :desc} }, conn.assigns.pagination, - Comment |> preload([:image, user: [awards: :badge]]) + Comment |> preload([image: [:tags], user: [awards: :badge]]) ) rendered = diff --git a/lib/philomena_web/controllers/post_controller.ex b/lib/philomena_web/controllers/post_controller.ex new file mode 100644 index 00000000..40abdf59 --- /dev/null +++ b/lib/philomena_web/controllers/post_controller.ex @@ -0,0 +1,7 @@ +defmodule PhilomenaWeb.PostController do + use PhilomenaWeb, :controller + + def index(conn, _params) do + + end +end \ No newline at end of file diff --git a/lib/philomena_web/templates/comment/_comment.html.slime b/lib/philomena_web/templates/comment/_comment.html.slime index eba40fd0..c79dc04a 100644 --- a/lib/philomena_web/templates/comment/_comment.html.slime +++ b/lib/philomena_web/templates/comment/_comment.html.slime @@ -5,20 +5,11 @@ article.block.communication id="comment_#{@comment.id}" .flex__grow.communication__body span.communication__body__sender-name = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @comment, awards: true, conn: @conn .communication__body__text - /- if comment.hidden_from_users - / strong.comment_deleted - / | Deletion reason: - / =<> comment.deletion_reason - / - if can?(:read, comment) - / | ( - / = comment.deleted_by.try(:name) || 'Orbital Friendship Cannon' - / | ) - / br - / - if comment.destroyed_content - / | This comment's contents have been destroyed. - / br - /= if can?(:read, @comment) - = if !@comment.hidden_from_users do + = if @comment.hidden_from_users do + strong.comment_deleted + ' Deletion reason: + => @comment.deletion_reason + - else ==<> @body .block__content.communication__options diff --git a/lib/philomena_web/templates/comment/_comment_with_image.html.slime b/lib/philomena_web/templates/comment/_comment_with_image.html.slime new file mode 100644 index 00000000..ca3d6333 --- /dev/null +++ b/lib/philomena_web/templates/comment/_comment_with_image.html.slime @@ -0,0 +1,17 @@ +article.block.communication id="comment_#{@comment.id}" + .block__content.flex.flex--no-wrap + .flex__fixed.spacing-right + = render PhilomenaWeb.ImageView, "_image_container.html", image: @comment.image, size: :thumb, conn: @conn + .flex__grow.communication__body + span.communication__body__sender-name = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @comment, awards: true, conn: @conn + .communication__body__text + = if @comment.hidden_from_users do + strong.comment_deleted + ' Deletion reason: + => @comment.deletion_reason + - else + ==<> @body + + .block__content.communication__options + .flex.flex--wrap.flex--spaced-out + = render PhilomenaWeb.CommentView, "_comment_options.html", comment: @comment, conn: @conn \ No newline at end of file diff --git a/lib/philomena_web/templates/comment/index.html.slime b/lib/philomena_web/templates/comment/index.html.slime index 2da87a7f..13968f55 100644 --- a/lib/philomena_web/templates/comment/index.html.slime +++ b/lib/philomena_web/templates/comment/index.html.slime @@ -7,7 +7,7 @@ elixir: = pagination = for {comment, body} <- @comments do - = render PhilomenaWeb.CommentView, "_comment.html", comment: comment, body: body, conn: @conn + = render PhilomenaWeb.CommentView, "_comment_with_image.html", image: comment.image, comment: comment, body: body, conn: @conn .block .block__header.block__header--light