diff --git a/lib/philomena/textile/renderer.ex b/lib/philomena/textile/renderer.ex index 5eef301b..850cea46 100644 --- a/lib/philomena/textile/renderer.ex +++ b/lib/philomena/textile/renderer.ex @@ -11,6 +11,9 @@ defmodule Philomena.Textile.Renderer do image_transform: &Camo.Image.image_url/1 } + # Kill bogus compile time dependency on ImageView + @image_view Module.concat(["PhilomenaWeb.ImageView"]) + def render_one(post, conn) do hd(render_collection([post], conn)) end @@ -79,15 +82,15 @@ defmodule Philomena.Textile.Renderer do match [image, "p"] -> - Phoenix.View.render(PhilomenaWeb.ImageView, "_image_target.html", image: image, size: :medium, conn: conn) + Phoenix.View.render(@image_view, "_image_target.html", image: image, size: :medium, conn: conn) |> safe_to_string() [image, "t"] -> - Phoenix.View.render(PhilomenaWeb.ImageView, "_image_target.html", image: image, size: :small, conn: conn) + Phoenix.View.render(@image_view, "_image_target.html", image: image, size: :small, conn: conn) |> safe_to_string() [image, "s"] -> - Phoenix.View.render(PhilomenaWeb.ImageView, "_image_target.html", image: image, size: :thumb_small, conn: conn) + Phoenix.View.render(@image_view, "_image_target.html", image: image, size: :thumb_small, conn: conn) |> safe_to_string() [image] -> diff --git a/lib/philomena_web/plugs/ensure_user_enabled_plug.ex b/lib/philomena_web/plugs/ensure_user_enabled_plug.ex index 0f14baf1..1ae54e8b 100644 --- a/lib/philomena_web/plugs/ensure_user_enabled_plug.ex +++ b/lib/philomena_web/plugs/ensure_user_enabled_plug.ex @@ -34,4 +34,4 @@ defmodule PhilomenaWeb.EnsureUserEnabledPlug do |> Controller.redirect(to: Routes.pow_session_path(conn, :new)) end defp maybe_halt(_any, conn), do: conn -end \ No newline at end of file +end diff --git a/lib/philomena_web/views/admin/advert_view.ex b/lib/philomena_web/views/admin/advert_view.ex index fa41d877..ac4aabc2 100644 --- a/lib/philomena_web/views/admin/advert_view.ex +++ b/lib/philomena_web/views/admin/advert_view.ex @@ -1,7 +1,10 @@ defmodule PhilomenaWeb.Admin.AdvertView do use PhilomenaWeb, :view - import PhilomenaWeb.AdvertView, only: [advert_image_url: 1] + alias PhilomenaWeb.AdvertView + + defp advert_image_url(advert), + do: AdvertView.advert_image_url(advert) def time_column_class(other_time) do now = DateTime.utc_now() diff --git a/lib/philomena_web/views/admin/badge_view.ex b/lib/philomena_web/views/admin/badge_view.ex index bb0157f8..af2987c5 100644 --- a/lib/philomena_web/views/admin/badge_view.ex +++ b/lib/philomena_web/views/admin/badge_view.ex @@ -1,5 +1,8 @@ defmodule PhilomenaWeb.Admin.BadgeView do use PhilomenaWeb, :view - import PhilomenaWeb.ProfileView, only: [badge_image: 2] + alias PhilomenaWeb.ProfileView + + defp badge_image(badge, options), + do: ProfileView.badge_image(badge, options) end diff --git a/lib/philomena_web/views/admin/dnp_entry_view.ex b/lib/philomena_web/views/admin/dnp_entry_view.ex index 9cc552ff..e9535278 100644 --- a/lib/philomena_web/views/admin/dnp_entry_view.ex +++ b/lib/philomena_web/views/admin/dnp_entry_view.ex @@ -1,7 +1,10 @@ defmodule PhilomenaWeb.Admin.DnpEntryView do use PhilomenaWeb, :view - import PhilomenaWeb.DnpEntryView, only: [pretty_state: 1] + alias PhilomenaWeb.DnpEntryView + + defp pretty_state(dnp_entry), + do: DnpEntryView.pretty_state(dnp_entry) def dnp_entry_row_class(%{aasm_state: state}) when state in ["closed", "listed"], do: "success" def dnp_entry_row_class(%{aasm_state: state}) when state in ["claimed", "acknowledged"], do: "warning" diff --git a/lib/philomena_web/views/admin/fingerprint_ban_view.ex b/lib/philomena_web/views/admin/fingerprint_ban_view.ex index 530e031e..c6c82c0b 100644 --- a/lib/philomena_web/views/admin/fingerprint_ban_view.ex +++ b/lib/philomena_web/views/admin/fingerprint_ban_view.ex @@ -1,7 +1,10 @@ defmodule PhilomenaWeb.Admin.FingerprintBanView do use PhilomenaWeb, :view - import PhilomenaWeb.ProfileView, only: [user_abbrv: 2] + alias PhilomenaWeb.ProfileView + + defp user_abbrv(conn, user), + do: ProfileView.user_abbrv(conn, user) defp 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 3bb3469b..a1615d85 100644 --- a/lib/philomena_web/views/admin/report_view.ex +++ b/lib/philomena_web/views/admin/report_view.ex @@ -4,8 +4,23 @@ defmodule PhilomenaWeb.Admin.ReportView do alias Philomena.Images.Image alias Philomena.Comments.Comment - import PhilomenaWeb.ReportView, only: [link_to_reported_thing: 2, report_row_class: 1, pretty_state: 1] - import PhilomenaWeb.ProfileView, only: [user_abbrv: 2, current?: 2] + alias PhilomenaWeb.ReportView + alias PhilomenaWeb.ProfileView + + defp link_to_reported_thing(conn, reportable), + do: ReportView.link_to_reported_thing(conn, reportable) + + defp report_row_class(report), + do: ReportView.report_row_class(report) + + defp pretty_state(report), + do: ReportView.pretty_state(report) + + defp user_abbrv(conn, user), + do: ProfileView.user_abbrv(conn, user) + + defp current?(current_user, user), + do: ProfileView.current?(current_user, user) def truncate(<>), do: string <> "..." def truncate(string), do: string diff --git a/lib/philomena_web/views/admin/subnet_ban_view.ex b/lib/philomena_web/views/admin/subnet_ban_view.ex index 3ac4ec9b..5190910f 100644 --- a/lib/philomena_web/views/admin/subnet_ban_view.ex +++ b/lib/philomena_web/views/admin/subnet_ban_view.ex @@ -1,7 +1,10 @@ defmodule PhilomenaWeb.Admin.SubnetBanView do use PhilomenaWeb, :view - import PhilomenaWeb.ProfileView, only: [user_abbrv: 2] + alias PhilomenaWeb.ProfileView + + defp user_abbrv(conn, user), + do: ProfileView.user_abbrv(conn, user) defp ban_row_class(%{valid_until: until, enabled: enabled}) do now = DateTime.utc_now() diff --git a/lib/philomena_web/views/admin/user_ban_view.ex b/lib/philomena_web/views/admin/user_ban_view.ex index fa54c658..12948daf 100644 --- a/lib/philomena_web/views/admin/user_ban_view.ex +++ b/lib/philomena_web/views/admin/user_ban_view.ex @@ -1,7 +1,10 @@ defmodule PhilomenaWeb.Admin.UserBanView do use PhilomenaWeb, :view - import PhilomenaWeb.ProfileView, only: [user_abbrv: 2] + alias PhilomenaWeb.ProfileView + + defp user_abbrv(conn, user), + do: ProfileView.user_abbrv(conn, user) defp ban_row_class(%{valid_until: until, enabled: enabled}) do now = DateTime.utc_now() diff --git a/lib/philomena_web/views/admin/user_link_view.ex b/lib/philomena_web/views/admin/user_link_view.ex index b8b7ebb3..266e78fc 100644 --- a/lib/philomena_web/views/admin/user_link_view.ex +++ b/lib/philomena_web/views/admin/user_link_view.ex @@ -1,7 +1,10 @@ defmodule PhilomenaWeb.Admin.UserLinkView do use PhilomenaWeb, :view - import Philomena.Tags.Tag, only: [display_order: 1] + alias Philomena.Tags.Tag + + defp display_order(tags), + do: Tag.display_order(tags) def link_state_class(%{aasm_state: state}) when state in ["verified", "link_verified"], do: "success" def link_state_class(%{aasm_state: state}) when state in ["unverified", "rejected"], do: "danger" diff --git a/lib/philomena_web/views/app_view.ex b/lib/philomena_web/views/app_view.ex index 81413f1f..f7f14ec6 100644 --- a/lib/philomena_web/views/app_view.ex +++ b/lib/philomena_web/views/app_view.ex @@ -1,5 +1,4 @@ defmodule PhilomenaWeb.AppView do - alias PhilomenaWeb.Router.Helpers, as: Routes use Phoenix.HTML @time_strings %{ @@ -127,8 +126,8 @@ defmodule PhilomenaWeb.AppView do end def link_to_ip(_conn, nil), do: content_tag(:code, "null") - def link_to_ip(conn, ip) do - link(to: Routes.ip_profile_path(conn, :show, to_string(ip))) do + def link_to_ip(_conn, ip) do + link(to: "/ip_profiles/#{ip}") do [ content_tag(:i, "", class: "fas fa-network-wired"), " ", @@ -138,8 +137,8 @@ defmodule PhilomenaWeb.AppView do end def link_to_fingerprint(_conn, nil), do: content_tag(:code, "null") - def link_to_fingerprint(conn, fp) do - link(to: Routes.fingerprint_profile_path(conn, :show, fp)) do + def link_to_fingerprint(_conn, fp) do + link(to: "/fingerprint_profiles/#{fp}") do [ content_tag(:i, "", class: "fas fa-desktop"), " ", diff --git a/lib/philomena_web/views/tag/image_view.ex b/lib/philomena_web/views/tag/image_view.ex index b9d8b1e6..43d697a3 100644 --- a/lib/philomena_web/views/tag/image_view.ex +++ b/lib/philomena_web/views/tag/image_view.ex @@ -1,5 +1,8 @@ defmodule PhilomenaWeb.Tag.ImageView do use PhilomenaWeb, :view - import PhilomenaWeb.TagView, only: [tag_image: 1] + alias PhilomenaWeb.TagView + + defp tag_image(tag), + do: TagView.tag_image(tag) end