philomena/lib/philomena_web/views/admin/report_view.ex

35 lines
1.1 KiB
Elixir
Raw Normal View History

2019-12-08 18:45:37 +01:00
defmodule PhilomenaWeb.Admin.ReportView do
use PhilomenaWeb, :view
2019-12-08 19:22:38 +01:00
alias Philomena.Images.Image
alias Philomena.Comments.Comment
2019-12-08 18:45:37 +01:00
import PhilomenaWeb.ReportView, only: [link_to_reported_thing: 2, report_row_class: 1, pretty_state: 1]
2019-12-08 19:18:10 +01:00
import PhilomenaWeb.ProfileView, only: [user_abbrv: 2, current?: 2]
2019-12-08 18:45:37 +01:00
def truncate(<<string::binary-size(50), _rest::binary>>), do: string <> "..."
def truncate(string), do: string
def truncated_ip_link(conn, ip) do
case to_string(ip) do
<<string::binary-size(25), _rest::binary>> = ip ->
link(string <> "...", to: Routes.ip_profile_path(conn, :show, ip))
ip ->
link(ip, to: Routes.ip_profile_path(conn, :show, ip))
end
end
def ordered_tags(tags) do
Enum.sort_by(tags, & &1.name)
end
2019-12-08 19:22:38 +01:00
def reported_image(conn, %Image{} = image) do
render PhilomenaWeb.ImageView, "_image_container.html", image: image, size: :thumb_tiny, conn: conn
end
def reported_image(conn, %Comment{image: image}) do
render PhilomenaWeb.ImageView, "_image_container.html", image: image, size: :thumb_tiny, conn: conn
end
def reported_image(_conn, _reportable), do: nil
2019-12-08 18:45:37 +01:00
end