mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
add user titles
This commit is contained in:
parent
83fed839ad
commit
d91346c9b1
7 changed files with 59 additions and 2 deletions
|
@ -2,8 +2,14 @@ article.block.communication id="comment_#{@comment.id}"
|
|||
.block__content.flex.flex--no-wrap
|
||||
.flex__fixed.spacing-right
|
||||
= render PhilomenaWeb.UserAttributionView, "_anon_user_avatar.html", object: @comment, conn: @conn
|
||||
|
||||
.flex__grow.communication__body
|
||||
|
||||
span.communication__body__sender-name = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @comment, awards: true, conn: @conn
|
||||
br
|
||||
|
||||
= render PhilomenaWeb.UserAttributionView, "_anon_user_title.html", object: @comment, conn: @conn
|
||||
|
||||
.communication__body__text
|
||||
= if @comment.hidden_from_users do
|
||||
strong.comment_deleted
|
||||
|
|
|
@ -3,8 +3,13 @@ article.block.communication id="comment_#{@comment.id}"
|
|||
.flex__fixed.spacing-right
|
||||
.post-image-container
|
||||
= render PhilomenaWeb.ImageView, "_image_container.html", image: @comment.image, size: :thumb_tiny, conn: @conn
|
||||
|
||||
.flex__grow.communication__body
|
||||
span.communication__body__sender-name = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @comment, awards: true, conn: @conn
|
||||
br
|
||||
|
||||
= render PhilomenaWeb.UserAttributionView, "_anon_user_title.html", object: @comment, conn: @conn
|
||||
|
||||
.communication__body__text
|
||||
= if @comment.hidden_from_users do
|
||||
strong.comment_deleted
|
||||
|
|
|
@ -2,9 +2,13 @@ article.block.communication
|
|||
.block__content.flex.flex--no-wrap
|
||||
.flex__fixed.spacing-right
|
||||
= render PhilomenaWeb.UserAttributionView, "_user_avatar.html", object: %{user: @message.from}, conn: @conn, class: "avatar--100px"
|
||||
|
||||
.flex__grow.communication__body
|
||||
span.communication__body__sender-name
|
||||
= render PhilomenaWeb.UserAttributionView, "_user.html", object: %{user: @message.from}, badges: true, conn: @conn
|
||||
|
||||
span.communication__body__sender-name = render PhilomenaWeb.UserAttributionView, "_user.html", object: %{user: @message.from}, badges: true, conn: @conn
|
||||
br
|
||||
|
||||
= render PhilomenaWeb.UserAttributionView, "_user_title.html", object: %{user: @message.from}, conn: @conn
|
||||
|
||||
br
|
||||
|
||||
|
|
|
@ -2,8 +2,13 @@ article.block.communication id="post_#{@post.id}"
|
|||
.block__content.flex.flex--no-wrap
|
||||
.flex__fixed.spacing-right
|
||||
= render PhilomenaWeb.UserAttributionView, "_anon_user_avatar.html", object: @post, awards: true, conn: @conn
|
||||
|
||||
.flex__grow.communication__body
|
||||
span.communication__body__sender-name = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @post, conn: @conn
|
||||
br
|
||||
|
||||
= render PhilomenaWeb.UserAttributionView, "_anon_user_title.html", object: @post, conn: @conn
|
||||
|
||||
.communication__body__text
|
||||
= if !@post.hidden_from_users do
|
||||
==<> @body
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
= if !!@object.user and !anonymous?(@object) do
|
||||
= for {class, label} <- user_labels(@object) do
|
||||
= if assigns[:large] do
|
||||
.label.label--block class=class = label
|
||||
- else
|
||||
.label.label--block.label--small class=class = label
|
|
@ -0,0 +1,5 @@
|
|||
= for {class, label} <- user_labels(@object) do
|
||||
= if assigns[:large] do
|
||||
.label.label--block class=class = label
|
||||
- else
|
||||
.label.label--block.label--small class=class = label
|
|
@ -33,6 +33,32 @@ defmodule PhilomenaWeb.UserAttributionView do
|
|||
def user_avatar(%{user: %{avatar: avatar}}, class),
|
||||
do: img_tag(avatar_url_root() <> "/" <> avatar, class: class)
|
||||
|
||||
def user_labels(%{user: user}) do
|
||||
[]
|
||||
|> personal_title(user)
|
||||
|> secondary_role(user)
|
||||
|> staff_role(user)
|
||||
end
|
||||
|
||||
defp personal_title(labels, %{personal_title: t}) when t not in [nil, ""],
|
||||
do: [{"label--primary", t} | labels]
|
||||
defp personal_title(labels, _user),
|
||||
do: labels
|
||||
|
||||
defp secondary_role(labels, %{secondary_role: t}) when t not in [nil, ""],
|
||||
do: [{"label--warning", t} | labels]
|
||||
defp secondary_role(labels, _user),
|
||||
do: labels
|
||||
|
||||
defp staff_role(labels, %{hide_default_role: false, role: "admin"}),
|
||||
do: [{"label--danger", "Site Administrator"} | labels]
|
||||
defp staff_role(labels, %{hide_default_role: false, role: "moderator"}),
|
||||
do: [{"label--success", "Site Moderator"} | labels]
|
||||
defp staff_role(labels, %{hide_default_role: false, role: "assisant"}),
|
||||
do: [{"label--purple", "Site Assistant"} | labels]
|
||||
defp staff_role(labels, _user),
|
||||
do: labels
|
||||
|
||||
defp avatar_url_root do
|
||||
Application.get_env(:philomena, :avatar_url_root)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue