From 42039491b63e5e674324c62647eab928073f44b7 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 28 Apr 2024 21:11:56 -0400 Subject: [PATCH] redirect_path, user_abbrv, last_message_path --- lib/philomena_web/controllers/report_controller.ex | 6 +++--- .../templates/admin/fingerprint_ban/index.html.slime | 2 +- .../templates/admin/report/_reports.html.slime | 2 +- .../templates/admin/subnet_ban/index.html.slime | 2 +- lib/philomena_web/templates/admin/user_ban/index.html.slime | 2 +- lib/philomena_web/templates/conversation/index.html.slime | 2 +- lib/philomena_web/templates/profile/show.html.slime | 2 +- lib/philomena_web/views/admin/ban_view.ex | 4 ++-- lib/philomena_web/views/admin/report_view.ex | 4 ++-- lib/philomena_web/views/conversation_view.ex | 2 +- lib/philomena_web/views/profile_view.ex | 4 ++-- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/philomena_web/controllers/report_controller.ex b/lib/philomena_web/controllers/report_controller.ex index 930ecf13..7860a32e 100644 --- a/lib/philomena_web/controllers/report_controller.ex +++ b/lib/philomena_web/controllers/report_controller.ex @@ -53,7 +53,7 @@ defmodule PhilomenaWeb.ReportController do :info, "Your report has been received and will be checked by staff shortly." ) - |> redirect(to: redirect_path(conn, conn.assigns.current_user)) + |> redirect(to: redirect_path(conn.assigns.current_user)) {:error, changeset} -> # Note that we are depending on the controller that called @@ -100,8 +100,8 @@ defmodule PhilomenaWeb.ReportController do reports_open >= max_reports() end - defp redirect_path(_conn, nil), do: "/" - defp redirect_path(conn, _user), do: ~p"/reports" + defp redirect_path(nil), do: "/" + defp redirect_path(_user), do: ~p"/reports" defp max_reports do 5 diff --git a/lib/philomena_web/templates/admin/fingerprint_ban/index.html.slime b/lib/philomena_web/templates/admin/fingerprint_ban/index.html.slime index 209ad509..7e42314a 100644 --- a/lib/philomena_web/templates/admin/fingerprint_ban/index.html.slime +++ b/lib/philomena_web/templates/admin/fingerprint_ban/index.html.slime @@ -35,7 +35,7 @@ h1 Fingerprint Bans td => pretty_time ban.created_at - = user_abbrv @conn, ban.banning_user + = user_abbrv ban.banning_user td class=ban_row_class(ban) = pretty_time ban.valid_until diff --git a/lib/philomena_web/templates/admin/report/_reports.html.slime b/lib/philomena_web/templates/admin/report/_reports.html.slime index 9ac6563e..a423d1e7 100644 --- a/lib/philomena_web/templates/admin/report/_reports.html.slime +++ b/lib/philomena_web/templates/admin/report/_reports.html.slime @@ -32,7 +32,7 @@ table.table td class=report_row_class(report) => pretty_state(report) - = user_abbrv @conn, report.admin + = user_abbrv report.admin td => link "Show", to: ~p"/admin/reports/#{report}" diff --git a/lib/philomena_web/templates/admin/subnet_ban/index.html.slime b/lib/philomena_web/templates/admin/subnet_ban/index.html.slime index ff139197..c051a10a 100644 --- a/lib/philomena_web/templates/admin/subnet_ban/index.html.slime +++ b/lib/philomena_web/templates/admin/subnet_ban/index.html.slime @@ -35,7 +35,7 @@ h1 Subnet Bans td => pretty_time ban.created_at - = user_abbrv @conn, ban.banning_user + = user_abbrv ban.banning_user td class=ban_row_class(ban) = pretty_time ban.valid_until diff --git a/lib/philomena_web/templates/admin/user_ban/index.html.slime b/lib/philomena_web/templates/admin/user_ban/index.html.slime index 3f76034d..5b60fc21 100644 --- a/lib/philomena_web/templates/admin/user_ban/index.html.slime +++ b/lib/philomena_web/templates/admin/user_ban/index.html.slime @@ -35,7 +35,7 @@ h1 User Bans td => pretty_time ban.created_at - = user_abbrv @conn, ban.banning_user + = user_abbrv ban.banning_user td class=ban_row_class(ban) = pretty_time ban.valid_until diff --git a/lib/philomena_web/templates/conversation/index.html.slime b/lib/philomena_web/templates/conversation/index.html.slime index ea476547..611610e0 100644 --- a/lib/philomena_web/templates/conversation/index.html.slime +++ b/lib/philomena_web/templates/conversation/index.html.slime @@ -36,7 +36,7 @@ h1 My Conversations td.table--communication-list__stats = render PhilomenaWeb.UserAttributionView, "_user.html", object: %{user: other_party(@current_user, c)}, conn: @conn td.table--communication-list__options - => link "Last message", to: last_message_path(@conn, c, count) + => link "Last message", to: last_message_path(c, count) ' • => link "Hide", to: ~p"/conversations/#{c}/hide", data: [method: "post"], data: [confirm: "Are you really, really sure?"] diff --git a/lib/philomena_web/templates/profile/show.html.slime b/lib/philomena_web/templates/profile/show.html.slime index 3179e247..6039a48d 100644 --- a/lib/philomena_web/templates/profile/show.html.slime +++ b/lib/philomena_web/templates/profile/show.html.slime @@ -116,7 +116,7 @@ .flex__grow.center => pretty_time(award.awarded_on) = if manages_awards?(@conn) do - = user_abbrv(@conn, award.awarded_by) + = user_abbrv(award.awarded_by) = if manages_awards?(@conn) do .flex__grow.center diff --git a/lib/philomena_web/views/admin/ban_view.ex b/lib/philomena_web/views/admin/ban_view.ex index 0df1e730..59fbe1de 100644 --- a/lib/philomena_web/views/admin/ban_view.ex +++ b/lib/philomena_web/views/admin/ban_view.ex @@ -1,8 +1,8 @@ defmodule PhilomenaWeb.Admin.BanView do alias PhilomenaWeb.ProfileView - def user_abbrv(conn, user), - do: ProfileView.user_abbrv(conn, user) + def user_abbrv(user), + do: ProfileView.user_abbrv(user) def ban_row_class(%{valid_until: until, enabled: enabled}) do now = DateTime.utc_now() diff --git a/lib/philomena_web/views/admin/report_view.ex b/lib/philomena_web/views/admin/report_view.ex index 56337cd2..7f81d93d 100644 --- a/lib/philomena_web/views/admin/report_view.ex +++ b/lib/philomena_web/views/admin/report_view.ex @@ -16,8 +16,8 @@ defmodule PhilomenaWeb.Admin.ReportView do defp pretty_state(report), do: ReportView.pretty_state(report) - defp user_abbrv(conn, user), - do: ProfileView.user_abbrv(conn, user) + defp user_abbrv(user), + do: ProfileView.user_abbrv(user) defp current?(current_user, user), do: ProfileView.current?(current_user, user) diff --git a/lib/philomena_web/views/conversation_view.ex b/lib/philomena_web/views/conversation_view.ex index c85902ab..97ce9c99 100644 --- a/lib/philomena_web/views/conversation_view.ex +++ b/lib/philomena_web/views/conversation_view.ex @@ -32,7 +32,7 @@ defmodule PhilomenaWeb.ConversationView do end end - def last_message_path(conn, conversation, count) do + def last_message_path(conversation, count) do page = trunc(Float.ceil(count / 25)) ~p"/conversations/#{conversation}?#{[page: page]}" diff --git a/lib/philomena_web/views/profile_view.ex b/lib/philomena_web/views/profile_view.ex index 2470d5cf..916ba334 100644 --- a/lib/philomena_web/views/profile_view.ex +++ b/lib/philomena_web/views/profile_view.ex @@ -77,7 +77,7 @@ defmodule PhilomenaWeb.ProfileView do def enabled_text(true), do: "Enabled" def enabled_text(_else), do: "Disabled" - def user_abbrv(conn, %{name: name} = user) do + def user_abbrv(%{name: name} = user) do abbrv = String.upcase(initials_abbrv(name) || uppercase_abbrv(name) || first_letters_abbrv(name)) @@ -86,7 +86,7 @@ defmodule PhilomenaWeb.ProfileView do link(abbrv, to: ~p"/profiles/#{user}") end - def user_abbrv(_conn, _user), do: content_tag(:span, "(n/a)") + def user_abbrv(_user), do: content_tag(:span, "(n/a)") defp initials_abbrv(name) do case String.split(name, " ", parts: 4) do