diff --git a/lib/philomena_web/controllers/admin/advert/image_controller.ex b/lib/philomena_web/controllers/admin/advert/image_controller.ex index 8fe46022..c3bae8c0 100644 --- a/lib/philomena_web/controllers/admin/advert/image_controller.ex +++ b/lib/philomena_web/controllers/admin/advert/image_controller.ex @@ -22,7 +22,7 @@ defmodule PhilomenaWeb.Admin.Advert.ImageController do {:ok, _advert} -> conn |> put_flash(:info, "Advert was successfully updated.") - |> redirect(to: Routes.admin_advert_path(conn, :index)) + |> redirect(to: ~p"/admin/adverts") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) diff --git a/lib/philomena_web/controllers/admin/advert_controller.ex b/lib/philomena_web/controllers/admin/advert_controller.ex index bb119f42..e058ce26 100644 --- a/lib/philomena_web/controllers/admin/advert_controller.ex +++ b/lib/philomena_web/controllers/admin/advert_controller.ex @@ -32,7 +32,7 @@ defmodule PhilomenaWeb.Admin.AdvertController do {:ok, _advert} -> conn |> put_flash(:info, "Advert was successfully created.") - |> redirect(to: Routes.admin_advert_path(conn, :index)) + |> redirect(to: ~p"/admin/adverts") {:error, :advert, changeset, _changes} -> render(conn, "new.html", changeset: changeset) @@ -49,7 +49,7 @@ defmodule PhilomenaWeb.Admin.AdvertController do {:ok, _advert} -> conn |> put_flash(:info, "Advert was successfully updated.") - |> redirect(to: Routes.admin_advert_path(conn, :index)) + |> redirect(to: ~p"/admin/adverts") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -61,7 +61,7 @@ defmodule PhilomenaWeb.Admin.AdvertController do conn |> put_flash(:info, "Advert was successfully deleted.") - |> redirect(to: Routes.admin_advert_path(conn, :index)) + |> redirect(to: ~p"/admin/adverts") end defp verify_authorized(conn, _opts) do diff --git a/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex b/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex index 98efb1f4..df25d5be 100644 --- a/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex @@ -18,14 +18,14 @@ defmodule PhilomenaWeb.Admin.ArtistLink.ContactController do conn |> put_flash(:info, "Artist successfully marked as contacted.") - |> moderation_log(details: &log_details/3, data: artist_link) - |> redirect(to: Routes.admin_artist_link_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: artist_link) + |> redirect(to: ~p"/admin/artist_links") end - defp log_details(conn, _action, artist_link) do + defp log_details(_action, artist_link) do %{ body: "Contacted artist #{artist_link.user.name} at #{artist_link.uri}", - subject_path: Routes.profile_artist_link_path(conn, :show, artist_link.user, artist_link) + subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}" } end end diff --git a/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex b/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex index 9bf92139..b9aab712 100644 --- a/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex @@ -17,14 +17,14 @@ defmodule PhilomenaWeb.Admin.ArtistLink.RejectController do conn |> put_flash(:info, "Artist link successfully marked as rejected.") - |> moderation_log(details: &log_details/3, data: artist_link) - |> redirect(to: Routes.admin_artist_link_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: artist_link) + |> redirect(to: ~p"/admin/artist_links") end - defp log_details(conn, _action, artist_link) do + defp log_details(_action, artist_link) do %{ body: "Rejected artist link #{artist_link.uri} created by #{artist_link.user.name}", - subject_path: Routes.profile_artist_link_path(conn, :show, artist_link.user, artist_link) + subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}" } end end diff --git a/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex b/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex index a4cc1fce..a1a2f86a 100644 --- a/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex @@ -18,14 +18,14 @@ defmodule PhilomenaWeb.Admin.ArtistLink.VerificationController do conn |> put_flash(:info, "Artist link successfully verified.") - |> moderation_log(details: &log_details/3, data: result.artist_link) - |> redirect(to: Routes.admin_artist_link_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: result.artist_link) + |> redirect(to: ~p"/admin/artist_links") end - defp log_details(conn, _action, artist_link) do + defp log_details(_action, artist_link) do %{ body: "Verified artist link #{artist_link.uri} created by #{artist_link.user.name}", - subject_path: Routes.profile_artist_link_path(conn, :show, artist_link.user, artist_link) + subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}" } end end diff --git a/lib/philomena_web/controllers/admin/badge/image_controller.ex b/lib/philomena_web/controllers/admin/badge/image_controller.ex index abdac0a2..069b8f0b 100644 --- a/lib/philomena_web/controllers/admin/badge/image_controller.ex +++ b/lib/philomena_web/controllers/admin/badge/image_controller.ex @@ -17,7 +17,7 @@ defmodule PhilomenaWeb.Admin.Badge.ImageController do {:ok, _badge} -> conn |> put_flash(:info, "Badge updated successfully.") - |> redirect(to: Routes.admin_badge_path(conn, :index)) + |> redirect(to: ~p"/admin/badges") {:error, :badge, changeset, _changes} -> render(conn, "edit.html", changeset: changeset) diff --git a/lib/philomena_web/controllers/admin/badge_controller.ex b/lib/philomena_web/controllers/admin/badge_controller.ex index 2aa79e31..f253f647 100644 --- a/lib/philomena_web/controllers/admin/badge_controller.ex +++ b/lib/philomena_web/controllers/admin/badge_controller.ex @@ -28,7 +28,7 @@ defmodule PhilomenaWeb.Admin.BadgeController do {:ok, _badge} -> conn |> put_flash(:info, "Badge created successfully.") - |> redirect(to: Routes.admin_badge_path(conn, :index)) + |> redirect(to: ~p"/admin/badges") {:error, :badge, changeset, _changes} -> render(conn, "new.html", changeset: changeset) @@ -45,7 +45,7 @@ defmodule PhilomenaWeb.Admin.BadgeController do {:ok, _badge} -> conn |> put_flash(:info, "Badge updated successfully.") - |> redirect(to: Routes.admin_badge_path(conn, :index)) + |> redirect(to: ~p"/admin/badges") {:error, :badge, changeset, _changes} -> render(conn, "edit.html", changeset: changeset) diff --git a/lib/philomena_web/controllers/admin/batch/tag_controller.ex b/lib/philomena_web/controllers/admin/batch/tag_controller.ex index 4ae3c714..ec98b530 100644 --- a/lib/philomena_web/controllers/admin/batch/tag_controller.ex +++ b/lib/philomena_web/controllers/admin/batch/tag_controller.ex @@ -48,10 +48,11 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do {:ok, _} -> conn |> moderation_log( - details: &log_details/3, + details: &log_details/2, data: %{ tag_list: tag_list, - image_count: Enum.count(image_ids) + image_count: Enum.count(image_ids), + user: conn.assigns.current_user } ) |> json(%{succeeded: image_ids, failed: []}) @@ -68,10 +69,10 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do end end - defp log_details(conn, _action, data) do + defp log_details(_action, data) do %{ body: "Batch tagged '#{data.tag_list}' on #{data.image_count} images", - subject_path: Routes.profile_path(conn, :show, conn.assigns.current_user) + subject_path: ~p"/profiles/#{data.user}" } end end diff --git a/lib/philomena_web/controllers/admin/dnp_entry/transition_controller.ex b/lib/philomena_web/controllers/admin/dnp_entry/transition_controller.ex index a774ece0..8f0fc52e 100644 --- a/lib/philomena_web/controllers/admin/dnp_entry/transition_controller.ex +++ b/lib/philomena_web/controllers/admin/dnp_entry/transition_controller.ex @@ -16,12 +16,12 @@ defmodule PhilomenaWeb.Admin.DnpEntry.TransitionController do {:ok, dnp_entry} -> conn |> put_flash(:info, "Successfully updated DNP entry.") - |> redirect(to: Routes.dnp_entry_path(conn, :show, dnp_entry)) + |> redirect(to: ~p"/dnp/#{dnp_entry}") {:error, _changeset} -> conn |> put_flash(:error, "Failed to update DNP entry!") - |> redirect(to: Routes.dnp_entry_path(conn, :show, conn.assigns.dnp_entry)) + |> redirect(to: ~p"/dnp/#{conn.assigns.dnp_entry}") end end diff --git a/lib/philomena_web/controllers/admin/donation_controller.ex b/lib/philomena_web/controllers/admin/donation_controller.ex index 91de59cf..2274daff 100644 --- a/lib/philomena_web/controllers/admin/donation_controller.ex +++ b/lib/philomena_web/controllers/admin/donation_controller.ex @@ -23,12 +23,12 @@ defmodule PhilomenaWeb.Admin.DonationController do {:ok, _donation} -> conn |> put_flash(:info, "Donation successfully created.") - |> redirect(to: Routes.admin_donation_path(conn, :index)) + |> redirect(to: ~p"/admin/donations") _error -> conn |> put_flash(:error, "Error creating donation!") - |> redirect(to: Routes.admin_donation_path(conn, :index)) + |> redirect(to: ~p"/admin/donations") end end diff --git a/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex b/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex index 5cb4ccd0..ccc4f56a 100644 --- a/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex @@ -47,8 +47,8 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do {:ok, fingerprint_ban} -> conn |> put_flash(:info, "Fingerprint was successfully banned.") - |> moderation_log(details: &log_details/3, data: fingerprint_ban) - |> redirect(to: Routes.admin_fingerprint_ban_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: fingerprint_ban) + |> redirect(to: ~p"/admin/fingerprint_bans") {:error, changeset} -> render(conn, "new.html", changeset: changeset) @@ -65,8 +65,8 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do {:ok, fingerprint_ban} -> conn |> put_flash(:info, "Fingerprint ban successfully updated.") - |> moderation_log(details: &log_details/3, data: fingerprint_ban) - |> redirect(to: Routes.admin_fingerprint_ban_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: fingerprint_ban) + |> redirect(to: ~p"/admin/fingerprint_bans") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -78,8 +78,8 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do conn |> put_flash(:info, "Fingerprint ban successfully deleted.") - |> moderation_log(details: &log_details/3, data: fingerprint_ban) - |> redirect(to: Routes.admin_fingerprint_ban_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: fingerprint_ban) + |> redirect(to: ~p"/admin/fingerprint_bans") end defp load_bans(queryable, conn) do @@ -110,7 +110,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do end end - defp log_details(conn, action, ban) do + defp log_details(action, ban) do body = case action do :create -> "Created a fingerprint ban #{ban.generated_ban_id}" @@ -118,6 +118,6 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do :delete -> "Deleted a fingerprint ban #{ban.generated_ban_id}" end - %{body: body, subject_path: Routes.admin_fingerprint_ban_path(conn, :index)} + %{body: body, subject_path: ~p"/admin/fingerprint_bans"} end end diff --git a/lib/philomena_web/controllers/admin/forum_controller.ex b/lib/philomena_web/controllers/admin/forum_controller.ex index 7d9e0190..5c40e4c4 100644 --- a/lib/philomena_web/controllers/admin/forum_controller.ex +++ b/lib/philomena_web/controllers/admin/forum_controller.ex @@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Admin.ForumController do {:ok, _forum} -> conn |> put_flash(:info, "Forum created successfully.") - |> redirect(to: Routes.admin_forum_path(conn, :index)) + |> redirect(to: ~p"/admin/forums") {:error, changeset} -> render(conn, "new.html", changeset: changeset) @@ -38,7 +38,7 @@ defmodule PhilomenaWeb.Admin.ForumController do {:ok, _forum} -> conn |> put_flash(:info, "Forum updated successfully.") - |> redirect(to: Routes.admin_forum_path(conn, :index)) + |> redirect(to: ~p"/admin/forums") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) diff --git a/lib/philomena_web/controllers/admin/mod_note_controller.ex b/lib/philomena_web/controllers/admin/mod_note_controller.ex index 23f71815..f5b3999f 100644 --- a/lib/philomena_web/controllers/admin/mod_note_controller.ex +++ b/lib/philomena_web/controllers/admin/mod_note_controller.ex @@ -46,7 +46,7 @@ defmodule PhilomenaWeb.Admin.ModNoteController do {:ok, _mod_note} -> conn |> put_flash(:info, "Successfully created mod note.") - |> redirect(to: Routes.admin_mod_note_path(conn, :index)) + |> redirect(to: ~p"/admin/mod_notes") {:error, changeset} -> render(conn, "new.html", changeset: changeset) @@ -63,7 +63,7 @@ defmodule PhilomenaWeb.Admin.ModNoteController do {:ok, _mod_note} -> conn |> put_flash(:info, "Successfully updated mod note.") - |> redirect(to: Routes.admin_mod_note_path(conn, :index)) + |> redirect(to: ~p"/admin/mod_notes") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -75,7 +75,7 @@ defmodule PhilomenaWeb.Admin.ModNoteController do conn |> put_flash(:info, "Successfully deleted mod note.") - |> redirect(to: Routes.admin_mod_note_path(conn, :index)) + |> redirect(to: ~p"/admin/mod_notes") end defp verify_authorized(conn, _opts) do diff --git a/lib/philomena_web/controllers/admin/report/claim_controller.ex b/lib/philomena_web/controllers/admin/report/claim_controller.ex index ffcdfcc6..fed9314b 100644 --- a/lib/philomena_web/controllers/admin/report/claim_controller.ex +++ b/lib/philomena_web/controllers/admin/report/claim_controller.ex @@ -12,12 +12,12 @@ defmodule PhilomenaWeb.Admin.Report.ClaimController do {:ok, _report} -> conn |> put_flash(:info, "Successfully marked report as in progress") - |> redirect(to: Routes.admin_report_path(conn, :index)) + |> redirect(to: ~p"/admin/reports") {:error, _changeset} -> conn |> put_flash(:warning, "Couldn't claim that report!") - |> redirect(to: Routes.admin_report_path(conn, :show, conn.assigns.report)) + |> redirect(to: ~p"/admin/reports/#{conn.assigns.report}") end end @@ -26,6 +26,6 @@ defmodule PhilomenaWeb.Admin.Report.ClaimController do conn |> put_flash(:info, "Successfully released report.") - |> redirect(to: Routes.admin_report_path(conn, :show, report)) + |> redirect(to: ~p"/admin/reports/#{report}") end end diff --git a/lib/philomena_web/controllers/admin/report/close_controller.ex b/lib/philomena_web/controllers/admin/report/close_controller.ex index dedb4d2d..75f1e7ff 100644 --- a/lib/philomena_web/controllers/admin/report/close_controller.ex +++ b/lib/philomena_web/controllers/admin/report/close_controller.ex @@ -12,6 +12,6 @@ defmodule PhilomenaWeb.Admin.Report.CloseController do conn |> put_flash(:info, "Successfully closed report") - |> redirect(to: Routes.admin_report_path(conn, :index)) + |> redirect(to: ~p"/admin/reports") end end diff --git a/lib/philomena_web/controllers/admin/site_notice_controller.ex b/lib/philomena_web/controllers/admin/site_notice_controller.ex index 11462540..7612422e 100644 --- a/lib/philomena_web/controllers/admin/site_notice_controller.ex +++ b/lib/philomena_web/controllers/admin/site_notice_controller.ex @@ -28,7 +28,7 @@ defmodule PhilomenaWeb.Admin.SiteNoticeController do {:ok, _site_notice} -> conn |> put_flash(:info, "Successfully created site notice.") - |> redirect(to: Routes.admin_site_notice_path(conn, :index)) + |> redirect(to: ~p"/admin/site_notices") {:error, changeset} -> render(conn, "new.html", changeset: changeset) @@ -45,7 +45,7 @@ defmodule PhilomenaWeb.Admin.SiteNoticeController do {:ok, _site_notice} -> conn |> put_flash(:info, "Succesfully updated site notice.") - |> redirect(to: Routes.admin_site_notice_path(conn, :index)) + |> redirect(to: ~p"/admin/site_notices") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -57,7 +57,7 @@ defmodule PhilomenaWeb.Admin.SiteNoticeController do conn |> put_flash(:info, "Sucessfully deleted site notice.") - |> redirect(to: Routes.admin_site_notice_path(conn, :index)) + |> redirect(to: ~p"/admin/site_notices") end defp verify_authorized(conn, _opts) do diff --git a/lib/philomena_web/controllers/admin/subnet_ban_controller.ex b/lib/philomena_web/controllers/admin/subnet_ban_controller.ex index 93c42807..f4163921 100644 --- a/lib/philomena_web/controllers/admin/subnet_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/subnet_ban_controller.ex @@ -49,8 +49,8 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do {:ok, subnet_ban} -> conn |> put_flash(:info, "Subnet was successfully banned.") - |> moderation_log(details: &log_details/3, data: subnet_ban) - |> redirect(to: Routes.admin_subnet_ban_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: subnet_ban) + |> redirect(to: ~p"/admin/subnet_bans") {:error, changeset} -> render(conn, "new.html", changeset: changeset) @@ -67,8 +67,8 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do {:ok, subnet_ban} -> conn |> put_flash(:info, "Subnet ban successfully updated.") - |> moderation_log(details: &log_details/3, data: subnet_ban) - |> redirect(to: Routes.admin_subnet_ban_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: subnet_ban) + |> redirect(to: ~p"/admin/subnet_bans") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -80,8 +80,8 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do conn |> put_flash(:info, "Subnet ban successfully deleted.") - |> moderation_log(details: &log_details/3, data: subnet_ban) - |> redirect(to: Routes.admin_subnet_ban_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: subnet_ban) + |> redirect(to: ~p"/admin/subnet_bans") end defp load_bans(queryable, conn) do @@ -112,7 +112,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do end end - defp log_details(conn, action, ban) do + defp log_details(action, ban) do body = case action do :create -> "Created a subnet ban #{ban.generated_ban_id}" @@ -120,6 +120,6 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do :delete -> "Deleted a subnet ban #{ban.generated_ban_id}" end - %{body: body, subject_path: Routes.admin_subnet_ban_path(conn, :index)} + %{body: body, subject_path: ~p"/admin/subnet_bans"} end end diff --git a/lib/philomena_web/controllers/admin/user/activation_controller.ex b/lib/philomena_web/controllers/admin/user/activation_controller.ex index e5f78aad..f261ab1b 100644 --- a/lib/philomena_web/controllers/admin/user/activation_controller.ex +++ b/lib/philomena_web/controllers/admin/user/activation_controller.ex @@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.ActivationController do conn |> put_flash(:info, "User was reactivated.") - |> redirect(to: Routes.profile_path(conn, :show, user)) + |> redirect(to: ~p"/profiles/#{user}") end def delete(conn, _params) do @@ -20,7 +20,7 @@ defmodule PhilomenaWeb.Admin.User.ActivationController do conn |> put_flash(:info, "User was deactivated.") - |> redirect(to: Routes.profile_path(conn, :show, user)) + |> redirect(to: ~p"/profiles/#{user}") end defp verify_authorized(conn, _opts) do diff --git a/lib/philomena_web/controllers/admin/user/api_key_controller.ex b/lib/philomena_web/controllers/admin/user/api_key_controller.ex index 7059779d..56414283 100644 --- a/lib/philomena_web/controllers/admin/user/api_key_controller.ex +++ b/lib/philomena_web/controllers/admin/user/api_key_controller.ex @@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.ApiKeyController do conn |> put_flash(:info, "API token was successfully reset.") - |> redirect(to: Routes.profile_path(conn, :show, user)) + |> redirect(to: ~p"/profiles/#{user}") end defp verify_authorized(conn, _opts) do diff --git a/lib/philomena_web/controllers/admin/user/avatar_controller.ex b/lib/philomena_web/controllers/admin/user/avatar_controller.ex index c04fdbcd..80c1e262 100644 --- a/lib/philomena_web/controllers/admin/user/avatar_controller.ex +++ b/lib/philomena_web/controllers/admin/user/avatar_controller.ex @@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.AvatarController do conn |> put_flash(:info, "Successfully removed avatar.") - |> redirect(to: Routes.admin_user_path(conn, :edit, conn.assigns.user)) + |> redirect(to: ~p"/admin/users/#{conn.assigns.user}/edit") end defp verify_authorized(conn, _opts) do diff --git a/lib/philomena_web/controllers/admin/user/downvote_controller.ex b/lib/philomena_web/controllers/admin/user/downvote_controller.ex index ec52452a..f2694da5 100644 --- a/lib/philomena_web/controllers/admin/user/downvote_controller.ex +++ b/lib/philomena_web/controllers/admin/user/downvote_controller.ex @@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.DownvoteController do conn |> put_flash(:alert, "Downvote wipe started.") - |> redirect(to: Routes.profile_path(conn, :show, conn.assigns.user)) + |> redirect(to: ~p"/profiles/#{conn.assigns.user}") end defp verify_authorized(conn, _opts) do diff --git a/lib/philomena_web/controllers/admin/user/force_filter_controller.ex b/lib/philomena_web/controllers/admin/user/force_filter_controller.ex index 049d68fb..74266ef5 100644 --- a/lib/philomena_web/controllers/admin/user/force_filter_controller.ex +++ b/lib/philomena_web/controllers/admin/user/force_filter_controller.ex @@ -18,7 +18,7 @@ defmodule PhilomenaWeb.Admin.User.ForceFilterController do conn |> put_flash(:info, "Filter was forced.") - |> redirect(to: Routes.profile_path(conn, :show, user)) + |> redirect(to: ~p"/profiles/#{user}") end def delete(conn, _params) do @@ -26,7 +26,7 @@ defmodule PhilomenaWeb.Admin.User.ForceFilterController do conn |> put_flash(:info, "Forced filter was removed.") - |> redirect(to: Routes.profile_path(conn, :show, user)) + |> redirect(to: ~p"/profiles/#{user}") end defp verify_authorized(conn, _opts) do diff --git a/lib/philomena_web/controllers/admin/user/unlock_controller.ex b/lib/philomena_web/controllers/admin/user/unlock_controller.ex index 0c36122e..54610fda 100644 --- a/lib/philomena_web/controllers/admin/user/unlock_controller.ex +++ b/lib/philomena_web/controllers/admin/user/unlock_controller.ex @@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.UnlockController do conn |> put_flash(:info, "User was unlocked.") - |> redirect(to: Routes.profile_path(conn, :show, user)) + |> redirect(to: ~p"/profiles/#{user}") end defp verify_authorized(conn, _opts) do diff --git a/lib/philomena_web/controllers/admin/user/verification_controller.ex b/lib/philomena_web/controllers/admin/user/verification_controller.ex index 982a520c..82b0745a 100644 --- a/lib/philomena_web/controllers/admin/user/verification_controller.ex +++ b/lib/philomena_web/controllers/admin/user/verification_controller.ex @@ -12,8 +12,8 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do conn |> put_flash(:info, "User verification granted.") - |> moderation_log(details: &log_details/3, data: user) - |> redirect(to: Routes.profile_path(conn, :show, user)) + |> moderation_log(details: &log_details/2, data: user) + |> redirect(to: ~p"/profiles/#{user}") end def delete(conn, _params) do @@ -21,8 +21,8 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do conn |> put_flash(:info, "User verification revoked.") - |> moderation_log(details: &log_details/3, data: user) - |> redirect(to: Routes.profile_path(conn, :show, user)) + |> moderation_log(details: &log_details/2, data: user) + |> redirect(to: ~p"/profiles/#{user}") end defp verify_authorized(conn, _opts) do @@ -32,13 +32,13 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do end end - defp log_details(conn, action, user) do + defp log_details(action, user) do body = case action do :create -> "Granted verification to #{user.name}" :delete -> "Revoked verification from #{user.name}" end - %{body: body, subject_path: Routes.profile_path(conn, :show, user)} + %{body: body, subject_path: ~p"/profiles/#{user}"} end end diff --git a/lib/philomena_web/controllers/admin/user/vote_controller.ex b/lib/philomena_web/controllers/admin/user/vote_controller.ex index 405bcd7d..a319e3f6 100644 --- a/lib/philomena_web/controllers/admin/user/vote_controller.ex +++ b/lib/philomena_web/controllers/admin/user/vote_controller.ex @@ -12,7 +12,7 @@ defmodule PhilomenaWeb.Admin.User.VoteController do conn |> put_flash(:alert, "Vote and fave wipe started.") - |> redirect(to: Routes.profile_path(conn, :show, conn.assigns.user)) + |> redirect(to: ~p"/profiles/#{conn.assigns.user}") end defp verify_authorized(conn, _opts) do diff --git a/lib/philomena_web/controllers/admin/user/wipe_controller.ex b/lib/philomena_web/controllers/admin/user/wipe_controller.ex index 8f194a38..1e887166 100644 --- a/lib/philomena_web/controllers/admin/user/wipe_controller.ex +++ b/lib/philomena_web/controllers/admin/user/wipe_controller.ex @@ -15,7 +15,7 @@ defmodule PhilomenaWeb.Admin.User.WipeController do :alert, "PII wipe queued, please verify and then deactivate the account as necessary." ) - |> redirect(to: Routes.profile_path(conn, :show, conn.assigns.user)) + |> redirect(to: ~p"/profiles/#{conn.assigns.user}") end defp verify_authorized(conn, _opts) do diff --git a/lib/philomena_web/controllers/admin/user_ban_controller.ex b/lib/philomena_web/controllers/admin/user_ban_controller.ex index f98c3337..24847076 100644 --- a/lib/philomena_web/controllers/admin/user_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/user_ban_controller.ex @@ -50,8 +50,8 @@ defmodule PhilomenaWeb.Admin.UserBanController do {:ok, user_ban} -> conn |> put_flash(:info, "User was successfully banned.") - |> moderation_log(details: &log_details/3, data: user_ban) - |> redirect(to: Routes.admin_user_ban_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: user_ban) + |> redirect(to: ~p"/admin/user_bans") {:error, :user_ban, changeset, _changes} -> render(conn, "new.html", changeset: changeset) @@ -71,8 +71,8 @@ defmodule PhilomenaWeb.Admin.UserBanController do {:ok, user_ban} -> conn |> put_flash(:info, "User ban successfully updated.") - |> moderation_log(details: &log_details/3, data: user_ban) - |> redirect(to: Routes.admin_user_ban_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: user_ban) + |> redirect(to: ~p"/admin/user_bans") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -84,8 +84,8 @@ defmodule PhilomenaWeb.Admin.UserBanController do conn |> put_flash(:info, "User ban successfully deleted.") - |> moderation_log(details: &log_details/3, data: user_ban) - |> redirect(to: Routes.admin_user_ban_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: user_ban) + |> redirect(to: ~p"/admin/user_bans") end defp load_bans(queryable, conn) do @@ -116,7 +116,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do end end - defp log_details(conn, action, ban) do + defp log_details(action, ban) do body = case action do :create -> "Created a user ban #{ban.generated_ban_id}" @@ -124,6 +124,6 @@ defmodule PhilomenaWeb.Admin.UserBanController do :delete -> "Deleted a user ban #{ban.generated_ban_id}" end - %{body: body, subject_path: Routes.admin_user_ban_path(conn, :index)} + %{body: body, subject_path: ~p"/admin/user_bans"} end end diff --git a/lib/philomena_web/controllers/admin/user_controller.ex b/lib/philomena_web/controllers/admin/user_controller.ex index fe31d2f4..266291de 100644 --- a/lib/philomena_web/controllers/admin/user_controller.ex +++ b/lib/philomena_web/controllers/admin/user_controller.ex @@ -62,8 +62,8 @@ defmodule PhilomenaWeb.Admin.UserController do {:ok, user} -> conn |> put_flash(:info, "User successfully updated.") - |> moderation_log(details: &log_details/3, data: user) - |> redirect(to: Routes.profile_path(conn, :show, user)) + |> moderation_log(details: &log_details/2, data: user) + |> redirect(to: ~p"/profiles/#{user}") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -81,10 +81,10 @@ defmodule PhilomenaWeb.Admin.UserController do assign(conn, :roles, Repo.all(Role)) end - defp log_details(conn, _action, user) do + defp log_details(_action, user) do %{ body: "Updated user details for #{user.name}", - subject_path: Routes.profile_path(conn, :show, user) + subject_path: ~p"/profiles/#{user}" } end end diff --git a/lib/philomena_web/controllers/avatar_controller.ex b/lib/philomena_web/controllers/avatar_controller.ex index 50a30cf2..9b6e4544 100644 --- a/lib/philomena_web/controllers/avatar_controller.ex +++ b/lib/philomena_web/controllers/avatar_controller.ex @@ -18,7 +18,7 @@ defmodule PhilomenaWeb.AvatarController do {:ok, _user} -> conn |> put_flash(:info, "Successfully updated avatar.") - |> redirect(to: Routes.avatar_path(conn, :edit)) + |> redirect(to: ~p"/avatar/edit") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -30,6 +30,6 @@ defmodule PhilomenaWeb.AvatarController do conn |> put_flash(:info, "Successfully removed avatar.") - |> redirect(to: Routes.avatar_path(conn, :edit)) + |> redirect(to: ~p"/avatar/edit") end end diff --git a/lib/philomena_web/controllers/channel/nsfw_controller.ex b/lib/philomena_web/controllers/channel/nsfw_controller.ex index f695fb4d..31125122 100644 --- a/lib/philomena_web/controllers/channel/nsfw_controller.ex +++ b/lib/philomena_web/controllers/channel/nsfw_controller.ex @@ -7,14 +7,14 @@ defmodule PhilomenaWeb.Channel.NsfwController do conn |> set_cookie("chan_nsfw", "true") |> put_flash(:info, "Successfully updated channel visibility.") - |> redirect(to: Routes.channel_path(conn, :index)) + |> redirect(to: ~p"/channels") end def delete(conn, _params) do conn |> set_cookie("chan_nsfw", "false") |> put_flash(:info, "Successfully updated channel visibility.") - |> redirect(to: Routes.channel_path(conn, :index)) + |> redirect(to: ~p"/channels") end # Duplicated from setting controller diff --git a/lib/philomena_web/controllers/channel_controller.ex b/lib/philomena_web/controllers/channel_controller.ex index 973017d3..6d88d257 100644 --- a/lib/philomena_web/controllers/channel_controller.ex +++ b/lib/philomena_web/controllers/channel_controller.ex @@ -52,7 +52,7 @@ defmodule PhilomenaWeb.ChannelController do {:ok, _channel} -> conn |> put_flash(:info, "Channel created successfully.") - |> redirect(to: Routes.channel_path(conn, :index)) + |> redirect(to: ~p"/channels") {:error, changeset} -> render(conn, "new.html", changeset: changeset) @@ -69,7 +69,7 @@ defmodule PhilomenaWeb.ChannelController do {:ok, _channel} -> conn |> put_flash(:info, "Channel updated successfully.") - |> redirect(to: Routes.channel_path(conn, :index)) + |> redirect(to: ~p"/channels") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -81,7 +81,7 @@ defmodule PhilomenaWeb.ChannelController do conn |> put_flash(:info, "Channel destroyed successfully.") - |> redirect(to: Routes.channel_path(conn, :index)) + |> redirect(to: ~p"/channels") end defp maybe_search(query, %{"cq" => cq}) when is_binary(cq) and cq != "" do diff --git a/lib/philomena_web/controllers/confirmation_controller.ex b/lib/philomena_web/controllers/confirmation_controller.ex index 37e96b18..64b0f2b7 100644 --- a/lib/philomena_web/controllers/confirmation_controller.ex +++ b/lib/philomena_web/controllers/confirmation_controller.ex @@ -14,7 +14,7 @@ defmodule PhilomenaWeb.ConfirmationController do if user = Users.get_user_by_email(email) do Users.deliver_user_confirmation_instructions( user, - &Routes.confirmation_url(conn, :show, &1) + &url(~p"/confirmations/#{&1}") ) end diff --git a/lib/philomena_web/controllers/conversation/hide_controller.ex b/lib/philomena_web/controllers/conversation/hide_controller.ex index 44bd8bad..71480de6 100644 --- a/lib/philomena_web/controllers/conversation/hide_controller.ex +++ b/lib/philomena_web/controllers/conversation/hide_controller.ex @@ -20,7 +20,7 @@ defmodule PhilomenaWeb.Conversation.HideController do conn |> put_flash(:info, "Conversation hidden.") - |> redirect(to: Routes.conversation_path(conn, :index)) + |> redirect(to: ~p"/conversations") end def delete(conn, _params) do @@ -31,6 +31,6 @@ defmodule PhilomenaWeb.Conversation.HideController do conn |> put_flash(:info, "Conversation restored.") - |> redirect(to: Routes.conversation_path(conn, :show, conversation)) + |> redirect(to: ~p"/conversations/#{conversation}") end end diff --git a/lib/philomena_web/controllers/conversation/message/approve_controller.ex b/lib/philomena_web/controllers/conversation/message/approve_controller.ex index 3ecade26..1693f432 100644 --- a/lib/philomena_web/controllers/conversation/message/approve_controller.ex +++ b/lib/philomena_web/controllers/conversation/message/approve_controller.ex @@ -20,11 +20,11 @@ defmodule PhilomenaWeb.Conversation.Message.ApproveController do conn |> put_flash(:info, "Conversation message approved.") - |> moderation_log(details: &log_details/3, data: message) + |> moderation_log(details: &log_details/2, data: message) |> redirect(to: "/") end - defp log_details(_conn, _action, message) do + defp log_details(_action, message) do %{ body: "Approved private message in conversation ##{message.conversation_id}", subject_path: "/" diff --git a/lib/philomena_web/controllers/conversation/message_controller.ex b/lib/philomena_web/controllers/conversation/message_controller.ex index 7e238902..8bd44940 100644 --- a/lib/philomena_web/controllers/conversation/message_controller.ex +++ b/lib/philomena_web/controllers/conversation/message_controller.ex @@ -36,12 +36,12 @@ defmodule PhilomenaWeb.Conversation.MessageController do conn |> put_flash(:info, "Message successfully sent.") - |> redirect(to: Routes.conversation_path(conn, :show, conversation, page: page)) + |> redirect(to: ~p"/conversations/#{conversation}?#{[page: page]}") _error -> conn |> put_flash(:error, "There was an error posting your message") - |> redirect(to: Routes.conversation_path(conn, :show, conversation)) + |> redirect(to: ~p"/conversations/#{conversation}") end end end diff --git a/lib/philomena_web/controllers/conversation/read_controller.ex b/lib/philomena_web/controllers/conversation/read_controller.ex index 93a5601e..aa777274 100644 --- a/lib/philomena_web/controllers/conversation/read_controller.ex +++ b/lib/philomena_web/controllers/conversation/read_controller.ex @@ -20,7 +20,7 @@ defmodule PhilomenaWeb.Conversation.ReadController do conn |> put_flash(:info, "Conversation marked as read.") - |> redirect(to: Routes.conversation_path(conn, :show, conversation)) + |> redirect(to: ~p"/conversations/#{conversation}") end def delete(conn, _params) do @@ -31,6 +31,6 @@ defmodule PhilomenaWeb.Conversation.ReadController do conn |> put_flash(:info, "Conversation marked as unread.") - |> redirect(to: Routes.conversation_path(conn, :index)) + |> redirect(to: ~p"/conversations") end end diff --git a/lib/philomena_web/controllers/conversation/report_controller.ex b/lib/philomena_web/controllers/conversation/report_controller.ex index 634bed1a..dab81482 100644 --- a/lib/philomena_web/controllers/conversation/report_controller.ex +++ b/lib/philomena_web/controllers/conversation/report_controller.ex @@ -22,7 +22,7 @@ defmodule PhilomenaWeb.Conversation.ReportController do def new(conn, _params) do conversation = conn.assigns.conversation - action = Routes.conversation_report_path(conn, :create, conversation) + action = ~p"/conversations/#{conversation}/reports" changeset = %Report{reportable_type: "Conversation", reportable_id: conversation.id} @@ -40,7 +40,7 @@ defmodule PhilomenaWeb.Conversation.ReportController do def create(conn, params) do conversation = conn.assigns.conversation - action = Routes.conversation_report_path(conn, :create, conversation) + action = ~p"/conversations/#{conversation}/reports" ReportController.create(conn, action, conversation, "Conversation", params) end diff --git a/lib/philomena_web/controllers/conversation_controller.ex b/lib/philomena_web/controllers/conversation_controller.ex index 8b936f8e..12784b42 100644 --- a/lib/philomena_web/controllers/conversation_controller.ex +++ b/lib/philomena_web/controllers/conversation_controller.ex @@ -115,7 +115,7 @@ defmodule PhilomenaWeb.ConversationController do conn |> put_flash(:info, "Conversation successfully created.") - |> redirect(to: Routes.conversation_path(conn, :show, conversation)) + |> redirect(to: ~p"/conversations/#{conversation}") {:error, changeset} -> conn diff --git a/lib/philomena_web/controllers/dnp_entry_controller.ex b/lib/philomena_web/controllers/dnp_entry_controller.ex index ff3f1a07..d2e675b2 100644 --- a/lib/philomena_web/controllers/dnp_entry_controller.ex +++ b/lib/philomena_web/controllers/dnp_entry_controller.ex @@ -97,7 +97,7 @@ defmodule PhilomenaWeb.DnpEntryController do {:ok, dnp_entry} -> conn |> put_flash(:info, "Successfully submitted DNP request.") - |> redirect(to: Routes.dnp_entry_path(conn, :show, dnp_entry)) + |> redirect(to: ~p"/dnp/#{dnp_entry}") {:error, changeset} -> render(conn, "new.html", changeset: changeset) @@ -122,7 +122,7 @@ defmodule PhilomenaWeb.DnpEntryController do {:ok, dnp_entry} -> conn |> put_flash(:info, "Successfully updated DNP request.") - |> redirect(to: Routes.dnp_entry_path(conn, :show, dnp_entry)) + |> redirect(to: ~p"/dnp/#{dnp_entry}") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) diff --git a/lib/philomena_web/controllers/duplicate_report/accept_controller.ex b/lib/philomena_web/controllers/duplicate_report/accept_controller.ex index 35c5f78f..2d45f457 100644 --- a/lib/philomena_web/controllers/duplicate_report/accept_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/accept_controller.ex @@ -20,21 +20,21 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptController do {:ok, report} -> conn |> put_flash(:info, "Successfully accepted report.") - |> moderation_log(details: &log_details/3, data: report.duplicate_report) - |> redirect(to: Routes.duplicate_report_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: report.duplicate_report) + |> redirect(to: ~p"/duplicate_reports") _error -> conn |> put_flash(:warning, "Failed to accept report! Maybe someone else already accepted it.") - |> redirect(to: Routes.duplicate_report_path(conn, :index)) + |> redirect(to: ~p"/duplicate_reports") end end - defp log_details(conn, _action, report) do + defp log_details(_action, report) do %{ body: "Accepted duplicate report, merged #{report.image.id} into #{report.duplicate_of_image.id}", - subject_path: Routes.image_path(conn, :show, report.image) + subject_path: ~p"/images/#{report.image}" } end end diff --git a/lib/philomena_web/controllers/duplicate_report/accept_reverse_controller.ex b/lib/philomena_web/controllers/duplicate_report/accept_reverse_controller.ex index 21978478..1c7125d8 100644 --- a/lib/philomena_web/controllers/duplicate_report/accept_reverse_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/accept_reverse_controller.ex @@ -20,21 +20,21 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptReverseController do {:ok, report} -> conn |> put_flash(:info, "Successfully accepted report in reverse.") - |> moderation_log(details: &log_details/3, data: report.duplicate_report) - |> redirect(to: Routes.duplicate_report_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: report.duplicate_report) + |> redirect(to: ~p"/duplicate_reports") _error -> conn |> put_flash(:warning, "Failed to accept report! Maybe someone else already accepted it.") - |> redirect(to: Routes.duplicate_report_path(conn, :index)) + |> redirect(to: ~p"/duplicate_reports") end end - defp log_details(conn, _action, report) do + defp log_details(_action, report) do %{ body: "Reverse-accepted duplicate report, merged #{report.image.id} into #{report.duplicate_of_image.id}", - subject_path: Routes.image_path(conn, :show, report.image) + subject_path: ~p"/images/#{report.image}" } end end diff --git a/lib/philomena_web/controllers/duplicate_report/claim_controller.ex b/lib/philomena_web/controllers/duplicate_report/claim_controller.ex index 31646f56..2abec4b3 100644 --- a/lib/philomena_web/controllers/duplicate_report/claim_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/claim_controller.ex @@ -20,8 +20,8 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do conn |> put_flash(:info, "Successfully claimed report.") - |> moderation_log(details: &log_details/3, data: report) - |> redirect(to: Routes.duplicate_report_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: report) + |> redirect(to: ~p"/duplicate_reports") end def delete(conn, _params) do @@ -29,11 +29,11 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do conn |> put_flash(:info, "Successfully released report.") - |> moderation_log(details: &log_details/3) - |> redirect(to: Routes.duplicate_report_path(conn, :index)) + |> moderation_log(details: &log_details/2) + |> redirect(to: ~p"/duplicate_reports") end - defp log_details(conn, action, _) do + defp log_details(action, _) do body = case action do :create -> "Claimed a duplicate report" @@ -42,7 +42,7 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do %{ body: body, - subject_path: Routes.duplicate_report_path(conn, :index) + subject_path: ~p"/duplicate_reports" } end end diff --git a/lib/philomena_web/controllers/duplicate_report/reject_controller.ex b/lib/philomena_web/controllers/duplicate_report/reject_controller.ex index e019fb2a..957a92c8 100644 --- a/lib/philomena_web/controllers/duplicate_report/reject_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/reject_controller.ex @@ -21,14 +21,14 @@ defmodule PhilomenaWeb.DuplicateReport.RejectController do conn |> put_flash(:info, "Successfully rejected report.") - |> moderation_log(details: &log_details/3, data: report) - |> redirect(to: Routes.duplicate_report_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: report) + |> redirect(to: ~p"/duplicate_reports") end - defp log_details(conn, _action, report) do + defp log_details(_action, report) do %{ body: "Rejected duplicate report (#{report.image.id} -> #{report.duplicate_of_image.id})", - subject_path: Routes.duplicate_report_path(conn, :index) + subject_path: ~p"/duplicate_reports" } end end diff --git a/lib/philomena_web/controllers/duplicate_report_controller.ex b/lib/philomena_web/controllers/duplicate_report_controller.ex index f30539a0..5fd80e38 100644 --- a/lib/philomena_web/controllers/duplicate_report_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report_controller.ex @@ -56,12 +56,12 @@ defmodule PhilomenaWeb.DuplicateReportController do {:ok, duplicate_report} -> conn |> put_flash(:info, "Duplicate report created successfully.") - |> redirect(to: Routes.image_path(conn, :show, duplicate_report.image_id)) + |> redirect(to: ~p"/images/#{duplicate_report.image_id}") {:error, _changeset} -> conn |> put_flash(:error, "Failed to submit duplicate report") - |> redirect(to: Routes.image_path(conn, :show, source)) + |> redirect(to: ~p"/images/#{source}") end end diff --git a/lib/philomena_web/controllers/filter/clear_recent.ex b/lib/philomena_web/controllers/filter/clear_recent.ex index f3aed68d..24f321d3 100644 --- a/lib/philomena_web/controllers/filter/clear_recent.ex +++ b/lib/philomena_web/controllers/filter/clear_recent.ex @@ -10,6 +10,6 @@ defmodule PhilomenaWeb.Filter.ClearRecentController do conn |> put_flash(:info, "Cleared recent filters.") - |> redirect(to: Routes.filter_path(conn, :index)) + |> redirect(to: ~p"/filters") end end diff --git a/lib/philomena_web/controllers/filter/public_controller.ex b/lib/philomena_web/controllers/filter/public_controller.ex index 80e23308..e31a8219 100644 --- a/lib/philomena_web/controllers/filter/public_controller.ex +++ b/lib/philomena_web/controllers/filter/public_controller.ex @@ -12,12 +12,12 @@ defmodule PhilomenaWeb.Filter.PublicController do {:ok, filter} -> conn |> put_flash(:info, "Successfully made filter public.") - |> redirect(to: Routes.filter_path(conn, :show, filter)) + |> redirect(to: ~p"/filters/#{filter}") _error -> conn |> put_flash(:error, "Couldn't make filter public!") - |> redirect(to: Routes.filter_path(conn, :show, conn.assigns.filter)) + |> redirect(to: ~p"/filters/#{conn.assigns.filter}") end end end diff --git a/lib/philomena_web/controllers/filter_controller.ex b/lib/philomena_web/controllers/filter_controller.ex index 0d188f38..63546767 100644 --- a/lib/philomena_web/controllers/filter_controller.ex +++ b/lib/philomena_web/controllers/filter_controller.ex @@ -146,7 +146,7 @@ defmodule PhilomenaWeb.FilterController do {:ok, filter} -> conn |> put_flash(:info, "Filter created successfully.") - |> redirect(to: Routes.filter_path(conn, :show, filter)) + |> redirect(to: ~p"/filters/#{filter}") {:error, %Ecto.Changeset{} = changeset} -> render(conn, "new.html", changeset: changeset) @@ -171,7 +171,7 @@ defmodule PhilomenaWeb.FilterController do {:ok, filter} -> conn |> put_flash(:info, "Filter updated successfully.") - |> redirect(to: Routes.filter_path(conn, :show, filter)) + |> redirect(to: ~p"/filters/#{filter}") {:error, %Ecto.Changeset{} = changeset} -> render(conn, "edit.html", filter: filter, changeset: changeset) @@ -185,12 +185,12 @@ defmodule PhilomenaWeb.FilterController do {:ok, _filter} -> conn |> put_flash(:info, "Filter deleted successfully.") - |> redirect(to: Routes.filter_path(conn, :index)) + |> redirect(to: ~p"/filters") _error -> conn |> put_flash(:warning, "Filter is still in use, not deleted.") - |> redirect(to: Routes.filter_path(conn, :show, filter)) + |> redirect(to: ~p"/filters/#{filter}") end end end diff --git a/lib/philomena_web/controllers/gallery/report_controller.ex b/lib/philomena_web/controllers/gallery/report_controller.ex index 879fd8fd..3d4b5fd5 100644 --- a/lib/philomena_web/controllers/gallery/report_controller.ex +++ b/lib/philomena_web/controllers/gallery/report_controller.ex @@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Gallery.ReportController do def new(conn, _params) do gallery = conn.assigns.gallery - action = Routes.gallery_report_path(conn, :create, gallery) + action = ~p"/galleries/#{gallery}/reports" changeset = %Report{reportable_type: "Gallery", reportable_id: gallery.id} @@ -39,7 +39,7 @@ defmodule PhilomenaWeb.Gallery.ReportController do def create(conn, params) do gallery = conn.assigns.gallery - action = Routes.gallery_report_path(conn, :create, gallery) + action = ~p"/galleries/#{gallery}/reports" ReportController.create(conn, action, gallery, "Gallery", params) end diff --git a/lib/philomena_web/controllers/gallery_controller.ex b/lib/philomena_web/controllers/gallery_controller.ex index ee19d230..2b298d2c 100644 --- a/lib/philomena_web/controllers/gallery_controller.ex +++ b/lib/philomena_web/controllers/gallery_controller.ex @@ -110,7 +110,7 @@ defmodule PhilomenaWeb.GalleryController do {:ok, gallery} -> conn |> put_flash(:info, "Gallery successfully created.") - |> redirect(to: Routes.gallery_path(conn, :show, gallery)) + |> redirect(to: ~p"/galleries/#{gallery}") {:error, changeset} -> conn @@ -132,7 +132,7 @@ defmodule PhilomenaWeb.GalleryController do {:ok, gallery} -> conn |> put_flash(:info, "Gallery successfully updated.") - |> redirect(to: Routes.gallery_path(conn, :show, gallery)) + |> redirect(to: ~p"/galleries/#{gallery}") {:error, changeset} -> conn @@ -147,7 +147,7 @@ defmodule PhilomenaWeb.GalleryController do conn |> put_flash(:info, "Gallery successfully destroyed.") - |> redirect(to: Routes.gallery_path(conn, :index)) + |> redirect(to: ~p"/galleries") end defp prev_next_page_images(conn, query) do diff --git a/lib/philomena_web/controllers/image/anonymous_controller.ex b/lib/philomena_web/controllers/image/anonymous_controller.ex index d74b1682..e36b5020 100644 --- a/lib/philomena_web/controllers/image/anonymous_controller.ex +++ b/lib/philomena_web/controllers/image/anonymous_controller.ex @@ -22,8 +22,8 @@ defmodule PhilomenaWeb.Image.AnonymousController do conn |> put_flash(:info, "Successfully updated anonymity.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") end defp verify_authorized(conn, _opts) do @@ -33,10 +33,10 @@ defmodule PhilomenaWeb.Image.AnonymousController do end end - defp log_details(conn, _action, image) do + defp log_details(_action, image) do %{ body: "Updated anonymity of image >>#{image.id}", - subject_path: Routes.image_path(conn, :show, image) + subject_path: ~p"/images/#{image}" } end end diff --git a/lib/philomena_web/controllers/image/approve_controller.ex b/lib/philomena_web/controllers/image/approve_controller.ex index 689339f8..bbb3e8da 100644 --- a/lib/philomena_web/controllers/image/approve_controller.ex +++ b/lib/philomena_web/controllers/image/approve_controller.ex @@ -14,11 +14,11 @@ defmodule PhilomenaWeb.Image.ApproveController do conn |> put_flash(:info, "Image has been approved.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.admin_approval_path(conn, :index)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/admin/approvals") end - defp log_details(conn, _action, image) do - %{body: "Approved image #{image.id}", subject_path: Routes.image_path(conn, :show, image)} + defp log_details(_action, image) do + %{body: "Approved image #{image.id}", subject_path: ~p"/images/#{image}"} end end diff --git a/lib/philomena_web/controllers/image/comment/approve_controller.ex b/lib/philomena_web/controllers/image/comment/approve_controller.ex index 699d0cc2..617d0280 100644 --- a/lib/philomena_web/controllers/image/comment/approve_controller.ex +++ b/lib/philomena_web/controllers/image/comment/approve_controller.ex @@ -22,14 +22,14 @@ defmodule PhilomenaWeb.Image.Comment.ApproveController do conn |> put_flash(:info, "Comment has been approved.") - |> moderation_log(details: &log_details/3, data: comment) - |> redirect(to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}") + |> moderation_log(details: &log_details/2, data: comment) + |> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}") end - defp log_details(conn, _action, comment) do + defp log_details(_action, comment) do %{ body: "Approved comment on image >>#{comment.image_id}", - subject_path: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}" + subject_path: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}" } end end diff --git a/lib/philomena_web/controllers/image/comment/delete_controller.ex b/lib/philomena_web/controllers/image/comment/delete_controller.ex index 4527e759..2cf8fb39 100644 --- a/lib/philomena_web/controllers/image/comment/delete_controller.ex +++ b/lib/philomena_web/controllers/image/comment/delete_controller.ex @@ -16,24 +16,20 @@ defmodule PhilomenaWeb.Image.Comment.DeleteController do conn |> put_flash(:info, "Comment successfully destroyed!") - |> moderation_log(details: &log_details/3, data: comment) - |> redirect( - to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}" - ) + |> moderation_log(details: &log_details/2, data: comment) + |> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}") {:error, _changeset} -> conn |> put_flash(:error, "Unable to destroy comment!") - |> redirect( - to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}" - ) + |> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}") end end - defp log_details(conn, _action, comment) do + defp log_details(_action, comment) do %{ body: "Destroyed comment on image >>#{comment.image_id}", - subject_path: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}" + subject_path: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}" } end end diff --git a/lib/philomena_web/controllers/image/comment/hide_controller.ex b/lib/philomena_web/controllers/image/comment/hide_controller.ex index 1e55f86d..2fe709a5 100644 --- a/lib/philomena_web/controllers/image/comment/hide_controller.ex +++ b/lib/philomena_web/controllers/image/comment/hide_controller.ex @@ -15,17 +15,13 @@ defmodule PhilomenaWeb.Image.Comment.HideController do {:ok, comment} -> conn |> put_flash(:info, "Comment successfully hidden!") - |> moderation_log(details: &log_details/3, data: comment) - |> redirect( - to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}" - ) + |> moderation_log(details: &log_details/2, data: comment) + |> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}") _error -> conn |> put_flash(:error, "Unable to hide comment!") - |> redirect( - to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}" - ) + |> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}") end end @@ -36,21 +32,17 @@ defmodule PhilomenaWeb.Image.Comment.HideController do {:ok, comment} -> conn |> put_flash(:info, "Comment successfully unhidden!") - |> moderation_log(details: &log_details/3, data: comment) - |> redirect( - to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}" - ) + |> moderation_log(details: &log_details/2, data: comment) + |> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}") {:error, _changeset} -> conn |> put_flash(:error, "Unable to unhide comment!") - |> redirect( - to: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}" - ) + |> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}") end end - defp log_details(conn, action, comment) do + defp log_details(action, comment) do body = case action do :create -> "Hidden comment on image >>#{comment.image_id} (#{comment.deletion_reason})" @@ -59,7 +51,7 @@ defmodule PhilomenaWeb.Image.Comment.HideController do %{ body: body, - subject_path: Routes.image_path(conn, :show, comment.image_id) <> "#comment_#{comment.id}" + subject_path: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}" } end end diff --git a/lib/philomena_web/controllers/image/comment/report_controller.ex b/lib/philomena_web/controllers/image/comment/report_controller.ex index 27725a4b..d957abbd 100644 --- a/lib/philomena_web/controllers/image/comment/report_controller.ex +++ b/lib/philomena_web/controllers/image/comment/report_controller.ex @@ -24,7 +24,7 @@ defmodule PhilomenaWeb.Image.Comment.ReportController do def new(conn, _params) do comment = conn.assigns.comment - action = Routes.image_comment_report_path(conn, :create, comment.image, comment) + action = ~p"/images/#{comment.image}/comments/#{comment}/reports" changeset = %Report{reportable_type: "Comment", reportable_id: comment.id} @@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Image.Comment.ReportController do def create(conn, params) do comment = conn.assigns.comment - action = Routes.image_comment_report_path(conn, :create, comment.image, comment) + action = ~p"/images/#{comment.image}/comments/#{comment}/reports" ReportController.create(conn, action, comment, "Comment", params) end diff --git a/lib/philomena_web/controllers/image/comment_controller.ex b/lib/philomena_web/controllers/image/comment_controller.ex index cfcda777..ca0ff9ad 100644 --- a/lib/philomena_web/controllers/image/comment_controller.ex +++ b/lib/philomena_web/controllers/image/comment_controller.ex @@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Image.CommentController do def index(conn, %{"comment_id" => comment_id}) do page = CommentLoader.find_page(conn, conn.assigns.image, comment_id) - redirect(conn, to: Routes.image_comment_path(conn, :index, conn.assigns.image, page: page)) + redirect(conn, to: ~p"/images/#{conn.assigns.image}/comments?#{[page: page]}") end def index(conn, _params) do @@ -93,7 +93,7 @@ defmodule PhilomenaWeb.Image.CommentController do _error -> conn |> put_flash(:error, "There was an error posting your comment") - |> redirect(to: Routes.image_path(conn, :show, image)) + |> redirect(to: ~p"/images/#{image}") end end @@ -126,9 +126,7 @@ defmodule PhilomenaWeb.Image.CommentController do conn |> put_flash(:info, "Comment updated successfully.") - |> redirect( - to: Routes.image_path(conn, :show, conn.assigns.image) <> "#comment_#{comment.id}" - ) + |> redirect(to: ~p"/images/#{conn.assigns.image}" <> "#comment_#{comment.id}") {:error, :comment, changeset, _changes} -> render(conn, "edit.html", comment: conn.assigns.comment, changeset: changeset) diff --git a/lib/philomena_web/controllers/image/comment_lock_controller.ex b/lib/philomena_web/controllers/image/comment_lock_controller.ex index e913bdb6..432d1283 100644 --- a/lib/philomena_web/controllers/image/comment_lock_controller.ex +++ b/lib/philomena_web/controllers/image/comment_lock_controller.ex @@ -12,8 +12,8 @@ defmodule PhilomenaWeb.Image.CommentLockController do conn |> put_flash(:info, "Successfully locked comments.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") end def delete(conn, _params) do @@ -21,11 +21,11 @@ defmodule PhilomenaWeb.Image.CommentLockController do conn |> put_flash(:info, "Successfully unlocked comments.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") end - defp log_details(conn, action, image) do + defp log_details(action, image) do body = case action do :create -> "Locked comments on image >>#{image.id}" @@ -34,7 +34,7 @@ defmodule PhilomenaWeb.Image.CommentLockController do %{ body: body, - subject_path: Routes.image_path(conn, :show, image) + subject_path: ~p"/images/#{image}" } end end diff --git a/lib/philomena_web/controllers/image/delete_controller.ex b/lib/philomena_web/controllers/image/delete_controller.ex index adae818c..c6b22d54 100644 --- a/lib/philomena_web/controllers/image/delete_controller.ex +++ b/lib/philomena_web/controllers/image/delete_controller.ex @@ -19,13 +19,13 @@ defmodule PhilomenaWeb.Image.DeleteController do {:ok, result} -> conn |> put_flash(:info, "Image successfully hidden.") - |> moderation_log(details: &log_details/3, data: result.image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: result.image) + |> redirect(to: ~p"/images/#{image}") _error -> conn |> put_flash(:error, "Failed to hide image.") - |> redirect(to: Routes.image_path(conn, :show, image)) + |> redirect(to: ~p"/images/#{image}") end end @@ -36,13 +36,13 @@ defmodule PhilomenaWeb.Image.DeleteController do {:ok, image} -> conn |> put_flash(:info, "Hide reason updated.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") {:error, _changeset} -> conn |> put_flash(:error, "Couldn't update hide reason.") - |> redirect(to: Routes.image_path(conn, :show, image)) + |> redirect(to: ~p"/images/#{image}") end end @@ -54,7 +54,7 @@ defmodule PhilomenaWeb.Image.DeleteController do _false -> conn |> put_flash(:error, "Cannot change hide reason on a non-hidden image!") - |> redirect(to: Routes.image_path(conn, :show, conn.assigns.image)) + |> redirect(to: ~p"/images/#{conn.assigns.image}") |> halt() end end @@ -66,11 +66,11 @@ defmodule PhilomenaWeb.Image.DeleteController do conn |> put_flash(:info, "Image successfully unhidden.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") end - defp log_details(conn, action, image) do + defp log_details(action, image) do body = case action do :create -> "Hidden image >>#{image.id} (#{image.deletion_reason})" @@ -80,7 +80,7 @@ defmodule PhilomenaWeb.Image.DeleteController do %{ body: body, - subject_path: Routes.image_path(conn, :show, image) + subject_path: ~p"/images/#{image}" } end end diff --git a/lib/philomena_web/controllers/image/description_lock_controller.ex b/lib/philomena_web/controllers/image/description_lock_controller.ex index ed8c9c87..9065ff6d 100644 --- a/lib/philomena_web/controllers/image/description_lock_controller.ex +++ b/lib/philomena_web/controllers/image/description_lock_controller.ex @@ -12,8 +12,8 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do conn |> put_flash(:info, "Successfully locked description.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") end def delete(conn, _params) do @@ -21,11 +21,11 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do conn |> put_flash(:info, "Successfully unlocked description.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") end - defp log_details(conn, action, image) do + defp log_details(action, image) do body = case action do :create -> "Locked description editing on image >>#{image.id}" @@ -34,7 +34,7 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do %{ body: body, - subject_path: Routes.image_path(conn, :show, image) + subject_path: ~p"/images/#{image}" } end end diff --git a/lib/philomena_web/controllers/image/destroy_controller.ex b/lib/philomena_web/controllers/image/destroy_controller.ex index fe2f3e6e..8685bc77 100644 --- a/lib/philomena_web/controllers/image/destroy_controller.ex +++ b/lib/philomena_web/controllers/image/destroy_controller.ex @@ -15,13 +15,13 @@ defmodule PhilomenaWeb.Image.DestroyController do {:ok, image} -> conn |> put_flash(:info, "Image contents destroyed.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") _error -> conn |> put_flash(:error, "Failed to destroy image.") - |> redirect(to: Routes.image_path(conn, :show, image)) + |> redirect(to: ~p"/images/#{image}") end end @@ -33,15 +33,15 @@ defmodule PhilomenaWeb.Image.DestroyController do _false -> conn |> put_flash(:error, "Cannot destroy a non-hidden image!") - |> redirect(to: Routes.image_path(conn, :show, conn.assigns.image)) + |> redirect(to: ~p"/images/#{conn.assigns.image}") |> halt() end end - defp log_details(conn, _action, image) do + defp log_details(_action, image) do %{ body: "Hard-deleted image >>#{image.id}", - subject_path: Routes.image_path(conn, :show, image) + subject_path: ~p"/images/#{image}" } end end diff --git a/lib/philomena_web/controllers/image/feature_controller.ex b/lib/philomena_web/controllers/image/feature_controller.ex index 36286c1f..4cac3d55 100644 --- a/lib/philomena_web/controllers/image/feature_controller.ex +++ b/lib/philomena_web/controllers/image/feature_controller.ex @@ -16,8 +16,8 @@ defmodule PhilomenaWeb.Image.FeatureController do conn |> put_flash(:info, "Image marked as featured image.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") end defp verify_not_deleted(conn, _opts) do @@ -25,7 +25,7 @@ defmodule PhilomenaWeb.Image.FeatureController do true -> conn |> put_flash(:warning, "Cannot feature a hidden image.") - |> redirect(to: Routes.image_path(conn, :show, conn.assigns.image)) + |> redirect(to: ~p"/images/#{conn.assigns.image}") |> halt() _false -> @@ -33,10 +33,10 @@ defmodule PhilomenaWeb.Image.FeatureController do end end - defp log_details(conn, _action, image) do + defp log_details(_action, image) do %{ body: "Featured image >>#{image.id}", - subject_path: Routes.image_path(conn, :show, image) + subject_path: ~p"/images/#{image}" } end end diff --git a/lib/philomena_web/controllers/image/file_controller.ex b/lib/philomena_web/controllers/image/file_controller.ex index e3bd2ab1..dc0672f0 100644 --- a/lib/philomena_web/controllers/image/file_controller.ex +++ b/lib/philomena_web/controllers/image/file_controller.ex @@ -16,12 +16,12 @@ defmodule PhilomenaWeb.Image.FileController do {:ok, image} -> conn |> put_flash(:info, "Successfully updated file.") - |> redirect(to: Routes.image_path(conn, :show, image)) + |> redirect(to: ~p"/images/#{image}") _error -> conn |> put_flash(:error, "Failed to update file!") - |> redirect(to: Routes.image_path(conn, :show, conn.assigns.image)) + |> redirect(to: ~p"/images/#{conn.assigns.image}") end end @@ -30,7 +30,7 @@ defmodule PhilomenaWeb.Image.FileController do true -> conn |> put_flash(:warning, "Cannot replace a hidden image.") - |> redirect(to: Routes.image_path(conn, :show, conn.assigns.image)) + |> redirect(to: ~p"/images/#{conn.assigns.image}") |> halt() _false -> diff --git a/lib/philomena_web/controllers/image/hash_controller.ex b/lib/philomena_web/controllers/image/hash_controller.ex index ad99b133..ab929724 100644 --- a/lib/philomena_web/controllers/image/hash_controller.ex +++ b/lib/philomena_web/controllers/image/hash_controller.ex @@ -12,14 +12,14 @@ defmodule PhilomenaWeb.Image.HashController do conn |> put_flash(:info, "Successfully cleared hash.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") end - defp log_details(conn, _action, image) do + defp log_details(_action, image) do %{ body: "Cleared hash of image >>#{image.id}", - subject_path: Routes.image_path(conn, :show, image) + subject_path: ~p"/images/#{image}" } end end diff --git a/lib/philomena_web/controllers/image/navigate_controller.ex b/lib/philomena_web/controllers/image/navigate_controller.ex index ab74f038..c0827caa 100644 --- a/lib/philomena_web/controllers/image/navigate_controller.ex +++ b/lib/philomena_web/controllers/image/navigate_controller.ex @@ -21,11 +21,11 @@ defmodule PhilomenaWeb.Image.NavigateController do |> case do {next_image, hit} -> redirect(conn, - to: Routes.image_path(conn, :show, next_image, Keyword.put(scope, :sort, hit["sort"])) + to: ~p"/images/#{next_image}?#{Keyword.put(scope, :sort, hit["sort"])}" ) nil -> - redirect(conn, to: Routes.image_path(conn, :show, image, scope)) + redirect(conn, to: ~p"/images/#{image}?#{scope}") end end @@ -41,7 +41,7 @@ defmodule PhilomenaWeb.Image.NavigateController do page_num = page_for_offset(pagination.page_size, images.total_entries) - redirect(conn, to: Routes.search_path(conn, :index, q: "*", page: page_num)) + redirect(conn, to: ~p"/search?#{[q: "*", page: page_num]}") end defp page_for_offset(per_page, offset) do diff --git a/lib/philomena_web/controllers/image/random_controller.ex b/lib/philomena_web/controllers/image/random_controller.ex index f39d8c75..9bc293f7 100644 --- a/lib/philomena_web/controllers/image/random_controller.ex +++ b/lib/philomena_web/controllers/image/random_controller.ex @@ -20,10 +20,10 @@ defmodule PhilomenaWeb.Image.RandomController do case unwrap_random_result(search_definition) do nil -> - redirect(conn, to: Routes.image_path(conn, :index)) + redirect(conn, to: ~p"/images") random_id -> - redirect(conn, to: Routes.image_path(conn, :show, random_id, scope)) + redirect(conn, to: ~p"/images/#{random_id}?#{scope}") end end diff --git a/lib/philomena_web/controllers/image/repair_controller.ex b/lib/philomena_web/controllers/image/repair_controller.ex index 7e40835a..972d79df 100644 --- a/lib/philomena_web/controllers/image/repair_controller.ex +++ b/lib/philomena_web/controllers/image/repair_controller.ex @@ -13,14 +13,14 @@ defmodule PhilomenaWeb.Image.RepairController do conn |> put_flash(:info, "Repair job enqueued.") - |> moderation_log(details: &log_details/3, data: conn.assigns.image) - |> redirect(to: Routes.image_path(conn, :show, conn.assigns.image)) + |> moderation_log(details: &log_details/2, data: conn.assigns.image) + |> redirect(to: ~p"/images/#{conn.assigns.image}") end - defp log_details(conn, _action, image) do + defp log_details(_action, image) do %{ body: "Repaired image >>#{image.id}", - subject_path: Routes.image_path(conn, :show, image) + subject_path: ~p"/images/#{image}" } end end diff --git a/lib/philomena_web/controllers/image/report_controller.ex b/lib/philomena_web/controllers/image/report_controller.ex index 99e2bace..6956832e 100644 --- a/lib/philomena_web/controllers/image/report_controller.ex +++ b/lib/philomena_web/controllers/image/report_controller.ex @@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Image.ReportController do def new(conn, _params) do image = conn.assigns.image - action = Routes.image_report_path(conn, :create, image) + action = ~p"/images/#{image}/reports" changeset = %Report{reportable_type: "Image", reportable_id: image.id} @@ -39,7 +39,7 @@ defmodule PhilomenaWeb.Image.ReportController do def create(conn, params) do image = conn.assigns.image - action = Routes.image_report_path(conn, :create, image) + action = ~p"/images/#{image}/reports" ReportController.create(conn, action, image, "Image", params) end diff --git a/lib/philomena_web/controllers/image/scratchpad_controller.ex b/lib/philomena_web/controllers/image/scratchpad_controller.ex index 863c0bc8..56ffe897 100644 --- a/lib/philomena_web/controllers/image/scratchpad_controller.ex +++ b/lib/philomena_web/controllers/image/scratchpad_controller.ex @@ -17,14 +17,14 @@ defmodule PhilomenaWeb.Image.ScratchpadController do conn |> put_flash(:info, "Successfully updated moderation notes.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") end - defp log_details(conn, _action, image) do + defp log_details(_action, image) do %{ body: "Updated mod notes on image >>#{image.id} (#{image.scratchpad})", - subject_path: Routes.image_path(conn, :show, image) + subject_path: ~p"/images/#{image}" } end end diff --git a/lib/philomena_web/controllers/image/source_history_controller.ex b/lib/philomena_web/controllers/image/source_history_controller.ex index 24bab27f..f82a344f 100644 --- a/lib/philomena_web/controllers/image/source_history_controller.ex +++ b/lib/philomena_web/controllers/image/source_history_controller.ex @@ -14,14 +14,14 @@ defmodule PhilomenaWeb.Image.SourceHistoryController do conn |> put_flash(:info, "Successfully deleted source history.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") end - defp log_details(conn, _action, image) do + defp log_details(_action, image) do %{ body: "Deleted source history for image >>#{image.id}", - subject_path: Routes.image_path(conn, :show, image) + subject_path: ~p"/images/#{image}" } end end diff --git a/lib/philomena_web/controllers/image/tag_change_controller.ex b/lib/philomena_web/controllers/image/tag_change_controller.ex index 6868ed96..fc35a782 100644 --- a/lib/philomena_web/controllers/image/tag_change_controller.ex +++ b/lib/philomena_web/controllers/image/tag_change_controller.ex @@ -43,10 +43,10 @@ defmodule PhilomenaWeb.Image.TagChangeController do conn |> put_flash(:info, "Successfully deleted tag change from history.") |> moderation_log( - details: &log_details/3, + details: &log_details/2, data: %{image: image, details: tag_change_details(tag_change)} ) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> redirect(to: ~p"/images/#{image}") end defp added_filter(query, %{"added" => "1"}), @@ -58,10 +58,10 @@ defmodule PhilomenaWeb.Image.TagChangeController do defp added_filter(query, _params), do: query - defp log_details(conn, _action, %{image: image, details: details}) do + defp log_details(_action, %{image: image, details: details}) do %{ body: "Deleted tag change #{details} on >>#{image.id} from history", - subject_path: Routes.image_path(conn, :show, image) + subject_path: ~p"/images/#{image}" } end diff --git a/lib/philomena_web/controllers/image/tag_lock_controller.ex b/lib/philomena_web/controllers/image/tag_lock_controller.ex index 2f71b4a3..028cbf4c 100644 --- a/lib/philomena_web/controllers/image/tag_lock_controller.ex +++ b/lib/philomena_web/controllers/image/tag_lock_controller.ex @@ -23,8 +23,8 @@ defmodule PhilomenaWeb.Image.TagLockController do conn |> put_flash(:info, "Successfully updated list of locked tags.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") end def create(conn, _params) do @@ -32,8 +32,8 @@ defmodule PhilomenaWeb.Image.TagLockController do conn |> put_flash(:info, "Successfully locked tags.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") end def delete(conn, _params) do @@ -41,11 +41,11 @@ defmodule PhilomenaWeb.Image.TagLockController do conn |> put_flash(:info, "Successfully unlocked tags.") - |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, image)) + |> moderation_log(details: &log_details/2, data: image) + |> redirect(to: ~p"/images/#{image}") end - defp log_details(conn, action, image) do + defp log_details(action, image) do body = case action do :create -> "Locked tags on image >>#{image.id}" @@ -55,7 +55,7 @@ defmodule PhilomenaWeb.Image.TagLockController do %{ body: body, - subject_path: Routes.image_path(conn, :show, image) + subject_path: ~p"/images/#{image}" } end end diff --git a/lib/philomena_web/controllers/image/tamper_controller.ex b/lib/philomena_web/controllers/image/tamper_controller.ex index 8eb66309..ede16a46 100644 --- a/lib/philomena_web/controllers/image/tamper_controller.ex +++ b/lib/philomena_web/controllers/image/tamper_controller.ex @@ -25,13 +25,13 @@ defmodule PhilomenaWeb.Image.TamperController do conn |> put_flash(:info, "Vote removed.") |> moderation_log( - details: &log_details/3, - data: %{vote: result, image: image} + details: &log_details/2, + data: %{vote: result, image: image, username: conn.assigns.user.name} ) - |> redirect(to: Routes.image_path(conn, :show, conn.assigns.image)) + |> redirect(to: ~p"/images/#{conn.assigns.image}") end - defp log_details(conn, _action, data) do + defp log_details(_action, data) do image = data.image vote_type = @@ -42,8 +42,8 @@ defmodule PhilomenaWeb.Image.TamperController do end %{ - body: "Deleted #{vote_type} by #{conn.assigns.user.name} on image >>#{data.image.id}", - subject_path: Routes.image_path(conn, :show, image) + body: "Deleted #{vote_type} by #{data.username} on image >>#{data.image.id}", + subject_path: ~p"/images/#{image}" } end end diff --git a/lib/philomena_web/controllers/image_controller.ex b/lib/philomena_web/controllers/image_controller.ex index 7d300dba..021ee028 100644 --- a/lib/philomena_web/controllers/image_controller.ex +++ b/lib/philomena_web/controllers/image_controller.ex @@ -128,7 +128,7 @@ defmodule PhilomenaWeb.ImageController do conn |> put_flash(:info, "Image created successfully.") - |> redirect(to: Routes.image_path(conn, :show, image)) + |> redirect(to: ~p"/images/#{image}") {:error, :image, changeset, _} -> conn @@ -208,7 +208,7 @@ defmodule PhilomenaWeb.ImageController do :alert, "The image you were looking for has been marked a duplicate of the image below" ) - |> redirect(to: Routes.image_path(conn, :show, image.duplicate_id)) + |> redirect(to: ~p"/images/#{image.duplicate_id}") |> halt() true -> diff --git a/lib/philomena_web/controllers/page_controller.ex b/lib/philomena_web/controllers/page_controller.ex index 1f8490a2..d9ebae27 100644 --- a/lib/philomena_web/controllers/page_controller.ex +++ b/lib/philomena_web/controllers/page_controller.ex @@ -26,7 +26,7 @@ defmodule PhilomenaWeb.PageController do {:ok, %{static_page: static_page}} -> conn |> put_flash(:info, "Static page successfully created.") - |> redirect(to: Routes.page_path(conn, :show, static_page)) + |> redirect(to: ~p"/pages/#{static_page}") {:error, :static_page, changeset, _changes} -> render(conn, "new.html", changeset: changeset) @@ -47,7 +47,7 @@ defmodule PhilomenaWeb.PageController do {:ok, %{static_page: static_page}} -> conn |> put_flash(:info, "Static page successfully updated.") - |> redirect(to: Routes.page_path(conn, :show, static_page)) + |> redirect(to: ~p"/pages/#{static_page}") {:error, :static_page, changeset, _changes} -> render(conn, "edit.html", changeset: changeset) diff --git a/lib/philomena_web/controllers/password_controller.ex b/lib/philomena_web/controllers/password_controller.ex index f042dc12..b4022742 100644 --- a/lib/philomena_web/controllers/password_controller.ex +++ b/lib/philomena_web/controllers/password_controller.ex @@ -16,7 +16,7 @@ defmodule PhilomenaWeb.PasswordController do if user = Users.get_user_by_email(email) do Users.deliver_user_reset_password_instructions( user, - &Routes.password_url(conn, :edit, &1) + &url(~p"/passwords/#{&1}/edit") ) end @@ -40,7 +40,7 @@ defmodule PhilomenaWeb.PasswordController do {:ok, _} -> conn |> put_flash(:info, "Password reset successfully.") - |> redirect(to: Routes.session_path(conn, :new)) + |> redirect(to: ~p"/sessions/new") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) diff --git a/lib/philomena_web/controllers/profile/artist_link_controller.ex b/lib/philomena_web/controllers/profile/artist_link_controller.ex index 593979f1..a7a128c3 100644 --- a/lib/philomena_web/controllers/profile/artist_link_controller.ex +++ b/lib/philomena_web/controllers/profile/artist_link_controller.ex @@ -52,9 +52,7 @@ defmodule PhilomenaWeb.Profile.ArtistLinkController do :alert, "Link submitted! Please put '#{artist_link.verification_code}' on your linked webpage now." ) - |> redirect( - to: Routes.profile_artist_link_path(conn, :show, conn.assigns.user, artist_link) - ) + |> redirect(to: ~p"/profiles/#{conn.assigns.user}/artist_links/#{artist_link}") {:error, %Ecto.Changeset{} = changeset} -> render(conn, "new.html", changeset: changeset) @@ -77,9 +75,7 @@ defmodule PhilomenaWeb.Profile.ArtistLinkController do {:ok, artist_link} -> conn |> put_flash(:info, "Link successfully updated.") - |> redirect( - to: Routes.profile_artist_link_path(conn, :show, conn.assigns.user, artist_link) - ) + |> redirect(to: ~p"/profiles/#{conn.assigns.user}/artist_links/#{artist_link}") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) diff --git a/lib/philomena_web/controllers/profile/award_controller.ex b/lib/philomena_web/controllers/profile/award_controller.ex index 07df9819..4e636236 100644 --- a/lib/philomena_web/controllers/profile/award_controller.ex +++ b/lib/philomena_web/controllers/profile/award_controller.ex @@ -23,7 +23,7 @@ defmodule PhilomenaWeb.Profile.AwardController do {:ok, _award} -> conn |> put_flash(:info, "Award successfully created.") - |> redirect(to: Routes.profile_path(conn, :show, conn.assigns.user)) + |> redirect(to: ~p"/profiles/#{conn.assigns.user}") {:error, changeset} -> render(conn, "new.html", changeset: changeset) @@ -40,7 +40,7 @@ defmodule PhilomenaWeb.Profile.AwardController do {:ok, _award} -> conn |> put_flash(:info, "Award successfully updated.") - |> redirect(to: Routes.profile_path(conn, :show, conn.assigns.user)) + |> redirect(to: ~p"/profiles/#{conn.assigns.user}") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -52,7 +52,7 @@ defmodule PhilomenaWeb.Profile.AwardController do conn |> put_flash(:info, "Award successfully destroyed. By cruel and unusual means.") - |> redirect(to: Routes.profile_path(conn, :show, conn.assigns.user)) + |> redirect(to: ~p"/profiles/#{conn.assigns.user}") end defp verify_authorized(conn, _opts) do diff --git a/lib/philomena_web/controllers/profile/commission/item_controller.ex b/lib/philomena_web/controllers/profile/commission/item_controller.ex index 7473a4ac..c2900eb1 100644 --- a/lib/philomena_web/controllers/profile/commission/item_controller.ex +++ b/lib/philomena_web/controllers/profile/commission/item_controller.ex @@ -47,7 +47,7 @@ defmodule PhilomenaWeb.Profile.Commission.ItemController do {:ok, _multi} -> conn |> put_flash(:info, "Item successfully created.") - |> redirect(to: Routes.profile_commission_path(conn, :show, conn.assigns.user)) + |> redirect(to: ~p"/profiles/#{conn.assigns.user}/commission") {:error, changeset} -> render(conn, "new.html", user: user, commission: commission, changeset: changeset) @@ -79,7 +79,7 @@ defmodule PhilomenaWeb.Profile.Commission.ItemController do {:ok, _commission} -> conn |> put_flash(:info, "Item successfully updated.") - |> redirect(to: Routes.profile_commission_path(conn, :show, conn.assigns.user)) + |> redirect(to: ~p"/profiles/#{conn.assigns.user}/commission") {:error, changeset} -> render(conn, "edit.html", @@ -100,7 +100,7 @@ defmodule PhilomenaWeb.Profile.Commission.ItemController do conn |> put_flash(:info, "Item successfully deleted.") - |> redirect(to: Routes.profile_commission_path(conn, :show, conn.assigns.user)) + |> redirect(to: ~p"/profiles/#{conn.assigns.user}/commission") end defp ensure_commission(conn, _opts) do diff --git a/lib/philomena_web/controllers/profile/commission/report_controller.ex b/lib/philomena_web/controllers/profile/commission/report_controller.ex index 9c9d7ac2..0ad943ef 100644 --- a/lib/philomena_web/controllers/profile/commission/report_controller.ex +++ b/lib/philomena_web/controllers/profile/commission/report_controller.ex @@ -32,7 +32,7 @@ defmodule PhilomenaWeb.Profile.Commission.ReportController do def new(conn, _params) do user = conn.assigns.user commission = conn.assigns.user.commission - action = Routes.profile_commission_report_path(conn, :create, user) + action = ~p"/profiles/#{user}/commission/reports" changeset = %Report{reportable_type: "Commission", reportable_id: commission.id} @@ -51,7 +51,7 @@ defmodule PhilomenaWeb.Profile.Commission.ReportController do def create(conn, params) do user = conn.assigns.user commission = conn.assigns.user.commission - action = Routes.profile_commission_report_path(conn, :create, user) + action = ~p"/profiles/#{user}/commission/reports" ReportController.create(conn, action, commission, "Commission", params) end diff --git a/lib/philomena_web/controllers/profile/commission_controller.ex b/lib/philomena_web/controllers/profile/commission_controller.ex index b5bf17fa..1bd2c58e 100644 --- a/lib/philomena_web/controllers/profile/commission_controller.ex +++ b/lib/philomena_web/controllers/profile/commission_controller.ex @@ -85,7 +85,7 @@ defmodule PhilomenaWeb.Profile.CommissionController do {:ok, _commission} -> conn |> put_flash(:info, "Commission successfully created.") - |> redirect(to: Routes.profile_commission_path(conn, :show, user)) + |> redirect(to: ~p"/profiles/#{user}/commission") {:error, changeset} -> render(conn, "new.html", changeset: changeset) @@ -104,7 +104,7 @@ defmodule PhilomenaWeb.Profile.CommissionController do {:ok, _commission} -> conn |> put_flash(:info, "Commission successfully updated.") - |> redirect(to: Routes.profile_commission_path(conn, :show, conn.assigns.user)) + |> redirect(to: ~p"/profiles/#{conn.assigns.user}/commission") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -118,7 +118,7 @@ defmodule PhilomenaWeb.Profile.CommissionController do conn |> put_flash(:info, "Commission deleted successfully.") - |> redirect(to: Routes.commission_path(conn, :index)) + |> redirect(to: ~p"/commissions") end defp ensure_commission(conn, _opts) do @@ -156,7 +156,7 @@ defmodule PhilomenaWeb.Profile.CommissionController do :warning, "You must have a verified artist link to create a commission listing." ) - |> redirect(to: Routes.commission_path(conn, :index)) + |> redirect(to: ~p"/commissions") |> halt() end end diff --git a/lib/philomena_web/controllers/profile/description_controller.ex b/lib/philomena_web/controllers/profile/description_controller.ex index 4a7836ba..6dac8e88 100644 --- a/lib/philomena_web/controllers/profile/description_controller.ex +++ b/lib/philomena_web/controllers/profile/description_controller.ex @@ -30,7 +30,7 @@ defmodule PhilomenaWeb.Profile.DescriptionController do {:ok, _user} -> conn |> put_flash(:info, "Description successfully updated.") - |> redirect(to: Routes.profile_path(conn, :show, user)) + |> redirect(to: ~p"/profiles/#{user}") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) diff --git a/lib/philomena_web/controllers/profile/report_controller.ex b/lib/philomena_web/controllers/profile/report_controller.ex index 0c326b8d..80a68895 100644 --- a/lib/philomena_web/controllers/profile/report_controller.ex +++ b/lib/philomena_web/controllers/profile/report_controller.ex @@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Profile.ReportController do def new(conn, _params) do user = conn.assigns.user - action = Routes.profile_report_path(conn, :create, user) + action = ~p"/profiles/#{user}/reports" changeset = %Report{reportable_type: "User", reportable_id: user.id} @@ -39,7 +39,7 @@ defmodule PhilomenaWeb.Profile.ReportController do def create(conn, params) do user = conn.assigns.user - action = Routes.profile_report_path(conn, :create, user) + action = ~p"/profiles/#{user}/reports" ReportController.create(conn, action, user, "User", params) end diff --git a/lib/philomena_web/controllers/profile/scratchpad_controller.ex b/lib/philomena_web/controllers/profile/scratchpad_controller.ex index 117fb3b6..3132436e 100644 --- a/lib/philomena_web/controllers/profile/scratchpad_controller.ex +++ b/lib/philomena_web/controllers/profile/scratchpad_controller.ex @@ -25,7 +25,7 @@ defmodule PhilomenaWeb.Profile.ScratchpadController do {:ok, _user} -> conn |> put_flash(:info, "Moderation scratchpad successfully updated.") - |> redirect(to: Routes.profile_path(conn, :show, user)) + |> redirect(to: ~p"/profiles/#{user}") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) diff --git a/lib/philomena_web/controllers/registration/email_controller.ex b/lib/philomena_web/controllers/registration/email_controller.ex index 1125ce66..04dd14ce 100644 --- a/lib/philomena_web/controllers/registration/email_controller.ex +++ b/lib/philomena_web/controllers/registration/email_controller.ex @@ -11,7 +11,7 @@ defmodule PhilomenaWeb.Registration.EmailController do Users.deliver_update_email_instructions( applied_user, user.email, - &Routes.registration_email_url(conn, :show, &1) + &url(~p"/registrations/email/#{&1}") ) conn @@ -19,12 +19,12 @@ defmodule PhilomenaWeb.Registration.EmailController do :alert, "A link to confirm your email change has been sent to the new address." ) - |> redirect(to: Routes.registration_path(conn, :edit)) + |> redirect(to: ~p"/registrations/edit") {:error, _changeset} -> conn |> put_flash(:error, "Failed to update email.") - |> redirect(to: Routes.registration_path(conn, :edit)) + |> redirect(to: ~p"/registrations/edit") end end @@ -33,12 +33,12 @@ defmodule PhilomenaWeb.Registration.EmailController do :ok -> conn |> put_flash(:info, "Email changed successfully.") - |> redirect(to: Routes.registration_path(conn, :edit)) + |> redirect(to: ~p"/registrations/edit") :error -> conn |> put_flash(:warning, "Email change link is invalid or it has expired.") - |> redirect(to: Routes.registration_path(conn, :edit)) + |> redirect(to: ~p"/registrations/edit") end end end diff --git a/lib/philomena_web/controllers/registration/name_controller.ex b/lib/philomena_web/controllers/registration/name_controller.ex index 7b5cd0dd..e0023f89 100644 --- a/lib/philomena_web/controllers/registration/name_controller.ex +++ b/lib/philomena_web/controllers/registration/name_controller.ex @@ -17,7 +17,7 @@ defmodule PhilomenaWeb.Registration.NameController do {:ok, user} -> conn |> put_flash(:info, "Name successfully updated.") - |> redirect(to: Routes.profile_path(conn, :show, user)) + |> redirect(to: ~p"/profiles/#{user}") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) diff --git a/lib/philomena_web/controllers/registration/password_controller.ex b/lib/philomena_web/controllers/registration/password_controller.ex index 909df6eb..6e3ba04a 100644 --- a/lib/philomena_web/controllers/registration/password_controller.ex +++ b/lib/philomena_web/controllers/registration/password_controller.ex @@ -13,13 +13,13 @@ defmodule PhilomenaWeb.Registration.PasswordController do {:ok, user} -> conn |> put_flash(:info, "Password updated successfully.") - |> put_session(:user_return_to, Routes.registration_path(conn, :edit)) + |> put_session(:user_return_to, ~p"/registrations/edit") |> UserAuth.log_in_user(user) {:error, _changeset} -> conn |> put_flash(:error, "Failed to update password.") - |> redirect(to: Routes.registration_path(conn, :edit)) + |> redirect(to: ~p"/registrations/edit") end end end diff --git a/lib/philomena_web/controllers/registration/totp_controller.ex b/lib/philomena_web/controllers/registration/totp_controller.ex index 3cea3279..9316aeb2 100644 --- a/lib/philomena_web/controllers/registration/totp_controller.ex +++ b/lib/philomena_web/controllers/registration/totp_controller.ex @@ -16,7 +16,7 @@ defmodule PhilomenaWeb.Registration.TotpController do |> Repo.update() # Redirect to have the conn pick up the changes - redirect(conn, to: Routes.registration_totp_path(conn, :edit)) + redirect(conn, to: ~p"/registrations/totp/edit") _ -> changeset = Users.change_user(user) @@ -48,7 +48,7 @@ defmodule PhilomenaWeb.Registration.TotpController do {:ok, user} -> conn |> put_flash(:totp_backup_codes, backup_codes) - |> put_session(:user_return_to, Routes.registration_totp_path(conn, :edit)) + |> put_session(:user_return_to, ~p"/registrations/totp/edit") |> UserAuth.totp_auth_user(user, %{}) end end diff --git a/lib/philomena_web/controllers/registration_controller.ex b/lib/philomena_web/controllers/registration_controller.ex index 389ae579..8f3e2bbd 100644 --- a/lib/philomena_web/controllers/registration_controller.ex +++ b/lib/philomena_web/controllers/registration_controller.ex @@ -20,7 +20,7 @@ defmodule PhilomenaWeb.RegistrationController do {:ok, _} = Users.deliver_user_confirmation_instructions( user, - &Routes.confirmation_url(conn, :show, &1) + &url(~p"/confirmations/#{&1}") ) conn diff --git a/lib/philomena_web/controllers/report_controller.ex b/lib/philomena_web/controllers/report_controller.ex index 49a5459c..c3e9ff8c 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 :alert, "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: Routes.report_path(conn, :index) + defp redirect_path(nil), do: "/" + defp redirect_path(_user), do: ~p"/reports" defp max_reports do 5 diff --git a/lib/philomena_web/controllers/session_controller.ex b/lib/philomena_web/controllers/session_controller.ex index ee15bc12..b5704501 100644 --- a/lib/philomena_web/controllers/session_controller.ex +++ b/lib/philomena_web/controllers/session_controller.ex @@ -15,7 +15,7 @@ defmodule PhilomenaWeb.SessionController do Users.get_user_by_email_and_password( email, password, - &Routes.unlock_url(conn, :show, &1) + &url(~p"/unlocks/#{&1}") ) cond do diff --git a/lib/philomena_web/controllers/setting_controller.ex b/lib/philomena_web/controllers/setting_controller.ex index 68cf76b9..371f1853 100644 --- a/lib/philomena_web/controllers/setting_controller.ex +++ b/lib/philomena_web/controllers/setting_controller.ex @@ -25,7 +25,7 @@ defmodule PhilomenaWeb.SettingController do {:ok, conn} -> conn |> put_flash(:info, "Settings updated successfully.") - |> redirect(to: Routes.setting_path(conn, :edit)) + |> redirect(to: ~p"/settings/edit") {:error, changeset} -> conn diff --git a/lib/philomena_web/controllers/tag/alias_controller.ex b/lib/philomena_web/controllers/tag/alias_controller.ex index b7687b1c..b0ed3483 100644 --- a/lib/philomena_web/controllers/tag/alias_controller.ex +++ b/lib/philomena_web/controllers/tag/alias_controller.ex @@ -23,7 +23,7 @@ defmodule PhilomenaWeb.Tag.AliasController do {:ok, tag} -> conn |> put_flash(:info, "Tag alias queued.") - |> redirect(to: Routes.tag_alias_path(conn, :edit, tag)) + |> redirect(to: ~p"/tags/#{tag}/alias/edit") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -35,6 +35,6 @@ defmodule PhilomenaWeb.Tag.AliasController do conn |> put_flash(:info, "Tag dealias queued.") - |> redirect(to: Routes.tag_path(conn, :show, tag)) + |> redirect(to: ~p"/tags/#{tag}") end end diff --git a/lib/philomena_web/controllers/tag/image_controller.ex b/lib/philomena_web/controllers/tag/image_controller.ex index 2f43ebe8..b98e1909 100644 --- a/lib/philomena_web/controllers/tag/image_controller.ex +++ b/lib/philomena_web/controllers/tag/image_controller.ex @@ -23,8 +23,8 @@ defmodule PhilomenaWeb.Tag.ImageController do {:ok, tag} -> conn |> put_flash(:info, "Tag image successfully updated.") - |> moderation_log(details: &log_details/3, data: tag) - |> redirect(to: Routes.tag_path(conn, :show, tag)) + |> moderation_log(details: &log_details/2, data: tag) + |> redirect(to: ~p"/tags/#{tag}") {:error, :tag, changeset, _changes} -> render(conn, "edit.html", changeset: changeset) @@ -36,11 +36,11 @@ defmodule PhilomenaWeb.Tag.ImageController do conn |> put_flash(:info, "Tag image successfully removed.") - |> moderation_log(details: &log_details/3, data: tag) - |> redirect(to: Routes.tag_path(conn, :show, conn.assigns.tag)) + |> moderation_log(details: &log_details/2, data: tag) + |> redirect(to: ~p"/tags/#{conn.assigns.tag}") end - defp log_details(conn, action, tag) do + defp log_details(action, tag) do body = case action do :update -> "Updated image on tag '#{tag.name}'" @@ -49,7 +49,7 @@ defmodule PhilomenaWeb.Tag.ImageController do %{ body: body, - subject_path: Routes.tag_path(conn, :show, tag) + subject_path: ~p"/tags/#{tag}" } end end diff --git a/lib/philomena_web/controllers/tag/reindex_controller.ex b/lib/philomena_web/controllers/tag/reindex_controller.ex index 70b7163c..aee27c28 100644 --- a/lib/philomena_web/controllers/tag/reindex_controller.ex +++ b/lib/philomena_web/controllers/tag/reindex_controller.ex @@ -18,6 +18,6 @@ defmodule PhilomenaWeb.Tag.ReindexController do conn |> put_flash(:info, "Tag reindex started.") - |> redirect(to: Routes.tag_path(conn, :edit, tag)) + |> redirect(to: ~p"/tags/#{tag}/edit") end end diff --git a/lib/philomena_web/controllers/tag_controller.ex b/lib/philomena_web/controllers/tag_controller.ex index f9abeeb0..5927c68f 100644 --- a/lib/philomena_web/controllers/tag_controller.ex +++ b/lib/philomena_web/controllers/tag_controller.ex @@ -97,8 +97,8 @@ defmodule PhilomenaWeb.TagController do {:ok, tag} -> conn |> put_flash(:info, "Tag successfully updated.") - |> moderation_log(details: &log_details/3, data: tag) - |> redirect(to: Routes.tag_path(conn, :show, tag)) + |> moderation_log(details: &log_details/2, data: tag) + |> redirect(to: ~p"/tags/#{tag}") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -110,7 +110,7 @@ defmodule PhilomenaWeb.TagController do conn |> put_flash(:info, "Tag queued for deletion.") - |> moderation_log(details: &log_details/3, data: tag) + |> moderation_log(details: &log_details/2, data: tag) |> redirect(to: "/") end @@ -167,12 +167,12 @@ defmodule PhilomenaWeb.TagController do :alert, "This tag (\"#{conn.assigns.tag.name}\") has been aliased into the tag \"#{tag.name}\"." ) - |> redirect(to: Routes.tag_path(conn, :show, tag)) + |> redirect(to: ~p"/tags/#{tag}") |> halt() end end - defp log_details(conn, action, tag) do + defp log_details(action, tag) do body = case action do :update -> "Updated details on tag '#{tag.name}'" @@ -181,7 +181,7 @@ defmodule PhilomenaWeb.TagController do %{ body: body, - subject_path: Routes.tag_path(conn, :show, tag) + subject_path: ~p"/tags/#{tag}" } end end diff --git a/lib/philomena_web/controllers/topic/hide_controller.ex b/lib/philomena_web/controllers/topic/hide_controller.ex index 3149501d..4558f393 100644 --- a/lib/philomena_web/controllers/topic/hide_controller.ex +++ b/lib/philomena_web/controllers/topic/hide_controller.ex @@ -27,13 +27,13 @@ defmodule PhilomenaWeb.Topic.HideController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully hidden!") - |> moderation_log(details: &log_details/3, data: topic) - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> moderation_log(details: &log_details/2, data: topic) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") {:error, _changeset} -> conn |> put_flash(:error, "Unable to hide the topic!") - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") end end @@ -44,17 +44,17 @@ defmodule PhilomenaWeb.Topic.HideController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully restored!") - |> moderation_log(details: &log_details/3, data: topic) - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> moderation_log(details: &log_details/2, data: topic) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") {:error, _changeset} -> conn |> put_flash(:error, "Unable to restore the topic!") - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") end end - defp log_details(conn, action, topic) do + defp log_details(action, topic) do body = case action do :create -> @@ -66,7 +66,7 @@ defmodule PhilomenaWeb.Topic.HideController do %{ body: body, - subject_path: Routes.forum_topic_path(conn, :show, topic.forum, topic) + subject_path: ~p"/forums/#{topic.forum}/topics/#{topic}" } end end diff --git a/lib/philomena_web/controllers/topic/lock_controller.ex b/lib/philomena_web/controllers/topic/lock_controller.ex index 88bf115b..c9b9c21f 100644 --- a/lib/philomena_web/controllers/topic/lock_controller.ex +++ b/lib/philomena_web/controllers/topic/lock_controller.ex @@ -26,13 +26,13 @@ defmodule PhilomenaWeb.Topic.LockController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully locked!") - |> moderation_log(details: &log_details/3, data: topic) - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> moderation_log(details: &log_details/2, data: topic) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") {:error, _changeset} -> conn |> put_flash(:error, "Unable to lock the topic!") - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") end end @@ -43,17 +43,17 @@ defmodule PhilomenaWeb.Topic.LockController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully unlocked!") - |> moderation_log(details: &log_details/3, data: topic) - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> moderation_log(details: &log_details/2, data: topic) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") {:error, _changeset} -> conn |> put_flash(:error, "Unable to unlock the topic!") - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") end end - defp log_details(conn, action, topic) do + defp log_details(action, topic) do body = case action do :create -> "Locked topic '#{topic.title}' (#{topic.lock_reason}) in #{topic.forum.name}" @@ -62,7 +62,7 @@ defmodule PhilomenaWeb.Topic.LockController do %{ body: body, - subject_path: Routes.forum_topic_path(conn, :show, topic.forum, topic) + subject_path: ~p"/forums/#{topic.forum}/topics/#{topic}" } end end diff --git a/lib/philomena_web/controllers/topic/move_controller.ex b/lib/philomena_web/controllers/topic/move_controller.ex index f12af72e..00fe220b 100644 --- a/lib/philomena_web/controllers/topic/move_controller.ex +++ b/lib/philomena_web/controllers/topic/move_controller.ex @@ -29,20 +29,20 @@ defmodule PhilomenaWeb.Topic.MoveController do conn |> put_flash(:info, "Topic successfully moved!") - |> moderation_log(details: &log_details/3, data: topic) - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> moderation_log(details: &log_details/2, data: topic) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") {:error, _changeset} -> conn |> put_flash(:error, "Unable to move the topic!") - |> redirect(to: Routes.forum_topic_path(conn, :show, conn.assigns.forum, topic)) + |> redirect(to: ~p"/forums/#{conn.assigns.forum}/topics/#{topic}") end end - defp log_details(conn, _action, topic) do + defp log_details(_action, topic) do %{ body: "Topic '#{topic.title}' moved to #{topic.forum.name}", - subject_path: Routes.forum_topic_path(conn, :show, topic.forum, topic) + subject_path: ~p"/forums/#{topic.forum}/topics/#{topic}" } end end diff --git a/lib/philomena_web/controllers/topic/poll/vote_controller.ex b/lib/philomena_web/controllers/topic/poll/vote_controller.ex index ba4e266d..089c5a17 100644 --- a/lib/philomena_web/controllers/topic/poll/vote_controller.ex +++ b/lib/philomena_web/controllers/topic/poll/vote_controller.ex @@ -42,12 +42,12 @@ defmodule PhilomenaWeb.Topic.Poll.VoteController do {:ok, _votes} -> conn |> put_flash(:info, "Your vote has been recorded.") - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") _error -> conn |> put_flash(:warning, "Your vote was not recorded.") - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") end end @@ -56,7 +56,7 @@ defmodule PhilomenaWeb.Topic.Poll.VoteController do conn |> put_flash(:error, "Your vote was not recorded.") - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") end def delete(conn, %{"id" => poll_vote_id}) do @@ -67,7 +67,7 @@ defmodule PhilomenaWeb.Topic.Poll.VoteController do conn |> put_flash(:info, "Vote successfully removed.") - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") end defp verify_authorized(conn, _opts) do diff --git a/lib/philomena_web/controllers/topic/poll_controller.ex b/lib/philomena_web/controllers/topic/poll_controller.ex index 61cec7d9..b2fdbb81 100644 --- a/lib/philomena_web/controllers/topic/poll_controller.ex +++ b/lib/philomena_web/controllers/topic/poll_controller.ex @@ -27,9 +27,7 @@ defmodule PhilomenaWeb.Topic.PollController do {:ok, _poll} -> conn |> put_flash(:info, "Poll successfully updated.") - |> redirect( - to: Routes.forum_topic_path(conn, :show, conn.assigns.forum, conn.assigns.topic) - ) + |> redirect(to: ~p"/forums/#{conn.assigns.forum}/topics/#{conn.assigns.topic}") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) diff --git a/lib/philomena_web/controllers/topic/post/approve_controller.ex b/lib/philomena_web/controllers/topic/post/approve_controller.ex index 90bf3948..65d289ca 100644 --- a/lib/philomena_web/controllers/topic/post/approve_controller.ex +++ b/lib/philomena_web/controllers/topic/post/approve_controller.ex @@ -20,10 +20,10 @@ defmodule PhilomenaWeb.Topic.Post.ApproveController do {:ok, post} -> conn |> put_flash(:info, "Post successfully approved.") - |> moderation_log(details: &log_details/3, data: post) + |> moderation_log(details: &log_details/2, data: post) |> redirect( to: - Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> + ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" ) @@ -32,17 +32,17 @@ defmodule PhilomenaWeb.Topic.Post.ApproveController do |> put_flash(:error, "Unable to approve post!") |> redirect( to: - Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> + ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" ) end end - defp log_details(conn, _action, post) do + defp log_details(_action, post) do %{ body: "Approved forum post ##{post.id} in topic '#{post.topic.title}'", subject_path: - Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> + ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" } end diff --git a/lib/philomena_web/controllers/topic/post/delete_controller.ex b/lib/philomena_web/controllers/topic/post/delete_controller.ex index 9e6d7a45..28aad707 100644 --- a/lib/philomena_web/controllers/topic/post/delete_controller.ex +++ b/lib/philomena_web/controllers/topic/post/delete_controller.ex @@ -19,10 +19,10 @@ defmodule PhilomenaWeb.Topic.Post.DeleteController do {:ok, post} -> conn |> put_flash(:info, "Post successfully destroyed!") - |> moderation_log(details: &log_details/3, data: post) + |> moderation_log(details: &log_details/2, data: post) |> redirect( to: - Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> + ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" ) @@ -31,17 +31,17 @@ defmodule PhilomenaWeb.Topic.Post.DeleteController do |> put_flash(:error, "Unable to destroy post!") |> redirect( to: - Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> + ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" ) end end - defp log_details(conn, _action, post) do + defp log_details(_action, post) do %{ body: "Destroyed forum post ##{post.id} in topic '#{post.topic.title}'", subject_path: - Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> + ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" } end diff --git a/lib/philomena_web/controllers/topic/post/hide_controller.ex b/lib/philomena_web/controllers/topic/post/hide_controller.ex index 9e449977..882321af 100644 --- a/lib/philomena_web/controllers/topic/post/hide_controller.ex +++ b/lib/philomena_web/controllers/topic/post/hide_controller.ex @@ -20,10 +20,10 @@ defmodule PhilomenaWeb.Topic.Post.HideController do {:ok, post} -> conn |> put_flash(:info, "Post successfully hidden.") - |> moderation_log(details: &log_details/3, data: post) + |> moderation_log(details: &log_details/2, data: post) |> redirect( to: - Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> + ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" ) @@ -32,7 +32,7 @@ defmodule PhilomenaWeb.Topic.Post.HideController do |> put_flash(:error, "Unable to hide post!") |> redirect( to: - Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> + ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" ) end @@ -45,10 +45,10 @@ defmodule PhilomenaWeb.Topic.Post.HideController do {:ok, post} -> conn |> put_flash(:info, "Post successfully unhidden.") - |> moderation_log(details: &log_details/3, data: post) + |> moderation_log(details: &log_details/2, data: post) |> redirect( to: - Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> + ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" ) @@ -57,13 +57,13 @@ defmodule PhilomenaWeb.Topic.Post.HideController do |> put_flash(:error, "Unable to unhide post!") |> redirect( to: - Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> + ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" ) end end - defp log_details(conn, action, post) do + defp log_details(action, post) do body = case action do :create -> @@ -76,7 +76,7 @@ defmodule PhilomenaWeb.Topic.Post.HideController do %{ body: body, subject_path: - Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> + ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" } end diff --git a/lib/philomena_web/controllers/topic/post/report_controller.ex b/lib/philomena_web/controllers/topic/post/report_controller.ex index 2d29f7b8..f09df511 100644 --- a/lib/philomena_web/controllers/topic/post/report_controller.ex +++ b/lib/philomena_web/controllers/topic/post/report_controller.ex @@ -26,7 +26,7 @@ defmodule PhilomenaWeb.Topic.Post.ReportController do def new(conn, _params) do topic = conn.assigns.topic post = conn.assigns.post - action = Routes.forum_topic_post_report_path(conn, :create, topic.forum, topic, post) + action = ~p"/forums/#{topic.forum}/topics/#{topic}/posts/#{post}/reports" changeset = %Report{reportable_type: "Post", reportable_id: post.id} @@ -40,7 +40,7 @@ defmodule PhilomenaWeb.Topic.Post.ReportController do def create(conn, params) do topic = conn.assigns.topic post = conn.assigns.post - action = Routes.forum_topic_post_report_path(conn, :create, topic.forum, topic, post) + action = ~p"/forums/#{topic.forum}/topics/#{topic}/posts/#{post}/reports" ReportController.create(conn, action, post, "Post", params) end diff --git a/lib/philomena_web/controllers/topic/post_controller.ex b/lib/philomena_web/controllers/topic/post_controller.ex index dce67f4a..7513f930 100644 --- a/lib/philomena_web/controllers/topic/post_controller.ex +++ b/lib/philomena_web/controllers/topic/post_controller.ex @@ -58,14 +58,14 @@ defmodule PhilomenaWeb.Topic.PostController do |> put_flash(:info, "Post created successfully.") |> redirect( to: - Routes.forum_topic_path(conn, :show, forum, topic, post_id: post.id) <> + ~p"/forums/#{forum}/topics/#{topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" ) _error -> conn |> put_flash(:warning, "There was an error creating the post") - |> redirect(to: Routes.forum_topic_path(conn, :show, forum, topic)) + |> redirect(to: ~p"/forums/#{forum}/topics/#{topic}") end end @@ -88,7 +88,7 @@ defmodule PhilomenaWeb.Topic.PostController do |> put_flash(:info, "Post successfully edited.") |> redirect( to: - Routes.forum_topic_path(conn, :show, post.topic.forum, post.topic, post_id: post.id) <> + ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" ) diff --git a/lib/philomena_web/controllers/topic/stick_controller.ex b/lib/philomena_web/controllers/topic/stick_controller.ex index 27f92168..39f0d562 100644 --- a/lib/philomena_web/controllers/topic/stick_controller.ex +++ b/lib/philomena_web/controllers/topic/stick_controller.ex @@ -25,13 +25,13 @@ defmodule PhilomenaWeb.Topic.StickController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully stickied!") - |> moderation_log(details: &log_details/3, data: topic) - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> moderation_log(details: &log_details/2, data: topic) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") {:error, _changeset} -> conn |> put_flash(:error, "Unable to stick the topic!") - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") end end @@ -42,17 +42,17 @@ defmodule PhilomenaWeb.Topic.StickController do {:ok, topic} -> conn |> put_flash(:info, "Topic successfully unstickied!") - |> moderation_log(details: &log_details/3, data: topic) - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> moderation_log(details: &log_details/2, data: topic) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") {:error, _changeset} -> conn |> put_flash(:error, "Unable to unstick the topic!") - |> redirect(to: Routes.forum_topic_path(conn, :show, topic.forum, topic)) + |> redirect(to: ~p"/forums/#{topic.forum}/topics/#{topic}") end end - defp log_details(conn, action, topic) do + defp log_details(action, topic) do body = case action do :create -> "Stickied topic '#{topic.title}' in #{topic.forum.name}" @@ -61,7 +61,7 @@ defmodule PhilomenaWeb.Topic.StickController do %{ body: body, - subject_path: Routes.forum_topic_path(conn, :show, topic.forum, topic) + subject_path: ~p"/forums/#{topic.forum}/topics/#{topic}" } end end diff --git a/lib/philomena_web/controllers/topic_controller.ex b/lib/philomena_web/controllers/topic_controller.ex index 4c433be2..e88670a0 100644 --- a/lib/philomena_web/controllers/topic_controller.ex +++ b/lib/philomena_web/controllers/topic_controller.ex @@ -128,7 +128,7 @@ defmodule PhilomenaWeb.TopicController do conn |> put_flash(:info, "Successfully posted topic.") - |> redirect(to: Routes.forum_topic_path(conn, :show, forum, topic)) + |> redirect(to: ~p"/forums/#{forum}/topics/#{topic}") {:error, :topic, changeset, _} -> conn @@ -137,7 +137,7 @@ defmodule PhilomenaWeb.TopicController do _error -> conn |> put_flash(:error, "There was an error with your submission. Please try again.") - |> redirect(to: Routes.forum_topic_path(conn, :new, forum)) + |> redirect(to: ~p"/forums/#{forum}/topics/new") end end @@ -146,14 +146,12 @@ defmodule PhilomenaWeb.TopicController do {:ok, topic} -> conn |> put_flash(:info, "Successfully updated topic.") - |> redirect(to: Routes.forum_topic_path(conn, :show, conn.assigns.forum, topic)) + |> redirect(to: ~p"/forums/#{conn.assigns.forum}/topics/#{topic}") {:error, _changeset} -> conn |> put_flash(:error, "There was an error with your submission. Please try again.") - |> redirect( - to: Routes.forum_topic_path(conn, :show, conn.assigns.forum, conn.assigns.topic) - ) + |> redirect(to: ~p"/forums/#{conn.assigns.forum}/topics/#{conn.assigns.topic}") end end diff --git a/lib/philomena_web/controllers/unlock_controller.ex b/lib/philomena_web/controllers/unlock_controller.ex index e2e5257f..0f5412c2 100644 --- a/lib/philomena_web/controllers/unlock_controller.ex +++ b/lib/philomena_web/controllers/unlock_controller.ex @@ -14,7 +14,7 @@ defmodule PhilomenaWeb.UnlockController do if user = Users.get_user_by_email(email) do Users.deliver_user_unlock_instructions( user, - &Routes.unlock_url(conn, :show, &1) + &url(~p"/unlocks/#{&1}") ) end diff --git a/lib/philomena_web/plugs/map_parameter_plug.ex b/lib/philomena_web/plugs/map_parameter_plug.ex index 93b7cce8..36fc7c04 100644 --- a/lib/philomena_web/plugs/map_parameter_plug.ex +++ b/lib/philomena_web/plugs/map_parameter_plug.ex @@ -3,7 +3,7 @@ defmodule PhilomenaWeb.MapParameterPlug do # symphony of failure: # # 1.) Router helpers do not strip nil query parameters. - # iex> Routes.gallery_path(conn, :index, gallery: nil) + # iex> ~p"/galleries?#{[gallery: nil]}" # "/galleries?gallery=" # # 2.) Pagination always sets the parameter in the route in order diff --git a/lib/philomena_web/plugs/moderation_log_plug.ex b/lib/philomena_web/plugs/moderation_log_plug.ex index 4ee75938..c29f45a5 100644 --- a/lib/philomena_web/plugs/moderation_log_plug.ex +++ b/lib/philomena_web/plugs/moderation_log_plug.ex @@ -29,7 +29,7 @@ defmodule PhilomenaWeb.ModerationLogPlug do user = conn.assigns.current_user action = Controller.action_name(conn) - %{subject_path: subject_path, body: body} = details_func.(conn, action, userdata) + %{subject_path: subject_path, body: body} = details_func.(action, userdata) mod = Controller.controller_module(conn) [mod_name] = Regex.run(@controller_regex, to_string(mod), capture: :all_but_first) diff --git a/lib/philomena_web/plugs/tor_plug.ex b/lib/philomena_web/plugs/tor_plug.ex index 8e6cc4e3..57d5745a 100644 --- a/lib/philomena_web/plugs/tor_plug.ex +++ b/lib/philomena_web/plugs/tor_plug.ex @@ -6,7 +6,6 @@ defmodule PhilomenaWeb.TorPlug do plug PhilomenaWeb.TorPlug """ - alias PhilomenaWeb.Router.Helpers, as: Routes use PhilomenaWeb, :verified_routes alias Phoenix.Controller @@ -27,7 +26,7 @@ defmodule PhilomenaWeb.TorPlug do def maybe_redirect(conn, nil, true) do conn - |> Controller.redirect(to: Routes.session_path(conn, :new)) + |> Controller.redirect(to: ~p"/sessions/new") |> Conn.halt() end diff --git a/lib/philomena_web/plugs/totp_plug.ex b/lib/philomena_web/plugs/totp_plug.ex index 30f87378..7f5e2d11 100644 --- a/lib/philomena_web/plugs/totp_plug.ex +++ b/lib/philomena_web/plugs/totp_plug.ex @@ -7,7 +7,6 @@ defmodule PhilomenaWeb.TotpPlug do plug PhilomenaWeb.TotpPlug """ - alias PhilomenaWeb.Router.Helpers, as: Routes use PhilomenaWeb, :verified_routes @doc false @@ -33,7 +32,7 @@ defmodule PhilomenaWeb.TotpPlug do _falsy -> conn - |> Phoenix.Controller.redirect(to: Routes.session_totp_path(conn, :new)) + |> Phoenix.Controller.redirect(to: ~p"/sessions/totp/new") |> Plug.Conn.halt() end end diff --git a/lib/philomena_web/templates/activity/_channel_strip.html.slime b/lib/philomena_web/templates/activity/_channel_strip.html.slime index 34acd120..278cc6e9 100644 --- a/lib/philomena_web/templates/activity/_channel_strip.html.slime +++ b/lib/philomena_web/templates/activity/_channel_strip.html.slime @@ -1,7 +1,7 @@ .block__content.flex.alternating-color .flex__grow / TODO - a href=Routes.channel_path(@conn, :show, @channel) + a href=~p"/channels/#{@channel}" /- if channel.channel_image.present? / => image_tag channel.uploaded_channel_image.url, width: 32, height: 32, alt: "#{channel.title}'s logo'", class: 'channel-strip__image' /- else diff --git a/lib/philomena_web/templates/activity/_topic_strip.html.slime b/lib/philomena_web/templates/activity/_topic_strip.html.slime index 4a18e7fb..37b4f543 100644 --- a/lib/philomena_web/templates/activity/_topic_strip.html.slime +++ b/lib/philomena_web/templates/activity/_topic_strip.html.slime @@ -4,7 +4,7 @@ = if @topic.last_post do span.hyphenate-breaks = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @topic.last_post, conn: @conn - = link("replied to", to: Routes.forum_topic_path(@conn, :show, @topic.forum, @topic, post_id: @topic.last_post) <> "#post_#{@topic.last_post.id}") - =<> link(@topic.title, to: Routes.forum_topic_path(@conn, :show, @topic.forum, @topic)) + = link("replied to", to: ~p"/forums/#{@topic.forum}/topics/#{@topic}?#{[post_id: @topic.last_post]}" <> "#post_#{@topic.last_post.id}") + =<> link(@topic.title, to: ~p"/forums/#{@topic.forum}/topics/#{@topic}") ' in - => link(@topic.forum.name, to: Routes.forum_path(@conn, :show, @topic.forum)) + => link(@topic.forum.name, to: ~p"/forums/#{@topic.forum}") diff --git a/lib/philomena_web/templates/activity/index.html.slime b/lib/philomena_web/templates/activity/index.html.slime index 0abadd9b..c330d94e 100644 --- a/lib/philomena_web/templates/activity/index.html.slime +++ b/lib/philomena_web/templates/activity/index.html.slime @@ -32,7 +32,7 @@ ' No artist tags have any associated streams. = if can?(@conn, :create, Philomena.Channels.Channel) do ' As an administrator of this site, you may - => link "click here", to: Routes.channel_path(@conn, :new) + => link "click here", to: ~p"/channels/new" ' to add some, or a href="/channels" ' click here @@ -63,4 +63,4 @@ ' Browse Watched Images .media-list = for image <- @watched do - = render PhilomenaWeb.ImageView, "_image_box.html", image: image, link: Routes.image_path(@conn, :show, image, q: "my:watched"), size: :thumb_small, conn: @conn + = render PhilomenaWeb.ImageView, "_image_box.html", image: image, link: ~p"/images/#{image}?#{[q: "my:watched"]}", size: :thumb_small, conn: @conn diff --git a/lib/philomena_web/templates/admin/advert/_form.html.slime b/lib/philomena_web/templates/admin/advert/_form.html.slime index df77528e..9fcd46c7 100644 --- a/lib/philomena_web/templates/admin/advert/_form.html.slime +++ b/lib/philomena_web/templates/admin/advert/_form.html.slime @@ -14,7 +14,7 @@ = error_tag f, :image_height - else .field - = link "Change image", to: Routes.admin_advert_image_path(@conn, :edit, @changeset.data), class: "button" + = link "Change image", to: ~p"/admin/adverts/#{@changeset.data}/image/edit", class: "button" .field => label f, :link, "Link which the advert should take users to:" diff --git a/lib/philomena_web/templates/admin/advert/edit.html.slime b/lib/philomena_web/templates/admin/advert/edit.html.slime index fba601a0..a3764720 100644 --- a/lib/philomena_web/templates/admin/advert/edit.html.slime +++ b/lib/philomena_web/templates/admin/advert/edit.html.slime @@ -1,2 +1,2 @@ h1 Editing advert -= render PhilomenaWeb.Admin.AdvertView, "_form.html", changeset: @changeset, action: Routes.admin_advert_path(@conn, :update, @advert), conn: @conn += render PhilomenaWeb.Admin.AdvertView, "_form.html", changeset: @changeset, action: ~p"/admin/adverts/#{@advert}", conn: @conn diff --git a/lib/philomena_web/templates/admin/advert/image/edit.html.slime b/lib/philomena_web/templates/admin/advert/image/edit.html.slime index 6055e6a3..6374e9c3 100644 --- a/lib/philomena_web/templates/admin/advert/image/edit.html.slime +++ b/lib/philomena_web/templates/admin/advert/image/edit.html.slime @@ -1,6 +1,6 @@ h2 Edit Advert -= form_for @changeset, Routes.admin_advert_image_path(@conn, :update, @advert), [multipart: true], fn f -> += form_for @changeset, ~p"/admin/adverts/#{@advert}/image", [multipart: true], fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/admin/advert/index.html.slime b/lib/philomena_web/templates/admin/advert/index.html.slime index 1c7e34d3..609d468e 100644 --- a/lib/philomena_web/templates/admin/advert/index.html.slime +++ b/lib/philomena_web/templates/admin/advert/index.html.slime @@ -1,9 +1,9 @@ -- route = fn p -> Routes.admin_advert_path(@conn, :index, p) end +- route = fn p -> ~p"/admin/adverts?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @adverts, route: route .block .block__header - a href=Routes.admin_advert_path(@conn, :new) + a href=~p"/admin/adverts/new" i.fa.fa-plus> ' New advert @@ -65,9 +65,9 @@ = advert.clicks td - => link "Edit", to: Routes.admin_advert_path(@conn, :edit, advert) + => link "Edit", to: ~p"/admin/adverts/#{advert}/edit" ' • - = link "Destroy", to: Routes.admin_advert_path(@conn, :delete, advert), data: [confirm: "Are you really, really sure?", method: "delete"] + = link "Destroy", to: ~p"/admin/adverts/#{advert}", data: [confirm: "Are you really, really sure?", method: "delete"] .block__header.block__header--light = pagination diff --git a/lib/philomena_web/templates/admin/advert/new.html.slime b/lib/philomena_web/templates/admin/advert/new.html.slime index ab27e617..76472e47 100644 --- a/lib/philomena_web/templates/admin/advert/new.html.slime +++ b/lib/philomena_web/templates/admin/advert/new.html.slime @@ -1,2 +1,2 @@ h1 New advert -= render PhilomenaWeb.Admin.AdvertView, "_form.html", changeset: @changeset, action: Routes.admin_advert_path(@conn, :create), conn: @conn += render PhilomenaWeb.Admin.AdvertView, "_form.html", changeset: @changeset, action: ~p"/admin/adverts", conn: @conn diff --git a/lib/philomena_web/templates/admin/approval/_approvals.html.slime b/lib/philomena_web/templates/admin/approval/_approvals.html.slime index 530b4d3b..a61564dd 100644 --- a/lib/philomena_web/templates/admin/approval/_approvals.html.slime +++ b/lib/philomena_web/templates/admin/approval/_approvals.html.slime @@ -12,23 +12,23 @@ .block__content.alternating-color .approval-grid .approval-items--main - span = link ">>#{image.id}", to: Routes.image_path(@conn, :show, image) + span = link ">>#{image.id}", to: ~p"/images/#{image}" .approval-items__details class=class_for_image(image) span = image_thumb(@conn, image) span = warning_text(image) span = if image.user do - = link image.user.name, to: Routes.profile_path(@conn, :show, image.user) + = link image.user.name, to: ~p"/profiles/#{image.user}" - else em> - = truncated_ip_link(@conn, image.ip) + = truncated_ip_link(image.ip) = link_to_fingerprint(@conn, image.fingerprint) span = pretty_time(image.created_at) .approval-items--footer = if can?(@conn, :approve, image) do - = button_to "Approve", Routes.image_approve_path(@conn, :create, image), method: "post", class: "button button--success" + = button_to "Approve", ~p"/images/#{image}/approve", method: "post", class: "button button--success" = if can?(@conn, :hide, image) do - = form_for :image, Routes.image_delete_path(@conn, :create, image), [method: "post"], fn f -> + = form_for :image, ~p"/images/#{image}/delete", [method: "post"], fn f -> .field.field--inline = text_input f, :deletion_reason, class: "input input--wide", placeholder: "Rule violation", required: true = submit "Delete", class: "button button--danger button--separate-left" diff --git a/lib/philomena_web/templates/admin/approval/index.html.slime b/lib/philomena_web/templates/admin/approval/index.html.slime index 818f7ae1..d3f8e098 100644 --- a/lib/philomena_web/templates/admin/approval/index.html.slime +++ b/lib/philomena_web/templates/admin/approval/index.html.slime @@ -1,4 +1,4 @@ -- route = fn p -> Routes.admin_approval_path(@conn, :index, p) end +- route = fn p -> ~p"/admin/approvals?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @images, route: route h1 Approval Queue diff --git a/lib/philomena_web/templates/admin/artist_link/index.html.slime b/lib/philomena_web/templates/admin/artist_link/index.html.slime index b9d0e8db..633ff2c1 100644 --- a/lib/philomena_web/templates/admin/artist_link/index.html.slime +++ b/lib/philomena_web/templates/admin/artist_link/index.html.slime @@ -2,20 +2,20 @@ h1 Artist Links p Link creation is done via the Users menu. p Verifying a link will automatically award an artist badge if the link is public, no artist badge exists, and an "artist:" tag is specified. -= form_for :artist_link, Routes.admin_artist_link_path(@conn, :index), [method: "get", class: "hform"], fn f -> += form_for :artist_link, ~p"/admin/artist_links", [method: "get", class: "hform"], fn f -> .field = text_input f, :q, name: :q, value: @conn.params["q"], class: "input hform__text", placeholder: "Search query", autocapitalize: "none" = submit "Search", class: "hform__button button" -- route = fn p -> Routes.admin_artist_link_path(@conn, :index, p) end +- route = fn p -> ~p"/admin/artist_links?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @artist_links, route: route, params: link_scope(@conn), conn: @conn .block .block__header = if @conn.params["all"] do - = link "Show unverified only", to: Routes.admin_artist_link_path(@conn, :index) + = link "Show unverified only", to: ~p"/admin/artist_links" - else - = link "Show all", to: Routes.admin_artist_link_path(@conn, :index, all: "true") + = link "Show all", to: ~p"/admin/artist_links?#{[all: "true"]}" = pagination @@ -56,20 +56,20 @@ p Verifying a link will automatically award an artist badge if the link is publi = render PhilomenaWeb.TagView, "_tag.html", tag: link.tag, conn: @conn td - => link "View", to: Routes.profile_artist_link_path(@conn, :show, link.user, link) + => link "View", to: ~p"/profiles/#{link.user}/artist_links/#{link}" ' • - = link "Edit", to: Routes.profile_artist_link_path(@conn, :edit, link.user, link) + = link "Edit", to: ~p"/profiles/#{link.user}/artist_links/#{link}/edit" td - => link "Verify", to: Routes.admin_artist_link_verification_path(@conn, :create, link), method: :post + => link "Verify", to: ~p"/admin/artist_links/#{link}/verification", method: :post ' • - => link "Reject", to: Routes.admin_artist_link_reject_path(@conn, :create, link), method: :post + => link "Reject", to: ~p"/admin/artist_links/#{link}/reject", method: :post br = if not verified?(link) do = if contacted?(link) do ' Artist contacted - else - = link "Artist contacted", to: Routes.admin_artist_link_contact_path(@conn, :create, link), method: :post + = link "Artist contacted", to: ~p"/admin/artist_links/#{link}/contact", method: :post td = public_text(link) diff --git a/lib/philomena_web/templates/admin/badge/_form.html.slime b/lib/philomena_web/templates/admin/badge/_form.html.slime index d8af18ab..1e5dc79b 100644 --- a/lib/philomena_web/templates/admin/badge/_form.html.slime +++ b/lib/philomena_web/templates/admin/badge/_form.html.slime @@ -30,6 +30,6 @@ = error_tag f, :image_mime_type - else .field - = link "Change image", to: Routes.admin_badge_image_path(@conn, :edit, @changeset.data), class: "button" + = link "Change image", to: ~p"/admin/badges/#{@changeset.data}/image/edit", class: "button" = submit "Save Badge", class: "button", data: [disable_with: raw("Saving…")] diff --git a/lib/philomena_web/templates/admin/badge/edit.html.slime b/lib/philomena_web/templates/admin/badge/edit.html.slime index 01df2fba..da713050 100644 --- a/lib/philomena_web/templates/admin/badge/edit.html.slime +++ b/lib/philomena_web/templates/admin/badge/edit.html.slime @@ -1,5 +1,5 @@ h2 Edit Badge -= render "_form.html", Map.put(assigns, :action, Routes.admin_badge_path(@conn, :update, @badge)) += render "_form.html", Map.put(assigns, :action, ~p"/admin/badges/#{@badge}") -= link "Back", to: Routes.admin_badge_path(@conn, :index) += link "Back", to: ~p"/admin/badges" diff --git a/lib/philomena_web/templates/admin/badge/image/edit.html.slime b/lib/philomena_web/templates/admin/badge/image/edit.html.slime index ca0d7b4a..90042dbb 100644 --- a/lib/philomena_web/templates/admin/badge/image/edit.html.slime +++ b/lib/philomena_web/templates/admin/badge/image/edit.html.slime @@ -1,6 +1,6 @@ h2 Edit Badge -= form_for @changeset, Routes.admin_badge_image_path(@conn, :update, @badge), [multipart: true], fn f -> += form_for @changeset, ~p"/admin/badges/#{@badge}/image", [multipart: true], fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/admin/badge/index.html.slime b/lib/philomena_web/templates/admin/badge/index.html.slime index b46f6b71..f3949858 100644 --- a/lib/philomena_web/templates/admin/badge/index.html.slime +++ b/lib/philomena_web/templates/admin/badge/index.html.slime @@ -1,11 +1,11 @@ h2 Badges -- route = fn p -> Routes.admin_badge_path(@conn, :index, p) end +- route = fn p -> ~p"/admin/badges?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @badges, route: route, conn: @conn .block .block__header - a href=Routes.admin_badge_path(@conn, :new) + a href=~p"/admin/badges/new" i.fa.fa-plus> ' New Badge @@ -28,9 +28,9 @@ h2 Badges = badge_image(badge, width: 32, height: 32) td - => link "Users", to: Routes.admin_badge_user_path(@conn, :index, badge) + => link "Users", to: ~p"/admin/badges/#{badge}/users" ' • - = link "Edit", to: Routes.admin_badge_path(@conn, :edit, badge) + = link "Edit", to: ~p"/admin/badges/#{badge}/edit" .block__header.block__header--light = pagination diff --git a/lib/philomena_web/templates/admin/badge/new.html.slime b/lib/philomena_web/templates/admin/badge/new.html.slime index 72962247..57fc8273 100644 --- a/lib/philomena_web/templates/admin/badge/new.html.slime +++ b/lib/philomena_web/templates/admin/badge/new.html.slime @@ -1,5 +1,5 @@ h2 New Badge -= render "_form.html", Map.put(assigns, :action, Routes.admin_badge_path(@conn, :create)) += render "_form.html", Map.put(assigns, :action, ~p"/admin/badges") -= link "Back", to: Routes.admin_badge_path(@conn, :index) += link "Back", to: ~p"/admin/badges" diff --git a/lib/philomena_web/templates/admin/badge/user/index.html.slime b/lib/philomena_web/templates/admin/badge/user/index.html.slime index 8670165e..2e832c89 100644 --- a/lib/philomena_web/templates/admin/badge/user/index.html.slime +++ b/lib/philomena_web/templates/admin/badge/user/index.html.slime @@ -3,7 +3,7 @@ h1 => @badge.title ' badge -- route = fn p -> Routes.admin_badge_user_path(@conn, :index, @badge, p) end +- route = fn p -> ~p"/admin/badges/#{@badge}/users?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @users, route: route, conn: @conn .block @@ -19,7 +19,7 @@ h1 = for user <- @users do tr td - = link user.name, to: Routes.profile_path(@conn, :show, user) + = link user.name, to: ~p"/profiles/#{user}" .block__header.block__header--light = pagination diff --git a/lib/philomena_web/templates/admin/dnp_entry/index.html.slime b/lib/philomena_web/templates/admin/dnp_entry/index.html.slime index ee39d9e8..03635f82 100644 --- a/lib/philomena_web/templates/admin/dnp_entry/index.html.slime +++ b/lib/philomena_web/templates/admin/dnp_entry/index.html.slime @@ -1,11 +1,11 @@ h2 Do-Not-Post Requests -= form_for :dnp_entry, Routes.admin_dnp_entry_path(@conn, :index), [method: "get", class: "hform"], fn f -> += form_for :dnp_entry, ~p"/admin/dnp_entries", [method: "get", class: "hform"], fn f -> .field = text_input f, :q, name: :q, value: @conn.params["q"], class: "input hform__text", placeholder: "Search query", autocapitalize: "none" = submit "Search", class: "hform__button button" -- route = fn p -> Routes.admin_dnp_entry_path(@conn, :index, p) end +- route = fn p -> ~p"/admin/dnp_entries?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @dnp_entries, route: route, params: [states: state_param(@conn.params["states"])] .block @@ -13,10 +13,10 @@ h2 Do-Not-Post Requests = pagination span Display Only: - => link "All Open", to: Routes.admin_dnp_entry_path(@conn, :index, states: ~W(requested claimed rescinded acknowledged)) - => link "Listed", to: Routes.admin_dnp_entry_path(@conn, :index, states: ~W(listed)) - => link "Rescinded", to: Routes.admin_dnp_entry_path(@conn, :index, states: ~W(rescinded acknowledged)) - => link "Closed", to: Routes.admin_dnp_entry_path(@conn, :index, states: ~W(closed)) + => link "All Open", to: ~p"/admin/dnp_entries?#{[states: ~W(requested claimed rescinded acknowledged)]}" + => link "Listed", to: ~p"/admin/dnp_entries?#{[states: ~W(listed)]}" + => link "Rescinded", to: ~p"/admin/dnp_entries?#{[states: ~W(rescinded acknowledged)]}" + => link "Closed", to: ~p"/admin/dnp_entries?#{[states: ~W(closed)]}" .block__content table.table @@ -38,7 +38,7 @@ h2 Do-Not-Post Requests = render PhilomenaWeb.TagView, "_tag.html", tag: request.tag, conn: @conn td - = link request.requesting_user.name, to: Routes.profile_path(@conn, :show, request.requesting_user) + = link request.requesting_user.name, to: ~p"/profiles/#{request.requesting_user}" td = request.dnp_type @@ -51,7 +51,7 @@ h2 Do-Not-Post Requests = if request.modifying_user do ' by - = link request.modifying_user.name, to: Routes.profile_path(@conn, :show, request.modifying_user) + = link request.modifying_user.name, to: ~p"/profiles/#{request.modifying_user}" td = pretty_time(request.created_at) @@ -60,31 +60,31 @@ h2 Do-Not-Post Requests = pretty_time(request.updated_at) td - => link "Show", to: Routes.dnp_entry_path(@conn, :show, request) + => link "Show", to: ~p"/dnp/#{request}" ' • - => link "Send PM", to: Routes.conversation_path(@conn, :new, recipient: request.requesting_user.name) + => link "Send PM", to: ~p"/conversations/new?#{[recipient: request.requesting_user.name]}" = case request.aasm_state do - s when s in ["requested", "claimed"] -> ' • - => link "Claim", to: Routes.admin_dnp_entry_transition_path(@conn, :create, request, state: "claimed"), data: [method: "post", confirm: "Are you really, really sure?"] + => link "Claim", to: ~p"/admin/dnp_entries/#{request}/transition?#{[state: "claimed"]}", data: [method: "post", confirm: "Are you really, really sure?"] ' • - => link "Approve", to: Routes.admin_dnp_entry_transition_path(@conn, :create, request, state: "listed"), data: [method: "post", confirm: "Are you really, really sure?"] + => link "Approve", to: ~p"/admin/dnp_entries/#{request}/transition?#{[state: "listed"]}", data: [method: "post", confirm: "Are you really, really sure?"] ' • - => link "Close", to: Routes.admin_dnp_entry_transition_path(@conn, :create, request, state: "closed"), data: [method: "post", confirm: "Are you really, really sure?"] + => link "Close", to: ~p"/admin/dnp_entries/#{request}/transition?#{[state: "closed"]}", data: [method: "post", confirm: "Are you really, really sure?"] - "listed" -> ' • - => link "Rescind", to: Routes.admin_dnp_entry_transition_path(@conn, :create, request, state: "rescinded"), data: [method: "post", confirm: "Are you really, really sure?"] + => link "Rescind", to: ~p"/admin/dnp_entries/#{request}/transition?#{[state: "rescinded"]}", data: [method: "post", confirm: "Are you really, really sure?"] ' • - = link "Close", to: Routes.admin_dnp_entry_transition_path(@conn, :create, request, state: "closed"), data: [method: "post", confirm: "Are you really, really sure?"] + = link "Close", to: ~p"/admin/dnp_entries/#{request}/transition?#{[state: "closed"]}", data: [method: "post", confirm: "Are you really, really sure?"] - s when s in ["rescinded", "acknowledged"] -> ' • - => link "Claim", to: Routes.admin_dnp_entry_transition_path(@conn, :create, request, state: "acknowledged"), data: [method: "post", confirm: "Are you really, really sure?"] + => link "Claim", to: ~p"/admin/dnp_entries/#{request}/transition?#{[state: "acknowledged"]}", data: [method: "post", confirm: "Are you really, really sure?"] ' • - = link "Close", to: Routes.admin_dnp_entry_transition_path(@conn, :create, request, state: "closed"), data: [method: "post", confirm: "Are you really, really sure?"] + = link "Close", to: ~p"/admin/dnp_entries/#{request}/transition?#{[state: "closed"]}", data: [method: "post", confirm: "Are you really, really sure?"] - _state -> ' • - => link "Claim", to: Routes.admin_dnp_entry_transition_path(@conn, :create, request, state: "claimed"), data: [method: "post", confirm: "Are you really, really sure?"] + => link "Claim", to: ~p"/admin/dnp_entries/#{request}/transition?#{[state: "claimed"]}", data: [method: "post", confirm: "Are you really, really sure?"] diff --git a/lib/philomena_web/templates/admin/donation/_table.html.slime b/lib/philomena_web/templates/admin/donation/_table.html.slime index 7bcd7ac6..023369b4 100644 --- a/lib/philomena_web/templates/admin/donation/_table.html.slime +++ b/lib/philomena_web/templates/admin/donation/_table.html.slime @@ -12,7 +12,7 @@ table.table tr td = if donation.user do - = link donation.user.name, to: Routes.profile_path(@conn, :show, donation.user) + = link donation.user.name, to: ~p"/profiles/#{donation.user}" td = donation.email diff --git a/lib/philomena_web/templates/admin/donation/index.html.slime b/lib/philomena_web/templates/admin/donation/index.html.slime index f27ed0bb..97ed6cac 100644 --- a/lib/philomena_web/templates/admin/donation/index.html.slime +++ b/lib/philomena_web/templates/admin/donation/index.html.slime @@ -1,4 +1,4 @@ -- route = fn p -> Routes.admin_donation_path(@conn, :index, p) end +- route = fn p -> ~p"/admin/donations?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @donations, route: route, conn: @conn h1 Donations diff --git a/lib/philomena_web/templates/admin/donation/user/index.html.slime b/lib/philomena_web/templates/admin/donation/user/index.html.slime index dc45ab3e..daf4f6c1 100644 --- a/lib/philomena_web/templates/admin/donation/user/index.html.slime +++ b/lib/philomena_web/templates/admin/donation/user/index.html.slime @@ -6,7 +6,7 @@ = render PhilomenaWeb.Admin.DonationView, "_table.html", donations: @donations, conn: @conn h1 Add Donation - = form_for @changeset, Routes.admin_donation_path(@conn, :create), fn f -> + = form_for @changeset, ~p"/admin/donations", fn f -> .field => label f, :user_id, "User ID:" = number_input f, :user_id, class: "input input--short", value: @user.id diff --git a/lib/philomena_web/templates/admin/fingerprint_ban/edit.html.slime b/lib/philomena_web/templates/admin/fingerprint_ban/edit.html.slime index 2e78f09b..eb424776 100644 --- a/lib/philomena_web/templates/admin/fingerprint_ban/edit.html.slime +++ b/lib/philomena_web/templates/admin/fingerprint_ban/edit.html.slime @@ -1,6 +1,6 @@ h1 Editing ban -= render PhilomenaWeb.Admin.FingerprintBanView, "_form.html", changeset: @changeset, action: Routes.admin_fingerprint_ban_path(@conn, :update, @fingerprint), conn: @conn += render PhilomenaWeb.Admin.FingerprintBanView, "_form.html", changeset: @changeset, action: ~p"/admin/fingerprint_bans/#{@fingerprint}", conn: @conn br -= link "Back", to: Routes.admin_fingerprint_ban_path(@conn, :index) += link "Back", to: ~p"/admin/fingerprint_bans" 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 b173c39a..3888c7bf 100644 --- a/lib/philomena_web/templates/admin/fingerprint_ban/index.html.slime +++ b/lib/philomena_web/templates/admin/fingerprint_ban/index.html.slime @@ -1,16 +1,16 @@ h1 Fingerprint Bans -- route = fn p -> Routes.admin_fingerprint_ban_path(@conn, :index, p) end +- route = fn p -> ~p"/admin/fingerprint_bans?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @fingerprint_bans, route: route, params: page_params(@conn.params) -= form_for :fingerprint_ban, Routes.admin_fingerprint_ban_path(@conn, :index), [method: "get", class: "hform"], fn f -> += form_for :fingerprint_ban, ~p"/admin/fingerprint_bans", [method: "get", class: "hform"], fn f -> .field = text_input f, :q, name: "q", class: "hform__text input", placeholder: "Search" = submit "Search", class: "button hform__button" .block .block__header - a href=Routes.admin_fingerprint_ban_path(@conn, :new) + a href=~p"/admin/fingerprint_bans/new" i.fa.fa-plus> ' New fingerprint ban @@ -31,11 +31,11 @@ h1 Fingerprint Bans = for ban <- @fingerprint_bans do tr td - = link ban.fingerprint, to: Routes.fingerprint_profile_path(@conn, :show, ban.fingerprint) + = link ban.fingerprint, to: ~p"/fingerprint_profiles/#{ban.fingerprint}" 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 @@ -53,10 +53,10 @@ h1 Fingerprint Bans = ban.generated_ban_id td - => link "Edit", to: Routes.admin_fingerprint_ban_path(@conn, :edit, ban) + => link "Edit", to: ~p"/admin/fingerprint_bans/#{ban}/edit" = if @current_user.role == "admin" do ' • - => link "Destroy", to: Routes.admin_fingerprint_ban_path(@conn, :delete, ban), data: [confirm: "Are you really, really sure?", method: "delete"] + => link "Destroy", to: ~p"/admin/fingerprint_bans/#{ban}", data: [confirm: "Are you really, really sure?", method: "delete"] .block__header.block__header--light = pagination diff --git a/lib/philomena_web/templates/admin/fingerprint_ban/new.html.slime b/lib/philomena_web/templates/admin/fingerprint_ban/new.html.slime index 75db4f62..02d20b60 100644 --- a/lib/philomena_web/templates/admin/fingerprint_ban/new.html.slime +++ b/lib/philomena_web/templates/admin/fingerprint_ban/new.html.slime @@ -1,5 +1,5 @@ h1 New Fingerprint Ban -= render PhilomenaWeb.Admin.FingerprintBanView, "_form.html", changeset: @changeset, action: Routes.admin_fingerprint_ban_path(@conn, :create), conn: @conn += render PhilomenaWeb.Admin.FingerprintBanView, "_form.html", changeset: @changeset, action: ~p"/admin/fingerprint_bans", conn: @conn br -= link "Back", to: Routes.admin_fingerprint_ban_path(@conn, :index) += link "Back", to: ~p"/admin/fingerprint_bans" diff --git a/lib/philomena_web/templates/admin/forum/edit.html.slime b/lib/philomena_web/templates/admin/forum/edit.html.slime index 4f513a09..8d0e959b 100644 --- a/lib/philomena_web/templates/admin/forum/edit.html.slime +++ b/lib/philomena_web/templates/admin/forum/edit.html.slime @@ -1,5 +1,5 @@ h2 Edit Forum -= render "_form.html", Map.put(assigns, :action, Routes.admin_forum_path(@conn, :update, @forum)) += render "_form.html", Map.put(assigns, :action, ~p"/admin/forums/#{@forum}") -= link "Back", to: Routes.admin_forum_path(@conn, :index) += link "Back", to: ~p"/admin/forums" diff --git a/lib/philomena_web/templates/admin/forum/index.html.slime b/lib/philomena_web/templates/admin/forum/index.html.slime index fec3c55c..c1423ece 100644 --- a/lib/philomena_web/templates/admin/forum/index.html.slime +++ b/lib/philomena_web/templates/admin/forum/index.html.slime @@ -9,9 +9,9 @@ table.table = for forum <- @forums do tr td - = link forum.name, to: Routes.forum_path(@conn, :show, forum) + = link forum.name, to: ~p"/forums/#{forum}" td class="text-right" - = link "Edit", to: Routes.admin_forum_path(@conn, :edit, forum) + = link "Edit", to: ~p"/admin/forums/#{forum}/edit" -= link "New Forum", to: Routes.admin_forum_path(@conn, :new) += link "New Forum", to: ~p"/admin/forums/new" diff --git a/lib/philomena_web/templates/admin/forum/new.html.slime b/lib/philomena_web/templates/admin/forum/new.html.slime index 2d6fd0cd..602d7d14 100644 --- a/lib/philomena_web/templates/admin/forum/new.html.slime +++ b/lib/philomena_web/templates/admin/forum/new.html.slime @@ -1,5 +1,5 @@ h2 New Forum -= render "_form.html", Map.put(assigns, :action, Routes.admin_forum_path(@conn, :create)) += render "_form.html", Map.put(assigns, :action, ~p"/admin/forums") -= link "Back", to: Routes.admin_forum_path(@conn, :index) += link "Back", to: ~p"/admin/forums" diff --git a/lib/philomena_web/templates/admin/mod_note/_table.html.slime b/lib/philomena_web/templates/admin/mod_note/_table.html.slime index a47663a7..45207800 100644 --- a/lib/philomena_web/templates/admin/mod_note/_table.html.slime +++ b/lib/philomena_web/templates/admin/mod_note/_table.html.slime @@ -10,7 +10,7 @@ table.table = for {body, note} <- @mod_notes do tr td - = link_to_noted_thing(@conn, note.notable) + = link_to_noted_thing(note.notable) td = body @@ -19,9 +19,9 @@ table.table = pretty_time note.created_at td - = link note.moderator.name, to: Routes.profile_path(@conn, :show, note.moderator) + = link note.moderator.name, to: ~p"/profiles/#{note.moderator}" td - => link "Edit", to: Routes.admin_mod_note_path(@conn, :edit, note) + => link "Edit", to: ~p"/admin/mod_notes/#{note}/edit" ' • - => link "Delete", to: Routes.admin_mod_note_path(@conn, :delete, note), data: [confirm: "Are you really, really sure?", method: "delete"] + => link "Delete", to: ~p"/admin/mod_notes/#{note}", data: [confirm: "Are you really, really sure?", method: "delete"] diff --git a/lib/philomena_web/templates/admin/mod_note/edit.html.slime b/lib/philomena_web/templates/admin/mod_note/edit.html.slime index e9df5556..aed68f42 100644 --- a/lib/philomena_web/templates/admin/mod_note/edit.html.slime +++ b/lib/philomena_web/templates/admin/mod_note/edit.html.slime @@ -3,4 +3,4 @@ h2 => @mod_note.notable_type => @mod_note.notable_id -= render PhilomenaWeb.Admin.ModNoteView, "_form.html", changeset: @changeset, action: Routes.admin_mod_note_path(@conn, :update, @mod_note), conn: @conn += render PhilomenaWeb.Admin.ModNoteView, "_form.html", changeset: @changeset, action: ~p"/admin/mod_notes/#{@mod_note}", conn: @conn diff --git a/lib/philomena_web/templates/admin/mod_note/index.html.slime b/lib/philomena_web/templates/admin/mod_note/index.html.slime index fed17420..4c005f9e 100644 --- a/lib/philomena_web/templates/admin/mod_note/index.html.slime +++ b/lib/philomena_web/templates/admin/mod_note/index.html.slime @@ -1,4 +1,4 @@ -- route = fn p -> Routes.admin_mod_note_path(@conn, :index, p) end +- route = fn p -> ~p"/admin/mod_notes?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @mod_notes, route: route, conn: @conn h2 Mod Notes diff --git a/lib/philomena_web/templates/admin/mod_note/new.html.slime b/lib/philomena_web/templates/admin/mod_note/new.html.slime index 1cb13aea..09d7291e 100644 --- a/lib/philomena_web/templates/admin/mod_note/new.html.slime +++ b/lib/philomena_web/templates/admin/mod_note/new.html.slime @@ -3,4 +3,4 @@ h2 => @conn.params["notable_type"] => @conn.params["notable_id"] -= render PhilomenaWeb.Admin.ModNoteView, "_form.html", changeset: @changeset, action: Routes.admin_mod_note_path(@conn, :create), conn: @conn += render PhilomenaWeb.Admin.ModNoteView, "_form.html", changeset: @changeset, action: ~p"/admin/mod_notes", conn: @conn diff --git a/lib/philomena_web/templates/admin/report/_reports.html.slime b/lib/philomena_web/templates/admin/report/_reports.html.slime index 773a2072..c80176e3 100644 --- a/lib/philomena_web/templates/admin/report/_reports.html.slime +++ b/lib/philomena_web/templates/admin/report/_reports.html.slime @@ -12,16 +12,16 @@ table.table tr td => reported_image @conn, report.reportable - = link_to_reported_thing @conn, report.reportable + = link_to_reported_thing(report.reportable) td span title=report.reason = truncate(report.reason) td = if report.user do - = link report.user.name, to: Routes.profile_path(@conn, :show, report.user) + = link report.user.name, to: ~p"/profiles/#{report.user}" - else em> - = truncated_ip_link(@conn, report.ip) + = truncated_ip_link(report.ip) = link_to_fingerprint(@conn, report.fingerprint) = if not is_nil(report.user) and Enum.any?(report.user.linked_tags) do @@ -32,22 +32,22 @@ table.table td class=report_row_class(report) => pretty_state(report) - = user_abbrv @conn, report.admin + = user_abbrv(report.admin) td - => link "Show", to: Routes.admin_report_path(@conn, :show, report) + => link "Show", to: ~p"/admin/reports/#{report}" = if report.open do = if report.user do ' • - => link "Send PM", to: Routes.conversation_path(@conn, :new, recipient: report.user.name) + => link "Send PM", to: ~p"/conversations/new?#{[recipient: report.user.name]}" = if is_nil(report.admin) and not current?(report.admin, @conn.assigns.current_user) do ' • - => link "Claim", to: Routes.admin_report_claim_path(@conn, :create, report), data: [method: "post"] + => link "Claim", to: ~p"/admin/reports/#{report}/claim", data: [method: "post"] = if current?(report.admin, @conn.assigns.current_user) do ' • - => link "Release", to: Routes.admin_report_claim_path(@conn, :delete, report), data: [method: "delete"] + => link "Release", to: ~p"/admin/reports/#{report}/claim", data: [method: "delete"] ' • - => link "Close", to: Routes.admin_report_close_path(@conn, :create, report), data: [method: "post", confirm: "Are you really, really sure?"] + => link "Close", to: ~p"/admin/reports/#{report}/close", data: [method: "post", confirm: "Are you really, really sure?"] diff --git a/lib/philomena_web/templates/admin/report/index.html.slime b/lib/philomena_web/templates/admin/report/index.html.slime index d65af25c..bd467e23 100644 --- a/lib/philomena_web/templates/admin/report/index.html.slime +++ b/lib/philomena_web/templates/admin/report/index.html.slime @@ -1,4 +1,4 @@ -- route = fn p -> Routes.admin_report_path(@conn, :index, p) end +- route = fn p -> ~p"/admin/reports?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", route: route, page: @reports, conn: @conn, params: [rq: @conn.params["rq"] || "*"] h1 Reports @@ -30,7 +30,7 @@ h1 Reports .block__header.block__header--light = pagination -= form_for :report, Routes.admin_report_path(@conn, :index), [method: "get", class: "hform"], fn f -> += form_for :report, ~p"/admin/reports", [method: "get", class: "hform"], fn f -> .field = text_input f, :rq, name: :rq, value: @conn.params["rq"], class: "input hform__text", placeholder: "Search reports", autocapitalize: "none" = submit "Search", class: "hform__button button" diff --git a/lib/philomena_web/templates/admin/report/show.html.slime b/lib/philomena_web/templates/admin/report/show.html.slime index 4b819f94..9c227fae 100644 --- a/lib/philomena_web/templates/admin/report/show.html.slime +++ b/lib/philomena_web/templates/admin/report/show.html.slime @@ -1,6 +1,6 @@ h1 Showing Report p - = link_to_reported_thing @conn, @report.reportable + = link_to_reported_thing(@report.reportable) article.block.communication .block__content.flex.flex--no-wrap @@ -24,18 +24,18 @@ article.block.communication = if assigns[:mod_notes] do h4 Mod Notes = render PhilomenaWeb.Admin.ModNoteView, "_table.html", mod_notes: @mod_notes, conn: @conn - = link "Add New Note", to: Routes.admin_mod_note_path(@conn, :new, notable_id: @report.id, notable_type: "Report") + = link "Add New Note", to: ~p"/admin/mod_notes/new?#{[notable_id: @report.id, notable_type: "Report"]}" p = if @report.user do - => link "Send PM", to: Routes.conversation_path(@conn, :new, recipient: @report.user.name), class: "button" + => link "Send PM", to: ~p"/conversations/new?#{[recipient: @report.user.name]}", class: "button" = if @report.open do - => link "Close", to: Routes.admin_report_close_path(@conn, :create, @report), class: "button", data: [method: "post"] + => link "Close", to: ~p"/admin/reports/#{@report}/close", class: "button", data: [method: "post"] = if current?(@report.admin, @conn.assigns.current_user) do - => link "Release", to: Routes.admin_report_claim_path(@conn, :delete, @report), class: "button", data: [method: "delete"] + => link "Release", to: ~p"/admin/reports/#{@report}/claim", class: "button", data: [method: "delete"] - else - => link "Claim", to: Routes.admin_report_claim_path(@conn, :create, @report), class: "button", data: [method: "post"] + => link "Claim", to: ~p"/admin/reports/#{@report}/claim", class: "button", data: [method: "post"] -= link "Back", to: Routes.admin_report_path(@conn, :index), class: "button button-link" += link "Back", to: ~p"/admin/reports", class: "button button-link" diff --git a/lib/philomena_web/templates/admin/site_notice/edit.html.slime b/lib/philomena_web/templates/admin/site_notice/edit.html.slime index bd745654..de39c73e 100644 --- a/lib/philomena_web/templates/admin/site_notice/edit.html.slime +++ b/lib/philomena_web/templates/admin/site_notice/edit.html.slime @@ -1,2 +1,2 @@ h1 Editing site notice -= render PhilomenaWeb.Admin.SiteNoticeView, "_form.html", changeset: @changeset, action: Routes.admin_site_notice_path(@conn, :update, @site_notice), conn: @conn += render PhilomenaWeb.Admin.SiteNoticeView, "_form.html", changeset: @changeset, action: ~p"/admin/site_notices/#{@site_notice}", conn: @conn diff --git a/lib/philomena_web/templates/admin/site_notice/index.html.slime b/lib/philomena_web/templates/admin/site_notice/index.html.slime index 1ff2ee3f..21cac767 100644 --- a/lib/philomena_web/templates/admin/site_notice/index.html.slime +++ b/lib/philomena_web/templates/admin/site_notice/index.html.slime @@ -1,11 +1,11 @@ h1 Site Notices -- route = fn p -> Routes.admin_site_notice_path(@conn, :index, p) end +- route = fn p -> ~p"/admin/site_notices?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @admin_site_notices, route: route, conn: @conn .block .block__header - a href=Routes.admin_site_notice_path(@conn, :new) + a href=~p"/admin/site_notices/new" i.fa.fa-plus> ' New site notice @@ -36,9 +36,9 @@ h1 Site Notices = live_text site_notice td - => link "Edit", to: Routes.admin_site_notice_path(@conn, :edit, site_notice) + => link "Edit", to: ~p"/admin/site_notices/#{site_notice}/edit" ' • - => link "Destroy", to: Routes.admin_site_notice_path(@conn, :delete, site_notice), data: [confirm: "Are you really, really sure?", method: "delete"] + => link "Destroy", to: ~p"/admin/site_notices/#{site_notice}", data: [confirm: "Are you really, really sure?", method: "delete"] .block__header.block__header--light = pagination diff --git a/lib/philomena_web/templates/admin/site_notice/new.html.slime b/lib/philomena_web/templates/admin/site_notice/new.html.slime index b8c2f34b..cf85b793 100644 --- a/lib/philomena_web/templates/admin/site_notice/new.html.slime +++ b/lib/philomena_web/templates/admin/site_notice/new.html.slime @@ -1,2 +1,2 @@ h1 New site notice -= render PhilomenaWeb.Admin.SiteNoticeView, "_form.html", changeset: @changeset, action: Routes.admin_site_notice_path(@conn, :create), conn: @conn += render PhilomenaWeb.Admin.SiteNoticeView, "_form.html", changeset: @changeset, action: ~p"/admin/site_notices", conn: @conn diff --git a/lib/philomena_web/templates/admin/subnet_ban/edit.html.slime b/lib/philomena_web/templates/admin/subnet_ban/edit.html.slime index 98f35634..dc451983 100644 --- a/lib/philomena_web/templates/admin/subnet_ban/edit.html.slime +++ b/lib/philomena_web/templates/admin/subnet_ban/edit.html.slime @@ -1,6 +1,6 @@ h1 Editing ban -= render PhilomenaWeb.Admin.SubnetBanView, "_form.html", changeset: @changeset, action: Routes.admin_subnet_ban_path(@conn, :update, @subnet), conn: @conn += render PhilomenaWeb.Admin.SubnetBanView, "_form.html", changeset: @changeset, action: ~p"/admin/subnet_bans/#{@subnet}", conn: @conn br -= link "Back", to: Routes.admin_subnet_ban_path(@conn, :index) += link "Back", to: ~p"/admin/subnet_bans" 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 f6b4dc5d..162d1342 100644 --- a/lib/philomena_web/templates/admin/subnet_ban/index.html.slime +++ b/lib/philomena_web/templates/admin/subnet_ban/index.html.slime @@ -1,16 +1,16 @@ h1 Subnet Bans -- route = fn p -> Routes.admin_subnet_ban_path(@conn, :index, p) end +- route = fn p -> ~p"/admin/subnet_bans?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @subnet_bans, route: route, params: page_params(@conn.params) -= form_for :subnet_ban, Routes.admin_subnet_ban_path(@conn, :index), [method: "get", class: "hform"], fn f -> += form_for :subnet_ban, ~p"/admin/subnet_bans", [method: "get", class: "hform"], fn f -> .field = text_input f, :q, name: "q", class: "hform__text input", placeholder: "Search" = submit "Search", class: "button hform__button" .block .block__header - a href=Routes.admin_subnet_ban_path(@conn, :new) + a href=~p"/admin/subnet_bans/new" i.fa.fa-plus> ' New subnet ban @@ -31,11 +31,11 @@ h1 Subnet Bans = for ban <- @subnet_bans do tr td - = link ban.specification, to: Routes.ip_profile_path(@conn, :show, to_string(ban.specification)) + = link ban.specification, to: ~p"/ip_profiles/#{to_string(ban.specification)}" 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 @@ -53,10 +53,10 @@ h1 Subnet Bans = ban.generated_ban_id td - => link "Edit", to: Routes.admin_subnet_ban_path(@conn, :edit, ban) + => link "Edit", to: ~p"/admin/subnet_bans/#{ban}/edit" = if @current_user.role == "admin" do ' • - => link "Destroy", to: Routes.admin_subnet_ban_path(@conn, :delete, ban), data: [confirm: "Are you really, really sure?", method: "delete"] + => link "Destroy", to: ~p"/admin/subnet_bans/#{ban}", data: [confirm: "Are you really, really sure?", method: "delete"] .block__header.block__header--light = pagination diff --git a/lib/philomena_web/templates/admin/subnet_ban/new.html.slime b/lib/philomena_web/templates/admin/subnet_ban/new.html.slime index 50d01a78..7732231b 100644 --- a/lib/philomena_web/templates/admin/subnet_ban/new.html.slime +++ b/lib/philomena_web/templates/admin/subnet_ban/new.html.slime @@ -1,5 +1,5 @@ h1 New Subnet Ban -= render PhilomenaWeb.Admin.SubnetBanView, "_form.html", changeset: @changeset, action: Routes.admin_subnet_ban_path(@conn, :create), conn: @conn += render PhilomenaWeb.Admin.SubnetBanView, "_form.html", changeset: @changeset, action: ~p"/admin/subnet_bans", conn: @conn br -= link "Back", to: Routes.admin_subnet_ban_path(@conn, :index) += link "Back", to: ~p"/admin/subnet_bans" diff --git a/lib/philomena_web/templates/admin/user/_form.html.slime b/lib/philomena_web/templates/admin/user/_form.html.slime index a89a8347..7d529f24 100644 --- a/lib/philomena_web/templates/admin/user/_form.html.slime +++ b/lib/philomena_web/templates/admin/user/_form.html.slime @@ -27,7 +27,7 @@ .field label Avatar .with-error - = link to: Routes.admin_user_avatar_path(@conn, :delete, @user), class: "button button--danger", data: [method: "delete", confirm: "Are you really, really sure?"] do + = link to: ~p"/admin/users/#{@user}/avatar", class: "button button--danger", data: [method: "delete", confirm: "Are you really, really sure?"] do i.fa.fa-trash | Remove diff --git a/lib/philomena_web/templates/admin/user/edit.html.slime b/lib/philomena_web/templates/admin/user/edit.html.slime index bb1e6d02..e7a649de 100644 --- a/lib/philomena_web/templates/admin/user/edit.html.slime +++ b/lib/philomena_web/templates/admin/user/edit.html.slime @@ -1,3 +1,3 @@ h1 Editing user -= render PhilomenaWeb.Admin.UserView, "_form.html", Map.put(assigns, :action, Routes.admin_user_path(@conn, :update, @user)) += render PhilomenaWeb.Admin.UserView, "_form.html", Map.put(assigns, :action, ~p"/admin/users/#{@user}") diff --git a/lib/philomena_web/templates/admin/user/force_filter/new.html.slime b/lib/philomena_web/templates/admin/user/force_filter/new.html.slime index 87533d78..d7bd12e3 100644 --- a/lib/philomena_web/templates/admin/user/force_filter/new.html.slime +++ b/lib/philomena_web/templates/admin/user/force_filter/new.html.slime @@ -2,7 +2,7 @@ h1 ' Force-assigning a filter for user = @user.name -= form_for @changeset, Routes.admin_user_force_filter_path(@conn, :create, @user), [method: "post"], fn f -> += form_for @changeset, ~p"/admin/users/#{@user}/force_filter", [method: "post"], fn f -> .field => text_input f, :forced_filter_id, placeholder: "Filter ID", class: "input", required: true .field diff --git a/lib/philomena_web/templates/admin/user/index.html.slime b/lib/philomena_web/templates/admin/user/index.html.slime index 6378abd7..29ceb803 100644 --- a/lib/philomena_web/templates/admin/user/index.html.slime +++ b/lib/philomena_web/templates/admin/user/index.html.slime @@ -1,15 +1,15 @@ h1 Users -= form_for :user, Routes.admin_user_path(@conn, :index), [method: "get", class: "hform"], fn f -> += form_for :user, ~p"/admin/users", [method: "get", class: "hform"], fn f -> .field => text_input f, :q, name: "q", class: "hform__text input", placeholder: "Search query" = submit "Search", class: "button hform__button" -=> link "Site staff", to: Routes.admin_user_path(@conn, :index, staff: 1) +=> link "Site staff", to: ~p"/admin/users?#{[staff: 1]}" ' • -=> link "2FA users", to: Routes.admin_user_path(@conn, :index, twofactor: 1) +=> link "2FA users", to: ~p"/admin/users?#{[twofactor: 1]}" -- route = fn p -> Routes.admin_user_path(@conn, :index, p) end +- route = fn p -> ~p"/admin/users?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @users, route: route, conn: @conn, params: page_params(@conn.params) .block @@ -30,7 +30,7 @@ h1 Users = for user <- @users do tr td - = link user.name, to: Routes.profile_path(@conn, :show, user) + = link user.name, to: ~p"/profiles/#{user}" = cond do - user.otp_required_for_login -> @@ -71,7 +71,7 @@ h1 Users td = if can?(@conn, :edit, user) do - => link to: Routes.admin_user_path(@conn, :edit, user) do + => link to: ~p"/admin/users/#{user}/edit" do i.fa.icon--padded.small.fa-user-edit ' Edit @@ -82,11 +82,11 @@ h1 Users /' • = if can?(@conn, :index, Philomena.Bans.User) do - => link to: Routes.admin_user_ban_path(@conn, :new, username: user.name) do + => link to: ~p"/admin/user_bans/new?#{[username: user.name]}" do i.fa.icon--padded.small.fa-ban ' Ban = if can?(@conn, :edit, Philomena.ArtistLinks.ArtistLink) do - => link to: Routes.profile_artist_link_path(@conn, :new, user) do + => link to: ~p"/profiles/#{user}/artist_links/new" do i.fa.icon--padded.small.fa-link ' Add link diff --git a/lib/philomena_web/templates/admin/user_ban/edit.html.slime b/lib/philomena_web/templates/admin/user_ban/edit.html.slime index ff4f23bb..604f0ed6 100644 --- a/lib/philomena_web/templates/admin/user_ban/edit.html.slime +++ b/lib/philomena_web/templates/admin/user_ban/edit.html.slime @@ -1,6 +1,6 @@ h1 Editing ban -= render PhilomenaWeb.Admin.UserBanView, "_form.html", changeset: @changeset, action: Routes.admin_user_ban_path(@conn, :update, @user), conn: @conn += render PhilomenaWeb.Admin.UserBanView, "_form.html", changeset: @changeset, action: ~p"/admin/user_bans/#{@user}", conn: @conn br -= link "Back", to: Routes.admin_user_ban_path(@conn, :index) += link "Back", to: ~p"/admin/user_bans" 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 c81d4ab2..61087b58 100644 --- a/lib/philomena_web/templates/admin/user_ban/index.html.slime +++ b/lib/philomena_web/templates/admin/user_ban/index.html.slime @@ -1,16 +1,16 @@ h1 User Bans -- route = fn p -> Routes.admin_user_ban_path(@conn, :index, p) end +- route = fn p -> ~p"/admin/user_bans?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @user_bans, route: route, params: page_params(@conn.params) -= form_for :user_ban, Routes.admin_user_ban_path(@conn, :index), [method: "get", class: "hform"], fn f -> += form_for :user_ban, ~p"/admin/user_bans", [method: "get", class: "hform"], fn f -> .field = text_input f, :q, name: "q", class: "hform__text input", placeholder: "Search" = submit "Search", class: "button hform__button" .block .block__header - a href=Routes.admin_user_ban_path(@conn, :new) + a href=~p"/admin/user_bans/new" i.fa.fa-plus> ' New user ban @@ -31,11 +31,11 @@ h1 User Bans = for ban <- @user_bans do tr td - = link ban.user.name, to: Routes.profile_path(@conn, :show, ban.user) + = link ban.user.name, to: ~p"/profiles/#{ban.user}" 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 @@ -53,10 +53,10 @@ h1 User Bans = ban.generated_ban_id td - => link "Edit", to: Routes.admin_user_ban_path(@conn, :edit, ban) + => link "Edit", to: ~p"/admin/user_bans/#{ban}/edit" = if @current_user.role == "admin" do ' • - => link "Destroy", to: Routes.admin_user_ban_path(@conn, :delete, ban), data: [confirm: "Are you really, really sure?", method: "delete"] + => link "Destroy", to: ~p"/admin/user_bans/#{ban}", data: [confirm: "Are you really, really sure?", method: "delete"] .block__header.block__header--light = pagination diff --git a/lib/philomena_web/templates/admin/user_ban/new.html.slime b/lib/philomena_web/templates/admin/user_ban/new.html.slime index 468595cb..cdd82ff8 100644 --- a/lib/philomena_web/templates/admin/user_ban/new.html.slime +++ b/lib/philomena_web/templates/admin/user_ban/new.html.slime @@ -1,5 +1,5 @@ h1 New User Ban -= render PhilomenaWeb.Admin.UserBanView, "_form.html", changeset: @changeset, action: Routes.admin_user_ban_path(@conn, :create), conn: @conn += render PhilomenaWeb.Admin.UserBanView, "_form.html", changeset: @changeset, action: ~p"/admin/user_bans", conn: @conn br -= link "Back", to: Routes.admin_user_ban_path(@conn, :index) += link "Back", to: ~p"/admin/user_bans" diff --git a/lib/philomena_web/templates/advert/_box.html.slime b/lib/philomena_web/templates/advert/_box.html.slime index 77a2e77b..e66d2a27 100644 --- a/lib/philomena_web/templates/advert/_box.html.slime +++ b/lib/philomena_web/templates/advert/_box.html.slime @@ -6,7 +6,7 @@ => link "Click here", to: "/pages/advertising" ' for information! - a#imagespns__link href=Routes.advert_path(@conn, :show, @advert) rel="nofollow" title=@advert.title + a#imagespns__link href=~p"/adverts/#{@advert}" rel="nofollow" title=@advert.title img src=advert_image_url(@advert) alt=@advert.title p diff --git a/lib/philomena_web/templates/api/rss/watched/index.html.eex b/lib/philomena_web/templates/api/rss/watched/index.html.eex index cf70bb69..dc8334d3 100644 --- a/lib/philomena_web/templates/api/rss/watched/index.html.eex +++ b/lib/philomena_web/templates/api/rss/watched/index.html.eex @@ -3,7 +3,7 @@ <%= site_name() %> Watchlist Your watched tags feed from <%= site_name() %> - <%= Routes.api_rss_watched_url(@conn, :index) %> + <%= url(~p"/api/v1/rss/watched") %> <%= last_build_date() %> <%= for image <- @images do %> @@ -12,14 +12,14 @@ - + "> <%= mouseovertext %> ]]> <%= DateTime.to_iso8601(image.created_at) %> - <%= Routes.image_url(@conn, :show, image) %> - <%= Routes.image_url(@conn, :show, image) %> + <%= url(~p"/images/#{image}") %> + <%= url(~p"/images/#{image}") %> <% end %> diff --git a/lib/philomena_web/templates/avatar/edit.html.slime b/lib/philomena_web/templates/avatar/edit.html.slime index 81bd63f5..3ee56baf 100644 --- a/lib/philomena_web/templates/avatar/edit.html.slime +++ b/lib/philomena_web/templates/avatar/edit.html.slime @@ -8,7 +8,7 @@ p Add a new avatar or remove your existing one here. p Avatars must be less than 1000px tall and wide, and smaller than 300 kilobytes in size. PNG, JPEG, and GIF are acceptable. - = form_for @changeset, Routes.avatar_path(@conn, :update), [method: "put", multipart: true], fn f -> + = form_for @changeset, ~p"/avatar", [method: "put", multipart: true], fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. @@ -37,10 +37,10 @@ => submit "Update my avatar", class: "button" br - = button_to "Remove my avatar", Routes.avatar_path(@conn, :delete), method: "delete", class: "button", data: [confirm: "Are you really, really sure?"] + = button_to "Remove my avatar", ~p"/avatar", method: "delete", class: "button", data: [confirm: "Are you really, really sure?"] br = if blank?(@conn.params["profile"]) do - = link "Back", to: Routes.registration_path(@conn, :edit) + = link "Back", to: ~p"/registrations/edit" - else - = link "Back", to: Routes.profile_path(@conn, :show, @current_user) + = link "Back", to: ~p"/profiles/#{@current_user}" diff --git a/lib/philomena_web/templates/channel/_channel_box.html.slime b/lib/philomena_web/templates/channel/_channel_box.html.slime index 3a3ce14c..b949406d 100644 --- a/lib/philomena_web/templates/channel/_channel_box.html.slime +++ b/lib/philomena_web/templates/channel/_channel_box.html.slime @@ -1,7 +1,7 @@ - link_class = "media-box__header media-box__header--channel media-box__header--link" .media-box - a.media-box__header.media-box__header--channel.media-box__header--link href=Routes.channel_path(@conn, :show, @channel) title=@channel.title + a.media-box__header.media-box__header--channel.media-box__header--link href=~p"/channels/#{@channel}" title=@channel.title = @channel.title || @channel.short_name .media-box__header.media-box__header--channel @@ -17,22 +17,22 @@ | NSFW .media-box__content.media-box__content--channel - a href=Routes.channel_path(@conn, :show, @channel) + a href=~p"/channels/#{@channel}" .image-constrained.media-box__content--channel img src=channel_image(@channel) alt="#{@channel.title}" = if @channel.associated_artist_tag do - a href=Routes.tag_path(@conn, :show, @channel.associated_artist_tag) class=link_class + a href=~p"/tags/#{@channel.associated_artist_tag}" class=link_class i.fa.icon--padded.small.fa-tags> = @channel.associated_artist_tag.name - else .media-box__header.media-box__header--channel No artist tag = if can?(@conn, :edit, @channel) do - a href=Routes.channel_path(@conn, :edit, @channel) class=link_class + a href=~p"/channels/#{@channel}/edit" class=link_class i.fas.icon--padded.small.fa-edit> ' Edit - a href=Routes.channel_path(@conn, :delete, @channel) class=link_class data-method="delete" data-confirm="Are you really, really sure?" + a href=~p"/channels/#{@channel}" class=link_class data-method="delete" data-confirm="Are you really, really sure?" i.fas.icon--padded.small.fa-trash> ' Delete diff --git a/lib/philomena_web/templates/channel/edit.html.slime b/lib/philomena_web/templates/channel/edit.html.slime index 47f0e53b..6eb25d31 100644 --- a/lib/philomena_web/templates/channel/edit.html.slime +++ b/lib/philomena_web/templates/channel/edit.html.slime @@ -1,3 +1,3 @@ h1 Editing Channel -= render PhilomenaWeb.ChannelView, "_form.html", changeset: @changeset, action: Routes.channel_path(@conn, :update, @channel), conn: @conn += render PhilomenaWeb.ChannelView, "_form.html", changeset: @changeset, action: ~p"/channels/#{@channel}", conn: @conn diff --git a/lib/philomena_web/templates/channel/index.html.slime b/lib/philomena_web/templates/channel/index.html.slime index 7fd24c1c..50b0bbaa 100644 --- a/lib/philomena_web/templates/channel/index.html.slime +++ b/lib/philomena_web/templates/channel/index.html.slime @@ -1,9 +1,9 @@ h1 Livestreams -- route = fn p -> Routes.channel_path(@conn, :index, p) end +- route = fn p -> ~p"/channels?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @channels, route: route, conn: @conn, params: [cq: @conn.params["cq"]] -= form_for :channels, Routes.channel_path(@conn, :index), [method: "get", class: "hform", enforce_utf8: false], fn f -> += form_for :channels, ~p"/channels", [method: "get", class: "hform", enforce_utf8: false], fn f -> .field = text_input f, :cq, name: :cq, value: @conn.params["cq"], class: "input hform__text", placeholder: "Search channels", autocapitalize: "none" = submit "Search", class: "hform__button button" @@ -13,11 +13,11 @@ h1 Livestreams .page__pagination = pagination = if @conn.cookies["chan_nsfw"] == "true" do - a href=Routes.channel_nsfw_path(@conn, :delete) data-method="delete" + a href=~p"/channels/nsfw" data-method="delete" i.fa.fa-eye-slash> ' Hide NSFW streams - else - a href=Routes.channel_nsfw_path(@conn, :create) data-method="create" + a href=~p"/channels/nsfw" data-method="create" i.fa.fa-eye> ' Show NSFW streams @@ -30,7 +30,7 @@ h1 Livestreams br = if can?(@conn, :create, Philomena.Channels.Channel) do - = link "New Channel", to: Routes.channel_path(@conn, :new) + = link "New Channel", to: ~p"/channels/new" h2 FAQ p diff --git a/lib/philomena_web/templates/channel/new.html.slime b/lib/philomena_web/templates/channel/new.html.slime index 8a3551e9..a7361ef7 100644 --- a/lib/philomena_web/templates/channel/new.html.slime +++ b/lib/philomena_web/templates/channel/new.html.slime @@ -1,3 +1,3 @@ h1 Adding Channel -= render PhilomenaWeb.ChannelView, "_form.html", changeset: @changeset, action: Routes.channel_path(@conn, :create), conn: @conn += render PhilomenaWeb.ChannelView, "_form.html", changeset: @changeset, action: ~p"/channels", conn: @conn diff --git a/lib/philomena_web/templates/channel/subscription/_subscription.html.slime b/lib/philomena_web/templates/channel/subscription/_subscription.html.slime index 663ecff2..f5a171f4 100644 --- a/lib/philomena_web/templates/channel/subscription/_subscription.html.slime +++ b/lib/philomena_web/templates/channel/subscription/_subscription.html.slime @@ -1,8 +1,8 @@ elixir: - watch_path = Routes.channel_subscription_path(@conn, :create, @channel) + watch_path = ~p"/channels/#{@channel}/subscription" watch_class = if @watching, do: "hidden", else: "" - unwatch_path = Routes.channel_subscription_path(@conn, :delete, @channel) + unwatch_path = ~p"/channels/#{@channel}/subscription" unwatch_class = if @watching, do: "", else: "hidden" = if @conn.assigns.current_user do @@ -17,7 +17,7 @@ elixir: span.hidden--mobile ' Unsubscribe - else - a.media-box__header.media-box__header--channel.media-box__header--link href=Routes.session_path(@conn, :new) + a.media-box__header.media-box__header--channel.media-box__header--link href=~p"/sessions/new" i.fa.fa-bell> span.hidden--mobile ' Subscribe diff --git a/lib/philomena_web/templates/comment/_comment.html.slime b/lib/philomena_web/templates/comment/_comment.html.slime index 127ebe7c..f3d40d6a 100644 --- a/lib/philomena_web/templates/comment/_comment.html.slime +++ b/lib/philomena_web/templates/comment/_comment.html.slime @@ -12,7 +12,7 @@ article.block.communication id="comment_#{@comment.id}" class=block_class p ul.horizontal-list li - = link(to: Routes.image_comment_approve_path(@conn, :create, @comment.image_id, @comment), data: [confirm: "Are you sure?"], method: "post", class: "button") do + = link(to: ~p"/images/#{@comment.image_id}/comments/#{@comment}/approve", data: [confirm: "Are you sure?"], method: "post", class: "button") do i.fas.fa-check> ' Approve li @@ -20,7 +20,7 @@ article.block.communication id="comment_#{@comment.id}" class=block_class i.fa.fa-times> ' Reject - = form_for :comment, Routes.image_comment_hide_path(@conn, :create, @comment.image_id, @comment), [class: "togglable-delete-form hidden flex", id: "inline-reject-form-comment-#{@comment.id}"], fn f -> + = form_for :comment, ~p"/images/#{@comment.image_id}/comments/#{@comment}/hide", [class: "togglable-delete-form hidden flex", id: "inline-reject-form-comment-#{@comment.id}"], fn f -> = text_input f, :deletion_reason, class: "input input--wide", placeholder: "Deletion Reason", id: "inline-reject-reason-comment-#{@comment.id}", required: true = submit "Delete", class: "button" @@ -38,12 +38,12 @@ article.block.communication id="comment_#{@comment.id}" class=block_class .communication__options__staff = cond do - @comment.hidden_from_users and not @comment.destroyed_content -> - = link(to: Routes.image_comment_hide_path(@conn, :delete, @comment.image_id, @comment), data: [confirm: "Are you sure?"], method: "delete", class: "communication__interaction") do + = link(to: ~p"/images/#{@comment.image_id}/comments/#{@comment}/hide", data: [confirm: "Are you sure?"], method: "delete", class: "communication__interaction") do i.fas.fa-check> ' Restore = if can?(@conn, :delete, @comment) do - = link(to: Routes.image_comment_delete_path(@conn, :create, @comment.image_id, @comment), data: [confirm: "Are you sure?"], method: "post", class: "communication__interaction") do + = link(to: ~p"/images/#{@comment.image_id}/comments/#{@comment}/delete", data: [confirm: "Are you sure?"], method: "post", class: "communication__interaction") do i.fas.fa-times> ' Delete Contents @@ -60,6 +60,6 @@ article.block.communication id="comment_#{@comment.id}" class=block_class .button.button--warning.button--transparent.js-staff-action =<> link_to_fingerprint(@conn, @comment.fingerprint) - = form_for :comment, Routes.image_comment_hide_path(@conn, :create, @comment.image_id, @comment), [class: "togglable-delete-form hidden flex", id: "inline-del-form-comment-#{@comment.id}"], fn f -> + = form_for :comment, ~p"/images/#{@comment.image_id}/comments/#{@comment}/hide", [class: "togglable-delete-form hidden flex", id: "inline-del-form-comment-#{@comment.id}"], fn f -> = text_input f, :deletion_reason, class: "input input--wide", placeholder: "Deletion Reason", id: "inline-del-reason-comment-#{@comment.id}", required: true = submit "Delete", class: "button" diff --git a/lib/philomena_web/templates/comment/_comment_link.html.slime b/lib/philomena_web/templates/comment/_comment_link.html.slime index 862dc21d..061e8c61 100644 --- a/lib/philomena_web/templates/comment/_comment_link.html.slime +++ b/lib/philomena_web/templates/comment/_comment_link.html.slime @@ -1,10 +1,10 @@ -- comment_link = Routes.image_path(@conn, :show, @comment.image) <> "#comment_#{@comment.id}" +- comment_link = ~p"/images/#{@comment.image}" <> "#comment_#{@comment.id}" .flex__spacer.hidden--desktop a.communication__interaction.hidden--desktop title="Link to comment" href=comment_link i.fa.fa-link = if not is_nil(@comment.edited_at) and can?(@conn, :show, @comment) do - a.communication__options__edit-time href=Routes.image_comment_history_path(@conn, :index, @comment.image, @comment) + a.communication__options__edit-time href=~p"/images/#{@comment.image}/comments/#{@comment}/history" span.hidden--mobile> - edited span.hidden--desktop> Edited => pretty_time(@comment.edited_at) diff --git a/lib/philomena_web/templates/comment/_comment_options.html.slime b/lib/philomena_web/templates/comment/_comment_options.html.slime index b662b982..5d1b7996 100644 --- a/lib/philomena_web/templates/comment/_comment_options.html.slime +++ b/lib/philomena_web/templates/comment/_comment_options.html.slime @@ -1,11 +1,11 @@ = if not @comment.hidden_from_users or can?(@conn, :hide, @comment) do .flex.flex--normal-gap.flex--centered = if not @comment.hidden_from_users do - - link_path = Routes.image_path(@conn, :show, @comment.image) <> "#comment_#{@comment.id}" + - link_path = ~p"/images/#{@comment.image}" <> "#comment_#{@comment.id}" - safe_author = PhilomenaWeb.PostView.markdown_safe_author(@comment) - quote_body = if @comment.hidden_from_users, do: "", else: @comment.body - a.button href=Routes.image_comment_report_path(@conn, :new, @comment.image, @comment) + a.button href=~p"/images/#{@comment.image}/comments/#{@comment}/reports/new" i.fa.fa-flag> ' Report @@ -18,6 +18,6 @@ ' Reply = if not @comment.destroyed_content and can?(@conn, :edit, @comment) do - a.button href=Routes.image_comment_path(@conn, :edit, @comment.image, @comment) + a.button href=~p"/images/#{@comment.image}/comments/#{@comment}/edit" i.fas.fa-edit ' Edit diff --git a/lib/philomena_web/templates/comment/_comment_with_image.html.slime b/lib/philomena_web/templates/comment/_comment_with_image.html.slime index 1ff5e0ab..60ab90df 100644 --- a/lib/philomena_web/templates/comment/_comment_with_image.html.slime +++ b/lib/philomena_web/templates/comment/_comment_with_image.html.slime @@ -14,12 +14,12 @@ article.block.communication id="comment_#{@comment.id}" class=block_class .flex.flex--normal-gap.flex--centered.js-staff-action = cond do - @comment.hidden_from_users and not @comment.destroyed_content -> - = link(to: Routes.image_comment_hide_path(@conn, :delete, @comment.image_id, @comment), data: [confirm: "Are you sure?"], method: "delete", class: "button button--success") do + = link(to: ~p"/images/#{@comment.image_id}/comments/#{@comment}/hide", data: [confirm: "Are you sure?"], method: "delete", class: "button button--success") do i.fas.fa-check> ' Restore = if can?(@conn, :delete, @comment) do - = link(to: Routes.image_comment_delete_path(@conn, :create, @comment.image_id, @comment), data: [confirm: "Are you sure?"], method: "post", class: "button button--danger button--transparent") do + = link(to: ~p"/images/#{@comment.image_id}/comments/#{@comment}/delete", data: [confirm: "Are you sure?"], method: "post", class: "button button--danger button--transparent") do i.fas.fa-times> ' Delete Contents @@ -36,6 +36,6 @@ article.block.communication id="comment_#{@comment.id}" class=block_class .button.button--warning.button--transparent.js-staff-action =<> link_to_fingerprint(@conn, @comment.fingerprint) - = form_for :comment, Routes.image_comment_hide_path(@conn, :create, @comment.image_id, @comment), [class: "togglable-delete-form hidden flex", id: "inline-del-form-comment-#{@comment.id}"], fn f -> + = form_for :comment, ~p"/images/#{@comment.image_id}/comments/#{@comment}/hide", [class: "togglable-delete-form hidden flex", id: "inline-del-form-comment-#{@comment.id}"], fn f -> = text_input f, :deletion_reason, class: "input input--wide", placeholder: "Deletion Reason", id: "inline-del-reason-comment-#{@comment.id}", required: true = submit "Delete", class: "button" diff --git a/lib/philomena_web/templates/comment/index.html.slime b/lib/philomena_web/templates/comment/index.html.slime index 4494c793..44aebd2d 100644 --- a/lib/philomena_web/templates/comment/index.html.slime +++ b/lib/philomena_web/templates/comment/index.html.slime @@ -1,6 +1,6 @@ h1 Comments -= form_for :comments, Routes.comment_path(@conn, :index), [method: "get", class: "hform", enforce_utf8: false], fn f -> += form_for :comments, ~p"/comments", [method: "get", class: "hform", enforce_utf8: false], fn f -> .field = text_input f, :cq, name: :cq, value: @conn.params["cq"], class: "input hform__text", placeholder: "Search comments", autocapitalize: "none" = submit "Search", class: "hform__button button" @@ -14,7 +14,7 @@ h2 Search Results = cond do - Enum.any?(@comments) -> - - route = fn p -> Routes.comment_path(@conn, :index, p) end + - route = fn p -> ~p"/comments?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @comments, route: route, params: [cq: @conn.params["cq"]], conn: @conn = for {body, comment} <- @comments, comment.image.hidden_from_users == false do @@ -68,35 +68,35 @@ table.table td Literal td Matches the author of this comment. Anonymous authors will never match this term. td - code = link "author:Joey", to: Routes.comment_path(@conn, :index, cq: "author:Joey") + code = link "author:Joey", to: ~p"/comments?#{[cq: "author:Joey"]}" tr td code body td Full Text td Matches the body of this comment. This is the default field. td - code = link "body:test", to: Routes.comment_path(@conn, :index, cq: "body:test") + code = link "body:test", to: ~p"/comments?#{[cq: "body:test"]}" tr td code created_at td Date/Time Range td Matches the creation time of this comment. td - code = link "created_at:2015", to: Routes.comment_path(@conn, :index, cq: "created_at:2015") + code = link "created_at:2015", to: ~p"/comments?#{[cq: "created_at:2015"]}" tr td code id td Numeric Range td Matches the numeric surrogate key for this comment. td - code = link "id:1000000", to: Routes.comment_path(@conn, :index, cq: "id:1000000") + code = link "id:1000000", to: ~p"/comments?#{[cq: "id:1000000"]}" tr td code image_id td Literal td Matches the numeric surrogate key for the image this comment belongs to. td - code = link "image_id:1000000", to: Routes.comment_path(@conn, :index, cq: "image_id:1000000") + code = link "image_id:1000000", to: ~p"/comments?#{[cq: "image_id:1000000"]}" tr td code my @@ -105,11 +105,11 @@ table.table code> my:comments ' matches comments you have posted if you are signed in. td - code = link "my:comments", to: Routes.comment_path(@conn, :index, cq: "my:comments") + code = link "my:comments", to: ~p"/comments?#{[cq: "my:comments"]}" tr td code user_id td Literal td Matches comments with the specified user_id. Anonymous users will never match this term. td - code = link "user_id:211190", to: Routes.comment_path(@conn, :index, cq: "user_id:211190") + code = link "user_id:211190", to: ~p"/comments?#{[cq: "user_id:211190"]}" diff --git a/lib/philomena_web/templates/commission/_directory_results.html.slime b/lib/philomena_web/templates/commission/_directory_results.html.slime index aa2a7001..8071b52f 100644 --- a/lib/philomena_web/templates/commission/_directory_results.html.slime +++ b/lib/philomena_web/templates/commission/_directory_results.html.slime @@ -1,5 +1,5 @@ elixir: - route = fn p -> Routes.commission_path(@conn, :index, p) end + route = fn p -> ~p"/commissions?#{p}" end pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @commissions, route: route, conn: @conn, params: [commission: @conn.params["commission"]] .block @@ -9,10 +9,10 @@ elixir: .page__info = cond do - not is_nil(@conn.assigns.current_user) and not is_nil(@conn.assigns.current_user.commission) -> - = link "View my listing", to: Routes.profile_commission_path(@conn, :show, @conn.assigns.current_user) + = link "View my listing", to: ~p"/profiles/#{@conn.assigns.current_user}/commission" - not is_nil(@conn.assigns.current_user) -> - = link "Create my listing", to: Routes.profile_commission_path(@conn, :new, @conn.assigns.current_user) + = link "Create my listing", to: ~p"/profiles/#{@conn.assigns.current_user}/commission/new" - true -> @@ -58,7 +58,7 @@ elixir: p strong - = link "More information", to: Routes.profile_commission_path(@conn, :show, c.user) + = link "More information", to: ~p"/profiles/#{c.user}/commission" - true -> p We couldn't find any commission listings to display. Sorry! diff --git a/lib/philomena_web/templates/commission/_directory_sidebar.html.slime b/lib/philomena_web/templates/commission/_directory_sidebar.html.slime index f9f8670a..7693e8b9 100644 --- a/lib/philomena_web/templates/commission/_directory_sidebar.html.slime +++ b/lib/philomena_web/templates/commission/_directory_sidebar.html.slime @@ -2,7 +2,7 @@ .block__header span Search .block__content - = form_for @conn, Routes.commission_path(@conn, :index), [as: :commission, method: "get", class: "hform"], fn f -> + = form_for @conn, ~p"/commissions", [as: :commission, method: "get", class: "hform"], fn f -> .field = label f, :categories, "Art Categories:" = for {name, value} <- categories() do diff --git a/lib/philomena_web/templates/confirmation/new.html.slime b/lib/philomena_web/templates/confirmation/new.html.slime index 2f4a5177..7972f595 100644 --- a/lib/philomena_web/templates/confirmation/new.html.slime +++ b/lib/philomena_web/templates/confirmation/new.html.slime @@ -1,6 +1,6 @@ h1 Resend confirmation instructions -= form_for :user, Routes.confirmation_path(@conn, :create), fn f -> += form_for :user, ~p"/confirmations", fn f -> .field = email_input f, :email, placeholder: "Email", class: "input", required: true diff --git a/lib/philomena_web/templates/conversation/index.html.slime b/lib/philomena_web/templates/conversation/index.html.slime index 6abf46a9..4528329b 100644 --- a/lib/philomena_web/templates/conversation/index.html.slime +++ b/lib/philomena_web/templates/conversation/index.html.slime @@ -1,5 +1,5 @@ elixir: - route = fn p -> Routes.conversation_path(@conn, :index, p) end + route = fn p -> ~p"/conversations?#{p}" end pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @conversations, route: route, conn: @conn h1 My Conversations @@ -8,7 +8,7 @@ h1 My Conversations .page__pagination = pagination .page__info - a href=Routes.conversation_path(@conn, :new) + a href=~p"/conversations/new" i.fa.fa-paper-plane> ' Create New Conversation @@ -23,7 +23,7 @@ h1 My Conversations = for {c, count} <- @conversations do tr class=conversation_class(@conn.assigns.current_user, c) td.table--communication-list__name - => link c.title, to: Routes.conversation_path(@conn, :show, c) + => link c.title, to: ~p"/conversations/#{c}" .small-text.hidden--mobile => count @@ -36,9 +36,9 @@ 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: Routes.conversation_hide_path(@conn, :create, c), data: [method: "post"], data: [confirm: "Are you really, really sure?"] + => link "Hide", to: ~p"/conversations/#{c}/hide", data: [method: "post"], data: [confirm: "Are you really, really sure?"] .block__header.block__header--light.page__header .page__pagination = pagination diff --git a/lib/philomena_web/templates/conversation/message/_form.html.slime b/lib/philomena_web/templates/conversation/message/_form.html.slime index 7234a3e7..cbaec375 100644 --- a/lib/philomena_web/templates/conversation/message/_form.html.slime +++ b/lib/philomena_web/templates/conversation/message/_form.html.slime @@ -1,4 +1,4 @@ -= form_for @changeset, Routes.conversation_message_path(@conn, :create, @conversation), fn f -> += form_for @changeset, ~p"/conversations/#{@conversation}/messages", fn f -> .block .communication-edit__wrap = render PhilomenaWeb.MarkdownView, "_input.html", conn: @conn, f: f, action_icon: "pencil-alt", action_text: "Reply" diff --git a/lib/philomena_web/templates/conversation/new.html.slime b/lib/philomena_web/templates/conversation/new.html.slime index 31207ac8..ef0f3758 100644 --- a/lib/philomena_web/templates/conversation/new.html.slime +++ b/lib/philomena_web/templates/conversation/new.html.slime @@ -1,7 +1,7 @@ h1 New Conversation .block .block__header - => link "Conversations", to: Routes.conversation_path(@conn, :index) + => link "Conversations", to: ~p"/conversations" ' » span New Conversation @@ -20,7 +20,7 @@ h1 New Conversation - _ -> / Nothing -= form_for @changeset, Routes.conversation_path(@conn, :create), fn f -> += form_for @changeset, ~p"/conversations", fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/conversation/show.html.slime b/lib/philomena_web/templates/conversation/show.html.slime index 537533c1..e62d6fc4 100644 --- a/lib/philomena_web/templates/conversation/show.html.slime +++ b/lib/philomena_web/templates/conversation/show.html.slime @@ -1,14 +1,14 @@ elixir: - route = fn p -> Routes.conversation_path(@conn, :show, @conversation, p) end + route = fn p -> ~p"/conversations/#{@conversation}?#{p}" end pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @messages, route: route, conn: @conn other = other_party(@current_user, @conversation) h1 = @conversation.title .block .block__header - => link "Message Center", to: Routes.conversation_path(@conn, :index) + => link "Message Center", to: ~p"/conversations" ' » - => link @conversation.title, to: Routes.conversation_path(@conn, :show, @conversation) + => link @conversation.title, to: ~p"/conversations/#{@conversation}" ' Conversation with => render PhilomenaWeb.UserAttributionView, "_user.html", object: %{user: other}, conn: @conn .block__header--sub.block__header--light.page__header @@ -18,11 +18,11 @@ h1 = @conversation.title .page__pagination = pagination .page__info = if hidden_by?(@current_user, @conversation) do - = link "Restore conversation", to: Routes.conversation_hide_path(@conn, :delete, @conversation), data: [method: "delete"] + = link "Restore conversation", to: ~p"/conversations/#{@conversation}/hide", data: [method: "delete"] - else - = link "Remove conversation", to: Routes.conversation_hide_path(@conn, :create, @conversation), data: [method: "post", confirm: "Are you really, really sure?"] - = link "Report conversation", to: Routes.conversation_report_path(@conn, :new, @conversation) - = link "Mark as unread", to: Routes.conversation_read_path(@conn, :delete, @conversation), data: [method: "delete"] + = link "Remove conversation", to: ~p"/conversations/#{@conversation}/hide", data: [method: "post", confirm: "Are you really, really sure?"] + = link "Report conversation", to: ~p"/conversations/#{@conversation}/reports/new" + = link "Mark as unread", to: ~p"/conversations/#{@conversation}/read", data: [method: "delete"] = for {message, body} <- @messages do = render PhilomenaWeb.MessageView, "_message.html", message: message, body: body, conn: @conn @@ -59,5 +59,5 @@ h1 = @conversation.title p You've managed to send over 1,000 messages in this conversation! p We'd like to ask you to make a new conversation. Don't worry, this one won't go anywhere if you need to refer back to it. p - => link "Click here", to: Routes.conversation_path(@conn, :new, receipient: other.name) + => link "Click here", to: ~p"/conversations/new?#{[receipient: other.name]}" ' to make a new conversation with this user. diff --git a/lib/philomena_web/templates/dnp_entry/edit.html.slime b/lib/philomena_web/templates/dnp_entry/edit.html.slime index 2761b395..969f4ffd 100644 --- a/lib/philomena_web/templates/dnp_entry/edit.html.slime +++ b/lib/philomena_web/templates/dnp_entry/edit.html.slime @@ -1,2 +1,2 @@ h2 Edit DNP Request -= render PhilomenaWeb.DnpEntryView, "_form.html", changeset: @changeset, action: Routes.dnp_entry_path(@conn, :update, @dnp_entry, tag_id: @dnp_entry.tag_id), conn: @conn, selectable_tags: @selectable_tags += render PhilomenaWeb.DnpEntryView, "_form.html", changeset: @changeset, action: ~p"/dnp/#{@dnp_entry}?#{[tag_id: @dnp_entry.tag_id]}", conn: @conn, selectable_tags: @selectable_tags diff --git a/lib/philomena_web/templates/dnp_entry/index.html.slime b/lib/philomena_web/templates/dnp_entry/index.html.slime index 63415038..3a51abce 100644 --- a/lib/philomena_web/templates/dnp_entry/index.html.slime +++ b/lib/philomena_web/templates/dnp_entry/index.html.slime @@ -16,13 +16,13 @@ br .block__content = cond do - not is_nil(@current_user) and Enum.any?(@linked_tags) -> - = link "Create an entry", to: Routes.dnp_entry_path(@conn, :new) + = link "Create an entry", to: ~p"/dnp/new" br - = link "My Listings", to: Routes.dnp_entry_path(@conn, :index, mine: "1") + = link "My Listings", to: ~p"/dnp?#{[mine: "1"]}" - not is_nil(@current_user) -> ' You must have a verified artist link to create and manage DNP entries. - = link "Request an artist link", to: Routes.profile_artist_link_path(@conn, :new, @current_user) + = link "Request an artist link", to: ~p"/profiles/#{@current_user}/artist_links/new" | . - true -> @@ -31,7 +31,7 @@ br h3 The List .block - - route = fn p -> Routes.dnp_entry_path(@conn, :index, p) end + - route = fn p -> ~p"/dnp?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @dnp_entries, route: route, conn: @conn .block__header.page__header @@ -69,7 +69,7 @@ h3 The List = pretty_time(entry.created_at) td - = link "More Info", to: Routes.dnp_entry_path(@conn, :show, entry) + = link "More Info", to: ~p"/dnp/#{entry}" .block__header.page__header .page__pagination = pagination diff --git a/lib/philomena_web/templates/dnp_entry/new.html.slime b/lib/philomena_web/templates/dnp_entry/new.html.slime index 95c822d2..1bb616f8 100644 --- a/lib/philomena_web/templates/dnp_entry/new.html.slime +++ b/lib/philomena_web/templates/dnp_entry/new.html.slime @@ -1,2 +1,2 @@ h2 New DNP Request -= render PhilomenaWeb.DnpEntryView, "_form.html", changeset: @changeset, action: Routes.dnp_entry_path(@conn, :create, tag_id: @conn.params["tag_id"]), conn: @conn, selectable_tags: @selectable_tags += render PhilomenaWeb.DnpEntryView, "_form.html", changeset: @changeset, action: ~p"/dnp?#{[tag_id: @conn.params["tag_id"]]}", conn: @conn, selectable_tags: @selectable_tags diff --git a/lib/philomena_web/templates/dnp_entry/show.html.slime b/lib/philomena_web/templates/dnp_entry/show.html.slime index a7342f4d..34184dd1 100644 --- a/lib/philomena_web/templates/dnp_entry/show.html.slime +++ b/lib/philomena_web/templates/dnp_entry/show.html.slime @@ -6,9 +6,9 @@ h2 .block__header span DNP Information = if can?(@conn, :edit, @dnp_entry) do - = link "Edit listing", to: Routes.dnp_entry_path(@conn, :edit, @dnp_entry, tag_id: @dnp_entry.tag_id) + = link "Edit listing", to: ~p"/dnp/#{@dnp_entry}/edit?#{[tag_id: @dnp_entry.tag_id]}" - = link "Back to DNP List", to: Routes.dnp_entry_path(@conn, :index) + = link "Back to DNP List", to: ~p"/dnp" .block__content table.table @@ -53,26 +53,26 @@ h2 = if can?(@conn, :index, Philomena.DnpEntries.DnpEntry) do = case @dnp_entry.aasm_state do - s when s in ["requested", "claimed"] -> - => link "Claim", to: Routes.admin_dnp_entry_transition_path(@conn, :create, @dnp_entry, state: "claimed"), data: [method: "post", confirm: "Are you really, really sure?"] + => link "Claim", to: ~p"/admin/dnp_entries/#{@dnp_entry}/transition?#{[state: "claimed"]}", data: [method: "post", confirm: "Are you really, really sure?"] ' • - => link "Approve", to: Routes.admin_dnp_entry_transition_path(@conn, :create, @dnp_entry, state: "listed"), data: [method: "post", confirm: "Are you really, really sure?"] + => link "Approve", to: ~p"/admin/dnp_entries/#{@dnp_entry}/transition?#{[state: "listed"]}", data: [method: "post", confirm: "Are you really, really sure?"] ' • - => link "Close", to: Routes.admin_dnp_entry_transition_path(@conn, :create, @dnp_entry, state: "closed"), data: [method: "post", confirm: "Are you really, really sure?"] + => link "Close", to: ~p"/admin/dnp_entries/#{@dnp_entry}/transition?#{[state: "closed"]}", data: [method: "post", confirm: "Are you really, really sure?"] - "listed" -> - => link "Rescind", to: Routes.admin_dnp_entry_transition_path(@conn, :create, @dnp_entry, state: "rescinded"), data: [method: "post", confirm: "Are you really, really sure?"] + => link "Rescind", to: ~p"/admin/dnp_entries/#{@dnp_entry}/transition?#{[state: "rescinded"]}", data: [method: "post", confirm: "Are you really, really sure?"] ' • - = link "Close", to: Routes.admin_dnp_entry_transition_path(@conn, :create, @dnp_entry, state: "closed"), data: [method: "post", confirm: "Are you really, really sure?"] + = link "Close", to: ~p"/admin/dnp_entries/#{@dnp_entry}/transition?#{[state: "closed"]}", data: [method: "post", confirm: "Are you really, really sure?"] - s when s in ["rescinded", "acknowledged"] -> - => link "Claim", to: Routes.admin_dnp_entry_transition_path(@conn, :create, @dnp_entry, state: "acknowledged"), data: [method: "post", confirm: "Are you really, really sure?"] + => link "Claim", to: ~p"/admin/dnp_entries/#{@dnp_entry}/transition?#{[state: "acknowledged"]}", data: [method: "post", confirm: "Are you really, really sure?"] ' • - = link "Close", to: Routes.admin_dnp_entry_transition_path(@conn, :create, @dnp_entry, state: "closed"), data: [method: "post", confirm: "Are you really, really sure?"] + = link "Close", to: ~p"/admin/dnp_entries/#{@dnp_entry}/transition?#{[state: "closed"]}", data: [method: "post", confirm: "Are you really, really sure?"] - _state -> - => link "Claim", to: Routes.admin_dnp_entry_transition_path(@conn, :create, @dnp_entry, state: "claimed"), data: [method: "post", confirm: "Are you really, really sure?"] + => link "Claim", to: ~p"/admin/dnp_entries/#{@dnp_entry}/transition?#{[state: "claimed"]}", data: [method: "post", confirm: "Are you really, really sure?"] = if assigns[:mod_notes] do h4 Mod Notes = render PhilomenaWeb.Admin.ModNoteView, "_table.html", mod_notes: @mod_notes, conn: @conn - = link "Add New Note", to: Routes.admin_mod_note_path(@conn, :new, notable_id: @dnp_entry.id, notable_type: "DnpEntry") + = link "Add New Note", to: ~p"/admin/mod_notes/new?#{[notable_id: @dnp_entry.id, notable_type: "DnpEntry"]}" diff --git a/lib/philomena_web/templates/duplicate_report/_form.html.slime b/lib/philomena_web/templates/duplicate_report/_form.html.slime index 128de57b..19d1ec64 100644 --- a/lib/philomena_web/templates/duplicate_report/_form.html.slime +++ b/lib/philomena_web/templates/duplicate_report/_form.html.slime @@ -1,4 +1,4 @@ -= form_for @changeset, Routes.duplicate_report_path(@conn, :create), fn f -> += form_for @changeset, ~p"/duplicate_reports", fn f -> = hidden_input f, :image_id, value: @image.id .field ' Delete this image and redirect to diff --git a/lib/philomena_web/templates/duplicate_report/_image_cell.html.slime b/lib/philomena_web/templates/duplicate_report/_image_cell.html.slime index 1e262a35..9e52462c 100644 --- a/lib/philomena_web/templates/duplicate_report/_image_cell.html.slime +++ b/lib/philomena_web/templates/duplicate_report/_image_cell.html.slime @@ -18,12 +18,12 @@ = if can?(@conn, :edit, @report) and mergeable?(@report) do = if @source do - a href=Routes.duplicate_report_accept_reverse_path(@conn, :create, @report) data-method="post" + a href=~p"/duplicate_reports/#{@report}/accept_reverse" data-method="post" button.button ' Keep Source i.fa.fa-arrow-left - else - a href=Routes.duplicate_report_accept_path(@conn, :create, @report) data-method="post" + a href=~p"/duplicate_reports/#{@report}/accept" data-method="post" button.button i.fa.fa-arrow-right> | Keep Target diff --git a/lib/philomena_web/templates/duplicate_report/_list.html.slime b/lib/philomena_web/templates/duplicate_report/_list.html.slime index 87de9fc0..bb18bb50 100644 --- a/lib/philomena_web/templates/duplicate_report/_list.html.slime +++ b/lib/philomena_web/templates/duplicate_report/_list.html.slime @@ -15,7 +15,7 @@ tr = if same_aspect_ratio?(report) do td.success - a href=Routes.duplicate_report_path(@conn, :show, report) + a href=~p"/duplicate_reports/#{report}" ' Visual diff | (Same aspect ratio) @@ -139,13 +139,13 @@ = if can?(@conn, :edit, report) do div = if report.state == "open" do - a href=(Routes.duplicate_report_claim_path(@conn, :create, report) <> "#report_options_#{report.id}") data-method="post" + a href=(~p"/duplicate_reports/#{report}/claim" <> "#report_options_#{report.id}") data-method="post" button.button.button--separate-right i.fa.fa-clipboard> ' Claim = if report.state != "rejected" do - a href=Routes.duplicate_report_reject_path(@conn, :create, report) data-method="post" + a href=~p"/duplicate_reports/#{report}/reject" data-method="post" button.button i.fa.fa-times> ' Reject @@ -157,6 +157,6 @@ = if report.user do ' by - =< link report.user.name, to: Routes.profile_path(@conn, :show, report.user) + =< link report.user.name, to: ~p"/profiles/#{report.user}" = escape_nl2br(report.reason) diff --git a/lib/philomena_web/templates/duplicate_report/index.html.slime b/lib/philomena_web/templates/duplicate_report/index.html.slime index 0837f277..a76e986a 100644 --- a/lib/philomena_web/templates/duplicate_report/index.html.slime +++ b/lib/philomena_web/templates/duplicate_report/index.html.slime @@ -1,6 +1,6 @@ h1 Duplicate Reports -- route = fn p -> Routes.duplicate_report_path(@conn, :index, p) end +- route = fn p -> ~p"/duplicate_reports?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @duplicate_reports, route: route, conn: @conn, params: [states: @conn.params["states"] || ["open", "claimed"]] .block @@ -8,14 +8,14 @@ h1 Duplicate Reports .page__pagination = pagination .page__info span Display only: - => link "Open (All)", to: Routes.duplicate_report_path(@conn, :index, states: ~W(open claimed)) - => link "Open (Unclaimed)", to: Routes.duplicate_report_path(@conn, :index, states: ~W(open)) - => link "Open (Claimed)", to: Routes.duplicate_report_path(@conn, :index, states: ~W(claimed)) - => link "Open + Rejected", to: Routes.duplicate_report_path(@conn, :index, states: ~W(open rejected)) - => link "Rejected", to: Routes.duplicate_report_path(@conn, :index, states: ~W(rejected)) - => link "Rejected + Accepted", to: Routes.duplicate_report_path(@conn, :index, states: ~W(rejected accepted)) - => link "Accepted", to: Routes.duplicate_report_path(@conn, :index, states: ~W(accepted)) - = link "All", to: Routes.duplicate_report_path(@conn, :index, states: ~W(open rejected accepted claimed)) + => link "Open (All)", to: ~p"/duplicate_reports?#{[states: ~W(open claimed)]}" + => link "Open (Unclaimed)", to: ~p"/duplicate_reports?#{[states: ~W(open)]}" + => link "Open (Claimed)", to: ~p"/duplicate_reports?#{[states: ~W(claimed)]}" + => link "Open + Rejected", to: ~p"/duplicate_reports?#{[states: ~W(open rejected)]}" + => link "Rejected", to: ~p"/duplicate_reports?#{[states: ~W(rejected)]}" + => link "Rejected + Accepted", to: ~p"/duplicate_reports?#{[states: ~W(rejected accepted)]}" + => link "Accepted", to: ~p"/duplicate_reports?#{[states: ~W(accepted)]}" + = link "All", to: ~p"/duplicate_reports?#{[states: ~W(open rejected accepted claimed)]}" = render PhilomenaWeb.DuplicateReportView, "_list.html", duplicate_reports: @duplicate_reports, conn: @conn diff --git a/lib/philomena_web/templates/filter/_filter.html.slime b/lib/philomena_web/templates/filter/_filter.html.slime index 859608f7..ab4e9260 100644 --- a/lib/philomena_web/templates/filter/_filter.html.slime +++ b/lib/philomena_web/templates/filter/_filter.html.slime @@ -20,20 +20,20 @@ = length(@filter.hidden_tag_ids) li - = link "View this filter", to: Routes.filter_path(@conn, :show, @filter), class: "button" + = link "View this filter", to: ~p"/filters/#{@filter}", class: "button" li - = link "Copy and Customize", to: Routes.filter_path(@conn, :new, based_on: @filter), class: "button" + = link "Copy and Customize", to: ~p"/filters/new?#{[based_on: @filter]}", class: "button" = if can?(@conn, :edit, @filter) do li - = link "Edit this filter", to: Routes.filter_path(@conn, :edit, @filter), class: "button" + = link "Edit this filter", to: ~p"/filters/#{@filter}/edit", class: "button" = if @filter.id == @conn.assigns.current_filter.id do li strong Your current filter - else li - = button_to "Use this filter", Routes.filter_current_path(@conn, :update, id: @filter), method: "put", class: "button" + = button_to "Use this filter", ~p"/filters/current?#{[id: @filter]}", method: "put", class: "button" p em = @filter.description diff --git a/lib/philomena_web/templates/filter/edit.html.slime b/lib/philomena_web/templates/filter/edit.html.slime index 4ec94253..db0bf5d6 100644 --- a/lib/philomena_web/templates/filter/edit.html.slime +++ b/lib/philomena_web/templates/filter/edit.html.slime @@ -1,5 +1,5 @@ h2 Editing Filter -= render PhilomenaWeb.FilterView, "_form.html", filter: @changeset, route: Routes.filter_path(@conn, :update, @filter) += render PhilomenaWeb.FilterView, "_form.html", filter: @changeset, route: ~p"/filters/#{@filter}" = if not @filter.public and not @filter.system do br @@ -19,4 +19,4 @@ h2 Editing Filter strong irreversible ' . Once you make a filter public, you cannot make it private again. - = button_to "Convert to Public Filter", Routes.filter_public_path(@conn, :create, @filter), class: "button", method: "create", data: [confirm: "Are you really, really sure?"] + = button_to "Convert to Public Filter", ~p"/filters/#{@filter}/public", class: "button", method: "create", data: [confirm: "Are you really, really sure?"] diff --git a/lib/philomena_web/templates/filter/index.html.slime b/lib/philomena_web/templates/filter/index.html.slime index 3056bd14..8b94a091 100644 --- a/lib/philomena_web/templates/filter/index.html.slime +++ b/lib/philomena_web/templates/filter/index.html.slime @@ -28,7 +28,7 @@ h2 My Filters = if @current_user do p - = link("Click here to make a new filter from scratch", to: Routes.filter_path(@conn, :new)) + = link("Click here to make a new filter from scratch", to: ~p"/filters/new") = for filter <- @my_filters do = render PhilomenaWeb.FilterView, "_filter.html", conn: @conn, filter: filter - else @@ -43,12 +43,12 @@ h2 Recent Filters p ' Clicking this button will clear the recent filters list in the header dropdown. - = button_to "Clear recent filter list", Routes.filter_clear_recent_path(@conn, :delete), method: "delete", class: "button" + = button_to "Clear recent filter list", ~p"/filters/clear_recent", method: "delete", class: "button" h2 Search Filters p ' Some users maintain custom filters which are publicly shared; you can search these filters with the box below. - = form_for :filters, Routes.filter_path(@conn, :index), [method: "get", class: "hform", enforce_utf8: false], fn f -> + = form_for :filters, ~p"/filters", [method: "get", class: "hform", enforce_utf8: false], fn f -> .field = text_input f, :fq, name: :fq, value: @conn.params["fq"], class: "input hform__text", placeholder: "Search filters", autocapitalize: "none" = submit "Search", class: "hform__button button" @@ -62,7 +62,7 @@ h2 Search Results = cond do - Enum.any?(@filters) -> - - route = fn p -> Routes.filter_path(@conn, :index, p) end + - route = fn p -> ~p"/filters?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @filters, route: route, params: [fq: @conn.params["fq"]], conn: @conn = for filter <- @filters do @@ -99,49 +99,49 @@ table.table td Literal td Matches the creator of this filter. td - code = link "creator:AppleDash", to: Routes.filter_path(@conn, :index, fq: "creator:AppleDash") + code = link "creator:AppleDash", to: ~p"/filters?#{[fq: "creator:AppleDash"]}" tr td code name td Literal td Matches the name of this filter. This is the default field. td - code = link "name:default", to: Routes.filter_path(@conn, :index, fq: "name:default") + code = link "name:default", to: ~p"/filters?#{[fq: "name:default"]}" tr td code description td Full Text td Matches the description of this filter. td - code = link "description:the show's rating", to: Routes.filter_path(@conn, :index, fq: "description:the show's rating") + code = link "description:the show's rating", to: ~p"/filters?#{[fq: "description:the show's rating"]}" tr td code created_at td Date/Time Range td Matches the creation time of this filter. td - code = link "created_at:2015", to: Routes.filter_path(@conn, :index, fq: "created_at:2015") + code = link "created_at:2015", to: ~p"/filters?#{[fq: "created_at:2015"]}" tr td code id td Numeric Range td Matches the numeric surrogate key for this filter. td - code = link "id:1", to: Routes.filter_path(@conn, :index, fq: "id:1") + code = link "id:1", to: ~p"/filters?#{[fq: "id:1"]}" tr td code spoilered_count td Numeric Range td Matches the number of spoilered tags in this filter. td - code = link "spoilered_count:1", to: Routes.filter_path(@conn, :index, fq: "spoilered_count:1") + code = link "spoilered_count:1", to: ~p"/filters?#{[fq: "spoilered_count:1"]}" tr td code hidden_count td Numeric Range td Matches the number of hidden tags in this filter. td - code = link "hidden_count:1", to: Routes.filter_path(@conn, :index, fq: "hidden_count:1") + code = link "hidden_count:1", to: ~p"/filters?#{[fq: "hidden_count:1"]}" tr td code my @@ -150,14 +150,14 @@ table.table code> my:filters ' matches filters you have published if you are signed in. td - code = link "my:filters", to: Routes.filter_path(@conn, :index, fq: "my:filters") + code = link "my:filters", to: ~p"/filters?#{[fq: "my:filters"]}" tr td code system td Boolean td Matches system filters td - code = link "system:true", to: Routes.filter_path(@conn, :index, fq: "system:true") + code = link "system:true", to: ~p"/filters?#{[fq: "system:true"]}" tr td code public @@ -167,14 +167,14 @@ table.table code> public:false ' matches only your own private filters. td - code = link "public:false", to: Routes.filter_path(@conn, :index, fq: "public:false") + code = link "public:false", to: ~p"/filters?#{[fq: "public:false"]}" tr td code user_id td Literal td Matches filters with the specified user_id. td - code = link "user_id:307505", to: Routes.filter_path(@conn, :index, fq: "user_id:307505") + code = link "user_id:307505", to: ~p"/filters?#{[fq: "user_id:307505"]}" = if @conn.params["fq"] do - p = link("Back to filters", to: Routes.filter_path(@conn, :index)) + p = link("Back to filters", to: ~p"/filters") diff --git a/lib/philomena_web/templates/filter/new.html.slime b/lib/philomena_web/templates/filter/new.html.slime index de881073..26dc5513 100644 --- a/lib/philomena_web/templates/filter/new.html.slime +++ b/lib/philomena_web/templates/filter/new.html.slime @@ -1,2 +1,2 @@ h2 Creating New Filter -= render PhilomenaWeb.FilterView, "_form.html", filter: @changeset, route: Routes.filter_path(@conn, :create) \ No newline at end of file += render PhilomenaWeb.FilterView, "_form.html", filter: @changeset, route: ~p"/filters" \ No newline at end of file diff --git a/lib/philomena_web/templates/filter/show.html.slime b/lib/philomena_web/templates/filter/show.html.slime index 15608482..6e1221f3 100644 --- a/lib/philomena_web/templates/filter/show.html.slime +++ b/lib/philomena_web/templates/filter/show.html.slime @@ -18,14 +18,14 @@ h1 strong Your current filter - else li - = button_to "Use this filter", Routes.filter_current_path(@conn, :update, id: @filter), method: "put", class: "button" + = button_to "Use this filter", ~p"/filters/current?#{[id: @filter]}", method: "put", class: "button" = if can?(@conn, :edit, @filter) do li - = link "Edit this filter", to: Routes.filter_path(@conn, :edit, @filter), class: "button" + = link "Edit this filter", to: ~p"/filters/#{@filter}/edit", class: "button" = if can?(@conn, :delete, @filter) do - = button_to "Destroy this filter", Routes.filter_path(@conn, :delete, @filter), method: "delete", class: "button", data: [confirm: "Are you really, really sure?"] + = button_to "Destroy this filter", ~p"/filters/#{@filter}", method: "delete", class: "button", data: [confirm: "Are you really, really sure?"] = if @filter.user do p.filter-maintainer @@ -61,4 +61,4 @@ h1 /p = link("Report filter to moderators", new_report_path(reportable_class: 'filter', reportable_id: @filter.id) -p = link("Back to filters", to: Routes.filter_path(@conn, :index)) +p = link("Back to filters", to: ~p"/filters") diff --git a/lib/philomena_web/templates/fingerprint_profile/show.html.slime b/lib/philomena_web/templates/fingerprint_profile/show.html.slime index dae6b6a2..cfb36e1e 100644 --- a/lib/philomena_web/templates/fingerprint_profile/show.html.slime +++ b/lib/philomena_web/templates/fingerprint_profile/show.html.slime @@ -3,24 +3,24 @@ h1 ' 's fingerprint profile ul - li = link "View images this fingerprint has uploaded", to: Routes.search_path(@conn, :index, q: "fingerprint:#{@fingerprint}") - li = link "View comments this fingerprint has posted", to: Routes.comment_path(@conn, :index, cq: "fingerprint:#{@fingerprint}") - li = link "View posts this fingerprint has made", to: Routes.post_path(@conn, :index, pq: "fingerprint:#{@fingerprint}") + li = link "View images this fingerprint has uploaded", to: ~p"/search?#{[q: "fingerprint:#{@fingerprint}"]}" + li = link "View comments this fingerprint has posted", to: ~p"/comments?#{[cq: "fingerprint:#{@fingerprint}"]}" + li = link "View posts this fingerprint has made", to: ~p"/posts?#{[pq: "fingerprint:#{@fingerprint}"]}" = render PhilomenaWeb.BanView, "_bans.html", bans: @fingerprint_bans, conn: @conn h2 Administration Options ul - li = link "View tag changes", to: Routes.fingerprint_profile_tag_change_path(@conn, :index, @fingerprint) - li = link "View source URL history", to: Routes.fingerprint_profile_source_change_path(@conn, :index, @fingerprint) - li = link "View reports this fingerprint has made", to: Routes.admin_report_path(@conn, :index, rq: "fingerprint:#{@fingerprint}") - li = link "View fingerprint ban history", to: Routes.admin_fingerprint_ban_path(@conn, :index, fingerprint: @fingerprint) - li = link "Ban this sucker", to: Routes.admin_fingerprint_ban_path(@conn, :new, fingerprint: @fingerprint) + li = link "View tag changes", to: ~p"/fingerprint_profiles/#{@fingerprint}/tag_changes" + li = link "View source URL history", to: ~p"/fingerprint_profiles/#{@fingerprint}/source_changes" + li = link "View reports this fingerprint has made", to: ~p"/admin/reports?#{[rq: "fingerprint:#{@fingerprint}"]}" + li = link "View fingerprint ban history", to: ~p"/admin/fingerprint_bans?#{[fingerprint: @fingerprint]}" + li = link "Ban this sucker", to: ~p"/admin/fingerprint_bans/new?#{[fingerprint: @fingerprint]}" h2 Actions ul - li = link "Revert all tag changes", to: Routes.tag_change_full_revert_path(@conn, :create, [fingerprint: @fingerprint]), data: [confirm: "Are you really, really sure?", method: "create"] - li = link "...the button above didn't work (use carefully, this is resource-intensive)", to: Routes.tag_change_full_revert_path(@conn, :create, [fingerprint: @fingerprint, batch_size: 1]), data: [confirm: "Please confirm that you're aware that this may crash the site and are ready to take on the full wrath of the admins if it does so after you press this button.", method: "create"] + li = link "Revert all tag changes", to: ~p"/tag_changes/full_revert?#{[fingerprint: @fingerprint]}", data: [confirm: "Are you really, really sure?", method: "create"] + li = link "...the button above didn't work (use carefully, this is resource-intensive)", to: ~p"/tag_changes/full_revert?#{[fingerprint: @fingerprint, batch_size: 1]}", data: [confirm: "Please confirm that you're aware that this may crash the site and are ready to take on the full wrath of the admins if it does so after you press this button.", method: "create"] h4 Observed users table.table @@ -34,7 +34,7 @@ table.table = for ufp <- @user_fps do tr td - = link ufp.user.name, to: Routes.profile_path(@conn, :show, ufp.user) + = link ufp.user.name, to: ~p"/profiles/#{ufp.user}" td => ufp.uses ' times diff --git a/lib/philomena_web/templates/fingerprint_profile/source_change/index.html.slime b/lib/philomena_web/templates/fingerprint_profile/source_change/index.html.slime index d1dd1440..0c92e88d 100644 --- a/lib/philomena_web/templates/fingerprint_profile/source_change/index.html.slime +++ b/lib/philomena_web/templates/fingerprint_profile/source_change/index.html.slime @@ -2,7 +2,7 @@ h1 ' Source changes by = @fingerprint -- route = fn p -> Routes.fingerprint_profile_source_change_path(@conn, :index, @fingerprint, p) end +- route = fn p -> ~p"/fingerprint_profiles/#{@fingerprint}/source_changes?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @source_changes, route: route, conn: @conn = render PhilomenaWeb.SourceChangeView, "index.html", conn: @conn, source_changes: @source_changes, pagination: pagination diff --git a/lib/philomena_web/templates/fingerprint_profile/tag_change/index.html.slime b/lib/philomena_web/templates/fingerprint_profile/tag_change/index.html.slime index 5beca37d..492f95ee 100644 --- a/lib/philomena_web/templates/fingerprint_profile/tag_change/index.html.slime +++ b/lib/philomena_web/templates/fingerprint_profile/tag_change/index.html.slime @@ -2,7 +2,7 @@ h1 ' Tag changes by = @fingerprint -- route = fn p -> Routes.fingerprint_profile_tag_change_path(@conn, :index, @fingerprint, p) end +- route = fn p -> ~p"/fingerprint_profiles/#{@fingerprint}/tag_changes?#{p}" end - params = if @conn.params["added"], do: [added: @conn.params["added"]] - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @tag_changes, route: route, conn: @conn, params: params @@ -11,8 +11,8 @@ h1 span | Display only: - = link "Removed", to: Routes.fingerprint_profile_tag_change_path(@conn, :index, @fingerprint, added: 0) - = link "Added", to: Routes.fingerprint_profile_tag_change_path(@conn, :index, @fingerprint, added: 1) - = link "All", to: Routes.fingerprint_profile_tag_change_path(@conn, :index, @fingerprint) + = link "Removed", to: ~p"/fingerprint_profiles/#{@fingerprint}/tag_changes?#{[added: 0]}" + = link "Added", to: ~p"/fingerprint_profiles/#{@fingerprint}/tag_changes?#{[added: 1]}" + = link "All", to: ~p"/fingerprint_profiles/#{@fingerprint}/tag_changes" = render PhilomenaWeb.TagChangeView, "index.html", conn: @conn, tag_changes: @tag_changes, pagination: pagination diff --git a/lib/philomena_web/templates/forum/index.html.slime b/lib/philomena_web/templates/forum/index.html.slime index 5d203504..df328dee 100644 --- a/lib/philomena_web/templates/forum/index.html.slime +++ b/lib/philomena_web/templates/forum/index.html.slime @@ -1,7 +1,7 @@ h1 Discussion Forums .block .block__header - a href=Routes.post_path(@conn, :index) + a href=~p"/posts" i.fa.icon--padded.small.fa-search> ' Search Posts span.block__header__item @@ -19,16 +19,16 @@ h1 Discussion Forums = for forum <- @forums do tr td.table--communication-list__name - => link(forum.name, to: Routes.forum_path(@conn, :show, forum)) + => link(forum.name, to: ~p"/forums/#{forum}") .small-text = forum.description td.table--communication-list__stats.hidden--mobile = forum.topic_count td.table--communication-list__stats.hidden--mobile = forum.post_count td.table--communication-list__last-post = if forum.last_post do strong - => link(forum.last_post.topic.title, to: Routes.forum_topic_path(@conn, :show, forum.last_post.topic.forum, forum.last_post.topic)) + => link(forum.last_post.topic.title, to: ~p"/forums/#{forum.last_post.topic.forum}/topics/#{forum.last_post.topic}") br - => link("Go to post", to: Routes.forum_topic_path(@conn, :show, forum.last_post.topic.forum, forum.last_post.topic, post_id: forum.last_post.id) <> "#post_#{forum.last_post.id}") + => link("Go to post", to: ~p"/forums/#{forum.last_post.topic.forum}/topics/#{forum.last_post.topic}?#{[post_id: forum.last_post.id]}" <> "#post_#{forum.last_post.id}") ' by => render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: forum.last_post, conn: @conn br diff --git a/lib/philomena_web/templates/forum/show.html.slime b/lib/philomena_web/templates/forum/show.html.slime index 1182e702..c7f7b089 100644 --- a/lib/philomena_web/templates/forum/show.html.slime +++ b/lib/philomena_web/templates/forum/show.html.slime @@ -1,16 +1,16 @@ -- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @topics, route: fn p -> Routes.forum_path(@conn, :show, @forum, p) end +- pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @topics, route: fn p -> ~p"/forums/#{@forum}?#{p}" end h1 = @forum.name .block .block__header - => link("Forums", to: Routes.forum_path(@conn, :index)) + => link("Forums", to: ~p"/forums") ' » - => link(@forum.name, to: Routes.forum_path(@conn, :show, @forum)) - a href=Routes.forum_topic_path(@conn, :new, @forum) + => link(@forum.name, to: ~p"/forums/#{@forum}") + a href=~p"/forums/#{@forum}/topics/new" i.fa.icon--padded.small.fa-edit> ' New Topic - a href=Routes.post_path(@conn, :index, pq: "forum:#{@forum.short_name}") + a href=~p"/posts?#{[pq: "forum:#{@forum.short_name}"]}" i.fa.icon--padded.small.fa-search> ' Search Posts span.spacing--left @@ -38,7 +38,7 @@ h1 = @forum.name i.fa.fa-lock = if topic.poll do i.fas.fa-poll-h - =< link(topic.title, to: Routes.forum_topic_path(@conn, :show, @forum, topic)) + =< link(topic.title, to: ~p"/forums/#{@forum}/topics/#{topic}") .small-text ' Posted => pretty_time(topic.created_at) @@ -47,7 +47,7 @@ h1 = @forum.name td.table--communication-list__stats.hidden--mobile = topic.post_count td.table--communication-list__last-post = if topic.last_post do - => link("Go to post", to: Routes.forum_topic_path(@conn, :show, topic.forum, topic, post_id: topic.last_post) <> "#post_#{topic.last_post.id}") + => link("Go to post", to: ~p"/forums/#{topic.forum}/topics/#{topic}?#{[post_id: topic.last_post]}" <> "#post_#{topic.last_post.id}") ' by = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: topic.last_post, conn: @conn br diff --git a/lib/philomena_web/templates/forum/subscription/_subscription.html.slime b/lib/philomena_web/templates/forum/subscription/_subscription.html.slime index b9e4876a..53fd9b61 100644 --- a/lib/philomena_web/templates/forum/subscription/_subscription.html.slime +++ b/lib/philomena_web/templates/forum/subscription/_subscription.html.slime @@ -1,8 +1,8 @@ elixir: - watch_path = Routes.forum_subscription_path(@conn, :create, @forum) + watch_path = ~p"/forums/#{@forum}/subscription" watch_class = if @watching, do: "hidden", else: "" - unwatch_path = Routes.forum_subscription_path(@conn, :delete, @forum) + unwatch_path = ~p"/forums/#{@forum}/subscription" unwatch_class = if @watching, do: "", else: "hidden" = if @conn.assigns.current_user do @@ -17,7 +17,7 @@ elixir: span.hidden--mobile ' Unsubscribe - else - a href=Routes.session_path(@conn, :new) + a href=~p"/sessions/new" i.fa.fa-bell> span.hidden--mobile ' Subscribe diff --git a/lib/philomena_web/templates/gallery/_gallery.html.slime b/lib/philomena_web/templates/gallery/_gallery.html.slime index d7c18a80..60ae2d56 100644 --- a/lib/philomena_web/templates/gallery/_gallery.html.slime +++ b/lib/philomena_web/templates/gallery/_gallery.html.slime @@ -1,4 +1,4 @@ -- link = Routes.gallery_path(@conn, :show, @gallery) +- link = ~p"/galleries/#{@gallery}" .media-box a.media-box__header.media-box__header--link href=link title=@gallery.title diff --git a/lib/philomena_web/templates/gallery/edit.html.slime b/lib/philomena_web/templates/gallery/edit.html.slime index fe0fc4af..80687435 100644 --- a/lib/philomena_web/templates/gallery/edit.html.slime +++ b/lib/philomena_web/templates/gallery/edit.html.slime @@ -1,3 +1,3 @@ h1 Editing Gallery -= render PhilomenaWeb.GalleryView, "_form.html", conn: @conn, changeset: @changeset, action: Routes.gallery_path(@conn, :update, @gallery) \ No newline at end of file += render PhilomenaWeb.GalleryView, "_form.html", conn: @conn, changeset: @changeset, action: ~p"/galleries/#{@gallery}" \ No newline at end of file diff --git a/lib/philomena_web/templates/gallery/index.html.slime b/lib/philomena_web/templates/gallery/index.html.slime index 4c34cddb..3f3c143a 100644 --- a/lib/philomena_web/templates/gallery/index.html.slime +++ b/lib/philomena_web/templates/gallery/index.html.slime @@ -1,5 +1,5 @@ elixir: - route = fn p -> Routes.gallery_path(@conn, :index, p) end + route = fn p -> ~p"/galleries?#{p}" end pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @galleries, route: route, params: [gallery: @conn.params["gallery"]] .column-layout @@ -8,7 +8,7 @@ elixir: .block__content h3 Search Galleries - = form_for @conn, Routes.gallery_path(@conn, :index), [as: :gallery, method: "get", class: "hform"], fn f -> + = form_for @conn, ~p"/galleries", [as: :gallery, method: "get", class: "hform"], fn f -> .field = label f, :title, "Title" .field = text_input f, :title, class: "input hform__text", placeholder: "Gallery title (* as wildcard)" diff --git a/lib/philomena_web/templates/gallery/new.html.slime b/lib/philomena_web/templates/gallery/new.html.slime index 7a555f67..3aa4a7f3 100644 --- a/lib/philomena_web/templates/gallery/new.html.slime +++ b/lib/philomena_web/templates/gallery/new.html.slime @@ -1,3 +1,3 @@ h1 Create a Gallery -= render PhilomenaWeb.GalleryView, "_form.html", conn: @conn, changeset: @changeset, action: Routes.gallery_path(@conn, :create) \ No newline at end of file += render PhilomenaWeb.GalleryView, "_form.html", conn: @conn, changeset: @changeset, action: ~p"/galleries" \ No newline at end of file diff --git a/lib/philomena_web/templates/gallery/show.html.slime b/lib/philomena_web/templates/gallery/show.html.slime index e7d9b852..f9df18a2 100644 --- a/lib/philomena_web/templates/gallery/show.html.slime +++ b/lib/philomena_web/templates/gallery/show.html.slime @@ -1,7 +1,7 @@ elixir: scope = scope(@conn) - image_url = fn image, hit -> Routes.image_path(@conn, :show, image, Keyword.put(scope, :sort, hit["sort"])) end - route = fn p -> Routes.gallery_path(@conn, :show, @gallery, p) end + image_url = fn image, hit -> ~p"/images/#{image}?#{Keyword.put(scope, :sort, hit["sort"])}" end + route = fn p -> ~p"/galleries/#{@gallery}?#{p}" end pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @images, route: route, params: scope info = render PhilomenaWeb.PaginationView, "_pagination_info.html", page: @images @@ -19,12 +19,12 @@ elixir: .flex__right.page__info = render PhilomenaWeb.ImageView, "_random_button.html", conn: @conn, params: scope - a href=Routes.gallery_report_path(@conn, :new, @gallery) + a href=~p"/galleries/#{@gallery}/reports/new" i.fa.fa-exclamation-triangle> span.hidden--mobile Report = if can?(@conn, :edit, @gallery) do - a href=Routes.gallery_path(@conn, :edit, @gallery) + a href=~p"/galleries/#{@gallery}/edit" i.fas.fa-edit> span.hidden--mobile Edit @@ -33,11 +33,11 @@ elixir: i.fa.fa-sort> ' Rearrange - a.rearrange-button.js-save.hidden href="#" data-click-hide=".js-save,#gallery-rearrange-info" data-click-show=".js-rearrange" data-reorder-path=Routes.gallery_order_path(@conn, :update, @gallery) + a.rearrange-button.js-save.hidden href="#" data-click-hide=".js-save,#gallery-rearrange-info" data-click-show=".js-rearrange" data-reorder-path=~p"/galleries/#{@gallery}/order" i.fa.fa-check> ' Save - a href=Routes.gallery_path(@conn, :delete, @gallery) data-method="delete" data-confirm="Are you really, really sure?" + a href=~p"/galleries/#{@gallery}" data-method="delete" data-confirm="Are you really, really sure?" i.fa.fa-trash> span.hidden--mobile Delete @@ -47,7 +47,7 @@ elixir: .block__header.block__header--light.block__header--sub span A gallery by - => link @gallery.creator.name, to: Routes.profile_path(@conn, :show, @gallery.creator) + => link @gallery.creator.name, to: ~p"/profiles/#{@gallery.creator}" ' with => @gallery.image_count = pluralize("image", "images", @gallery.image_count) diff --git a/lib/philomena_web/templates/gallery/subscription/_subscription.html.slime b/lib/philomena_web/templates/gallery/subscription/_subscription.html.slime index a6dec246..52fbe519 100644 --- a/lib/philomena_web/templates/gallery/subscription/_subscription.html.slime +++ b/lib/philomena_web/templates/gallery/subscription/_subscription.html.slime @@ -1,8 +1,8 @@ elixir: - watch_path = Routes.gallery_subscription_path(@conn, :create, @gallery) + watch_path = ~p"/galleries/#{@gallery}/subscription" watch_class = if @watching, do: "hidden", else: "" - unwatch_path = Routes.gallery_subscription_path(@conn, :delete, @gallery) + unwatch_path = ~p"/galleries/#{@gallery}/subscription" unwatch_class = if @watching, do: "", else: "hidden" = if @conn.assigns.current_user do @@ -17,7 +17,7 @@ elixir: span.hidden--mobile ' Unsubscribe - else - a href=Routes.session_path(@conn, :new) + a href=~p"/sessions/new" i.fa.fa-bell> span.hidden--mobile ' Subscribe diff --git a/lib/philomena_web/templates/image/_add_to_gallery_dropdown.html.slime b/lib/philomena_web/templates/image/_add_to_gallery_dropdown.html.slime index ce5a57d2..b5df278f 100644 --- a/lib/philomena_web/templates/image/_add_to_gallery_dropdown.html.slime +++ b/lib/philomena_web/templates/image/_add_to_gallery_dropdown.html.slime @@ -8,7 +8,7 @@ .block .block__content.add-to-gallery-list .block__list - a.block__list__link.primary href=Routes.gallery_path(@conn, :index, gallery: [include_image: @image.id]) + a.block__list__link.primary href=~p"/galleries?#{[gallery: [include_image: @image.id]]}" i.fa.fa-table> span.hidden--mobile Featured in @@ -18,24 +18,24 @@ = if present do / Options to remove li id="gallery_#{gallery.id}" - a.block__list__link.js-gallery-add.hidden data-fetchcomplete-hide="#gallery_#{gallery.id} .js-gallery-add" data-fetchcomplete-show="#gallery_#{gallery.id} .js-gallery-remove" data-method="post" data-remote="true" href=Routes.gallery_image_path(@conn, :create, gallery, image_id: @image.id) + a.block__list__link.js-gallery-add.hidden data-fetchcomplete-hide="#gallery_#{gallery.id} .js-gallery-add" data-fetchcomplete-show="#gallery_#{gallery.id} .js-gallery-remove" data-method="post" data-remote="true" href=~p"/galleries/#{gallery}/images?#{[image_id: @image.id]}" = gallery.title - a.block__list__link.active.js-gallery-remove data-fetchcomplete-hide="#gallery_#{gallery.id} .js-gallery-remove" data-fetchcomplete-show="#gallery_#{gallery.id} .js-gallery-add" data-method="delete" data-remote="true" href=Routes.gallery_image_path(@conn, :delete, gallery, image_id: @image.id) + a.block__list__link.active.js-gallery-remove data-fetchcomplete-hide="#gallery_#{gallery.id} .js-gallery-remove" data-fetchcomplete-show="#gallery_#{gallery.id} .js-gallery-add" data-method="delete" data-remote="true" href=~p"/galleries/#{gallery}/images?#{[image_id: @image.id]}" = gallery.title - else / Options to add li id="gallery_#{gallery.id}" - a.block__list__link.js-gallery-add data-fetchcomplete-hide="#gallery_#{gallery.id} .js-gallery-add" data-fetchcomplete-show="#gallery_#{gallery.id} .js-gallery-remove" data-method="post" data-remote="true" href=Routes.gallery_image_path(@conn, :create, gallery, image_id: @image.id) + a.block__list__link.js-gallery-add data-fetchcomplete-hide="#gallery_#{gallery.id} .js-gallery-add" data-fetchcomplete-show="#gallery_#{gallery.id} .js-gallery-remove" data-method="post" data-remote="true" href=~p"/galleries/#{gallery}/images?#{[image_id: @image.id]}" = gallery.title - a.block__list__link.active.js-gallery-remove.hidden data-fetchcomplete-hide="#gallery_#{gallery.id} .js-gallery-remove" data-fetchcomplete-show="#gallery_#{gallery.id} .js-gallery-add" data-method="delete" data-remote="true" href=Routes.gallery_image_path(@conn, :delete, gallery, image_id: @image.id) + a.block__list__link.active.js-gallery-remove.hidden data-fetchcomplete-hide="#gallery_#{gallery.id} .js-gallery-remove" data-fetchcomplete-show="#gallery_#{gallery.id} .js-gallery-add" data-method="delete" data-remote="true" href=~p"/galleries/#{gallery}/images?#{[image_id: @image.id]}" = gallery.title .block__list = if @conn.assigns.current_user do - a.block__list__link.primary href=Routes.gallery_path(@conn, :new, with_image: @image.id) + a.block__list__link.primary href=~p"/galleries/new?#{[with_image: @image.id]}" i.fa.fa-plus> span.hidden--mobile Create a gallery - else - a.block__list__link.primary href=Routes.session_path(@conn, :new) + a.block__list__link.primary href=~p"/sessions/new" i.fa.fa-user-plus> span.hidden--mobile Sign in to create a gallery diff --git a/lib/philomena_web/templates/image/_image_box.html.slime b/lib/philomena_web/templates/image/_image_box.html.slime index e456cd39..a6a44ce9 100644 --- a/lib/philomena_web/templates/image/_image_box.html.slime +++ b/lib/philomena_web/templates/image/_image_box.html.slime @@ -1,5 +1,5 @@ elixir: - link = assigns[:link] || Routes.image_path(@conn, :show, @image) + link = assigns[:link] || ~p"/images/#{@image}" size_class = case @size do :thumb -> diff --git a/lib/philomena_web/templates/image/_image_container.html.slime b/lib/philomena_web/templates/image/_image_container.html.slime index ee16d628..bae4fea7 100644 --- a/lib/philomena_web/templates/image/_image_container.html.slime +++ b/lib/philomena_web/templates/image/_image_container.html.slime @@ -1,4 +1,4 @@ -- link = assigns[:link] || Routes.image_path(@conn, :show, @image) +- link = assigns[:link] || ~p"/images/#{@image}" = image_container @conn, @image, @size, fn -> = cond do diff --git a/lib/philomena_web/templates/image/_image_meta.html.slime b/lib/philomena_web/templates/image/_image_meta.html.slime index 75af90f9..95e4ad99 100644 --- a/lib/philomena_web/templates/image/_image_meta.html.slime +++ b/lib/philomena_web/templates/image/_image_meta.html.slime @@ -1,13 +1,13 @@ .block.block__content .metabar.flex.flex--wrap.layout--centered id="image_meta_#{@image.id}" .metabar__navigation.hidden--phone - a.js-prev href=Routes.image_navigate_path(@conn, :index, @image, [rel: "prev"] ++ scope(@conn)) title="Previous Image (j)" + a.js-prev href=~p"/images/#{@image}/navigate?#{[rel: "prev"] ++ scope(@conn)}" title="Previous Image (j)" i.fa.fa-chevron-left - a.js-up href=Routes.image_navigate_path(@conn, :index, @image, [rel: "find"] ++ scope(@conn)) title="Find this image in the global image list (i)" + a.js-up href=~p"/images/#{@image}/navigate?#{[rel: "find"] ++ scope(@conn)}" title="Find this image in the global image list (i)" i.fa.fa-chevron-up - a.js-next href=Routes.image_navigate_path(@conn, :index, @image, [rel: "next"] ++ scope(@conn)) title="Next Image (k)" + a.js-next href=~p"/images/#{@image}/navigate?#{[rel: "next"] ++ scope(@conn)}" title="Next Image (k)" i.fa.fa-chevron-right - a.js-rand href=Routes.image_random_path(@conn, :index, scope(@conn)) title="Random (r)" + a.js-rand href=~p"/images/random?#{scope(@conn)}" title="Random (r)" i.fa.fa-random .metabar__interactions a.interaction--fave href="#" rel="nofollow" data-image-id=@image.id @@ -34,7 +34,7 @@ .metabar__interactions.hidden--mobile = render PhilomenaWeb.Image.SubscriptionView, "_subscription.html", watching: @watching, image: @image, conn: @conn = render PhilomenaWeb.ImageView, "_add_to_gallery_dropdown.html", image: @image, user_galleries: @user_galleries, conn: @conn - a href=Routes.image_related_path(@conn, :index, @image) title="Related Images" + a href=~p"/images/#{@image}/related" title="Related Images" i.fa.fa-sitemap> span.hidden--mobile Related .metabar__mobile-separator @@ -54,7 +54,7 @@ .metabar__interactions.hidden--desktop.hidden--tablet = render PhilomenaWeb.Image.SubscriptionView, "_subscription.html", watching: @watching, image: @image, conn: @conn = render PhilomenaWeb.ImageView, "_add_to_gallery_dropdown.html", image: @image, user_galleries: @user_galleries, conn: @conn - a href=Routes.image_related_path(@conn, :index, @image) title="Related Images" + a href=~p"/images/#{@image}/related" title="Related Images" i.fa.fa-sitemap a href="#{pretty_url(@image, true, false)}" rel="nofollow" title="View (no tags in filename)" i.fa.fa-eye diff --git a/lib/philomena_web/templates/image/_image_mobile_navigation.html.slime b/lib/philomena_web/templates/image/_image_mobile_navigation.html.slime index 5027c26d..5a776e04 100644 --- a/lib/philomena_web/templates/image/_image_mobile_navigation.html.slime +++ b/lib/philomena_web/templates/image/_image_mobile_navigation.html.slime @@ -1,10 +1,10 @@ .block.block__content.hidden--desktop.hidden--tablet .metabar__navigation - a.js-prev href=Routes.image_navigate_path(@conn, :index, @image, [rel: "prev"] ++ scope(@conn)) title="Previous Image (j)" + a.js-prev href=~p"/images/#{@image}/navigate?#{[rel: "prev"] ++ scope(@conn)}" title="Previous Image (j)" i.fa.fa-chevron-left - a.js-rand href=Routes.image_random_path(@conn, :index, scope(@conn)) title="Random (r)" + a.js-rand href=~p"/images/random?#{scope(@conn)}" title="Random (r)" i.fa.fa-random - a.js-up href=Routes.image_navigate_path(@conn, :index, @image, [rel: "find"] ++ scope(@conn)) title="Find this image in the global image list (i)" + a.js-up href=~p"/images/#{@image}/navigate?#{[rel: "find"] ++ scope(@conn)}" title="Find this image in the global image list (i)" i.fa.fa-chevron-up - a.js-next href=Routes.image_navigate_path(@conn, :index, @image, [rel: "next"] ++ scope(@conn)) title="Next Image (k)" + a.js-next href=~p"/images/#{@image}/navigate?#{[rel: "next"] ++ scope(@conn)}" title="Next Image (k)" i.fa.fa-chevron-right diff --git a/lib/philomena_web/templates/image/_image_target.html.slime b/lib/philomena_web/templates/image/_image_target.html.slime index 3443c74a..fba84b3a 100644 --- a/lib/philomena_web/templates/image/_image_target.html.slime +++ b/lib/philomena_web/templates/image/_image_target.html.slime @@ -8,7 +8,7 @@ p = img_tag(static_path(@conn, "/images/tagblocked.svg"), width: 250, height: 250, data: [click_unfilter: @image.id]) span.filter-explanation - =< link("your current filter", to: Routes.filter_path(@conn, :show, @conn.assigns.current_filter), class: "filter-link") + =< link("your current filter", to: ~p"/filters/#{@conn.assigns.current_filter}", class: "filter-link") ' . = if size == :full and not embed_display do @@ -19,7 +19,7 @@ picture - else .image-show.hidden - a href=Routes.image_path(@conn, :show, @image) title=title_text(@image) + a href=~p"/images/#{@image}" title=title_text(@image) span.imgspoiler - thumb_url = thumb_url(@image, can?(@conn, :show, @image), size) diff --git a/lib/philomena_web/templates/image/_options.html.slime b/lib/philomena_web/templates/image/_options.html.slime index c835e072..80b1143f 100644 --- a/lib/philomena_web/templates/image/_options.html.slime +++ b/lib/philomena_web/templates/image/_options.html.slime @@ -2,13 +2,13 @@ #image_options_area .block__header.block__header--js-tabbed - a.button.button--primary href="#" data-click-tab="reporting" data-load-tab=Routes.image_reporting_path(@conn, :show, @image) + a.button.button--primary href="#" data-click-tab="reporting" data-load-tab=~p"/images/#{@image}/reporting" i.fa.fa-exclamation-triangle> | Report a.button.button--primary href="#" data-click-tab="sharing" i.fa.fa-share> | Share - a.button.button--primary href="#" data-click-tab="favoriters" data-load-tab=Routes.image_favorite_path(@conn, :index, @image) + a.button.button--primary href="#" data-click-tab="favoriters" data-load-tab=~p"/images/#{@image}/favorites" i.fa.fa-star> span.hidden--phone | List favoriters @@ -60,7 +60,7 @@ | Copy br textarea.input.input--wide.input--separate-top#bbcode_embed_full_tag rows="2" cols="100" readonly="readonly" - = "[img]#{thumb_url(@image, false, :full)}[/img]\n[url=#{Routes.image_url(@conn, :show, @image)}]View on #{site_name()}[/url]#{source_link}" + = "[img]#{thumb_url(@image, false, :full)}[/img]\n[url=#{url(~p"/images/#{@image}")}]View on #{site_name()}[/url]#{source_link}" p strong> Thumbnailed BBcode a href="#" data-click-copy="#bbcode_embed_thumbnail_tag" @@ -68,11 +68,11 @@ | Copy br textarea.input.input--wide.input--separate-top#bbcode_embed_thumbnail_tag rows="2" cols="100" readonly="readonly" - = "[img]#{thumb_url(@image, false, :medium)}[/img]\n[url=#{Routes.image_url(@conn, :show, @image)}]View on #{site_name()}[/url]#{source_link}" + = "[img]#{thumb_url(@image, false, :medium)}[/img]\n[url=#{url(~p"/images/#{@image}")}]View on #{site_name()}[/url]#{source_link}" = if display_mod_tools? do .block__tab.hidden data-tab="replace" - = form_for @changeset, Routes.image_file_path(@conn, :update, @image), [method: "put", multipart: true], fn f -> + = form_for @changeset, ~p"/images/#{@image}/file", [method: "put", multipart: true], fn f -> #js-image-upload-previews p Upload a file from your computer .field @@ -89,7 +89,7 @@ .block__tab.hidden data-tab="administration" .block.block--danger - a.button> href=Routes.image_scratchpad_path(@conn, :edit, @image) + a.button> href=~p"/images/#{@image}/scratchpad/edit" i.far.fa-edit = if present?(@image.scratchpad) do strong> Mod notes: @@ -98,13 +98,13 @@ em No mod notes present = if not @image.hidden_from_users do - = form_for @changeset, Routes.image_delete_path(@conn, :create, @image), [method: "post"], fn f -> + = form_for @changeset, ~p"/images/#{@image}/delete", [method: "post"], fn f -> = label f, :deletion_reason, "Deletion reason (cannot be empty)" .field.field--inline = text_input f, :deletion_reason, class: "input input--wide", placeholder: "Rule violation", required: true = submit "Delete", class: "button button--danger button--separate-left" - else - = form_for @changeset, Routes.image_delete_path(@conn, :update, @image), [method: "put"], fn f -> + = form_for @changeset, ~p"/images/#{@image}/delete", [method: "put"], fn f -> = label f, :deletion_reason, "Deletion reason (cannot be empty)" .field.field--inline = text_input f, :deletion_reason, class: "input input--wide", placeholder: "Rule violation", required: true @@ -112,18 +112,18 @@ .flex.flex--spaced-out.flex--wrap = if not @image.hidden_from_users do - = form_for @changeset, Routes.image_feature_path(@conn, :create, @image), [method: "post"], fn _f -> + = form_for @changeset, ~p"/images/#{@image}/feature", [method: "post"], fn _f -> .field p Marks the image as featured = submit "Feature", data: [confirm: "Are you really, really sure?"], class: "button button--success" - else - = button_to "Restore", Routes.image_delete_path(@conn, :delete, @image), method: "delete", class: "button button--success" + = button_to "Restore", ~p"/images/#{@image}/delete", method: "delete", class: "button button--success" - = form_for @changeset, Routes.image_repair_path(@conn, :create, @image), [method: "post"], fn _f -> + = form_for @changeset, ~p"/images/#{@image}/repair", [method: "post"], fn _f -> .field = submit "Repair", class: "button button--success" - = form_for @changeset, Routes.image_hash_path(@conn, :delete, @image), [method: "delete"], fn _f -> + = form_for @changeset, ~p"/images/#{@image}/hash", [method: "delete"], fn _f -> .field p Allows reuploading the image .flex.flex--end-bunched @@ -132,24 +132,24 @@ br .flex.flex--spaced-out = if @image.commenting_allowed do - = button_to "Lock commenting", Routes.image_comment_lock_path(@conn, :create, @image), method: "post", class: "button" + = button_to "Lock commenting", ~p"/images/#{@image}/comment_lock", method: "post", class: "button" - else - = button_to "Unlock commenting", Routes.image_comment_lock_path(@conn, :delete, @image), method: "delete", class: "button" + = button_to "Unlock commenting", ~p"/images/#{@image}/comment_lock", method: "delete", class: "button" = if @image.description_editing_allowed do - = button_to "Lock description editing", Routes.image_description_lock_path(@conn, :create, @image), method: "post", class: "button" + = button_to "Lock description editing", ~p"/images/#{@image}/description_lock", method: "post", class: "button" - else - = button_to "Unlock description editing", Routes.image_description_lock_path(@conn, :delete, @image), method: "delete", class: "button" + = button_to "Unlock description editing", ~p"/images/#{@image}/description_lock", method: "delete", class: "button" = if @image.tag_editing_allowed do - = button_to "Lock tag editing", Routes.image_tag_lock_path(@conn, :create, @image), method: "post", class: "button" + = button_to "Lock tag editing", ~p"/images/#{@image}/tag_lock", method: "post", class: "button" - else - = button_to "Unlock tag editing", Routes.image_tag_lock_path(@conn, :delete, @image), method: "delete", class: "button" + = button_to "Unlock tag editing", ~p"/images/#{@image}/tag_lock", method: "delete", class: "button" br .flex.flex--spaced-out - = link "Lock specific tags", to: Routes.image_tag_lock_path(@conn, :show, @image), class: "button" + = link "Lock specific tags", to: ~p"/images/#{@image}/tag_lock", class: "button" = if not @image.approved and can?(@conn, :approve, @image) do - = button_to "Approve image", Routes.image_approve_path(@conn, :create, @image), method: "post", class: "button button--success", data: [confirm: "Are you sure?"] + = button_to "Approve image", ~p"/images/#{@image}/approve", method: "post", class: "button button--success", data: [confirm: "Are you sure?"] = if @image.hidden_from_users and can?(@conn, :destroy, @image) do - = button_to "Destroy image", Routes.image_destroy_path(@conn, :create, @image), method: "post", class: "button button--danger", data: [confirm: "This action is IRREVERSIBLE. Are you sure?"] + = button_to "Destroy image", ~p"/images/#{@image}/destroy", method: "post", class: "button button--danger", data: [confirm: "This action is IRREVERSIBLE. Are you sure?"] diff --git a/lib/philomena_web/templates/image/_random_button.html.slime b/lib/philomena_web/templates/image/_random_button.html.slime index 296bd711..a004dbea 100644 --- a/lib/philomena_web/templates/image/_random_button.html.slime +++ b/lib/philomena_web/templates/image/_random_button.html.slime @@ -1,3 +1,3 @@ -a href=Routes.image_random_path(@conn, :index, @params) title="Random Image" +a href=~p"/images/random?#{@params}" title="Random Image" i.fa.fa-random> span.hidden--mobile Random Image diff --git a/lib/philomena_web/templates/image/_source.html.slime b/lib/philomena_web/templates/image/_source.html.slime index c7b9ea07..6eecc792 100644 --- a/lib/philomena_web/templates/image/_source.html.slime +++ b/lib/philomena_web/templates/image/_source.html.slime @@ -1,6 +1,6 @@ .js-sourcesauce - has_sources = Enum.any?(@image.sources) - = form_for @changeset, Routes.image_source_path(@conn, :update, @image), [method: "put", class: "hidden", id: "source-form", data: [remote: "true"]], fn f -> + = form_for @changeset, ~p"/images/#{@image}/sources", [method: "put", class: "hidden", id: "source-form", data: [remote: "true"]], fn f -> = if can?(@conn, :edit_metadata, @image) and !@conn.assigns.current_ban do = if @changeset.action do .alert.alert-danger @@ -54,14 +54,14 @@ - else ' Add = if @source_change_count > 0 do - a.button href=Routes.image_source_change_path(@conn, :index, @image) title="Source history" + a.button href=~p"/images/#{@image}/source_changes" title="Source history" i.fa.fa-history> spanspan.hide-mobile> History | ( = @source_change_count | ) = if can?(@conn, :hide, @image) and not hide_staff_tools?(@conn) do - = form_for @changeset, Routes.image_source_history_path(@conn, :delete, @image), [method: "delete"], fn _f -> + = form_for @changeset, ~p"/images/#{@image}/source_history", [method: "delete"], fn _f -> a.button.button--warning type="submit" data-confirm="Are you really, really sure?" title="Wipe sources" i.fas.fa-eraser> ' Wipe diff --git a/lib/philomena_web/templates/image/_tags.html.slime b/lib/philomena_web/templates/image/_tags.html.slime index fa5f8e0c..52ae9c42 100644 --- a/lib/philomena_web/templates/image/_tags.html.slime +++ b/lib/philomena_web/templates/image/_tags.html.slime @@ -12,7 +12,7 @@ ' The following tags have been restricted on this image: code= Enum.map_join(@image.locked_tags, ", ", & &1.name) - = form_for @changeset, Routes.image_tag_path(@conn, :update, @image), [id: "tags-form", method: "put", data: [remote: "true"]], fn f -> + = form_for @changeset, ~p"/images/#{@image}/tags", [id: "tags-form", method: "put", data: [remote: "true"]], fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. @@ -69,7 +69,7 @@ i.fas.fa-edit> ' Edit = if @tag_change_count > 0 do - a.button href=Routes.image_tag_change_path(@conn, :index, @image) title="Tag history" + a.button href=~p"/images/#{@image}/tag_changes" title="Tag history" i.fa.fa-history> | History ( = @tag_change_count diff --git a/lib/philomena_web/templates/image/_uploader.html.slime b/lib/philomena_web/templates/image/_uploader.html.slime index ca40bd72..6062657e 100644 --- a/lib/philomena_web/templates/image/_uploader.html.slime +++ b/lib/philomena_web/templates/image/_uploader.html.slime @@ -11,7 +11,7 @@ span.image-uploader i.fas.fa-eye = if can?(@conn, :show, :ip_address) do - = form_for @changeset, Routes.image_uploader_path(@conn, :update, @image), [class: "block__content hidden", id: "uploader-form", data: [remote: "true", method: "put"]], fn f -> + = form_for @changeset, ~p"/images/#{@image}/uploader", [class: "block__content hidden", id: "uploader-form", data: [remote: "true", method: "put"]], fn f -> => label f, :username, "Uploader" => text_input f, :username, value: username(@image.user), class: "input input--short input--small" @@ -21,6 +21,6 @@ span.image-uploader .image-anonymous.hidden = if @image.anonymous do - = button_to "Reveal author", Routes.image_anonymous_path(@conn, :delete, @image), class: "button button--small", method: "delete", data: [confirm: "Are you really, really sure?"] + = button_to "Reveal author", ~p"/images/#{@image}/anonymous", class: "button button--small", method: "delete", data: [confirm: "Are you really, really sure?"] - else - = button_to "Hide author", Routes.image_anonymous_path(@conn, :create, @image), class: "button button--small", method: "create", data: [confirm: "Are you really, really sure?"] + = button_to "Hide author", ~p"/images/#{@image}/anonymous", class: "button button--small", method: "create", data: [confirm: "Are you really, really sure?"] diff --git a/lib/philomena_web/templates/image/comment/_form.html.slime b/lib/philomena_web/templates/image/comment/_form.html.slime index d1745a11..84bf2bd6 100644 --- a/lib/philomena_web/templates/image/comment/_form.html.slime +++ b/lib/philomena_web/templates/image/comment/_form.html.slime @@ -1,6 +1,6 @@ - options = if(assigns[:remote], do: [data: [remote: "true"], id: "js-comment-form"], else: []) -= form_for @changeset, Routes.image_comment_path(@conn, :create, @image), options, fn f -> += form_for @changeset, ~p"/images/#{@image}/comments", options, fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/image/comment/edit.html.slime b/lib/philomena_web/templates/image/comment/edit.html.slime index d7183a60..1b17c96a 100644 --- a/lib/philomena_web/templates/image/comment/edit.html.slime +++ b/lib/philomena_web/templates/image/comment/edit.html.slime @@ -1,4 +1,4 @@ -= form_for @changeset, Routes.image_comment_path(@conn, :update, @comment.image, @comment), fn f -> += form_for @changeset, ~p"/images/#{@comment.image}/comments/#{@comment}", fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/image/comment/history/index.html.slime b/lib/philomena_web/templates/image/comment/history/index.html.slime index b28ee066..71fc2186 100644 --- a/lib/philomena_web/templates/image/comment/history/index.html.slime +++ b/lib/philomena_web/templates/image/comment/history/index.html.slime @@ -2,7 +2,7 @@ h1 ' Viewing last 25 versions of comment by = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @comment, conn: @conn ' on image - a href=Routes.image_path(@conn, :show, @comment.image) + a href=~p"/images/#{@comment.image}" | # = @comment.image_id diff --git a/lib/philomena_web/templates/image/comment/index.html.slime b/lib/philomena_web/templates/image/comment/index.html.slime index e42c0b35..b351ff13 100644 --- a/lib/philomena_web/templates/image/comment/index.html.slime +++ b/lib/philomena_web/templates/image/comment/index.html.slime @@ -1,5 +1,5 @@ elixir: - route = fn p -> Routes.image_comment_path(@conn, :index, @image, p) end + route = fn p -> ~p"/images/#{@image}/comments?#{p}" end pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @comments, route: route .block diff --git a/lib/philomena_web/templates/image/deleted.html.slime b/lib/philomena_web/templates/image/deleted.html.slime index 4177b0a3..fc425b36 100644 --- a/lib/philomena_web/templates/image/deleted.html.slime +++ b/lib/philomena_web/templates/image/deleted.html.slime @@ -4,7 +4,7 @@ h1 This image has been merged into another image p ' This image was merged into image - => link "##{@image.duplicate_id}", to: Routes.image_path(@conn, :show, @image.duplicate_id) + => link "##{@image.duplicate_id}", to: ~p"/images/#{@image.duplicate_id}" ' because it was determined to be a duplicate of that image. - else diff --git a/lib/philomena_web/templates/image/description/_form.html.slime b/lib/philomena_web/templates/image/description/_form.html.slime index 6b4c4543..e47b5d3f 100644 --- a/lib/philomena_web/templates/image/description/_form.html.slime +++ b/lib/philomena_web/templates/image/description/_form.html.slime @@ -1,4 +1,4 @@ -= form_for @changeset, Routes.image_description_path(@conn, :update, @image), [class: "block hidden", id: "description-form", data: [remote: "true"]], fn f -> += form_for @changeset, ~p"/images/#{@image}/description", [class: "block hidden", id: "description-form", data: [remote: "true"]], fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/image/favorite/index.html.slime b/lib/philomena_web/templates/image/favorite/index.html.slime index 1e606aad..ed239797 100644 --- a/lib/philomena_web/templates/image/favorite/index.html.slime +++ b/lib/philomena_web/templates/image/favorite/index.html.slime @@ -4,7 +4,7 @@ h5 = pluralize("user", "users", @image.faves_count) = for fave <- Enum.sort_by(@image.faves, & String.downcase(&1.user.name)) do - => link fave.user.name, to: Routes.profile_path(@conn, :show, fave.user), class: "interaction-user-list-item" + => link fave.user.name, to: ~p"/profiles/#{fave.user}", class: "interaction-user-list-item" = if @has_votes do h5 @@ -14,8 +14,8 @@ h5 = for upvote <- Enum.sort_by(@image.upvotes, & String.downcase(&1.user.name)) do span.interaction-user-list-item - => link upvote.user.name, to: Routes.profile_path(@conn, :show, upvote.user) - => link "(x)", to: Routes.image_tamper_path(@conn, :create, @image, user_id: upvote.user_id), method: "post" + => link upvote.user.name, to: ~p"/profiles/#{upvote.user}" + => link "(x)", to: ~p"/images/#{@image}/tamper?#{[user_id: upvote.user_id]}", method: "post" h5 ' Downvoted by @@ -24,8 +24,8 @@ h5 = for downvote <- Enum.sort_by(@image.downvotes, & String.downcase(&1.user.name)) do span.interaction-user-list-item - => link downvote.user.name, to: Routes.profile_path(@conn, :show, downvote.user) - => link "(x)", to: Routes.image_tamper_path(@conn, :create, @image, user_id: downvote.user_id), method: "post" + => link downvote.user.name, to: ~p"/profiles/#{downvote.user}" + => link "(x)", to: ~p"/images/#{@image}/tamper?#{[user_id: downvote.user_id]}", method: "post" h5 ' Hidden by @@ -33,4 +33,4 @@ h5 = pluralize("user", "users", @image.hides_count) = for hide <- Enum.sort_by(@image.hides, & String.downcase(&1.user.name)) do - => link hide.user.name, to: Routes.profile_path(@conn, :show, hide.user), class: "interaction-user-list-item" + => link hide.user.name, to: ~p"/profiles/#{hide.user}", class: "interaction-user-list-item" diff --git a/lib/philomena_web/templates/image/index.html.slime b/lib/philomena_web/templates/image/index.html.slime index 389fe61b..ff4e27f6 100644 --- a/lib/philomena_web/templates/image/index.html.slime +++ b/lib/philomena_web/templates/image/index.html.slime @@ -3,9 +3,9 @@ elixir: params = assigns[:params] || assigns[:scope] || [] scope = assigns[:scope] || [] tags = assigns[:tags] || [] - route = assigns[:route] || fn p -> Routes.image_path(@conn, :index, p) end - image_url = fn image -> Routes.image_path(@conn, :show, image, scope) end - sorted_url = fn image, hit -> Routes.image_path(@conn, :show, image, Keyword.put(scope, :sort, hit["sort"])) end + route = assigns[:route] || fn p -> ~p"/images?#{p}" end + image_url = fn image -> ~p"/images/#{image}?#{scope}" end + sorted_url = fn image, hit -> ~p"/images/#{image}?#{Keyword.put(scope, :sort, hit["sort"])}" end pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @images, route: route, params: params info = render PhilomenaWeb.PaginationView, "_pagination_info.html", page: @images diff --git a/lib/philomena_web/templates/image/new.html.slime b/lib/philomena_web/templates/image/new.html.slime index f290077f..68fe7471 100644 --- a/lib/philomena_web/templates/image/new.html.slime +++ b/lib/philomena_web/templates/image/new.html.slime @@ -1,4 +1,4 @@ -= form_for @changeset, Routes.image_path(@conn, :create), [multipart: true], fn f -> += form_for @changeset, ~p"/images", [multipart: true], fn f -> .dnp-warning h4 ' Read the diff --git a/lib/philomena_web/templates/image/related/index.html.slime b/lib/philomena_web/templates/image/related/index.html.slime index fe7bd41c..36646969 100644 --- a/lib/philomena_web/templates/image/related/index.html.slime +++ b/lib/philomena_web/templates/image/related/index.html.slime @@ -8,4 +8,4 @@ .media-list = for image <- @images do - = render PhilomenaWeb.ImageView, "_image_box.html", image: image, link: Routes.image_path(@conn, :show, image), size: :thumb, conn: @conn + = render PhilomenaWeb.ImageView, "_image_box.html", image: image, link: ~p"/images/#{image}", size: :thumb, conn: @conn diff --git a/lib/philomena_web/templates/image/reporting/show.html.slime b/lib/philomena_web/templates/image/reporting/show.html.slime index 274b07eb..6dbf9650 100644 --- a/lib/philomena_web/templates/image/reporting/show.html.slime +++ b/lib/philomena_web/templates/image/reporting/show.html.slime @@ -1,4 +1,4 @@ -a href=Routes.image_report_path(@conn, :new, @image) +a href=~p"/images/#{@image}/reports/new" button.button i.fa.fa-exclamation-triangle> ' General reporting @@ -15,7 +15,7 @@ a href=Routes.image_report_path(@conn, :new, @image) - else p ' You must - a> href=Routes.session_path(@conn, :new) log in + a> href=~p"/sessions/new" log in ' to report duplicate images. - target_reports = Enum.filter(@dupe_reports, & &1.duplicate_of_image_id == @image.id) diff --git a/lib/philomena_web/templates/image/scratchpad/edit.html.slime b/lib/philomena_web/templates/image/scratchpad/edit.html.slime index 31e37f9f..bd27ab6e 100644 --- a/lib/philomena_web/templates/image/scratchpad/edit.html.slime +++ b/lib/philomena_web/templates/image/scratchpad/edit.html.slime @@ -1,8 +1,8 @@ h1 ' Editing moderation notes for image - = link "##{@image.id}", to: Routes.image_path(@conn, :show, @image) + = link "##{@image.id}", to: ~p"/images/#{@image}" -= form_for @changeset, Routes.image_scratchpad_path(@conn, :update, @image), fn f -> += form_for @changeset, ~p"/images/#{@image}/scratchpad", fn f -> .field = textarea f, :scratchpad, placeholder: "Scratchpad contents", class: "input input--wide" diff --git a/lib/philomena_web/templates/image/show.html.slime b/lib/philomena_web/templates/image/show.html.slime index 7b9c0842..d40ee7b9 100644 --- a/lib/philomena_web/templates/image/show.html.slime +++ b/lib/philomena_web/templates/image/show.html.slime @@ -27,5 +27,5 @@ - true -> - #comments data-current-url=Routes.image_comment_path(@conn, :index, @image) data-loaded="true" + #comments data-current-url=~p"/images/#{@image}/comments" data-loaded="true" = render PhilomenaWeb.Image.CommentView, "index.html", image: @image, comments: @comments, conn: @conn diff --git a/lib/philomena_web/templates/image/source_change/index.html.slime b/lib/philomena_web/templates/image/source_change/index.html.slime index 712f434a..bd5f4a57 100644 --- a/lib/philomena_web/templates/image/source_change/index.html.slime +++ b/lib/philomena_web/templates/image/source_change/index.html.slime @@ -1,10 +1,10 @@ h1 ' Source changes for - a href=Routes.image_path(@conn, :show, @image) + a href=~p"/images/#{@image}" | image # = @image.id -- route = fn p -> Routes.image_source_change_path(@conn, :index, @image, p) end +- route = fn p -> ~p"/images/#{@image}/source_changes?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @source_changes, route: route, conn: @conn = render PhilomenaWeb.SourceChangeView, "index.html", conn: @conn, source_changes: @source_changes, pagination: pagination \ No newline at end of file diff --git a/lib/philomena_web/templates/image/subscription/_subscription.html.slime b/lib/philomena_web/templates/image/subscription/_subscription.html.slime index 8df7e54c..aac74992 100644 --- a/lib/philomena_web/templates/image/subscription/_subscription.html.slime +++ b/lib/philomena_web/templates/image/subscription/_subscription.html.slime @@ -1,8 +1,8 @@ elixir: - watch_path = Routes.image_subscription_path(@conn, :create, @image) + watch_path = ~p"/images/#{@image}/subscription" watch_class = if @watching, do: "hidden", else: "" - unwatch_path = Routes.image_subscription_path(@conn, :delete, @image) + unwatch_path = ~p"/images/#{@image}/subscription" unwatch_class = if @watching, do: "", else: "hidden" = if @conn.assigns.current_user do @@ -15,6 +15,6 @@ elixir: i.fa.fa-bell-slash span.hidden--phone< Unsubscribe - else - a href=Routes.session_path(@conn, :new) + a href=~p"/sessions/new" i.fa.fa-bell span.hidden--phone< Subscribe diff --git a/lib/philomena_web/templates/image/tag_change/index.html.slime b/lib/philomena_web/templates/image/tag_change/index.html.slime index f246f12e..1ddd57f9 100644 --- a/lib/philomena_web/templates/image/tag_change/index.html.slime +++ b/lib/philomena_web/templates/image/tag_change/index.html.slime @@ -1,10 +1,10 @@ h1 ' Tag changes for - a href=Routes.image_path(@conn, :show, @image) + a href=~p"/images/#{@image}" | image # = @image.id -- route = fn p -> Routes.image_tag_change_path(@conn, :index, @image, p) end +- route = fn p -> ~p"/images/#{@image}/tag_changes?#{p}" end - params = if @conn.params["added"], do: [added: @conn.params["added"]] - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @tag_changes, route: route, conn: @conn, params: params @@ -13,8 +13,8 @@ h1 span | Display only: - = link "Removed", to: Routes.image_tag_change_path(@conn, :index, @image, added: 0) - = link "Added", to: Routes.image_tag_change_path(@conn, :index, @image, added: 1) - = link "All", to: Routes.image_tag_change_path(@conn, :index, @image) + = link "Removed", to: ~p"/images/#{@image}/tag_changes?#{[added: 0]}" + = link "Added", to: ~p"/images/#{@image}/tag_changes?#{[added: 1]}" + = link "All", to: ~p"/images/#{@image}/tag_changes" = render PhilomenaWeb.TagChangeView, "index.html", conn: @conn, tag_changes: @tag_changes, pagination: pagination diff --git a/lib/philomena_web/templates/image/tag_lock/show.html.slime b/lib/philomena_web/templates/image/tag_lock/show.html.slime index 81a52cdf..e5a9841d 100644 --- a/lib/philomena_web/templates/image/tag_lock/show.html.slime +++ b/lib/philomena_web/templates/image/tag_lock/show.html.slime @@ -4,7 +4,7 @@ h1 | Editing locked tags on image # = @image.id -= form_for @changeset, Routes.image_tag_lock_path(@conn, :update, @image), fn f -> += form_for @changeset, ~p"/images/#{@image}/tag_lock", fn f -> .field = render PhilomenaWeb.TagView, "_tag_editor.html", f: f, name: :tag_input, type: :edit, extra: [value: tag_input] = error_tag f, :tag_input diff --git a/lib/philomena_web/templates/ip_profile/show.html.slime b/lib/philomena_web/templates/ip_profile/show.html.slime index c752d9ff..eb3ac25c 100644 --- a/lib/philomena_web/templates/ip_profile/show.html.slime +++ b/lib/philomena_web/templates/ip_profile/show.html.slime @@ -3,24 +3,24 @@ h1 ' 's IP profile ul - li = link "View images this IP has uploaded", to: Routes.search_path(@conn, :index, q: "ip:#{@ip}") - li = link "View comments this IP has posted", to: Routes.comment_path(@conn, :index, cq: "ip:#{@ip}") - li = link "View posts this IP has made", to: Routes.post_path(@conn, :index, pq: "ip:#{@ip}") + li = link "View images this IP has uploaded", to: ~p"/search?#{[q: "ip:#{@ip}"]}" + li = link "View comments this IP has posted", to: ~p"/comments?#{[cq: "ip:#{@ip}"]}" + li = link "View posts this IP has made", to: ~p"/posts?#{[pq: "ip:#{@ip}"]}" = render PhilomenaWeb.BanView, "_bans.html", bans: @subnet_bans, conn: @conn h2 Administration Options ul - li = link "View tag changes", to: Routes.ip_profile_tag_change_path(@conn, :index, to_string(@ip)) - li = link "View source URL history", to: Routes.ip_profile_source_change_path(@conn, :index, to_string(@ip)) - li = link "View reports this IP has made", to: Routes.admin_report_path(@conn, :index, rq: "ip:#{@ip}") - li = link "View IP ban history", to: Routes.admin_subnet_ban_path(@conn, :index, ip: to_string(@ip)) - li = link "Ban this sucker", to: Routes.admin_subnet_ban_path(@conn, :new, specification: to_string(@ip)) + li = link "View tag changes", to: ~p"/ip_profiles/#{to_string(@ip)}/tag_changes" + li = link "View source URL history", to: ~p"/ip_profiles/#{to_string(@ip)}/source_changes" + li = link "View reports this IP has made", to: ~p"/admin/reports?#{[rq: "ip:#{@ip}"]}" + li = link "View IP ban history", to: ~p"/admin/subnet_bans?#{[ip: to_string(@ip)]}" + li = link "Ban this sucker", to: ~p"/admin/subnet_bans/new?#{[specification: to_string(@ip)]}" h2 Actions ul - li = link "Revert all tag changes", to: Routes.tag_change_full_revert_path(@conn, :create, [ip: to_string(@ip)]), data: [confirm: "Are you really, really sure?", method: "create"] - li = link "...the button above didn't work (use carefully, this is resource-intensive)", to: Routes.tag_change_full_revert_path(@conn, :create, [ip: to_string(@ip), batch_size: 1]), data: [confirm: "Please confirm that you're aware that this may crash the site and are ready to take on the full wrath of the admins if it does so after you press this button.", method: "create"] + li = link "Revert all tag changes", to: ~p"/tag_changes/full_revert?#{[ip: to_string(@ip)]}", data: [confirm: "Are you really, really sure?", method: "create"] + li = link "...the button above didn't work (use carefully, this is resource-intensive)", to: ~p"/tag_changes/full_revert?#{[ip: to_string(@ip), batch_size: 1]}", data: [confirm: "Please confirm that you're aware that this may crash the site and are ready to take on the full wrath of the admins if it does so after you press this button.", method: "create"] h4 Observed users table.table @@ -34,7 +34,7 @@ table.table = for uip <- @user_ips do tr td - = link uip.user.name, to: Routes.profile_path(@conn, :show, uip.user) + = link uip.user.name, to: ~p"/profiles/#{uip.user}" td => uip.uses ' times diff --git a/lib/philomena_web/templates/ip_profile/source_change/index.html.slime b/lib/philomena_web/templates/ip_profile/source_change/index.html.slime index 5bf1bea1..d31a7968 100644 --- a/lib/philomena_web/templates/ip_profile/source_change/index.html.slime +++ b/lib/philomena_web/templates/ip_profile/source_change/index.html.slime @@ -2,7 +2,7 @@ h1 ' Source changes by = @ip -- route = fn p -> Routes.ip_profile_source_change_path(@conn, :index, to_string(@ip), p) end +- route = fn p -> ~p"/ip_profiles/#{to_string(@ip)}/source_changes?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @source_changes, route: route, conn: @conn = render PhilomenaWeb.SourceChangeView, "index.html", conn: @conn, source_changes: @source_changes, pagination: pagination diff --git a/lib/philomena_web/templates/ip_profile/tag_change/index.html.slime b/lib/philomena_web/templates/ip_profile/tag_change/index.html.slime index 53a3c5e8..55741974 100644 --- a/lib/philomena_web/templates/ip_profile/tag_change/index.html.slime +++ b/lib/philomena_web/templates/ip_profile/tag_change/index.html.slime @@ -2,7 +2,7 @@ h1 ' Tag changes by = @ip -- route = fn p -> Routes.ip_profile_tag_change_path(@conn, :index, to_string(@ip), p) end +- route = fn p -> ~p"/ip_profiles/#{to_string(@ip)}/tag_changes?#{p}" end - params = if @conn.params["added"], do: [added: @conn.params["added"]] - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @tag_changes, route: route, conn: @conn, params: params @@ -11,8 +11,8 @@ h1 span | Display only: - = link "Removed", to: Routes.ip_profile_tag_change_path(@conn, :index, to_string(@ip), added: 0) - = link "Added", to: Routes.ip_profile_tag_change_path(@conn, :index, to_string(@ip), added: 1) - = link "All", to: Routes.ip_profile_tag_change_path(@conn, :index, to_string(@ip)) + = link "Removed", to: ~p"/ip_profiles/#{to_string(@ip)}/tag_changes?#{[added: 0]}" + = link "Added", to: ~p"/ip_profiles/#{to_string(@ip)}/tag_changes?#{[added: 1]}" + = link "All", to: ~p"/ip_profiles/#{to_string(@ip)}/tag_changes" = render PhilomenaWeb.TagChangeView, "index.html", conn: @conn, tag_changes: @tag_changes, pagination: pagination diff --git a/lib/philomena_web/templates/layout/_header.html.slime b/lib/philomena_web/templates/layout/_header.html.slime index b88d7295..5d6b20e2 100644 --- a/lib/philomena_web/templates/layout/_header.html.slime +++ b/lib/philomena_web/templates/layout/_header.html.slime @@ -7,7 +7,7 @@ header span.hidden--mobile = site_name() a.header__link.hidden--mobile href="/images/new" title="Upload" i.fa.fa-upload - = form_for @conn, Routes.search_path(@conn, :index), [method: "get", class: "header__search", enforce_utf8: false], fn f -> + = form_for @conn, ~p"/search", [method: "get", class: "header__search", enforce_utf8: false], fn f -> input.input.input--text.header__input.header__input--text#q name="q" title="For terms all required, separate with ',' or 'AND'; also supports 'OR' for optional terms and '-' or 'NOT' for negation. Search with a blank query for more options or click the ? for syntax help." value=@conn.params["q"] placeholder="Search" autocapitalize="none" = if present?(@conn.params["sf"]) do @@ -44,19 +44,19 @@ header span.hidden--tablet< Filters .header__search - = form_for @user_changeset, Routes.filter_current_path(@conn, :update), [class: "header__filter-form", id: "filter-quick-form"], fn f -> + = form_for @user_changeset, ~p"/filters/current", [class: "header__filter-form", id: "filter-quick-form"], fn f -> = select f, :current_filter_id, @available_filters, name: "id", id: "filter-quick-menu", class: "input header__input", data: [change_submit: "#filter-quick-form"], autocomplete: "off" .header__search - = form_for @user_changeset, Routes.filter_spoiler_type_path(@conn, :update), [class: "header__filter-form hidden--mobile", id: "spoiler-quick-form"], fn f -> + = form_for @user_changeset, ~p"/filters/spoiler_type", [class: "header__filter-form hidden--mobile", id: "spoiler-quick-form"], fn f -> = select f, :spoiler_type, @spoiler_types, id: "spoiler-quick-menu", class: "input header__input", data: [change_submit: "#spoiler-quick-form"], autocomplete: "off" .dropdown - a.header__link.header__link--user href=Routes.profile_path(@conn, :show, @current_user) + a.header__link.header__link--user href=~p"/profiles/#{@current_user}" = render PhilomenaWeb.UserAttributionView, "_user_avatar.html", object: %{user: @current_user}, class: "avatar--navbar" i.fa.fa-chevron-down nav.dropdown__content.dropdown__content--right.hidden--mobile.js-burger-links - a.dropdown__item href=Routes.profile_path(@conn, :show, @current_user) + a.dropdown__item href=~p"/profiles/#{@current_user}" .dropdown__icon i.fa.icon--fixed.fa-user .dropdown__text @@ -74,7 +74,7 @@ header .dropdown__icon i.fa.icon--fixed.fa-arrow-up .dropdown__text Upvotes - a.dropdown__item href=Routes.gallery_path(@conn, :index, gallery: [creator: @current_user.name]) + a.dropdown__item href=~p"/galleries?#{[gallery: [creator: @current_user.name]]}" .dropdown__icon i.fa.icon--fixed.fa-image .dropdown__text Galleries @@ -90,7 +90,7 @@ header .dropdown__icon i.fa.icon--fixed.fa-pen-square .dropdown__text Posts - a.dropdown__item href=Routes.profile_artist_link_path(@conn, :index, @current_user) + a.dropdown__item href=~p"/profiles/#{@current_user}/artist_links" .dropdown__icon i.fa.icon--fixed.fa-link .dropdown__text Links @@ -103,12 +103,12 @@ header .dropdown__icon i.fa.icon--fixed.fa-cogs .dropdown__text Settings - a.dropdown__item href=Routes.registration_path(@conn, :edit) + a.dropdown__item href=~p"/registrations/edit" .dropdown__icon i.fa.icon--fixed.fa-user .dropdown__text Account hr.dropdown__separator - a.dropdown__item href=Routes.session_path(@conn, :delete) data-method="delete" + a.dropdown__item href=~p"/sessions" data-method="delete" .dropdown__icon i.fa.icon--fixed.fa-sign-out-alt .dropdown__text Logout @@ -121,9 +121,9 @@ header a.header__link href="/settings/edit" i.fa.icon--fixed.fa-cogs.hidden--desktop> | Settings - a.header__link href=Routes.registration_path(@conn, :new) + a.header__link href=~p"/registrations/new" | Register - a.header__link href=Routes.session_path(@conn, :new) + a.header__link href=~p"/sessions/new" | Login nav.header__secondary = render PhilomenaWeb.LayoutView, "_header_navigation.html", assigns diff --git a/lib/philomena_web/templates/layout/_header_navigation.html.slime b/lib/philomena_web/templates/layout/_header_navigation.html.slime index 7ceb5b96..dff5426a 100644 --- a/lib/philomena_web/templates/layout/_header_navigation.html.slime +++ b/lib/philomena_web/templates/layout/_header_navigation.html.slime @@ -30,7 +30,7 @@ i.fa.fa-caret-down< nav.dropdown__content = for forum <- @conn.assigns.forums do - a.dropdown__link href=Routes.forum_path(@conn, :show, forum) + a.dropdown__link href=~p"/forums/#{forum}" = forum.name hr.dropdown__separator diff --git a/lib/philomena_web/templates/layout/_header_staff_links.html.slime b/lib/philomena_web/templates/layout/_header_staff_links.html.slime index 0e376ba7..8543fa07 100644 --- a/lib/philomena_web/templates/layout/_header_staff_links.html.slime +++ b/lib/philomena_web/templates/layout/_header_staff_links.html.slime @@ -7,87 +7,87 @@ .dropdown__content.js-burger-links = if manages_site_notices?(@conn) do - = link to: Routes.admin_site_notice_path(@conn, :index) do + = link to: ~p"/admin/site_notices" do .dropdown__item .dropdown__icon i.fa.icon--padded.small.fa-info-circle .dropdown__text Site Notices = if manages_users?(@conn) do - = link to: Routes.admin_user_path(@conn, :index) do + = link to: ~p"/admin/users" do .dropdown__item .dropdown__icon i.fa.icon--padded.small.fa-users .dropdown__text Users = if manages_forums?(@conn) do - = link to: Routes.admin_forum_path(@conn, :index) do + = link to: ~p"/admin/forums" do .dropdown__item .dropdown__icon i.fa.icon--padded.small.fa-paragraph .dropdown__text Forums = if manages_ads?(@conn) do - = link to: Routes.admin_advert_path(@conn, :index) do + = link to: ~p"/admin/adverts" do .dropdown__item .dropdown__icon i.fa.icon--padded.small.fa-shopping-bag .dropdown__text Adverts = if manages_badges?(@conn) do - = link to: Routes.admin_badge_path(@conn, :index) do + = link to: ~p"/admin/badges" do .dropdown__item .dropdown__icon i.fa.icon--padded.small.fa-trophy .dropdown__text Badges = if manages_static_pages?(@conn) do - = link to: Routes.page_path(@conn, :index) do + = link to: ~p"/pages" do .dropdown__item .dropdown__icon i.fa.icon--padded.small.fa-sticky-note .dropdown__text Pages = if manages_mod_notes?(@conn) do - = link to: Routes.admin_mod_note_path(@conn, :index) do + = link to: ~p"/admin/mod_notes" do .dropdown__item .dropdown__icon i.fa.icon--padded.small.fa-sticky-note .dropdown__text Mod Notes = if can_see_moderation_log?(@conn) do - = link to: Routes.moderation_log_path(@conn, :index) do + = link to: ~p"/moderation_logs" do .dropdown__item .dropdown__icon i.fa.icon--padded.small.fa-list-alt .dropdown__text Mod Logs = if @pending_approval_count do - = link to: Routes.admin_approval_path(@conn, :index), class: "header__link", title: "Approval Queue" do + = link to: ~p"/admin/approvals", class: "header__link", title: "Approval Queue" do ' Q span.header__counter__admin = @pending_approval_count = if @duplicate_report_count do - = link to: Routes.duplicate_report_path(@conn, :index), class: "header__link", title: "Duplicates" do + = link to: ~p"/duplicate_reports", class: "header__link", title: "Duplicates" do ' D span.header__counter__admin = @duplicate_report_count = if @report_count do - = link to: Routes.admin_report_path(@conn, :index), class: "header__link", title: "Reports" do + = link to: ~p"/admin/reports", class: "header__link", title: "Reports" do ' R span.header__counter__admin = @report_count = if @artist_link_count do - = link to: Routes.admin_artist_link_path(@conn, :index), class: "header__link", title: "Artist Links" do + = link to: ~p"/admin/artist_links", class: "header__link", title: "Artist Links" do ' L span.header__counter__admin = @artist_link_count = if @dnp_entry_count do - = link to: Routes.admin_dnp_entry_path(@conn, :index), class: "header__link", title: "DNP Requests" do + = link to: ~p"/admin/dnp_entries", class: "header__link", title: "DNP Requests" do ' S span.header__counter__admin = @dnp_entry_count @@ -99,19 +99,19 @@ i.fa.fa-caret-down .dropdown__content.dropdown__content--right.js-burger-links - = link to: Routes.admin_user_ban_path(@conn, :index) do + = link to: ~p"/admin/user_bans" do .dropdown__item .dropdown__icon i.fa.icon--padded.small.fa-user .dropdown__text User Bans - = link to: Routes.admin_subnet_ban_path(@conn, :index) do + = link to: ~p"/admin/subnet_bans" do .dropdown__item .dropdown__icon i.fa.icon--padded.small.fa-network-wired .dropdown__text IP Bans - = link to: Routes.admin_fingerprint_ban_path(@conn, :index) do + = link to: ~p"/admin/fingerprint_bans" do .dropdown__item .dropdown__icon i.fa.icon--padded.small.fa-desktop diff --git a/lib/philomena_web/templates/layout/_opengraph.html.slime b/lib/philomena_web/templates/layout/_opengraph.html.slime index f7fac763..81daa32d 100644 --- a/lib/philomena_web/templates/layout/_opengraph.html.slime +++ b/lib/philomena_web/templates/layout/_opengraph.html.slime @@ -12,7 +12,7 @@ meta name="format-detection" content="telephone=no" meta name="keywords" content=tag_list(image) meta name="description" content=description meta property="og:title" content=description - meta property="og:url" content=Routes.image_url(@conn, :show, image) + meta property="og:url" content=url(~p"/images/#{image}") = for tag <- artist_tags(image.tags) do meta property="dc:creator" content=tag.name_in_namespace @@ -20,9 +20,9 @@ meta name="format-detection" content="telephone=no" = if image_has_sources(image) do meta property="foaf:primaryTopic" content=image_first_source(image) - link rel="alternate" type="application/json+oembed" href=Routes.api_json_oembed_url(@conn, :index, url: Routes.image_path(@conn, :show, image)) title="oEmbed JSON Profile" + link rel="alternate" type="application/json+oembed" href=url(~p"/api/v1/json/oembed?#{[url: ~p"/images/#{image}"]}") title="oEmbed JSON Profile" - link rel="canonical" href=Routes.image_url(@conn, :show, image) + link rel="canonical" href=url(~p"/images/#{image}") = cond do - image.image_mime_type == "video/webm" and not filtered -> diff --git a/lib/philomena_web/templates/layout/app.html.slime b/lib/philomena_web/templates/layout/app.html.slime index 2ddd1e5b..0578f288 100644 --- a/lib/philomena_web/templates/layout/app.html.slime +++ b/lib/philomena_web/templates/layout/app.html.slime @@ -11,7 +11,7 @@ html lang="en" =< site_name() - else =<> site_name() - link rel="stylesheet" href=Routes.static_path(@conn, "/css/application.css") + link rel="stylesheet" href=~p"/css/application.css" link rel="stylesheet" href=stylesheet_path(@conn, @current_user) = if is_nil(@current_user) do link rel="stylesheet" href=light_stylesheet_path(@conn) media="(prefers-color-scheme: light)" diff --git a/lib/philomena_web/templates/message/_message.html.slime b/lib/philomena_web/templates/message/_message.html.slime index 8522e124..09864ccf 100644 --- a/lib/philomena_web/templates/message/_message.html.slime +++ b/lib/philomena_web/templates/message/_message.html.slime @@ -9,7 +9,7 @@ article.block.communication p ul.horizontal-list li - = link(to: Routes.conversation_message_approve_path(@conn, :create, @message.conversation_id, @message), data: [confirm: "Are you sure?"], method: "post", class: "button") do + = link(to: ~p"/conversations/#{@message.conversation_id}/messages/#{@message}/approve", data: [confirm: "Are you sure?"], method: "post", class: "button") do i.fas.fa-check> ' Approve diff --git a/lib/philomena_web/templates/moderation_log/index.html.slime b/lib/philomena_web/templates/moderation_log/index.html.slime index a1927305..e2c81eef 100644 --- a/lib/philomena_web/templates/moderation_log/index.html.slime +++ b/lib/philomena_web/templates/moderation_log/index.html.slime @@ -1,5 +1,5 @@ elixir: - route = fn p -> Routes.moderation_log_path(@conn, :index, p) end + route = fn p -> ~p"/moderation_logs?#{p}" end pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @moderation_logs, route: route, conn: @conn h1 Listing Moderation Logs diff --git a/lib/philomena_web/templates/notification/_channel.html.slime b/lib/philomena_web/templates/notification/_channel.html.slime index 3e40d6f3..1fc57157 100644 --- a/lib/philomena_web/templates/notification/_channel.html.slime +++ b/lib/philomena_web/templates/notification/_channel.html.slime @@ -1,14 +1,14 @@ .flex.flex--centered.flex__grow div strong> - = link @notification.actor.title, to: Routes.channel_path(@conn, :show, @notification.actor) + = link @notification.actor.title, to: ~p"/channels/#{@notification.actor}" =<> @notification.action => pretty_time @notification.updated_at .flex.flex--centered.flex--no-wrap - a.button.button--separate-right title="Delete" href=Routes.channel_read_path(@conn, :create, @notification.actor) data-method="post" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" + a.button.button--separate-right title="Delete" href=~p"/channels/#{@notification.actor}/read" data-method="post" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" i.fa.fa-trash - a.button title="Unsubscribe" href=Routes.channel_subscription_path(@conn, :delete, @notification.actor) data-method="delete" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" + a.button title="Unsubscribe" href=~p"/channels/#{@notification.actor}/subscription" data-method="delete" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" i.fa.fa-bell-slash \ No newline at end of file diff --git a/lib/philomena_web/templates/notification/_forum.html.slime b/lib/philomena_web/templates/notification/_forum.html.slime index 512c49ea..f7edb198 100644 --- a/lib/philomena_web/templates/notification/_forum.html.slime +++ b/lib/philomena_web/templates/notification/_forum.html.slime @@ -9,17 +9,17 @@ ' titled strong> - = link topic.title, to: Routes.forum_topic_path(@conn, :show, forum, topic) + = link topic.title, to: ~p"/forums/#{forum}/topics/#{topic}" ' in - => link forum.name, to: Routes.forum_path(@conn, :show, forum) + => link forum.name, to: ~p"/forums/#{forum}" => pretty_time @notification.updated_at .flex.flex--centered.flex--no-wrap - a.button.button--separate-right title="Delete" href=Routes.forum_read_path(@conn, :create, forum) data-method="post" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" + a.button.button--separate-right title="Delete" href=~p"/forums/#{forum}/read" data-method="post" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" i.fa.fa-trash - a.button title="Unsubscribe" href=Routes.forum_subscription_path(@conn, :delete, forum) data-method="delete" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" + a.button title="Unsubscribe" href=~p"/forums/#{forum}/subscription" data-method="delete" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" i.fa.fa-bell-slash \ No newline at end of file diff --git a/lib/philomena_web/templates/notification/_gallery.html.slime b/lib/philomena_web/templates/notification/_gallery.html.slime index 767cbc73..09e3eccc 100644 --- a/lib/philomena_web/templates/notification/_gallery.html.slime +++ b/lib/philomena_web/templates/notification/_gallery.html.slime @@ -4,13 +4,13 @@ => @notification.action strong> - = link @notification.actor.title, to: Routes.gallery_path(@conn, :show, @notification.actor) + = link @notification.actor.title, to: ~p"/galleries/#{@notification.actor}" => pretty_time @notification.updated_at .flex.flex--centered.flex--no-wrap - a.button.button--separate-right title="Delete" href=Routes.gallery_read_path(@conn, :create, @notification.actor) data-method="post" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" + a.button.button--separate-right title="Delete" href=~p"/galleries/#{@notification.actor}/read" data-method="post" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" i.fa.fa-trash - a.button title="Unsubscribe" href=Routes.gallery_subscription_path(@conn, :delete, @notification.actor) data-method="delete" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" + a.button title="Unsubscribe" href=~p"/galleries/#{@notification.actor}/subscription" data-method="delete" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" i.fa.fa-bell-slash \ No newline at end of file diff --git a/lib/philomena_web/templates/notification/_image.html.slime b/lib/philomena_web/templates/notification/_image.html.slime index ebedb422..89814c39 100644 --- a/lib/philomena_web/templates/notification/_image.html.slime +++ b/lib/philomena_web/templates/notification/_image.html.slime @@ -7,13 +7,13 @@ => @notification.action strong> - = link "##{@notification.actor_id}", to: Routes.image_path(@conn, :show, @notification.actor) <> "#comments" + = link "##{@notification.actor_id}", to: ~p"/images/#{@notification.actor}" <> "#comments" => pretty_time @notification.updated_at .flex.flex--centered.flex--no-wrap - a.button.button--separate-right title="Delete" href=Routes.image_read_path(@conn, :create, @notification.actor) data-method="post" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" + a.button.button--separate-right title="Delete" href=~p"/images/#{@notification.actor}/read" data-method="post" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" i.fa.fa-trash - a.button title="Unsubscribe" href=Routes.image_subscription_path(@conn, :delete, @notification.actor) data-method="delete" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" + a.button title="Unsubscribe" href=~p"/images/#{@notification.actor}/subscription" data-method="delete" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" i.fa.fa-bell-slash \ No newline at end of file diff --git a/lib/philomena_web/templates/notification/_topic.html.slime b/lib/philomena_web/templates/notification/_topic.html.slime index 1a1c5ff6..5ecefcfd 100644 --- a/lib/philomena_web/templates/notification/_topic.html.slime +++ b/lib/philomena_web/templates/notification/_topic.html.slime @@ -7,13 +7,13 @@ => @notification.action strong> - = link topic.title, to: Routes.forum_topic_path(@conn, :show, topic.forum, topic, post_id: post.id) <> "#post_#{post.id}" + = link topic.title, to: ~p"/forums/#{topic.forum}/topics/#{topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" => pretty_time @notification.updated_at .flex.flex--centered.flex--no-wrap - a.button.button--separate-right title="Delete" href=Routes.forum_topic_read_path(@conn, :create, topic.forum, topic) data-method="post" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" + a.button.button--separate-right title="Delete" href=~p"/forums/#{topic.forum}/topics/#{topic}/read" data-method="post" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" i.fa.fa-trash - a.button title="Unsubscribe" href=Routes.forum_topic_subscription_path(@conn, :delete, topic.forum, topic) data-method="delete" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" + a.button title="Unsubscribe" href=~p"/forums/#{topic.forum}/topics/#{topic}/subscription" data-method="delete" data-remote="true" data-fetchcomplete-hide="#notification-#{@notification.id}" i.fa.fa-bell-slash \ No newline at end of file diff --git a/lib/philomena_web/templates/notification/index.html.slime b/lib/philomena_web/templates/notification/index.html.slime index be72130c..4503680d 100644 --- a/lib/philomena_web/templates/notification/index.html.slime +++ b/lib/philomena_web/templates/notification/index.html.slime @@ -1,4 +1,4 @@ -- route = fn p -> Routes.notification_path(@conn, :index, p) end +- route = fn p -> ~p"/notifications?#{p}" end h1 Notification Area .walloftext diff --git a/lib/philomena_web/templates/page/edit.html.slime b/lib/philomena_web/templates/page/edit.html.slime index 2ac4387b..f141d06b 100644 --- a/lib/philomena_web/templates/page/edit.html.slime +++ b/lib/philomena_web/templates/page/edit.html.slime @@ -1,3 +1,3 @@ h1 Editing static page -= render PhilomenaWeb.PageView, "_form.html", changeset: @changeset, action: Routes.page_path(@conn, :update, @static_page), conn: @conn += render PhilomenaWeb.PageView, "_form.html", changeset: @changeset, action: ~p"/pages/#{@static_page}", conn: @conn diff --git a/lib/philomena_web/templates/page/history/index.html.slime b/lib/philomena_web/templates/page/history/index.html.slime index cc7429f7..805492eb 100644 --- a/lib/philomena_web/templates/page/history/index.html.slime +++ b/lib/philomena_web/templates/page/history/index.html.slime @@ -1,6 +1,6 @@ h1 ' Revision history for - = link @static_page.title, to: Routes.page_path(@conn, :show, @static_page) + = link @static_page.title, to: ~p"/pages/#{@static_page}" table.table thead @@ -12,7 +12,7 @@ table.table tbody = for version <- @versions do tr - td = link version.user.name, to: Routes.profile_path(@conn, :show, version.user) + td = link version.user.name, to: ~p"/profiles/#{version.user}" td = pretty_time(version.created_at) td.static-page__diff = for diff <- version.difference do diff --git a/lib/philomena_web/templates/page/index.html.slime b/lib/philomena_web/templates/page/index.html.slime index 88731d64..5e535faa 100644 --- a/lib/philomena_web/templates/page/index.html.slime +++ b/lib/philomena_web/templates/page/index.html.slime @@ -8,7 +8,7 @@ table.table tbody = for static_page <- @static_pages do tr - td = link static_page.title, to: Routes.page_path(@conn, :show, static_page) + td = link static_page.title, to: ~p"/pages/#{static_page}" br -= link "New static page", to: Routes.page_path(@conn, :new) += link "New static page", to: ~p"/pages/new" diff --git a/lib/philomena_web/templates/page/new.html.slime b/lib/philomena_web/templates/page/new.html.slime index 48ad0fd1..c2b7b208 100644 --- a/lib/philomena_web/templates/page/new.html.slime +++ b/lib/philomena_web/templates/page/new.html.slime @@ -1,3 +1,3 @@ h1 New static page -= render PhilomenaWeb.PageView, "_form.html", changeset: @changeset, action: Routes.page_path(@conn, :create), conn: @conn += render PhilomenaWeb.PageView, "_form.html", changeset: @changeset, action: ~p"/pages", conn: @conn diff --git a/lib/philomena_web/templates/page/show.html.slime b/lib/philomena_web/templates/page/show.html.slime index 9eadee5f..f5bc82cc 100644 --- a/lib/philomena_web/templates/page/show.html.slime +++ b/lib/philomena_web/templates/page/show.html.slime @@ -4,11 +4,11 @@ p => pretty_time(@static_page.updated_at) p - => link to: Routes.page_history_path(@conn, :index, @static_page) do + => link to: ~p"/pages/#{@static_page}/history" do i.fa.fa-history> ' Revision history = if can?(@conn, :edit, Philomena.StaticPages.StaticPage) do - =< link to: Routes.page_path(@conn, :edit, @static_page) do + =< link to: ~p"/pages/#{@static_page}/edit" do i.fa.fa-edit> ' Edit diff --git a/lib/philomena_web/templates/password/edit.html.slime b/lib/philomena_web/templates/password/edit.html.slime index 0046b4d9..00cf1f71 100644 --- a/lib/philomena_web/templates/password/edit.html.slime +++ b/lib/philomena_web/templates/password/edit.html.slime @@ -1,6 +1,6 @@ h1 Reset password -= form_for @changeset, Routes.password_path(@conn, :update, @token), fn f -> += form_for @changeset, ~p"/passwords/#{@token}", fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/password/new.html.slime b/lib/philomena_web/templates/password/new.html.slime index 20b84e85..3aac61b5 100644 --- a/lib/philomena_web/templates/password/new.html.slime +++ b/lib/philomena_web/templates/password/new.html.slime @@ -3,7 +3,7 @@ p ' Provide the email address you signed up with and we will email you ' password reset instructions. -= form_for :user, Routes.password_path(@conn, :create), fn f -> += form_for :user, ~p"/passwords", fn f -> .field = email_input f, :email, class: "input", placeholder: "Email", required: true diff --git a/lib/philomena_web/templates/post/_post.html.slime b/lib/philomena_web/templates/post/_post.html.slime index 42a0b046..bdf7fd23 100644 --- a/lib/philomena_web/templates/post/_post.html.slime +++ b/lib/philomena_web/templates/post/_post.html.slime @@ -1,10 +1,10 @@ -- post_link = Routes.forum_topic_path(@conn, :show, @post.topic.forum, @post.topic, post_id: @post.id) <> "#post_#{@post.id}" +- post_link = ~p"/forums/#{@post.topic.forum}/topics/#{@post.topic}?#{[post_id: @post.id]}" <> "#post_#{@post.id}" - options = if true do .flex__spacer.hidden--desktop a.communication__interaction.hidden--desktop title="Link to post" href=post_link i.fa.fa-link = if not is_nil(@post.edited_at) and can?(@conn, :show, @post) do - a href=Routes.forum_topic_post_history_path(@conn, :index, @post.topic.forum, @post.topic, @post) + a href=~p"/forums/#{@post.topic.forum}/topics/#{@post.topic}/posts/#{@post}/history" ' Edited => pretty_time(@post.edited_at) @@ -23,7 +23,7 @@ article.block.communication id="post_#{@post.id}" p ul.horizontal-list li - = link(to: Routes.forum_topic_post_approve_path(@conn, :create, @post.topic.forum, @post.topic, @post), data: [confirm: "Are you sure?"], method: "post", class: "button") do + = link(to: ~p"/forums/#{@post.topic.forum}/topics/#{@post.topic}/posts/#{@post}/approve", data: [confirm: "Are you sure?"], method: "post", class: "button") do i.fas.fa-check> ' Approve li @@ -31,7 +31,7 @@ article.block.communication id="post_#{@post.id}" i.fa.fa-times> ' Reject - = form_for :post, Routes.forum_topic_post_hide_path(@conn, :create, @post.topic.forum, @post.topic, @post), [class: "togglable-delete-form hidden flex", id: "inline-reject-form-post-#{@post.id}"], fn f -> + = form_for :post, ~p"/forums/#{@post.topic.forum}/topics/#{@post.topic}/posts/#{@post}/hide", [class: "togglable-delete-form hidden flex", id: "inline-reject-form-post-#{@post.id}"], fn f -> = text_input f, :deletion_reason, class: "input input--wide", placeholder: "Deletion Reason", id: "inline-reject-reason-post-#{@post.id}", required: true = submit "Delete", class: "button" @@ -45,11 +45,11 @@ article.block.communication id="post_#{@post.id}" = if can?(@conn, :hide, @post) and not hide_staff_tools?(@conn) do = cond do - @post.hidden_from_users and not @post.destroyed_content -> - = link(to: Routes.forum_topic_post_hide_path(@conn, :delete, @post.topic.forum, @post.topic, @post), data: [confirm: "Are you sure?"], method: "delete", class: "communication__interaction") do + = link(to: ~p"/forums/#{@post.topic.forum}/topics/#{@post.topic}/posts/#{@post}/hide", data: [confirm: "Are you sure?"], method: "delete", class: "communication__interaction") do i.fas.fa-check> ' Restore = if can?(@conn, :delete, @post) do - = link(to: Routes.forum_topic_post_delete_path(@conn, :create, @post.topic.forum, @post.topic, @post), data: [confirm: "Are you sure?"], method: "post", class: "communication__interaction") do + = link(to: ~p"/forums/#{@post.topic.forum}/topics/#{@post.topic}/posts/#{@post}/delete", data: [confirm: "Are you sure?"], method: "post", class: "communication__interaction") do i.fas.fa-times> ' Delete Contents @@ -66,6 +66,6 @@ article.block.communication id="post_#{@post.id}" .communication__info =<> link_to_fingerprint(@conn, @post.fingerprint) - = form_for :post, Routes.forum_topic_post_hide_path(@conn, :create, @post.topic.forum, @post.topic, @post), [class: "togglable-delete-form hidden flex", id: "inline-del-form-post-#{@post.id}"], fn f -> + = form_for :post, ~p"/forums/#{@post.topic.forum}/topics/#{@post.topic}/posts/#{@post}/hide", [class: "togglable-delete-form hidden flex", id: "inline-del-form-post-#{@post.id}"], fn f -> = text_input f, :deletion_reason, class: "input input--wide", placeholder: "Deletion Reason", id: "inline-del-reason-post-#{@post.id}", required: true = submit "Delete", class: "button" diff --git a/lib/philomena_web/templates/post/_post_options.html.slime b/lib/philomena_web/templates/post/_post_options.html.slime index bd9aaf43..bb135395 100644 --- a/lib/philomena_web/templates/post/_post_options.html.slime +++ b/lib/philomena_web/templates/post/_post_options.html.slime @@ -1,9 +1,9 @@ div - - link_path = Routes.forum_topic_path(@conn, :show, @post.topic.forum, @post.topic, post_id: @post.id) <> "#post_#{@post.id}" + - link_path = ~p"/forums/#{@post.topic.forum}/topics/#{@post.topic}?#{[post_id: @post.id]}" <> "#post_#{@post.id}" - safe_author = markdown_safe_author(@post) - quote_body = if @post.hidden_from_users, do: "", else: @post.body - a.communication__interaction href=Routes.forum_topic_post_report_path(@conn, :new, @post.topic.forum, @post.topic, @post) + a.communication__interaction href=~p"/forums/#{@post.topic.forum}/topics/#{@post.topic}/posts/#{@post}/reports/new" i.fa.fa-flag> ' Report @@ -18,6 +18,6 @@ div = if can?(@conn, :edit, @post) do span.owner-options strong - a.communication__interaction href=Routes.forum_topic_post_path(@conn, :edit, @post.topic.forum, @post.topic, @post) + a.communication__interaction href=~p"/forums/#{@post.topic.forum}/topics/#{@post.topic}/posts/#{@post}/edit" i.fas.fa-edit> ' Edit diff --git a/lib/philomena_web/templates/post/index.html.slime b/lib/philomena_web/templates/post/index.html.slime index f0d9dcd4..c4f00f9c 100644 --- a/lib/philomena_web/templates/post/index.html.slime +++ b/lib/philomena_web/templates/post/index.html.slime @@ -1,6 +1,6 @@ h1 Posts -= form_for :posts, Routes.post_path(@conn, :index), [method: "get", class: "hform", enforce_utf8: false], fn f -> += form_for :posts, ~p"/posts", [method: "get", class: "hform", enforce_utf8: false], fn f -> .field = text_input f, :pq, name: :pq, value: @conn.params["pq"], class: "input hform__text", placeholder: "Search posts", autocapitalize: "none" = submit "Search", class: "hform__button button" @@ -14,17 +14,17 @@ h2 Search Results = cond do - Enum.any?(@posts) -> - - route = fn p -> Routes.post_path(@conn, :index, p) end + - route = fn p -> ~p"/posts?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @posts, route: route, params: [pq: @conn.params["pq"]], conn: @conn = for {body, post} <- @posts, post.topic.hidden_from_users == false do div h3 - =<> link post.topic.forum.name, to: Routes.forum_path(@conn, :show, post.topic.forum) + =<> link post.topic.forum.name, to: ~p"/forums/#{post.topic.forum}" | » - =<> link post.topic.title, to: Routes.forum_topic_path(@conn, :show, post.topic.forum, post.topic) + =<> link post.topic.title, to: ~p"/forums/#{post.topic.forum}/topics/#{post.topic}" | » - - post_link = Routes.forum_topic_path(@conn, :show, post.topic.forum, post.topic, post_id: post.id) <> "#post_#{post.id}" + - post_link = ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post.id]}" <> "#post_#{post.id}" = if post.topic_position == 0 do =<> link "Topic Opener", to: post_link - else @@ -79,28 +79,28 @@ table.table td Literal td Matches the author of this post. Anonymous authors will never match this term. td - code = link "author:Joey", to: Routes.post_path(@conn, :index, pq: "author:Joey") + code = link "author:Joey", to: ~p"/posts?#{[pq: "author:Joey"]}" tr td code body td Full Text td Matches the body of this post. This is the default field. td - code = link "body:test", to: Routes.post_path(@conn, :index, pq: "body:test") + code = link "body:test", to: ~p"/posts?#{[pq: "body:test"]}" tr td code created_at td Date/Time Range td Matches the creation time of this post. td - code = link "created_at:2015", to: Routes.post_path(@conn, :index, pq: "created_at:2015") + code = link "created_at:2015", to: ~p"/posts?#{[pq: "created_at:2015"]}" tr td code id td Numeric Range td Matches the numeric surrogate key for this post. td - code = link "id:1000000", to: Routes.post_path(@conn, :index, pq: "id:1000000") + code = link "id:1000000", to: ~p"/posts?#{[pq: "id:1000000"]}" tr td code my @@ -109,46 +109,46 @@ table.table code> my:posts ' matches posts you have posted if you are signed in. td - code = link "my:posts", to: Routes.post_path(@conn, :index, pq: "my:posts") + code = link "my:posts", to: ~p"/posts?#{[pq: "my:posts"]}" tr td code subject td Full Text td Matches the title of the topic. td - code = link "subject:time wasting thread", to: Routes.post_path(@conn, :index, pq: "subject:time wasting thread") + code = link "subject:time wasting thread", to: ~p"/posts?#{[pq: "subject:time wasting thread"]}" tr td code topic_id td Literal td Matches the numeric surrogate key for the topic this post belongs to. td - code = link "topic_id:7000", to: Routes.post_path(@conn, :index, pq: "topic_id:7000") + code = link "topic_id:7000", to: ~p"/posts?#{[pq: "topic_id:7000"]}" tr td code topic_position td Numeric Range td Matches the offset from the beginning of the topic of this post. Positions begin at 0. td - code = link "topic_position:0", to: Routes.post_path(@conn, :index, pq: "topic_position:0") + code = link "topic_position:0", to: ~p"/posts?#{[pq: "topic_position:0"]}" tr td code updated_at td Date/Time Range td Matches the creation or last edit time of this post. td - code = link "updated_at.gte:2 weeks ago", to: Routes.post_path(@conn, :index, pq: "updated_at.gte:2 weeks ago") + code = link "updated_at.gte:2 weeks ago", to: ~p"/posts?#{[pq: "updated_at.gte:2 weeks ago"]}" tr td code user_id td Literal td Matches posts with the specified user_id. Anonymous users will never match this term. td - code = link "user_id:211190", to: Routes.post_path(@conn, :index, pq: "user_id:211190") + code = link "user_id:211190", to: ~p"/posts?#{[pq: "user_id:211190"]}" tr td code forum td Literal td Matches the short name for the forum this post belongs to. td - code = link "forum:meta", to: Routes.post_path(@conn, :index, pq: "forum:meta") + code = link "forum:meta", to: ~p"/posts?#{[pq: "forum:meta"]}" diff --git a/lib/philomena_web/templates/profile/_about_me.html.slime b/lib/philomena_web/templates/profile/_about_me.html.slime index 55e5d732..345e2b2c 100644 --- a/lib/philomena_web/templates/profile/_about_me.html.slime +++ b/lib/philomena_web/templates/profile/_about_me.html.slime @@ -8,6 +8,6 @@ = if can?(@conn, :edit_description, @user) do = if @user.description not in [nil, ""] do hr.separator.separator--secondary - a.button href=Routes.profile_description_path(@conn, :edit, @user) + a.button href=~p"/profiles/#{@user}/description/edit" i.fa.fa-edit> | Edit diff --git a/lib/philomena_web/templates/profile/_admin_block.html.slime b/lib/philomena_web/templates/profile/_admin_block.html.slime index 565fa33b..88eb5b82 100644 --- a/lib/philomena_web/templates/profile/_admin_block.html.slime +++ b/lib/philomena_web/templates/profile/_admin_block.html.slime @@ -11,7 +11,7 @@ i.fa.icon--padded.small.fa-filter> ' Current Filter: = if @filter do - = link @filter.name, to: Routes.filter_path(@conn, :show, @filter) + = link @filter.name, to: ~p"/filters/#{@filter}" - else em ' (none) @@ -56,121 +56,121 @@ .profile-top__options.js-admin__options__toggle.hidden ul.profile-admin__options__column li - = link to: Routes.profile_detail_path(@conn, :index, @user) do + = link to: ~p"/profiles/#{@user}/details" do i.fa.icon--padded.small.fa-eye span.admin__button View Details li - = link to: Routes.search_path(@conn, :index, q: "upvoted_by_id:#{@user.id}") do + = link to: ~p"/search?#{[q: "upvoted_by_id:#{@user.id}"]}" do i.fa.icon--padded.small.fa-arrow-up span.admin__button Upvotes li - = link to: Routes.search_path(@conn, :index, q: "downvoted_by_id:#{@user.id}") do + = link to: ~p"/search?#{[q: "downvoted_by_id:#{@user.id}"]}" do i.fa.icon--padded.small.fa-arrow-down span.admin__button Downvotes li - = link to: Routes.search_path(@conn, :index, q: "hidden_by_id:#{@user.id}") do + = link to: ~p"/search?#{[q: "hidden_by_id:#{@user.id}"]}" do i.fa.icon--padded.small.fa-eye-slash span.admin__button Hidden Images li - = link to: Routes.admin_report_path(@conn, :index, rq: "user_id:#{@user.id}") do + = link to: ~p"/admin/reports?#{[rq: "user_id:#{@user.id}"]}" do i.fa.icon--padded.small.fa-exclamation span.admin__button Reports li - = link to: Routes.profile_ip_history_path(@conn, :index, @user) do + = link to: ~p"/profiles/#{@user}/ip_history" do i.fab.icon--padded.small.fa-internet-explorer span.admin__button IP History li - = link to: Routes.profile_fp_history_path(@conn, :index, @user) do + = link to: ~p"/profiles/#{@user}/fp_history" do i.fa.icon--padded.small.fa-desktop span.admin__button FP History li - = link to: Routes.profile_alias_path(@conn, :index, @user) do + = link to: ~p"/profiles/#{@user}/aliases" do i.fa.icon--padded.small.fa-users span.admin__button Potential Aliases = if can?(@conn, :index, %Philomena.Donations.Donation{}) do li - = link to: Routes.admin_donation_user_path(@conn, :show, @user) do + = link to: ~p"/admin/donations/user/#{@user}" do i.fas.icon--padded.small.fa-dollar-sign span.admin__button Donations ul.profile-admin__options__column = if can?(@conn, :edit, @user) do li - = link to: Routes.admin_user_path(@conn, :edit, @user) do + = link to: ~p"/admin/users/#{@user}/edit" do i.fas.icon--padded.small.fa-edit span.admin__button Edit User li - = link to: Routes.admin_user_force_filter_path(@conn, :new, @user) do + = link to: ~p"/admin/users/#{@user}/force_filter/new" do i.fas.faw-fw.fa-filter span.admin__button Force Filter = if @forced do li - = link to: Routes.profile_detail_path(@conn, :index, @user) do + = link to: ~p"/profiles/#{@user}/details" do i.fa.icon--padded.small.fa-eye span.admin__button View Details li - = link to: Routes.search_path(@conn, :index, q: "upvoted_by_id:#{@user.id}") do + = link to: ~p"/search?#{[q: "upvoted_by_id:#{@user.id}"]}" do i.fa.icon--padded.small.fa-arrow-up span.admin__button Upvotes li - = link to: Routes.search_path(@conn, :index, q: "downvoted_by_id:#{@user.id}") do + = link to: ~p"/search?#{[q: "downvoted_by_id:#{@user.id}"]}" do i.fa.icon--padded.small.fa-arrow-down span.admin__button Downvotes li - = link to: Routes.admin_user_unlock_path(@conn, :create, @user), data: [method: "post"] do + = link to: ~p"/admin/users/#{@user}/unlock", data: [method: "post"] do i.fas.icon--padded.small.fa-unlock span.admin__button Unlock Account li - = link to: Routes.admin_user_wipe_path(@conn, :create, @user), data: [confirm: "This is irreversible, destroying all identifying information including email. Are you sure?", method: "post"] do + = link to: ~p"/admin/users/#{@user}/wipe", data: [confirm: "This is irreversible, destroying all identifying information including email. Are you sure?", method: "post"] do i.fas.icon--padded.small.fa-eraser span.admin__button Wipe PII = if can?(@conn, :edit, %Philomena.ArtistLinks.ArtistLink{}) do li - = link to: Routes.profile_artist_link_path(@conn, :new, @user) do + = link to: ~p"/profiles/#{@user}/artist_links/new" do i.fa.icon--padded.small.fa-link span.admin__button Add Artist Link li - = link to: Routes.admin_user_force_filter_path(@conn, :new, @user) do + = link to: ~p"/admin/users/#{@user}/force_filter/new" do i.fas.faw-fw.fa-filter span.admin__button Force Filter ul.profile-admin__options__column = if can?(@conn, :index, Philomena.Users.User) do li - = link to: Routes.admin_user_api_key_path(@conn, :delete, @user), data: [confirm: "Are you really, really sure?", method: "delete"] do + = link to: ~p"/admin/users/#{@user}/api_key", data: [confirm: "Are you really, really sure?", method: "delete"] do i.fas.icon--padded.small.fa-key span.admin__button Reset API key li = if @user.verified do - = link to: Routes.admin_user_verification_path(@conn, :delete, @user), data: [confirm: "Are you really, really sure?", method: "delete"] do + = link to: ~p"/admin/users/#{@user}/verification", data: [confirm: "Are you really, really sure?", method: "delete"] do i.fas.icon--padded.small.fa-user-times span.admin__button Revoke Verification - else - = link to: Routes.admin_user_verification_path(@conn, :create, @user), data: [confirm: "Are you really, really sure?", method: "create"] do + = link to: ~p"/admin/users/#{@user}/verification", data: [confirm: "Are you really, really sure?", method: "create"] do i.fas.icon--padded.small.fa-user-check span.admin__button Grant Verification ul.profile-admin__options__column = if can?(@conn, :index, Philomena.Users.User) do li - = link to: Routes.admin_user_vote_path(@conn, :delete, @user), data: [confirm: "Are you really, really sure?", method: "delete"] do + = link to: ~p"/admin/users/#{@user}/votes", data: [confirm: "Are you really, really sure?", method: "delete"] do i.far.icon--padded.small.fa-file-excel span.admin__button Remove All Votes/Faves li - = link to: Routes.admin_user_downvote_path(@conn, :delete, @user), data: [confirm: "Are you really, really sure?", method: "delete"] do + = link to: ~p"/admin/users/#{@user}/downvotes", data: [confirm: "Are you really, really sure?", method: "delete"] do i.fa.icon--padded.small.fa-arrow-down span.admin__button Remove All Downvotes = if @user.role == "user" and can?(@conn, :revert, Philomena.TagChanges.TagChange) do li - = link to: Routes.tag_change_full_revert_path(@conn, :create, [user_id: @user.id]), data: [confirm: "Are you really, really sure?", method: "create"] do + = link to: ~p"/tag_changes/full_revert?#{[user_id: @user.id]}", data: [confirm: "Are you really, really sure?", method: "create"] do i.fa.icon--padded.small.fa-tag span.admin__button Revert All Tag Changes diff --git a/lib/philomena_web/templates/profile/_commission.html.slime b/lib/philomena_web/templates/profile/_commission.html.slime index db8e8d46..be102740 100644 --- a/lib/philomena_web/templates/profile/_commission.html.slime +++ b/lib/philomena_web/templates/profile/_commission.html.slime @@ -21,18 +21,18 @@ br br - = link "More information", to: Routes.profile_commission_path(@conn, :show, @user) + = link "More information", to: ~p"/profiles/#{@user}/commission" - current?(@user, @conn.assigns.current_user) -> = if Enum.any?(@conn.assigns.user.verified_links) do em ' You don't have any commission information listed yet. - => link "Click here", to: Routes.profile_commission_path(@conn, :new, @user) + => link "Click here", to: ~p"/profiles/#{@user}/commission/new" ' to set it up. - else em ' You must have a verified Artist Link to create a commission page. - => link "Click here", to: Routes.profile_artist_link_path(@conn, :new, @user) + => link "Click here", to: ~p"/profiles/#{@user}/artist_links/new" ' to set one up. - true -> diff --git a/lib/philomena_web/templates/profile/_recent_comments.html.slime b/lib/philomena_web/templates/profile/_recent_comments.html.slime index 9f18fe0e..d1567483 100644 --- a/lib/philomena_web/templates/profile/_recent_comments.html.slime +++ b/lib/philomena_web/templates/profile/_recent_comments.html.slime @@ -2,7 +2,7 @@ .block .block__header span Recent Comments - = link "View all", to: Routes.comment_path(@conn, :index, cq: "user_id:#{@user.id}") + = link "View all", to: ~p"/comments?#{[cq: "user_id:#{@user.id}"]}" .block__content = for {body, comment} <- @comments, can?(@conn, :show, comment.image) do diff --git a/lib/philomena_web/templates/profile/_recent_galleries.html.slime b/lib/philomena_web/templates/profile/_recent_galleries.html.slime index cbd25cff..c70e1aba 100644 --- a/lib/philomena_web/templates/profile/_recent_galleries.html.slime +++ b/lib/philomena_web/templates/profile/_recent_galleries.html.slime @@ -2,7 +2,7 @@ .block .block__header span Recent Galleries - = link "View all", to: Routes.gallery_path(@conn, :index, gallery: [creator: @user.name]) + = link "View all", to: ~p"/galleries?#{[gallery: [creator: @user.name]]}" .media-list = for gallery <- @galleries do diff --git a/lib/philomena_web/templates/profile/_recent_posts.html.slime b/lib/philomena_web/templates/profile/_recent_posts.html.slime index 3d2db240..5670fb2f 100644 --- a/lib/philomena_web/templates/profile/_recent_posts.html.slime +++ b/lib/philomena_web/templates/profile/_recent_posts.html.slime @@ -9,10 +9,10 @@ = for post <- @posts do .block__content.alternating-color ' Post - => link pretty_time(post.created_at), to: Routes.forum_topic_path(@conn, :show, post.topic.forum, post.topic, post_id: post) <> "#post_#{post.id}" + => link pretty_time(post.created_at), to: ~p"/forums/#{post.topic.forum}/topics/#{post.topic}?#{[post_id: post]}" <> "#post_#{post.id}" ' in topic - => link post.topic.title, to: Routes.forum_topic_path(@conn, :show, post.topic.forum, post.topic) + => link post.topic.title, to: ~p"/forums/#{post.topic.forum}/topics/#{post.topic}" hr.separator.separator--secondary - a.button href=Routes.post_path(@conn, :index, pq: "user_id:#{@user.id}") + a.button href=~p"/posts?#{[pq: "user_id:#{@user.id}"]}" i.fa.fa-eye> | View all diff --git a/lib/philomena_web/templates/profile/alias/_aliases.html.slime b/lib/philomena_web/templates/profile/alias/_aliases.html.slime index 53913aad..38030e40 100644 --- a/lib/philomena_web/templates/profile/alias/_aliases.html.slime +++ b/lib/philomena_web/templates/profile/alias/_aliases.html.slime @@ -1,7 +1,7 @@ = for u <- @aliases do tr td - = link u.name, to: Routes.profile_path(@conn, :show, u) + = link u.name, to: ~p"/profiles/#{u}" td = @type diff --git a/lib/philomena_web/templates/profile/artist_link/edit.html.slime b/lib/philomena_web/templates/profile/artist_link/edit.html.slime index 7c643cf4..c03ff454 100644 --- a/lib/philomena_web/templates/profile/artist_link/edit.html.slime +++ b/lib/philomena_web/templates/profile/artist_link/edit.html.slime @@ -1,2 +1,2 @@ h1 Edit Link -= render PhilomenaWeb.Profile.ArtistLinkView, "_form.html", conn: @conn, changeset: @changeset, tag_name: tag_name(@artist_link), action: Routes.profile_artist_link_path(@conn, :update, @artist_link.user, @artist_link) += render PhilomenaWeb.Profile.ArtistLinkView, "_form.html", conn: @conn, changeset: @changeset, tag_name: tag_name(@artist_link), action: ~p"/profiles/#{@artist_link.user}/artist_links/#{@artist_link}" diff --git a/lib/philomena_web/templates/profile/artist_link/index.html.slime b/lib/philomena_web/templates/profile/artist_link/index.html.slime index d85ac540..b8e21076 100644 --- a/lib/philomena_web/templates/profile/artist_link/index.html.slime +++ b/lib/philomena_web/templates/profile/artist_link/index.html.slime @@ -1,6 +1,6 @@ h1 Artist Links p - a.button href=Routes.profile_artist_link_path(@conn, :new, @user) + a.button href=~p"/profiles/#{@user}/artist_links/new" ' Request a link p ' Artist links associate your account on @@ -19,7 +19,7 @@ table.table = for link <- @artist_links do tr td = link link.uri, to: link.uri - td = link "View Details", to: Routes.profile_artist_link_path(@conn, :show, @user, link) + td = link "View Details", to: ~p"/profiles/#{@user}/artist_links/#{link}" td = link.verification_code th = verified_as_string(link) th = public_as_string(link) diff --git a/lib/philomena_web/templates/profile/artist_link/new.html.slime b/lib/philomena_web/templates/profile/artist_link/new.html.slime index 762d9be9..a2566378 100644 --- a/lib/philomena_web/templates/profile/artist_link/new.html.slime +++ b/lib/philomena_web/templates/profile/artist_link/new.html.slime @@ -1,2 +1,2 @@ h1 Request Artist Link -= render PhilomenaWeb.Profile.ArtistLinkView, "_form.html", changeset: @changeset, action: Routes.profile_artist_link_path(@conn, :create, @user), conn: @conn += render PhilomenaWeb.Profile.ArtistLinkView, "_form.html", changeset: @changeset, action: ~p"/profiles/#{@user}/artist_links", conn: @conn diff --git a/lib/philomena_web/templates/profile/artist_link/show.html.slime b/lib/philomena_web/templates/profile/artist_link/show.html.slime index d38133d4..73aedd3f 100644 --- a/lib/philomena_web/templates/profile/artist_link/show.html.slime +++ b/lib/philomena_web/templates/profile/artist_link/show.html.slime @@ -54,16 +54,16 @@ h3 Associated tag = if can?(@conn, :index, Philomena.ArtistLinks.ArtistLink) do p - => link "Edit", to: Routes.profile_artist_link_path(@conn, :edit, @user, @artist_link) + => link "Edit", to: ~p"/profiles/#{@user}/artist_links/#{@artist_link}/edit" ' • - => link "Verify", to: Routes.admin_artist_link_verification_path(@conn, :create, @artist_link), method: :post + => link "Verify", to: ~p"/admin/artist_links/#{@artist_link}/verification", method: :post ' • - => link "Reject", to: Routes.admin_artist_link_reject_path(@conn, :create, @artist_link), method: :post + => link "Reject", to: ~p"/admin/artist_links/#{@artist_link}/reject", method: :post = if not verified?(@artist_link) do ' • = if contacted?(@artist_link) do ' Artist contacted - else - = link "Artist contacted", to: Routes.admin_artist_link_contact_path(@conn, :create, @artist_link), method: :post + = link "Artist contacted", to: ~p"/admin/artist_links/#{@artist_link}/contact", method: :post -= link "Back", to: Routes.profile_artist_link_path(@conn, :index, @user) += link "Back", to: ~p"/profiles/#{@user}/artist_links" diff --git a/lib/philomena_web/templates/profile/award/edit.html.slime b/lib/philomena_web/templates/profile/award/edit.html.slime index 0216955e..94a5f3b6 100644 --- a/lib/philomena_web/templates/profile/award/edit.html.slime +++ b/lib/philomena_web/templates/profile/award/edit.html.slime @@ -1,3 +1,3 @@ h1 Editing award -= render PhilomenaWeb.Profile.AwardView, "_form.html", changeset: @changeset, badges: @badges, action: Routes.profile_award_path(@conn, :update, @user, @award), conn: @conn += render PhilomenaWeb.Profile.AwardView, "_form.html", changeset: @changeset, badges: @badges, action: ~p"/profiles/#{@user}/awards/#{@award}", conn: @conn diff --git a/lib/philomena_web/templates/profile/award/new.html.slime b/lib/philomena_web/templates/profile/award/new.html.slime index 489bc93e..525e06cf 100644 --- a/lib/philomena_web/templates/profile/award/new.html.slime +++ b/lib/philomena_web/templates/profile/award/new.html.slime @@ -1,3 +1,3 @@ h1 New award -= render PhilomenaWeb.Profile.AwardView, "_form.html", changeset: @changeset, badges: @badges, action: Routes.profile_award_path(@conn, :create, @user), conn: @conn += render PhilomenaWeb.Profile.AwardView, "_form.html", changeset: @changeset, badges: @badges, action: ~p"/profiles/#{@user}/awards", conn: @conn diff --git a/lib/philomena_web/templates/profile/commission/_listing_items.html.slime b/lib/philomena_web/templates/profile/commission/_listing_items.html.slime index dfb66ae1..15502ebb 100644 --- a/lib/philomena_web/templates/profile/commission/_listing_items.html.slime +++ b/lib/philomena_web/templates/profile/commission/_listing_items.html.slime @@ -3,7 +3,7 @@ span Available Items and Prices = if current?(@user, @conn.assigns.current_user) do - = link "Add an item", to: Routes.profile_commission_item_path(@conn, :new, @user) + = link "Add an item", to: ~p"/profiles/#{@user}/commission/items/new" .block__content @@ -12,7 +12,7 @@ p You have not added any items to your commissions sheet yet. p ' Your listing will not appear in search results until you - = link "list at least one item", to: Routes.profile_commission_item_path(@conn, :new, @user) + = link "list at least one item", to: ~p"/profiles/#{@user}/commission/items/new" ' . - else p This artist has not added any items yet. Please check back later. @@ -52,7 +52,7 @@ = if can?(@conn, :edit, @commission) do td - = link "Edit item", to: Routes.profile_commission_item_path(@conn, :edit, @user, item) + = link "Edit item", to: ~p"/profiles/#{@user}/commission/items/#{item}/edit" br br - = link "Delete item", to: Routes.profile_commission_item_path(@conn, :delete, @user, item), data: [confirm: "Are you really, really sure?", method: "delete"] + = link "Delete item", to: ~p"/profiles/#{@user}/commission/items/#{item}", data: [confirm: "Are you really, really sure?", method: "delete"] diff --git a/lib/philomena_web/templates/profile/commission/_listing_sidebar.html.slime b/lib/philomena_web/templates/profile/commission/_listing_sidebar.html.slime index 545d31e2..6c0d81fe 100644 --- a/lib/philomena_web/templates/profile/commission/_listing_sidebar.html.slime +++ b/lib/philomena_web/templates/profile/commission/_listing_sidebar.html.slime @@ -71,18 +71,18 @@ span Options .block__content = if can?(@conn, :edit, @commission) do - = link "Edit this listing", to: Routes.profile_commission_path(@conn, :edit, @user) + = link "Edit this listing", to: ~p"/profiles/#{@user}/commission/edit" br - = link "Delete this listing", to: Routes.profile_commission_path(@conn, :delete, @user), data: [confirm: "Are you really, really sure about that?", method: "delete"] + = link "Delete this listing", to: ~p"/profiles/#{@user}/commission", data: [confirm: "Are you really, really sure about that?", method: "delete"] br - = link "Report this listing", to: Routes.profile_commission_report_path(@conn, :new, @user) + = link "Report this listing", to: ~p"/profiles/#{@user}/commission/reports/new" / Share block .block .block__header span Share this listing .block__content - - url = Routes.profile_commission_url(@conn, :show, @user) + - url = url(~p"/profiles/#{@user}/commission") .field label> for="commission_url" URL diff --git a/lib/philomena_web/templates/profile/commission/edit.html.slime b/lib/philomena_web/templates/profile/commission/edit.html.slime index aa6bab71..514d03f0 100644 --- a/lib/philomena_web/templates/profile/commission/edit.html.slime +++ b/lib/philomena_web/templates/profile/commission/edit.html.slime @@ -1,5 +1,5 @@ h1 Edit Commission Listing p - = link "Back to commission", to: Routes.profile_commission_path(@conn, :show, @user) + = link "Back to commission", to: ~p"/profiles/#{@user}/commission" -= render PhilomenaWeb.Profile.CommissionView, "_form.html", changeset: @changeset, action: Routes.profile_commission_path(@conn, :update, @user), conn: @conn \ No newline at end of file += render PhilomenaWeb.Profile.CommissionView, "_form.html", changeset: @changeset, action: ~p"/profiles/#{@user}/commission", conn: @conn \ No newline at end of file diff --git a/lib/philomena_web/templates/profile/commission/item/edit.html.slime b/lib/philomena_web/templates/profile/commission/item/edit.html.slime index cb8124be..46d4e28b 100644 --- a/lib/philomena_web/templates/profile/commission/item/edit.html.slime +++ b/lib/philomena_web/templates/profile/commission/item/edit.html.slime @@ -1,5 +1,5 @@ h1 Edit Item on Listing p - = link "Back to listing", to: Routes.profile_commission_path(@conn, :show, @user) + = link "Back to listing", to: ~p"/profiles/#{@user}/commission" -= render PhilomenaWeb.Profile.Commission.ItemView, "_form.html", conn: @conn, changeset: @changeset, action: Routes.profile_commission_item_path(@conn, :update, @user, @item) += render PhilomenaWeb.Profile.Commission.ItemView, "_form.html", conn: @conn, changeset: @changeset, action: ~p"/profiles/#{@user}/commission/items/#{@item}" diff --git a/lib/philomena_web/templates/profile/commission/item/new.html.slime b/lib/philomena_web/templates/profile/commission/item/new.html.slime index b2a75690..6897a066 100644 --- a/lib/philomena_web/templates/profile/commission/item/new.html.slime +++ b/lib/philomena_web/templates/profile/commission/item/new.html.slime @@ -1,5 +1,5 @@ h1 New Item on Listing p - = link "Back to listing", to: Routes.profile_commission_path(@conn, :show, @user) + = link "Back to listing", to: ~p"/profiles/#{@user}/commission" -= render PhilomenaWeb.Profile.Commission.ItemView, "_form.html", conn: @conn, changeset: @changeset, action: Routes.profile_commission_item_path(@conn, :create, @user) += render PhilomenaWeb.Profile.Commission.ItemView, "_form.html", conn: @conn, changeset: @changeset, action: ~p"/profiles/#{@user}/commission/items" diff --git a/lib/philomena_web/templates/profile/commission/new.html.slime b/lib/philomena_web/templates/profile/commission/new.html.slime index 98653d8d..0e08e263 100644 --- a/lib/philomena_web/templates/profile/commission/new.html.slime +++ b/lib/philomena_web/templates/profile/commission/new.html.slime @@ -1,5 +1,5 @@ h1 New Commission Listing p - = link "Back to index", to: Routes.commission_path(@conn, :index) + = link "Back to index", to: ~p"/commissions" -= render PhilomenaWeb.Profile.CommissionView, "_form.html", changeset: @changeset, action: Routes.profile_commission_path(@conn, :create, @user), conn: @conn \ No newline at end of file += render PhilomenaWeb.Profile.CommissionView, "_form.html", changeset: @changeset, action: ~p"/profiles/#{@user}/commission", conn: @conn \ No newline at end of file diff --git a/lib/philomena_web/templates/profile/description/edit.html.slime b/lib/philomena_web/templates/profile/description/edit.html.slime index 9e5cddb7..5174098c 100644 --- a/lib/philomena_web/templates/profile/description/edit.html.slime +++ b/lib/philomena_web/templates/profile/description/edit.html.slime @@ -1,6 +1,6 @@ h1 Updating Profile Description -= form_for @changeset, Routes.profile_description_path(@conn, :update, @user), [method: "put"], fn f -> += form_for @changeset, ~p"/profiles/#{@user}/description", [method: "put"], fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/profile/detail/index.html.slime b/lib/philomena_web/templates/profile/detail/index.html.slime index 2384a855..7d51cdfc 100644 --- a/lib/philomena_web/templates/profile/detail/index.html.slime +++ b/lib/philomena_web/templates/profile/detail/index.html.slime @@ -1,10 +1,10 @@ h2 - = link @user.name, to: Routes.profile_path(@conn, :show, @user) + = link @user.name, to: ~p"/profiles/#{@user}" | 's User Details h4 Mod Notes = render PhilomenaWeb.Admin.ModNoteView, "_table.html", mod_notes: @mod_notes, conn: @conn -= link "Add New Note", to: Routes.admin_mod_note_path(@conn, :new, notable_id: @user.id, notable_type: "User") += link "Add New Note", to: ~p"/admin/mod_notes/new?#{[notable_id: @user.id, notable_type: "User"]}" h4 Name History table.table @@ -20,6 +20,6 @@ table.table h4 More Details ul - li = link "IP Address Usage History", to: Routes.profile_ip_history_path(@conn, :index, @user) - li = link "Fingerprint Usage History", to: Routes.profile_fp_history_path(@conn, :index, @user) - li = link "Potential Aliases", to: Routes.profile_alias_path(@conn, :index, @user) + li = link "IP Address Usage History", to: ~p"/profiles/#{@user}/ip_history" + li = link "Fingerprint Usage History", to: ~p"/profiles/#{@user}/fp_history" + li = link "Potential Aliases", to: ~p"/profiles/#{@user}/aliases" diff --git a/lib/philomena_web/templates/profile/fp_history/index.html.slime b/lib/philomena_web/templates/profile/fp_history/index.html.slime index b67a9e3c..182c30c5 100644 --- a/lib/philomena_web/templates/profile/fp_history/index.html.slime +++ b/lib/philomena_web/templates/profile/fp_history/index.html.slime @@ -10,7 +10,7 @@ ul ul = for u <- @other_users[ufp.fingerprint] do li - => link u.user.name, to: Routes.profile_path(@conn, :show, u.user) + => link u.user.name, to: ~p"/profiles/#{u.user}" | ( => u.uses ' uses, last used diff --git a/lib/philomena_web/templates/profile/ip_history/index.html.slime b/lib/philomena_web/templates/profile/ip_history/index.html.slime index 3d494d78..d5ffc0ff 100644 --- a/lib/philomena_web/templates/profile/ip_history/index.html.slime +++ b/lib/philomena_web/templates/profile/ip_history/index.html.slime @@ -10,7 +10,7 @@ ul ul = for u <- @other_users[uip.ip] do li - => link u.user.name, to: Routes.profile_path(@conn, :show, u.user) + => link u.user.name, to: ~p"/profiles/#{u.user}" | ( => u.uses ' uses, last used diff --git a/lib/philomena_web/templates/profile/scratchpad/edit.html.slime b/lib/philomena_web/templates/profile/scratchpad/edit.html.slime index a1eca8f5..fd1fea17 100644 --- a/lib/philomena_web/templates/profile/scratchpad/edit.html.slime +++ b/lib/philomena_web/templates/profile/scratchpad/edit.html.slime @@ -1,6 +1,6 @@ h1 Updating Moderation Scratchpad -= form_for @changeset, Routes.profile_scratchpad_path(@conn, :update, @user), [method: "put"], fn f -> += form_for @changeset, ~p"/profiles/#{@user}/scratchpad", [method: "put"], fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/profile/show.html.slime b/lib/philomena_web/templates/profile/show.html.slime index 4157abb3..81f68c3c 100644 --- a/lib/philomena_web/templates/profile/show.html.slime +++ b/lib/philomena_web/templates/profile/show.html.slime @@ -2,7 +2,7 @@ .profile-top__avatar - avatar = render PhilomenaWeb.UserAttributionView, "_user_avatar.html", object: %{user: @user}, class: "avatar--large" = if current?(@user, @conn.assigns.current_user) do - = link avatar, to: Routes.avatar_path(@conn, :edit, profile: true), title: "Change avatar" + = link avatar, to: ~p"/avatar/edit?#{[profile: true]}", title: "Change avatar" - else = avatar .profile-top__name-and-links @@ -14,7 +14,7 @@ br = if can?(@conn, :edit_description, @user) do - = link "Edit Personal Title", to: Routes.profile_description_path(@conn, :edit, @user) + = link "Edit Personal Title", to: ~p"/profiles/#{@user}/description/edit" br span @@ -23,21 +23,21 @@ .profile-top__options ul.profile-top__options__column - li = link("Send message", to: Routes.conversation_path(@conn, :new, recipient: @user.name)) - li = link("Our conversations", to: Routes.conversation_path(@conn, :index, with: @user.id)) - li = link("Report this user", to: Routes.profile_report_path(@conn, :new, @user)) + li = link("Send message", to: ~p"/conversations/new?#{[recipient: @user.name]}") + li = link("Our conversations", to: ~p"/conversations?#{[with: @user.id]}") + li = link("Report this user", to: ~p"/profiles/#{@user}/reports/new") ul.profile-top__options__column - li = link("Uploads", to: Routes.search_path(@conn, :index, q: "uploader_id:#{@user.id}")) - li = link("Comments", to: Routes.comment_path(@conn, :index, cq: "user_id:#{@user.id}")) - li = link("Posts", to: Routes.post_path(@conn, :index, pq: "user_id:#{@user.id}")) + li = link("Uploads", to: ~p"/search?#{[q: "uploader_id:#{@user.id}"]}") + li = link("Comments", to: ~p"/comments?#{[cq: "user_id:#{@user.id}"]}") + li = link("Posts", to: ~p"/posts?#{[pq: "user_id:#{@user.id}"]}") = if current?(@user, @conn.assigns.current_user) do - li = link "My reports", to: Routes.report_path(@conn, :index) + li = link "My reports", to: ~p"/reports" ul.profile-top__options__column - li = link("Favorites", to: Routes.search_path(@conn, :index, q: "faved_by_id:#{@user.id}")) - li = link("Tag changes", to: Routes.profile_tag_change_path(@conn, :index, @user)) - li = link("Source changes", to: Routes.profile_source_change_path(@conn, :index, @user)) + li = link("Favorites", to: ~p"/search?#{[q: "faved_by_id:#{@user.id}"]}") + li = link("Tag changes", to: ~p"/profiles/#{@user}/tag_changes") + li = link("Source changes", to: ~p"/profiles/#{@user}/source_changes") = if can_index_user?(@conn) do .js-staff-action @@ -47,7 +47,7 @@ .block i.fa.icon--padded.small.fa-filter> strong.comment_deleted> Forced Filter: - = link @forced.name, to: Routes.filter_path(@conn, :show, @forced) + = link @forced.name, to: ~p"/filters/#{@forced}" = if (current?(@user, @conn.assigns.current_user) or can?(@conn, :index, Philomena.Bans.User)) and Enum.any?(@bans) do .block.block--warning @@ -92,10 +92,10 @@ - else ' Hidden ' • - a href=Routes.profile_artist_link_path(@conn, :edit, @user, link) + a href=~p"/profiles/#{@user}/artist_links/#{link}/edit" ' Edit ' • - a href=Routes.admin_artist_link_reject_path(@conn, :create, link) data-method="post" + a href=~p"/admin/artist_links/#{link}/reject" data-method="post" ' Reject - else => unless link.public do @@ -104,7 +104,7 @@ = if current?(@user, @conn.assigns.current_user) or manages_links?(@conn, @user) do .block__content.alternating-color.break-word - a.button href=Routes.profile_artist_link_path(@conn, :new, @user) + a.button href=~p"/profiles/#{@user}/artist_links/new" i.fa.fa-link> | Create an Artist Link .block @@ -120,18 +120,18 @@ .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 - a href=Routes.profile_award_path(@conn, :delete, @user, award) data-method="delete" data-confirm="Are you really, really sure?" + a href=~p"/profiles/#{@user}/awards/#{award}" data-method="delete" data-confirm="Are you really, really sure?" ' Remove br - a href=Routes.profile_award_path(@conn, :edit, @user, award) + a href=~p"/profiles/#{@user}/awards/#{award}/edit" ' Edit = if manages_awards?(@conn) and not hide_staff_tools?(@conn) do .block__content.alternating-color.no-overflow - a.button href=Routes.profile_award_path(@conn, :new, @user) + a.button href=~p"/profiles/#{@user}/awards/new" i.fa.fa-trophy> | Award a badge @@ -158,7 +158,7 @@ td = body td = pretty_time(mod_note.created_at) .block__content - a.button href=Routes.profile_detail_path(@conn, :index, @user) + a.button href=~p"/profiles/#{@user}/details" i.fa.fa-plus> | Edit mod notes = if can_index_user?(@conn) do @@ -169,15 +169,15 @@ .block__content.profile-about = @scratchpad .block__content - a.button href=Routes.profile_scratchpad_path(@conn, :edit, @user) + a.button href=~p"/profiles/#{@user}/scratchpad/edit" i.fa.fa-edit> | Edit .column-layout__main = render PhilomenaWeb.ProfileView, "_statistics.html", user: @user, statistics: @statistics, conn: @conn - = render PhilomenaWeb.ProfileView, "_recent_images.html", title: "Recent Artwork", images: @recent_artwork, view_all_path: Routes.search_path(@conn, :index, q: tag_disjunction(@tags)), conn: @conn - = render PhilomenaWeb.ProfileView, "_recent_images.html", title: "Recent Uploads", images: @recent_uploads, view_all_path: Routes.search_path(@conn, :index, q: "uploader_id:#{@user.id}"), conn: @conn - = render PhilomenaWeb.ProfileView, "_recent_images.html", title: "Recent Favorites", images: @recent_faves, view_all_path: Routes.search_path(@conn, :index, q: "faved_by_id:#{@user.id}"), conn: @conn + = render PhilomenaWeb.ProfileView, "_recent_images.html", title: "Recent Artwork", images: @recent_artwork, view_all_path: ~p"/search?#{[q: tag_disjunction(@tags)]}", conn: @conn + = render PhilomenaWeb.ProfileView, "_recent_images.html", title: "Recent Uploads", images: @recent_uploads, view_all_path: ~p"/search?#{[q: "uploader_id:#{@user.id}"]}", conn: @conn + = render PhilomenaWeb.ProfileView, "_recent_images.html", title: "Recent Favorites", images: @recent_faves, view_all_path: ~p"/search?#{[q: "faved_by_id:#{@user.id}"]}", conn: @conn = render PhilomenaWeb.ProfileView, "_recent_galleries.html", galleries: @recent_galleries, user: @user, conn: @conn = render PhilomenaWeb.ProfileView, "_recent_comments.html", comments: @recent_comments, user: @user, conn: @conn = render PhilomenaWeb.ProfileView, "_recent_posts.html", posts: @recent_posts, user: @user, conn: @conn diff --git a/lib/philomena_web/templates/profile/source_change/index.html.slime b/lib/philomena_web/templates/profile/source_change/index.html.slime index 906a2820..d03fb4f5 100644 --- a/lib/philomena_web/templates/profile/source_change/index.html.slime +++ b/lib/philomena_web/templates/profile/source_change/index.html.slime @@ -1,9 +1,9 @@ h1 ' Source changes by - a href=Routes.profile_path(@conn, :show, @user) + a href=~p"/profiles/#{@user}" = @user.name -- route = fn p -> Routes.profile_source_change_path(@conn, :index, @user, p) end +- route = fn p -> ~p"/profiles/#{@user}/source_changes?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @source_changes, route: route, conn: @conn = render PhilomenaWeb.SourceChangeView, "index.html", conn: @conn, source_changes: @source_changes, pagination: pagination \ No newline at end of file diff --git a/lib/philomena_web/templates/profile/tag_change/index.html.slime b/lib/philomena_web/templates/profile/tag_change/index.html.slime index 806d843a..0cbc97dd 100644 --- a/lib/philomena_web/templates/profile/tag_change/index.html.slime +++ b/lib/philomena_web/templates/profile/tag_change/index.html.slime @@ -1,20 +1,20 @@ h1 ' Tag changes by - a href=Routes.profile_path(@conn, :show, @user) + a href=~p"/profiles/#{@user}" = @user.name -- route = fn p -> Routes.profile_tag_change_path(@conn, :index, @user, p) end +- route = fn p -> ~p"/profiles/#{@user}/tag_changes?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @tag_changes, route: route, conn: @conn, params: @pagination_params .block .block__header - = form_for @conn, Routes.profile_tag_change_path(@conn, :index, @user), [method: "get", enforce_utf8: false], fn f -> + = form_for @conn, ~p"/profiles/#{@user}/tag_changes", [method: "get", enforce_utf8: false], fn f -> = text_input f, :only_tag, class: "input", placeholder: "Tag", title: "Only show this tag", autocapitalize: "none" = submit "Search", class: "button", title: "Search" - = link "Removed", to: Routes.profile_tag_change_path(@conn, :index, @user, Keyword.merge(@pagination_params, added: 0)) - = link "Added", to: Routes.profile_tag_change_path(@conn, :index, @user, Keyword.merge(@pagination_params, added: 1)) - = link "All", to: Routes.profile_tag_change_path(@conn, :index, @user, Keyword.delete(@pagination_params, :added)) + = link "Removed", to: ~p"/profiles/#{@user}/tag_changes?#{Keyword.merge(@pagination_params, added: 0)}" + = link "Added", to: ~p"/profiles/#{@user}/tag_changes?#{Keyword.merge(@pagination_params, added: 1)}" + = link "All", to: ~p"/profiles/#{@user}/tag_changes?#{Keyword.delete(@pagination_params, :added)}" .block__header.block__header--light span.block__header__title.page__info diff --git a/lib/philomena_web/templates/registration/edit.html.slime b/lib/philomena_web/templates/registration/edit.html.slime index 88bfd1aa..a0134b6e 100644 --- a/lib/philomena_web/templates/registration/edit.html.slime +++ b/lib/philomena_web/templates/registration/edit.html.slime @@ -6,16 +6,16 @@ p p ' Looking for two factor authentication? - = link "Click here!", to: Routes.registration_totp_path(@conn, :edit) + = link "Click here!", to: ~p"/registrations/totp/edit" p ' Looking to change your avatar? - = link "Click here!", to: Routes.avatar_path(@conn, :edit) + = link "Click here!", to: ~p"/avatar/edit" = if can?(@conn, :change_username, @current_user) do p ' Looking to change your username? - = link "Click here!", to: Routes.registration_name_path(@conn, :edit) + = link "Click here!", to: ~p"/registrations/name/edit" h3 API Key p @@ -33,7 +33,7 @@ p h3 Change email -= form_for @email_changeset, Routes.registration_email_path(@conn, :create), [method: :post], fn f -> += form_for @email_changeset, ~p"/registrations/email", [method: :post], fn f -> = if @email_changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. @@ -51,7 +51,7 @@ h3 Change email h3 Change password -= form_for @password_changeset, Routes.registration_password_path(@conn, :update), fn f -> += form_for @password_changeset, ~p"/registrations/password", fn f -> = if @password_changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/registration/name/edit.html.slime b/lib/philomena_web/templates/registration/name/edit.html.slime index 529b57a1..1f9bce28 100644 --- a/lib/philomena_web/templates/registration/name/edit.html.slime +++ b/lib/philomena_web/templates/registration/name/edit.html.slime @@ -1,6 +1,6 @@ h1 Editing Name -= form_for @changeset, Routes.registration_name_path(@conn, :update), [as: :user], fn f -> += form_for @changeset, ~p"/registrations/name", [as: :user], fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. @@ -14,4 +14,4 @@ h1 Editing Name .action = submit "Save", class: "button" -p = link "Back", to: Routes.registration_path(@conn, :edit) +p = link "Back", to: ~p"/registrations/edit" diff --git a/lib/philomena_web/templates/registration/new.html.slime b/lib/philomena_web/templates/registration/new.html.slime index 99e49ab6..82d8b8d5 100644 --- a/lib/philomena_web/templates/registration/new.html.slime +++ b/lib/philomena_web/templates/registration/new.html.slime @@ -1,6 +1,6 @@ h1 Register -= form_for @changeset, Routes.registration_path(@conn, :create), fn f -> += form_for @changeset, ~p"/registrations", fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/registration/totp/edit.html.slime b/lib/philomena_web/templates/registration/totp/edit.html.slime index 9c95f2f8..8fd3028b 100644 --- a/lib/philomena_web/templates/registration/totp/edit.html.slime +++ b/lib/philomena_web/templates/registration/totp/edit.html.slime @@ -1,6 +1,6 @@ h1 Two Factor Authentication -= form_for @changeset, Routes.registration_totp_path(@conn, :update), [as: :user], fn f -> += form_for @changeset, ~p"/registrations/totp", [as: :user], fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. @@ -133,4 +133,4 @@ h1 Two Factor Authentication = submit "Save Account", class: "button" -p = link "Back", to: Routes.registration_path(@conn, :edit) +p = link "Back", to: ~p"/registrations/edit" diff --git a/lib/philomena_web/templates/report/index.html.slime b/lib/philomena_web/templates/report/index.html.slime index cbc9c191..5c25d676 100644 --- a/lib/philomena_web/templates/report/index.html.slime +++ b/lib/philomena_web/templates/report/index.html.slime @@ -2,7 +2,7 @@ h1 Your Reports .block .block__header span Reports - - route = fn p -> Routes.report_path(@conn, :index, p) end + - route = fn p -> ~p"/reports?#{p}" end = render PhilomenaWeb.PaginationView, "_pagination.html", page: @reports, route: route, conn: @conn .block__content @@ -18,6 +18,6 @@ h1 Your Reports tr td class=report_row_class(r) = pretty_state(r) - td = link_to_reported_thing(@conn, r.reportable) + td = link_to_reported_thing(r.reportable) td = r.reason td = pretty_time(r.created_at) diff --git a/lib/philomena_web/templates/report/new.html.slime b/lib/philomena_web/templates/report/new.html.slime index 15f2a32a..f7839783 100644 --- a/lib/philomena_web/templates/report/new.html.slime +++ b/lib/philomena_web/templates/report/new.html.slime @@ -1,7 +1,7 @@ h2 Submit a report p strong - = link_to_reported_thing(@conn, @reportable) + = link_to_reported_thing(@reportable) .image-other .dnp-warning diff --git a/lib/philomena_web/templates/search/_form.html.slime b/lib/philomena_web/templates/search/_form.html.slime index 1569f200..d1ceb34d 100644 --- a/lib/philomena_web/templates/search/_form.html.slime +++ b/lib/philomena_web/templates/search/_form.html.slime @@ -1,6 +1,6 @@ h1 Search -= form_for :search, Routes.search_path(@conn, :index), [id: "searchform", method: "get", class: "js-search-form", enforce_utf8: false], fn f -> += form_for :search, ~p"/search", [id: "searchform", method: "get", class: "js-search-form", enforce_utf8: false], fn f -> = text_input f, :q, class: "input input--wide js-search-field", placeholder: "Search terms are chained with commas", autocapitalize: "none", name: "q", value: @conn.params["q"] .block diff --git a/lib/philomena_web/templates/search/index.html.slime b/lib/philomena_web/templates/search/index.html.slime index 2c4cffe9..130d7dd4 100644 --- a/lib/philomena_web/templates/search/index.html.slime +++ b/lib/philomena_web/templates/search/index.html.slime @@ -1,6 +1,6 @@ = cond do - Enum.any?(@images) or override_display(@tags) -> - = render PhilomenaWeb.ImageView, "index.html", conn: @conn, tags: @tags, images: @images, header: "Searching for #{@conn.params["q"]}", route: fn p -> Routes.search_path(@conn, :index, p) end, scope: scope(@conn) + = render PhilomenaWeb.ImageView, "index.html", conn: @conn, tags: @tags, images: @images, header: "Searching for #{@conn.params["q"]}", route: fn p -> ~p"/search?#{p}" end, scope: scope(@conn) - assigns[:error] -> .block.block--fixed.block--danger diff --git a/lib/philomena_web/templates/search/reverse/index.html.slime b/lib/philomena_web/templates/search/reverse/index.html.slime index 9d8db2c3..6ae7b2d7 100644 --- a/lib/philomena_web/templates/search/reverse/index.html.slime +++ b/lib/philomena_web/templates/search/reverse/index.html.slime @@ -1,6 +1,6 @@ h1 Reverse Search -= form_for :image, Routes.search_reverse_path(@conn, :create), [multipart: true], fn f -> += form_for :image, ~p"/search/reverse", [multipart: true], fn f -> p ' Basic image similarity search. Finds uploaded images similar to the one ' provided based on simple intensities and uses the median frame of @@ -46,7 +46,7 @@ h1 Reverse Search = for match <- @images do tr th - h3 = link "##{match.id}", to: Routes.image_path(@conn, :show, match) + h3 = link "##{match.id}", to: ~p"/images/#{match}" p = if image_has_sources(match) do span.source_url diff --git a/lib/philomena_web/templates/session/new.html.slime b/lib/philomena_web/templates/session/new.html.slime index a8fd640c..11a86ae9 100644 --- a/lib/philomena_web/templates/session/new.html.slime +++ b/lib/philomena_web/templates/session/new.html.slime @@ -1,13 +1,13 @@ h1 Sign in -= form_for @conn, Routes.session_path(@conn, :create), [as: :user], fn f -> += form_for @conn, ~p"/sessions", [as: :user], fn f -> = if @error_message do .alert.alert-danger p = @error_message - p = link "Resend unlock instructions", to: Routes.unlock_path(@conn, :new) - p = link "Resend confirmation email", to: Routes.confirmation_path(@conn, :new) + p = link "Resend unlock instructions", to: ~p"/unlocks/new" + p = link "Resend confirmation email", to: ~p"/confirmations/new" - p = link "Forgot your password?", to: Routes.password_path(@conn, :new) + p = link "Forgot your password?", to: ~p"/passwords/new" .field = email_input f, :email, class: "input", required: true, placeholder: "Email", autofocus: true, pattern: ~S/[^\s]+@[^\s]+\.[^\s]+/ diff --git a/lib/philomena_web/templates/session/totp/new.html.slime b/lib/philomena_web/templates/session/totp/new.html.slime index 0c3bf9eb..0a632f9f 100644 --- a/lib/philomena_web/templates/session/totp/new.html.slime +++ b/lib/philomena_web/templates/session/totp/new.html.slime @@ -1,6 +1,6 @@ h1 Two Factor Authentication -= form_for @changeset, Routes.session_totp_path(@conn, :create), [as: :user, method: "post"], fn f -> += form_for @changeset, ~p"/sessions/totp", [as: :user, method: "post"], fn f -> .field h4 Please enter your 2FA code = text_input f, :twofactor_token, class: "input", placeholder: "6-digit code", required: true, autofocus: true, autocomplete: "off" diff --git a/lib/philomena_web/templates/setting/edit.html.slime b/lib/philomena_web/templates/setting/edit.html.slime index cce9bdf3..2da58c65 100644 --- a/lib/philomena_web/templates/setting/edit.html.slime +++ b/lib/philomena_web/templates/setting/edit.html.slime @@ -1,5 +1,5 @@ h1 Content Settings -= form_for @changeset, Routes.setting_path(@conn, :update), [method: "put"], fn f -> += form_for @changeset, ~p"/settings", [method: "put"], fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. @@ -51,7 +51,7 @@ h1 Content Settings code> = link("Click to show", to: "#", data: [click_show: "#rss-link", click_hide: "#rss-feed-button"]) #rss-link.hidden - = url_input f, :subscribe_url, value: Routes.api_rss_watched_url(@conn, :index, key: @conn.assigns.current_user.authentication_token), class: "input input--wide" + = url_input f, :subscribe_url, value: url(~p"/api/v1/rss/watched?#{[key: @conn.assigns.current_user.authentication_token]}"), class: "input input--wide" br ' Do not share this URL with anyone, it may allow an attacker to compromise your account. @@ -90,13 +90,13 @@ h1 Content Settings .field#js-theme-dark label Theme color .with-error - => select f, :dark_theme, theme_options(@conn), class: "input" + => select f, :dark_theme, theme_options(), class: "input" = error_tag f, :dark_theme .fieldlabel: i Color of the theme, don't forget to save settings to apply the theme .field.hidden#js-theme-light label Theme color .with-error - => select f, :light_theme, light_theme_options(@conn), class: "input" + => select f, :light_theme, light_theme_options(), class: "input" = error_tag f, :light_theme .fieldlabel: i Preview themes by selecting one from the dropdown. Saving sets the currently selected theme. .field @@ -202,7 +202,7 @@ h1 Content Settings .block__tab.hidden data-tab="join-the-herd" p ' Consider - => link "creating an account!", to: Routes.registration_path(@conn, :new) + => link "creating an account!", to: ~p"/registrations/new" br ' You will be able to customize the number of images and comments you get on a single page, as well as change the appearance of the site with custom themes. diff --git a/lib/philomena_web/templates/source_change/index.html.slime b/lib/philomena_web/templates/source_change/index.html.slime index 05971a76..fe4b37b2 100644 --- a/lib/philomena_web/templates/source_change/index.html.slime +++ b/lib/philomena_web/templates/source_change/index.html.slime @@ -16,7 +16,7 @@ = for source_change <- @source_changes do tr td.center - = link source_change.image_id, to: Routes.image_path(@conn, :show, source_change.image) + = link source_change.image_id, to: ~p"/images/#{source_change.image}" td.center = render PhilomenaWeb.ImageView, "_image_container.html", image: source_change.image, size: :thumb_tiny, conn: @conn diff --git a/lib/philomena_web/templates/staff/index.html.slime b/lib/philomena_web/templates/staff/index.html.slime index dc7de958..54828027 100644 --- a/lib/philomena_web/templates/staff/index.html.slime +++ b/lib/philomena_web/templates/staff/index.html.slime @@ -39,12 +39,12 @@ h1 Staff .block__content.staff-block__user .staff-block__user-card .staff-block__avatar - a.profile-block href=Routes.profile_path(@conn, :show, user) + a.profile-block href=~p"/profiles/#{user}" = render PhilomenaWeb.UserAttributionView, "_user_avatar.html", object: %{user: user}, class: "avatar--large" p b = user.name .staff-block__info - = link to: Routes.conversation_path(@conn, :new, recipient: user.name), class: "button button--secondary" do + = link to: ~p"/conversations/new?#{[recipient: user.name]}", class: "button button--secondary" do i.fa.fa-envelope> ' Send PM hr.staff-block__separator diff --git a/lib/philomena_web/templates/tag/_tag.html.slime b/lib/philomena_web/templates/tag/_tag.html.slime index 4bc77882..0de59b7e 100644 --- a/lib/philomena_web/templates/tag/_tag.html.slime +++ b/lib/philomena_web/templates/tag/_tag.html.slime @@ -13,14 +13,14 @@ span.tag.dropdown data-tag-category="#{@tag.category}" data-tag-id="#{@tag.id}" a.tag__name< href=pretty_tag_path(@tag) title="#{@tag.short_description}" = @tag.name div.dropdown__content - a.tag__dropdown__link.hidden data-method="delete" data-remote="true" data-tag-action="unwatch" href=Routes.tag_watch_path(@conn, :delete, @tag) Unwatch - a.tag__dropdown__link.hidden data-method="post" data-remote="true" data-tag-action="watch" href=Routes.tag_watch_path(@conn, :create, @tag) Watch + a.tag__dropdown__link.hidden data-method="delete" data-remote="true" data-tag-action="unwatch" href=~p"/tags/#{@tag}/watch" Unwatch + a.tag__dropdown__link.hidden data-method="post" data-remote="true" data-tag-action="watch" href=~p"/tags/#{@tag}/watch" Watch - a.tag__dropdown__link.hidden data-method="delete" data-remote="true" data-tag-action="unspoiler" href=Routes.filter_spoiler_path(@conn, :delete, tag: @tag) Unspoiler - a.tag__dropdown__link.hidden data-method="post" data-remote="true" data-tag-action="spoiler" href=Routes.filter_spoiler_path(@conn, :create, tag: @tag) Spoiler + a.tag__dropdown__link.hidden data-method="delete" data-remote="true" data-tag-action="unspoiler" href=~p"/filters/spoiler?#{[tag: @tag]}" Unspoiler + a.tag__dropdown__link.hidden data-method="post" data-remote="true" data-tag-action="spoiler" href=~p"/filters/spoiler?#{[tag: @tag]}" Spoiler - a.tag__dropdown__link.hidden data-method="delete" data-remote="true" data-tag-action="unhide" href=Routes.filter_hide_path(@conn, :delete, tag: @tag) Unhide - a.tag__dropdown__link.hidden data-method="post" data-remote="true" data-tag-action="hide" href=Routes.filter_hide_path(@conn, :create, tag: @tag) Hide + a.tag__dropdown__link.hidden data-method="delete" data-remote="true" data-tag-action="unhide" href=~p"/filters/hide?#{[tag: @tag]}" Unhide + a.tag__dropdown__link.hidden data-method="post" data-remote="true" data-tag-action="hide" href=~p"/filters/hide?#{[tag: @tag]}" Hide a.tag__dropdown__link.hidden href="/sessions/new" Sign in to Watch a.tag__dropdown__link.hidden href="/filters" Filter diff --git a/lib/philomena_web/templates/tag/_tag_info_row.html.slime b/lib/philomena_web/templates/tag/_tag_info_row.html.slime index 766420f6..8444c697 100644 --- a/lib/philomena_web/templates/tag/_tag_info_row.html.slime +++ b/lib/philomena_web/templates/tag/_tag_info_row.html.slime @@ -9,15 +9,15 @@ .tag-info__controls = render PhilomenaWeb.TagView, "_tag.html", tag: @tag, conn: @conn .button__group--standalone - = link "Tag changes", to: Routes.tag_tag_change_path(@conn, :index, @tag), class: "detail-link" + = link "Tag changes", to: ~p"/tags/#{@tag}/tag_changes", class: "detail-link" = if manages_tags?(@conn) do .button__group--standalone.button__group--warning - = link "Edit details", to: Routes.tag_path(@conn, :edit, @tag), class: "detail-link" + = link "Edit details", to: ~p"/tags/#{@tag}/edit", class: "detail-link" .separator--vertical.separator--warning - = link "Usage", to: Routes.tag_detail_path(@conn, :index, @tag), class: "detail-link" + = link "Usage", to: ~p"/tags/#{@tag}/details", class: "detail-link" = if manages_dnp?(@conn) do .button__group--standalone.button__group--danger - = link "Create new DNP entry", to: Routes.dnp_entry_path(@conn, :new, tag_id: @tag.id), class: "detail-link" + = link "Create new DNP entry", to: ~p"/dnp/new?#{[tag_id: @tag.id]}", class: "detail-link" br @@ -34,14 +34,14 @@ = if Enum.any?(@tag.aliases) do strong> Aliases: = if aliases_tags?(@conn) do - = map_join(@tag.aliases, ", ", &link(&1.name, to: Routes.tag_alias_path(@conn, :edit, &1))) + = map_join(@tag.aliases, ", ", &link(&1.name, to: ~p"/tags/#{&1}/alias/edit")) - else = map_join(@tag.aliases, ", ", & &1.name) br = if Enum.any?(@tag.implied_tags) do strong> Implies: - = map_join(@tag.implied_tags, ", ", &link(&1.name, to: Routes.tag_path(@conn, :show, &1))) + = map_join(@tag.implied_tags, ", ", &link(&1.name, to: ~p"/tags/#{&1}")) br = if Enum.any?(@tag.hidden_links) and manages_links?(@conn) do @@ -49,7 +49,7 @@ br = for artist_link <- @tag.hidden_links do - => link artist_link.user.name, to: Routes.profile_path(@conn, :show, artist_link.user) + => link artist_link.user.name, to: ~p"/profiles/#{artist_link.user}" ' → => link artist_link.uri, to: artist_link.uri br @@ -75,18 +75,18 @@ - users = Enum.map(@tag.public_links, & &1.user) |> Enum.uniq_by(& &1.id) = for user <- users do - => link user.name, to: Routes.profile_path(@conn, :show, user) + => link user.name, to: ~p"/profiles/#{user}" br = if Enum.any?(@tag.channels) do strong> Associated streams: = for channel <- @tag.channels do - => link channel.title, to: Routes.channel_path(@conn, :show, channel) + => link channel.title, to: ~p"/channels/#{channel}" = if can?(@conn, :edit, channel) do | ( - = link "Edit", to: Routes.channel_path(@conn, :edit, channel) + = link "Edit", to: ~p"/channels/#{channel}/edit" ' ) br @@ -99,7 +99,7 @@ .toggle-box-container .toggle-box-container__content = map_join @tag.implied_by_tags, ", ", fn tag -> - = link tag.name, to: Routes.tag_path(@conn, :show, tag) + = link tag.name, to: ~p"/tags/#{tag}" br @@ -122,5 +122,5 @@ => body | ( - = link "more info", to: Routes.dnp_entry_path(@conn, :show, entry) + = link "more info", to: ~p"/dnp/#{entry}" | ) diff --git a/lib/philomena_web/templates/tag/alias/edit.html.slime b/lib/philomena_web/templates/tag/alias/edit.html.slime index 706545bc..346aae09 100644 --- a/lib/philomena_web/templates/tag/alias/edit.html.slime +++ b/lib/philomena_web/templates/tag/alias/edit.html.slime @@ -2,7 +2,7 @@ h1 ' Aliasing tag = @tag.name -= form_for @changeset, Routes.tag_alias_path(@conn, :update, @tag), [method: "put"], fn f -> += form_for @changeset, ~p"/tags/#{@tag}/alias", [method: "put"], fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. @@ -17,7 +17,7 @@ h1 => submit "Alias tag", class: "button" br -= button_to "Remove tag alias", Routes.tag_alias_path(@conn, :delete, @tag), method: "delete", class: "button", data: [confirm: "Are you really, really sure?", disable_with: raw("Saving…")] += button_to "Remove tag alias", ~p"/tags/#{@tag}/alias", method: "delete", class: "button", data: [confirm: "Are you really, really sure?", disable_with: raw("Saving…")] br -= link "Back", to: Routes.tag_path(@conn, :show, @tag) += link "Back", to: ~p"/tags/#{@tag}" diff --git a/lib/philomena_web/templates/tag/detail/_filters.html.slime b/lib/philomena_web/templates/tag/detail/_filters.html.slime index b09071a8..8dfdb621 100644 --- a/lib/philomena_web/templates/tag/detail/_filters.html.slime +++ b/lib/philomena_web/templates/tag/detail/_filters.html.slime @@ -9,7 +9,7 @@ table.table tbody = for filter <- @filters do tr - td = link filter.name, to: Routes.filter_path(@conn, :show, filter) + td = link filter.name, to: ~p"/filters/#{filter}" td = cond do - filter.system -> @@ -23,7 +23,7 @@ table.table td = if filter.user do - = link filter.user.name, to: Routes.profile_path(@conn, :show, filter.user) + = link filter.user.name, to: ~p"/profiles/#{filter.user}" - else ' No user associated diff --git a/lib/philomena_web/templates/tag/detail/index.html.slime b/lib/philomena_web/templates/tag/detail/index.html.slime index 8a11358a..5271cab2 100644 --- a/lib/philomena_web/templates/tag/detail/index.html.slime +++ b/lib/philomena_web/templates/tag/detail/index.html.slime @@ -1,6 +1,6 @@ h1 ' Tag Usage for - = link @tag.name, to: Routes.tag_path(@conn, :show, @tag) + = link @tag.name, to: ~p"/tags/#{@tag}" h3 Filters that spoiler this tag: = render PhilomenaWeb.Tag.DetailView, "_filters.html", filters: @filters_spoilering, conn: @conn @@ -14,4 +14,4 @@ h3 | ) = for u <- @users_watching do - = link u.name, to: Routes.profile_path(@conn, :show, u), class: "interaction-user-list-item" + = link u.name, to: ~p"/profiles/#{u}", class: "interaction-user-list-item" diff --git a/lib/philomena_web/templates/tag/edit.html.slime b/lib/philomena_web/templates/tag/edit.html.slime index 5925112b..1089bafb 100644 --- a/lib/philomena_web/templates/tag/edit.html.slime +++ b/lib/philomena_web/templates/tag/edit.html.slime @@ -1,10 +1,10 @@ h1 Editing Tag -p = link "Edit image", to: Routes.tag_image_path(@conn, :edit, @tag) +p = link "Edit image", to: ~p"/tags/#{@tag}/image/edit" = if can?(@conn, :alias, @tag) do - p = link "Edit aliases", to: Routes.tag_alias_path(@conn, :edit, @tag) + p = link "Edit aliases", to: ~p"/tags/#{@tag}/alias/edit" -= form_for @changeset, Routes.tag_path(@conn, :update, @tag), [class: "form"], fn f -> += form_for @changeset, ~p"/tags/#{@tag}", [class: "form"], fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. @@ -44,10 +44,10 @@ br label for="tag-management" Tag Processing .toggle-box-container .toggle-box-container__content - = button_to "Rebuild index", Routes.tag_reindex_path(@conn, :create, @tag), method: "post", class: "button", data: [confirm: "Are you really, really sure?", disable_with: raw("Reindexing…")] + = button_to "Rebuild index", ~p"/tags/#{@tag}/reindex", method: "post", class: "button", data: [confirm: "Are you really, really sure?", disable_with: raw("Reindexing…")] p Use this if the tag displays the wrong number of images or returns the wrong search results. - = button_to "Destroy tag", Routes.tag_path(@conn, :delete, @tag), method: "delete", class: "button button--danger", data: [confirm: "Are you really, really sure?", disable_with: raw("Deleting…")] + = button_to "Destroy tag", ~p"/tags/#{@tag}", method: "delete", class: "button button--danger", data: [confirm: "Are you really, really sure?", disable_with: raw("Deleting…")] p strong Irreversible. Use with extreme caution! ul diff --git a/lib/philomena_web/templates/tag/image/edit.html.slime b/lib/philomena_web/templates/tag/image/edit.html.slime index e7f538e4..4965a0dd 100644 --- a/lib/philomena_web/templates/tag/image/edit.html.slime +++ b/lib/philomena_web/templates/tag/image/edit.html.slime @@ -15,7 +15,7 @@ p Add a new image or remove the existing one here. p SVG is preferred. - = form_for @changeset, Routes.tag_image_path(@conn, :update, @tag), [method: "put", multipart: true], fn f -> + = form_for @changeset, ~p"/tags/#{@tag}/image", [method: "put", multipart: true], fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. @@ -35,7 +35,7 @@ => submit "Update tag image", class: "button" br - = button_to "Remove tag image", Routes.tag_image_path(@conn, :delete, @tag), method: "delete", class: "button", data: [confirm: "Are you really, really sure?"] + = button_to "Remove tag image", ~p"/tags/#{@tag}/image", method: "delete", class: "button", data: [confirm: "Are you really, really sure?"] br - = link "Back", to: Routes.tag_path(@conn, :show, @tag) + = link "Back", to: ~p"/tags/#{@tag}" diff --git a/lib/philomena_web/templates/tag/index.html.slime b/lib/philomena_web/templates/tag/index.html.slime index d1970602..9198e64b 100644 --- a/lib/philomena_web/templates/tag/index.html.slime +++ b/lib/philomena_web/templates/tag/index.html.slime @@ -1,6 +1,6 @@ h1 Tags -= form_for :tags, Routes.tag_path(@conn, :index), [method: "get", class: "hform", enforce_utf8: false], fn f -> += form_for :tags, ~p"/tags", [method: "get", class: "hform", enforce_utf8: false], fn f -> .field = text_input f, :tq, name: :tq, value: @conn.params["tq"] || "*", class: "input hform__text", placeholder: "Search tags", autocapitalize: "none" = submit "Search", class: "hform__button button" @@ -15,7 +15,7 @@ h2 Search Results = cond do - Enum.any?(@tags) -> - - route = fn p -> Routes.tag_path(@conn, :index, p) end + - route = fn p -> ~p"/tags?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @tags, route: route, params: [tq: @conn.params["tq"] || "*"] = render PhilomenaWeb.TagView, "_tag_list.html", tags: @tags, conn: @conn @@ -56,102 +56,102 @@ table.table td Literal td Matches the name of the target tag, if this tag is aliased. td - code = link "alias_of:twilight sparkle", to: Routes.tag_path(@conn, :index, tq: "alias_of:twilight sparkle") + code = link "alias_of:twilight sparkle", to: ~p"/tags?#{[tq: "alias_of:twilight sparkle"]}" tr td code aliased td Boolean td Matches when this tag is aliased. td - code = link "aliased:true", to: Routes.tag_path(@conn, :index, tq: "aliased:true") + code = link "aliased:true", to: ~p"/tags?#{[tq: "aliased:true"]}" tr td code aliases td Literal td Matches the name of any of this tag's aliases. td - code = link "aliases:ts", to: Routes.tag_path(@conn, :index, tq: "aliases:ts") + code = link "aliases:ts", to: ~p"/tags?#{[tq: "aliases:ts"]}" tr td code analyzed_name td Full Text td Matches the name of this tag. This is the default field. td - code = link "analyzed_name:wing", to: Routes.tag_path(@conn, :index, tq: "analyzed_name:wing") + code = link "analyzed_name:wing", to: ~p"/tags?#{[tq: "analyzed_name:wing"]}" tr td code category td Literal td Matches the category this tag belongs to. td - code = link "category:origin", to: Routes.tag_path(@conn, :index, tq: "category:origin") + code = link "category:origin", to: ~p"/tags?#{[tq: "category:origin"]}" tr td code description td Full Text td Matches the text of the full description for this tag. td - code = link "description:species", to: Routes.tag_path(@conn, :index, tq: "description:species") + code = link "description:species", to: ~p"/tags?#{[tq: "description:species"]}" tr td code id td Numeric Range td Matches the numeric surrogate key for this tag. td - code = link "id:40482", to: Routes.tag_path(@conn, :index, tq: "id:40482") + code = link "id:40482", to: ~p"/tags?#{[tq: "id:40482"]}" tr td code images td Numeric Range td Matches tags with the specified image count. td - code = link "images.lte:1000", to: Routes.tag_path(@conn, :index, tq: "images.lte:1000") + code = link "images.lte:1000", to: ~p"/tags?#{[tq: "images.lte:1000"]}" tr td code implied_by td Literal td Matches this tag if it is implied by the given tag. td - code = link "implied_by:transparent background", to: Routes.tag_path(@conn, :index, tq: "implied_by:transparent background") + code = link "implied_by:transparent background", to: ~p"/tags?#{[tq: "implied_by:transparent background"]}" tr td code implies td Literal td Matches this tag if it implies the given tag. td - code = link "implies:shipping", to: Routes.tag_path(@conn, :index, tq: "implies:shipping") + code = link "implies:shipping", to: ~p"/tags?#{[tq: "implies:shipping"]}" tr td code name td Literal td Matches the exact name of this tag. td - code = link "name:safe", to: Routes.tag_path(@conn, :index, tq: "name:safe") + code = link "name:safe", to: ~p"/tags?#{[tq: "name:safe"]}" tr td code name_in_namespace td Literal td Matches the name of this tag with any namespace component removed. td - code = link "name_in_namespace:johnjoseco", to: Routes.tag_path(@conn, :index, tq: "name_in_namespace:johnjoseco") + code = link "name_in_namespace:johnjoseco", to: ~p"/tags?#{[tq: "name_in_namespace:johnjoseco"]}" tr td code namespace td Literal td Matches tags with the given namespace. td - code = link "namespace:artist", to: Routes.tag_path(@conn, :index, tq: "namespace:artist") + code = link "namespace:artist", to: ~p"/tags?#{[tq: "namespace:artist"]}" tr td code short_description td Full Text td Matches the text of the short description for this tag. td - code = link "short_description:gender", to: Routes.tag_path(@conn, :index, tq: "short_description:gender") + code = link "short_description:gender", to: ~p"/tags?#{[tq: "short_description:gender"]}" tr td code slug td Literal td Matches the slug of this tag. td - code = link "slug:-fwslash-mlp-fwslash-", to: Routes.tag_path(@conn, :index, tq: "slug:-fwslash-mlp-fwslash-") + code = link "slug:-fwslash-mlp-fwslash-", to: ~p"/tags?#{[tq: "slug:-fwslash-mlp-fwslash-"]}" diff --git a/lib/philomena_web/templates/tag/show.html.slime b/lib/philomena_web/templates/tag/show.html.slime index a8b85c43..ad85fbed 100644 --- a/lib/philomena_web/templates/tag/show.html.slime +++ b/lib/philomena_web/templates/tag/show.html.slime @@ -1,3 +1,3 @@ -= render PhilomenaWeb.ImageView, "index.html", conn: @conn, tags: @tags, images: @images, header: "Images tagged #{@tag.name}", scope: scope(@conn), route: fn p -> Routes.tag_path(@conn, :show, @tag, p) end += render PhilomenaWeb.ImageView, "index.html", conn: @conn, tags: @tags, images: @images, header: "Images tagged #{@tag.name}", scope: scope(@conn), route: fn p -> ~p"/tags/#{@tag}?#{p}" end = render PhilomenaWeb.SearchView, "_form.html", conn: @conn diff --git a/lib/philomena_web/templates/tag/tag_change/index.html.slime b/lib/philomena_web/templates/tag/tag_change/index.html.slime index 5c9aed29..b4ce6a57 100644 --- a/lib/philomena_web/templates/tag/tag_change/index.html.slime +++ b/lib/philomena_web/templates/tag/tag_change/index.html.slime @@ -1,9 +1,9 @@ h1 ' Tag changes on tag - a href=Routes.tag_path(@conn, :show, @tag) + a href=~p"/tags/#{@tag}" = @tag.name -- route = fn p -> Routes.tag_tag_change_path(@conn, :index, @tag, p) end +- route = fn p -> ~p"/tags/#{@tag}/tag_changes?#{p}" end - params = if @conn.params["added"], do: [added: @conn.params["added"]] - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @tag_changes, route: route, conn: @conn, params: params @@ -12,8 +12,8 @@ h1 span | Display only: - = link "Removed", to: Routes.tag_tag_change_path(@conn, :index, @tag, added: 0) - = link "Added", to: Routes.tag_tag_change_path(@conn, :index, @tag, added: 1) - = link "All", to: Routes.tag_tag_change_path(@conn, :index, @tag) + = link "Removed", to: ~p"/tags/#{@tag}/tag_changes?#{[added: 0]}" + = link "Added", to: ~p"/tags/#{@tag}/tag_changes?#{[added: 1]}" + = link "All", to: ~p"/tags/#{@tag}/tag_changes" = render PhilomenaWeb.TagChangeView, "index.html", conn: @conn, tag_changes: @tag_changes, pagination: pagination diff --git a/lib/philomena_web/templates/tag_change/index.html.slime b/lib/philomena_web/templates/tag_change/index.html.slime index a5f6b64b..cfffd345 100644 --- a/lib/philomena_web/templates/tag_change/index.html.slime +++ b/lib/philomena_web/templates/tag_change/index.html.slime @@ -7,7 +7,7 @@ i.fa.fa-check> ' Toggle all -= form_for :tag_changes, Routes.tag_change_revert_path(@conn, :create), [class: "tag-changes-form"], fn _f -> += form_for :tag_changes, ~p"/tag_changes/revert", [class: "tag-changes-form"], fn _f -> .block__content table.table thead @@ -31,7 +31,7 @@ input type="checkbox" name="ids[]" value=tag_change.id td.center - = link tag_change.image_id, to: Routes.image_path(@conn, :show, tag_change.image) + = link tag_change.image_id, to: ~p"/images/#{tag_change.image}" td.center = render PhilomenaWeb.ImageView, "_image_container.html", image: tag_change.image, size: :thumb_tiny, conn: @conn @@ -69,7 +69,7 @@ td.danger No = if reverts_tag_changes?(@conn) do td - a href=Routes.image_tag_change_path(@conn, :delete, tag_change.image, tag_change) data-method="delete" data-confirm="Are you really, really sure?" + a href=~p"/images/#{tag_change.image}/tag_changes/#{tag_change}" data-method="delete" data-confirm="Are you really, really sure?" ' Delete from history .block__header diff --git a/lib/philomena_web/templates/topic/new.html.slime b/lib/philomena_web/templates/topic/new.html.slime index 5d42d130..05236f7a 100644 --- a/lib/philomena_web/templates/topic/new.html.slime +++ b/lib/philomena_web/templates/topic/new.html.slime @@ -1,4 +1,4 @@ -= form_for @changeset, Routes.forum_topic_path(@conn, :create, @forum), fn f -> += form_for @changeset, ~p"/forums/#{@forum}/topics", fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/topic/poll/_display.html.slime b/lib/philomena_web/templates/topic/poll/_display.html.slime index ed185fac..37e7711c 100644 --- a/lib/philomena_web/templates/topic/poll/_display.html.slime +++ b/lib/philomena_web/templates/topic/poll/_display.html.slime @@ -2,7 +2,7 @@ = link "Voting", to: "#", class: "selected", data: [click_tab: "voting"] = if can?(@conn, :hide, @topic) do - = link "Voters", to: "#", data: [click_tab: "voters", load_tab: Routes.forum_topic_poll_vote_path(@conn, :index, @forum, @topic)] + = link "Voters", to: "#", data: [click_tab: "voters", load_tab: ~p"/forums/#{@forum}/topics/#{@topic}/poll/votes"] = link "Administrate", to: "#", data: [click_tab: "administration"] .block__tab data-tab="voting" @@ -31,6 +31,6 @@ .block__tab.hidden data-tab="voters" p Loading… .block__tab.hidden data-tab="administration" - a.button.button--warning.js-staff-action> href=Routes.forum_topic_poll_path(@conn, :edit, @forum, @topic) + a.button.button--warning.js-staff-action> href=~p"/forums/#{@forum}/topics/#{@topic}/poll/edit" i.fa.fa-edit> | Edit diff --git a/lib/philomena_web/templates/topic/poll/_vote_form.html.slime b/lib/philomena_web/templates/topic/poll/_vote_form.html.slime index 080833bc..7368acdf 100644 --- a/lib/philomena_web/templates/topic/poll/_vote_form.html.slime +++ b/lib/philomena_web/templates/topic/poll/_vote_form.html.slime @@ -1,4 +1,4 @@ -= form_for :poll_vote, Routes.forum_topic_poll_vote_path(@conn, :create, @forum, @topic), [class: "poll-vote-form"], fn _f -> += form_for :poll_vote, ~p"/forums/#{@forum}/topics/#{@topic}/poll/votes", [class: "poll-vote-form"], fn _f -> h4.poll__header ' Poll: = @poll.title diff --git a/lib/philomena_web/templates/topic/poll/edit.html.slime b/lib/philomena_web/templates/topic/poll/edit.html.slime index 1282a99e..03cf0640 100644 --- a/lib/philomena_web/templates/topic/poll/edit.html.slime +++ b/lib/philomena_web/templates/topic/poll/edit.html.slime @@ -1,6 +1,6 @@ h1 Editing Poll -= form_for @changeset, Routes.forum_topic_poll_path(@conn, :update, @forum, @topic), fn f -> += form_for @changeset, ~p"/forums/#{@forum}/topics/#{@topic}/poll", fn f -> = render PhilomenaWeb.Topic.PollView, "_form.html", f: f br diff --git a/lib/philomena_web/templates/topic/poll/vote/index.html.slime b/lib/philomena_web/templates/topic/poll/vote/index.html.slime index 5b71a100..749d9cb3 100644 --- a/lib/philomena_web/templates/topic/poll/vote/index.html.slime +++ b/lib/philomena_web/templates/topic/poll/vote/index.html.slime @@ -4,8 +4,8 @@ = for vote <- option.poll_votes do span.interaction-user-list-item - => link vote.user.name, to: Routes.profile_path(@conn, :show, vote.user) - /= link "(x)", to: Routes.forum_topic_poll_vote_path(@conn, :delete, @forum, @topic, vote) + => link vote.user.name, to: ~p"/profiles/#{vote.user}" + /= link "(x)", to: ~p"/forums/#{@forum}/topics/#{@topic}/poll/votes/#{vote}" - else p diff --git a/lib/philomena_web/templates/topic/post/_form.html.slime b/lib/philomena_web/templates/topic/post/_form.html.slime index aa69b979..dcb15f40 100644 --- a/lib/philomena_web/templates/topic/post/_form.html.slime +++ b/lib/philomena_web/templates/topic/post/_form.html.slime @@ -1,4 +1,4 @@ -= form_for @changeset, Routes.forum_topic_post_path(@conn, :create, @forum, @topic), fn f -> += form_for @changeset, ~p"/forums/#{@forum}/topics/#{@topic}/posts", fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/topic/post/edit.html.slime b/lib/philomena_web/templates/topic/post/edit.html.slime index 5f815ff2..b7544121 100644 --- a/lib/philomena_web/templates/topic/post/edit.html.slime +++ b/lib/philomena_web/templates/topic/post/edit.html.slime @@ -1,4 +1,4 @@ -= form_for @changeset, Routes.forum_topic_post_path(@conn, :update, @post.topic.forum, @post.topic, @post), fn f -> += form_for @changeset, ~p"/forums/#{@post.topic.forum}/topics/#{@post.topic}/posts/#{@post}", fn f -> = if @changeset.action do .alert.alert-danger p Oops, something went wrong! Please check the errors below. diff --git a/lib/philomena_web/templates/topic/post/history/index.html.slime b/lib/philomena_web/templates/topic/post/history/index.html.slime index 59660d72..d204a40e 100644 --- a/lib/philomena_web/templates/topic/post/history/index.html.slime +++ b/lib/philomena_web/templates/topic/post/history/index.html.slime @@ -2,7 +2,7 @@ h1 ' Viewing last 25 versions of post by = render PhilomenaWeb.UserAttributionView, "_anon_user.html", object: @post, conn: @conn ' in topic - a href=(Routes.forum_topic_path(@conn, :show, @post.topic.forum, @post.topic, post_id: @post.id) <> "#post_#{@post.id}") + a href=(~p"/forums/#{@post.topic.forum}/topics/#{@post.topic}?#{[post_id: @post.id]}" <> "#post_#{@post.id}") = @post.topic.title = for version <- @versions do diff --git a/lib/philomena_web/templates/topic/show.html.slime b/lib/philomena_web/templates/topic/show.html.slime index cbda4007..e78b13b4 100644 --- a/lib/philomena_web/templates/topic/show.html.slime +++ b/lib/philomena_web/templates/topic/show.html.slime @@ -1,4 +1,4 @@ -- route = fn p -> Routes.forum_topic_path(@conn, :show, @forum, @topic, p) end +- route = fn p -> ~p"/forums/#{@forum}/topics/#{@topic}?#{p}" end - pagination = render PhilomenaWeb.PaginationView, "_pagination.html", page: @posts, route: route, last: true h1 = @topic.title @@ -16,22 +16,22 @@ h1 = @topic.title strong> Deleted by: em strong - = link(@topic.deleted_by.name, to: Routes.profile_path(@conn, :show, @topic.deleted_by)) + = link(@topic.deleted_by.name, to: ~p"/profiles/#{@topic.deleted_by}") p - = link(to: Routes.forum_topic_hide_path(@conn, :delete, @forum, @topic), method: :delete, class: "button") do + = link(to: ~p"/forums/#{@forum}/topics/#{@topic}/hide", method: :delete, class: "button") do i.fas.fa-check> ' Restore / Header section .block .block__header - => link(@forum.name, to: Routes.forum_path(@conn, :show, @forum)) + => link(@forum.name, to: ~p"/forums/#{@forum}") ' » - => link(@topic.title, to: Routes.forum_topic_path(@conn, :show, @forum, @topic)) + => link(@topic.title, to: ~p"/forums/#{@forum}/topics/#{@topic}") = if not @topic.hidden_from_users or can?(@conn, :hide, @topic) do - a href=Routes.post_path(@conn, :index, pq: "topic_id:#{@topic.id}") + a href=~p"/posts?#{[pq: "topic_id:#{@topic.id}"]}" i.fa.icon--padded.small.fa-search> ' Search Posts .flex.flex--wrap.block__header.block__header--light.page__header @@ -86,7 +86,7 @@ h1 = @topic.title ' Locked by: em strong - = link(@topic.locked_by.name, to: Routes.profile_path(@conn, :show, @topic.locked_by)) + = link(@topic.locked_by.name, to: ~p"/profiles/#{@topic.locked_by}") / Post form = cond do @@ -116,43 +116,43 @@ h1 = @topic.title p = if not @topic.hidden_from_users do = if @topic.sticky do - = link(to: Routes.forum_topic_stick_path(@conn, :delete, @forum, @topic), method: :delete, class: "button") do + = link(to: ~p"/forums/#{@forum}/topics/#{@topic}/stick", method: :delete, class: "button") do i.fas.fa-thumbtack> ' Unstick - else - = link(to: Routes.forum_topic_stick_path(@conn, :create, @forum, @topic), method: :post, class: "button") do + = link(to: ~p"/forums/#{@forum}/topics/#{@topic}/stick", method: :post, class: "button") do i.fas.fa-thumbtack> ' Stick = if @topic.locked_at do - = link(to: Routes.forum_topic_lock_path(@conn, :delete, @forum, @topic), method: :delete, class: "button") do + = link(to: ~p"/forums/#{@forum}/topics/#{@topic}/lock", method: :delete, class: "button") do i.fas.fa-unlock> ' Unlock - else - = form_for :topic, Routes.forum_topic_lock_path(@conn, :create, @forum, @topic), [method: :post, class: "hform"], fn f -> + = form_for :topic, ~p"/forums/#{@forum}/topics/#{@topic}/lock", [method: :post, class: "hform"], fn f -> .field = text_input f, :lock_reason, class: "input hform__text", placeholder: "Lock reason", required: true = submit class: "hform__button button" do i.fas.fa-lock> ' Lock - = form_for @topic_changeset, Routes.forum_topic_path(@conn, :update, @forum, @topic), [method: :put, class: "hform"], fn f -> + = form_for @topic_changeset, ~p"/forums/#{@forum}/topics/#{@topic}", [method: :put, class: "hform"], fn f -> .field = text_input f, :title, class: "input hform__text", placeholder: "New Title" = submit class: "hform__button button" do i.fas.fa-pen> ' Set Title - = form_for :topic, Routes.forum_topic_move_path(@conn, :create, @forum, @topic), [method: :post, class: "hform"], fn f -> + = form_for :topic, ~p"/forums/#{@forum}/topics/#{@topic}/move", [method: :post, class: "hform"], fn f -> .field = select f, :target_forum_id, Enum.map(@conn.assigns.forums, &{&1.name, &1.id}), class: "input hform__text" = submit class: "hform__button button" do i.fas.fa-truck> ' Move - = form_for :topic, Routes.forum_topic_hide_path(@conn, :create, @forum, @topic), [method: :post, class: "hform"], fn f -> + = form_for :topic, ~p"/forums/#{@forum}/topics/#{@topic}/hide", [method: :post, class: "hform"], fn f -> .field = text_input f, :deletion_reason, class: "input hform__text", placeholder: "Deletion reason", required: true = submit class: "hform__button button" do diff --git a/lib/philomena_web/templates/topic/subscription/_subscription.html.slime b/lib/philomena_web/templates/topic/subscription/_subscription.html.slime index bda8240f..14422579 100644 --- a/lib/philomena_web/templates/topic/subscription/_subscription.html.slime +++ b/lib/philomena_web/templates/topic/subscription/_subscription.html.slime @@ -1,8 +1,8 @@ elixir: - watch_path = Routes.forum_topic_subscription_path(@conn, :create, @forum, @topic) + watch_path = ~p"/forums/#{@forum}/topics/#{@topic}/subscription" watch_class = if @watching, do: "hidden", else: "" - unwatch_path = Routes.forum_topic_subscription_path(@conn, :delete, @forum, @topic) + unwatch_path = ~p"/forums/#{@forum}/topics/#{@topic}/subscription" unwatch_class = if @watching, do: "", else: "hidden" = if @conn.assigns.current_user do @@ -17,7 +17,7 @@ elixir: span.hidden--mobile ' Unsubscribe - else - a href=Routes.session_path(@conn, :new) + a href=~p"/sessions/new" i.fa.fa-bell> span.hidden--mobile ' Subscribe diff --git a/lib/philomena_web/templates/unlock/new.html.slime b/lib/philomena_web/templates/unlock/new.html.slime index 5d64af56..9c8e05cc 100644 --- a/lib/philomena_web/templates/unlock/new.html.slime +++ b/lib/philomena_web/templates/unlock/new.html.slime @@ -1,6 +1,6 @@ h1 Resend unlock instructions -= form_for :user, Routes.unlock_path(@conn, :create), fn f -> += form_for :user, ~p"/unlocks", fn f -> .field = email_input f, :email, placeholder: "Email", class: "input", required: true diff --git a/lib/philomena_web/templates/user_attribution/_anon_user.html.slime b/lib/philomena_web/templates/user_attribution/_anon_user.html.slime index f58c6cde..2f13abb7 100644 --- a/lib/philomena_web/templates/user_attribution/_anon_user.html.slime +++ b/lib/philomena_web/templates/user_attribution/_anon_user.html.slime @@ -4,13 +4,13 @@ - icon = user_icon(@object.user) = if icon do i class="fa #{icon}" - = link(@object.user.name, to: Routes.profile_path(@conn, :show, @object.user)) + = link(@object.user.name, to: ~p"/profiles/#{@object.user}") = if assigns[:awards] do = render PhilomenaWeb.ProfileView, "_awards.html", awards: @object.user.awards - not is_nil(@object.user) and (can?(@conn, :reveal_anon, @object) and not hide_staff_tools?(@conn)) -> strong<> - = link(anonymous_name(@object, true), to: Routes.profile_path(@conn, :show, @object.user)) + = link(anonymous_name(@object, true), to: ~p"/profiles/#{@object.user}") - true -> strong<> diff --git a/lib/philomena_web/templates/user_attribution/_user.html.slime b/lib/philomena_web/templates/user_attribution/_user.html.slime index 63013ac1..848706b4 100644 --- a/lib/philomena_web/templates/user_attribution/_user.html.slime +++ b/lib/philomena_web/templates/user_attribution/_user.html.slime @@ -3,6 +3,6 @@ - icon = user_icon(@object.user) = if icon do i class="fa #{icon}"> - = link(@object.user.name, to: Routes.profile_path(@conn, :show, @object.user)) + = link(@object.user.name, to: ~p"/profiles/#{@object.user}") = if assigns[:awards] do = render PhilomenaWeb.ProfileView, "_awards.html", awards: @object.user.awards diff --git a/lib/philomena_web/user_auth.ex b/lib/philomena_web/user_auth.ex index 9d00e768..b815537f 100644 --- a/lib/philomena_web/user_auth.ex +++ b/lib/philomena_web/user_auth.ex @@ -3,7 +3,6 @@ defmodule PhilomenaWeb.UserAuth do import Phoenix.Controller alias Philomena.Users - alias PhilomenaWeb.Router.Helpers, as: Routes alias PhilomenaWeb.UserIpUpdater alias PhilomenaWeb.UserFingerprintUpdater @@ -196,7 +195,7 @@ defmodule PhilomenaWeb.UserAuth do conn |> put_flash(:warning, "You must log in to access this page.") |> maybe_store_return_to() - |> redirect(to: Routes.session_path(conn, :new)) + |> redirect(to: ~p"/sessions/new") |> halt() end end diff --git a/lib/philomena_web/views/admin/approval_view.ex b/lib/philomena_web/views/admin/approval_view.ex index 03b0f3c2..b90fa752 100644 --- a/lib/philomena_web/views/admin/approval_view.ex +++ b/lib/philomena_web/views/admin/approval_view.ex @@ -4,7 +4,7 @@ defmodule PhilomenaWeb.Admin.ApprovalView do alias PhilomenaWeb.Admin.ReportView # Shamelessly copied from ReportView - def truncated_ip_link(conn, ip), do: ReportView.truncated_ip_link(conn, ip) + def truncated_ip_link(ip), do: ReportView.truncated_ip_link(ip) def image_thumb(conn, image) do render(PhilomenaWeb.ImageView, "_image_container.html", 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/mod_note_view.ex b/lib/philomena_web/views/admin/mod_note_view.ex index a873208a..021e4721 100644 --- a/lib/philomena_web/views/admin/mod_note_view.ex +++ b/lib/philomena_web/views/admin/mod_note_view.ex @@ -5,20 +5,20 @@ defmodule PhilomenaWeb.Admin.ModNoteView do alias Philomena.Reports.Report alias Philomena.DnpEntries.DnpEntry - def link_to_noted_thing(conn, %DnpEntry{tag: tag} = dnp_entry), - do: link("DNP entry for #{tag.name}", to: Routes.dnp_entry_path(conn, :show, dnp_entry)) + def link_to_noted_thing(%DnpEntry{tag: tag} = dnp_entry), + do: link("DNP entry for #{tag.name}", to: ~p"/dnp/#{dnp_entry}") - def link_to_noted_thing(conn, %Report{user: nil} = report), - do: link("Report #{report.id}", to: Routes.admin_report_path(conn, :show, report)) + def link_to_noted_thing(%Report{user: nil} = report), + do: link("Report #{report.id}", to: ~p"/admin/reports/#{report}") - def link_to_noted_thing(conn, %Report{user: user} = report), + def link_to_noted_thing(%Report{user: user} = report), do: link("Report #{report.id} by #{user.name}", - to: Routes.admin_report_path(conn, :show, report) + to: ~p"/admin/reports/#{report}" ) - def link_to_noted_thing(conn, %User{} = user), - do: link("User #{user.name}", to: Routes.profile_path(conn, :show, user)) + def link_to_noted_thing(%User{} = user), + do: link("User #{user.name}", to: ~p"/profiles/#{user}") - def link_to_noted_thing(_conn, _notable), do: "Item permanently deleted" + def link_to_noted_thing(_notable), do: "Item permanently deleted" end diff --git a/lib/philomena_web/views/admin/report_view.ex b/lib/philomena_web/views/admin/report_view.ex index a9cd5bcc..82de807d 100644 --- a/lib/philomena_web/views/admin/report_view.ex +++ b/lib/philomena_web/views/admin/report_view.ex @@ -7,8 +7,8 @@ defmodule PhilomenaWeb.Admin.ReportView do alias PhilomenaWeb.ReportView alias PhilomenaWeb.ProfileView - defp link_to_reported_thing(conn, reportable), - do: ReportView.link_to_reported_thing(conn, reportable) + defp link_to_reported_thing(reportable), + do: ReportView.link_to_reported_thing(reportable) defp report_row_class(report), do: ReportView.report_row_class(report) @@ -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) @@ -25,13 +25,13 @@ defmodule PhilomenaWeb.Admin.ReportView do def truncate(<>), do: string <> "..." def truncate(string), do: string - def truncated_ip_link(conn, ip) do + def truncated_ip_link(ip) do case to_string(ip) do <> = ip -> - link(string <> "...", to: Routes.ip_profile_path(conn, :show, ip)) + link(string <> "...", to: ~p"/ip_profiles/#{ip}") ip -> - link(ip, to: Routes.ip_profile_path(conn, :show, ip)) + link(ip, to: ~p"/ip_profiles/#{ip}") end end diff --git a/lib/philomena_web/views/conversation_view.ex b/lib/philomena_web/views/conversation_view.ex index 4ce91283..97ce9c99 100644 --- a/lib/philomena_web/views/conversation_view.ex +++ b/lib/philomena_web/views/conversation_view.ex @@ -32,9 +32,9 @@ 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)) - Routes.conversation_path(conn, :show, conversation, page: page) + ~p"/conversations/#{conversation}?#{[page: page]}" end end diff --git a/lib/philomena_web/views/profile_view.ex b/lib/philomena_web/views/profile_view.ex index e1e73f4d..a10b9e8b 100644 --- a/lib/philomena_web/views/profile_view.ex +++ b/lib/philomena_web/views/profile_view.ex @@ -54,13 +54,20 @@ defmodule PhilomenaWeb.ProfileView do sy = height / 20 factor = 100 / 90 - content_tag :svg, id: "js-graph-svg", width: "100%", preserveAspectRatio: "xMinYMin", viewBox: "0 0 #{width} #{height}" do + content_tag :svg, + id: "js-graph-svg", + width: "100%", + preserveAspectRatio: "xMinYMin", + viewBox: "0 0 #{width} #{height}" do first = List.first(data) last = List.last(data) first_y = sparkline_y(first, max) * sy last_y = sparkline_y(last, max) * sy - indexed_data = data + + indexed_data = + data |> Enum.with_index() + points = indexed_data |> Enum.chunk_every(2, 1, :discard) @@ -68,19 +75,30 @@ defmodule PhilomenaWeb.ProfileView do cy = sparkline_y(cv, max) ny = sparkline_y(nv, max) - "C #{(ci * sx) + 0.5 * sx},#{cy * sy} #{(ni * sx) - 0.5 * sx},#{ny * sy} #{ni * sx},#{ny * sy}" + "C #{ci * sx + 0.5 * sx},#{cy * sy} #{ni * sx - 0.5 * sx},#{ny * sy} #{ni * sx},#{ny * sy}" end) |> Enum.join("") - circles = for {val, i} <- indexed_data do - y = sparkline_y(val, max) * sy + circles = + for {val, i} <- indexed_data do + y = sparkline_y(val, max) * sy - content_tag :circle, class: "barline__dot", cx: "#{i * factor}%", cy: y * sy + 1.25, r: 2.5 do - content_tag(:title, val) + content_tag :circle, + class: "barline__dot", + cx: "#{i * factor}%", + cy: y * sy + 1.25, + r: 2.5 do + content_tag(:title, val) + end end - end - graph = content_tag :path, "", id: "js-graph", class: "barline__bar", d: "M0,#{first_y}#{points}L#{width - sx},#{last_y}L#{width - sx},#{height}L0,#{height}L0,#{first_y}" + graph = + content_tag(:path, "", + id: "js-graph", + class: "barline__bar", + d: + "M0,#{first_y}#{points}L#{width - sx},#{last_y}L#{width - sx},#{height}L0,#{height}L0,#{first_y}" + ) [graph, circles] end @@ -105,16 +123,16 @@ 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)) abbrv = "(" <> abbrv <> ")" - link(abbrv, to: Routes.profile_path(conn, :show, user)) + 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 diff --git a/lib/philomena_web/views/report_view.ex b/lib/philomena_web/views/report_view.ex index 7ffae693..f65fcf09 100644 --- a/lib/philomena_web/views/report_view.ex +++ b/lib/philomena_web/views/report_view.ex @@ -41,42 +41,42 @@ defmodule PhilomenaWeb.ReportView do def pretty_state(%{state: "claimed"}), do: "Claimed" def pretty_state(_report), do: "Open" - def link_to_reported_thing(conn, %Image{} = r), - do: link("Image >>#{r.id}", to: Routes.image_path(conn, :show, r)) + def link_to_reported_thing(%Image{} = r), + do: link("Image >>#{r.id}", to: ~p"/images/#{r}") - def link_to_reported_thing(conn, %Comment{} = r), + def link_to_reported_thing(%Comment{} = r), do: link("Comment on image >>#{r.image.id}", - to: Routes.image_path(conn, :show, r.image) <> "#comment_#{r.id}" + to: ~p"/images/#{r.image}" <> "#comment_#{r.id}" ) - def link_to_reported_thing(conn, %Conversation{} = r), + def link_to_reported_thing(%Conversation{} = r), do: link("Conversation between #{r.from.name} and #{r.to.name}", - to: Routes.conversation_path(conn, :show, r) + to: ~p"/conversations/#{r}" ) - def link_to_reported_thing(conn, %Commission{} = r), + def link_to_reported_thing(%Commission{} = r), do: link("#{r.user.name}'s commission page", - to: Routes.profile_commission_path(conn, :show, r.user) + to: ~p"/profiles/#{r.user}/commission" ) - def link_to_reported_thing(conn, %Gallery{} = r), - do: link("Gallery '#{r.title}' by #{r.creator.name}", to: Routes.gallery_path(conn, :show, r)) + def link_to_reported_thing(%Gallery{} = r), + do: link("Gallery '#{r.title}' by #{r.creator.name}", to: ~p"/galleries/#{r}") - def link_to_reported_thing(conn, %Post{} = r), + def link_to_reported_thing(%Post{} = r), do: link("Post in #{r.topic.title}", to: - Routes.forum_topic_path(conn, :show, r.topic.forum, r.topic, post_id: r.id) <> + ~p"/forums/#{r.topic.forum}/topics/#{r.topic}?#{[post_id: r.id]}" <> "#post_#{r.id}" ) - def link_to_reported_thing(conn, %User{} = r), - do: link("User '#{r.name}'", to: Routes.profile_path(conn, :show, r)) + def link_to_reported_thing(%User{} = r), + do: link("User '#{r.name}'", to: ~p"/profiles/#{r}") - def link_to_reported_thing(_conn, _reportable) do + def link_to_reported_thing(_reportable) do "Reported item permanently destroyed." end end diff --git a/lib/philomena_web/views/setting_view.ex b/lib/philomena_web/views/setting_view.ex index ea95c816..a9eb68cd 100644 --- a/lib/philomena_web/views/setting_view.ex +++ b/lib/philomena_web/views/setting_view.ex @@ -51,7 +51,7 @@ defmodule PhilomenaWeb.SettingView do ] end - def light_theme_options(conn) do + def light_theme_options do [ [ key: "Red", diff --git a/test/philomena_web/controllers/confirmation_controller_test.exs b/test/philomena_web/controllers/confirmation_controller_test.exs index 55cbb172..049fd6d1 100644 --- a/test/philomena_web/controllers/confirmation_controller_test.exs +++ b/test/philomena_web/controllers/confirmation_controller_test.exs @@ -12,7 +12,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do describe "GET /confirmations/new" do test "renders the confirmation page", %{conn: conn} do - conn = get(conn, Routes.confirmation_path(conn, :new)) + conn = get(conn, ~p"/confirmations/new") response = html_response(conn, 200) assert response =~ "

Resend confirmation instructions

" end @@ -22,7 +22,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do @tag :capture_log test "sends a new confirmation token", %{conn: conn, user: user} do conn = - post(conn, Routes.confirmation_path(conn, :create), %{ + post(conn, ~p"/confirmations", %{ "user" => %{"email" => user.email} }) @@ -35,7 +35,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do Repo.update!(Users.User.confirm_changeset(user)) conn = - post(conn, Routes.confirmation_path(conn, :create), %{ + post(conn, ~p"/confirmations", %{ "user" => %{"email" => user.email} }) @@ -46,7 +46,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do test "does not send confirmation token if email is invalid", %{conn: conn} do conn = - post(conn, Routes.confirmation_path(conn, :create), %{ + post(conn, ~p"/confirmations", %{ "user" => %{"email" => "unknown@example.com"} }) @@ -63,14 +63,14 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do Users.deliver_user_confirmation_instructions(user, url) end) - conn = get(conn, Routes.confirmation_path(conn, :show, token)) + conn = get(conn, ~p"/confirmations/#{token}") assert redirected_to(conn) == "/" assert Flash.get(conn.assigns.flash, :info) =~ "Account confirmed successfully" assert Users.get_user!(user.id).confirmed_at refute get_session(conn, :user_token) assert Repo.all(Users.UserToken) == [] - conn = get(conn, Routes.confirmation_path(conn, :show, token)) + conn = get(conn, ~p"/confirmations/#{token}") assert redirected_to(conn) == "/" assert Flash.get(conn.assigns.flash, :error) =~ @@ -78,7 +78,7 @@ defmodule PhilomenaWeb.ConfirmationControllerTest do end test "does not confirm email with invalid token", %{conn: conn, user: user} do - conn = get(conn, Routes.confirmation_path(conn, :show, "oops")) + conn = get(conn, ~p"/confirmations/oops") assert redirected_to(conn) == "/" assert Flash.get(conn.assigns.flash, :error) =~ diff --git a/test/philomena_web/controllers/password_controller_test.exs b/test/philomena_web/controllers/password_controller_test.exs index 4d421f72..b74cf046 100644 --- a/test/philomena_web/controllers/password_controller_test.exs +++ b/test/philomena_web/controllers/password_controller_test.exs @@ -12,7 +12,7 @@ defmodule PhilomenaWeb.PasswordControllerTest do describe "GET /passwords/new" do test "renders the reset password page", %{conn: conn} do - conn = get(conn, Routes.password_path(conn, :new)) + conn = get(conn, ~p"/passwords/new") html_response(conn, 200) end end @@ -21,7 +21,7 @@ defmodule PhilomenaWeb.PasswordControllerTest do @tag :capture_log test "sends a new reset password token", %{conn: conn, user: user} do conn = - post(conn, Routes.password_path(conn, :create), %{ + post(conn, ~p"/passwords", %{ "user" => %{"email" => user.email} }) @@ -32,7 +32,7 @@ defmodule PhilomenaWeb.PasswordControllerTest do test "does not send reset password token if email is invalid", %{conn: conn} do conn = - post(conn, Routes.password_path(conn, :create), %{ + post(conn, ~p"/passwords", %{ "user" => %{"email" => "unknown@example.com"} }) @@ -53,12 +53,12 @@ defmodule PhilomenaWeb.PasswordControllerTest do end test "renders reset password", %{conn: conn, token: token} do - conn = get(conn, Routes.password_path(conn, :edit, token)) + conn = get(conn, ~p"/passwords/#{token}/edit") html_response(conn, 200) end test "does not render reset password with invalid token", %{conn: conn} do - conn = get(conn, Routes.password_path(conn, :edit, "oops")) + conn = get(conn, ~p"/passwords/oops/edit") assert redirected_to(conn) == "/" assert Flash.get(conn.assigns.flash, :error) =~ @@ -78,14 +78,14 @@ defmodule PhilomenaWeb.PasswordControllerTest do test "resets password once", %{conn: conn, user: user, token: token} do conn = - put(conn, Routes.password_path(conn, :update, token), %{ + put(conn, ~p"/passwords/#{token}", %{ "user" => %{ "password" => "new valid password", "password_confirmation" => "new valid password" } }) - assert redirected_to(conn) == Routes.session_path(conn, :new) + assert redirected_to(conn) == ~p"/sessions/new" refute get_session(conn, :user_token) assert Flash.get(conn.assigns.flash, :info) =~ "Password reset successfully" assert Users.get_user_by_email_and_password(user.email, "new valid password", & &1) @@ -93,7 +93,7 @@ defmodule PhilomenaWeb.PasswordControllerTest do test "does not reset password on invalid data", %{conn: conn, token: token} do conn = - put(conn, Routes.password_path(conn, :update, token), %{ + put(conn, ~p"/passwords/#{token}", %{ "user" => %{ "password" => "too short", "password_confirmation" => "does not match" @@ -106,7 +106,7 @@ defmodule PhilomenaWeb.PasswordControllerTest do end test "does not reset password with invalid token", %{conn: conn} do - conn = put(conn, Routes.password_path(conn, :update, "oops")) + conn = put(conn, ~p"/passwords/oops") assert redirected_to(conn) == "/" assert Flash.get(conn.assigns.flash, :error) =~ diff --git a/test/philomena_web/controllers/registration/email_controller_test.exs b/test/philomena_web/controllers/registration/email_controller_test.exs index 2107a80f..756fea2e 100644 --- a/test/philomena_web/controllers/registration/email_controller_test.exs +++ b/test/philomena_web/controllers/registration/email_controller_test.exs @@ -11,19 +11,19 @@ defmodule PhilomenaWeb.Registration.EmailControllerTest do @tag :capture_log test "updates the user email", %{conn: conn, user: user} do conn = - post(conn, Routes.registration_email_path(conn, :create), %{ + post(conn, ~p"/registrations/email", %{ "current_password" => valid_user_password(), "user" => %{"email" => unique_user_email()} }) - assert redirected_to(conn) == Routes.registration_path(conn, :edit) + assert redirected_to(conn) == ~p"/registrations/edit" assert Flash.get(conn.assigns.flash, :info) =~ "A link to confirm your email" assert Users.get_user_by_email(user.email) end test "does not update email on invalid data", %{conn: conn} do conn = - post(conn, Routes.registration_email_path(conn, :create), %{ + post(conn, ~p"/registrations/email", %{ "current_password" => "invalid", "user" => %{"email" => "with spaces"} }) @@ -45,22 +45,22 @@ defmodule PhilomenaWeb.Registration.EmailControllerTest do end test "updates the user email once", %{conn: conn, user: user, token: token, email: email} do - conn = get(conn, Routes.registration_email_path(conn, :show, token)) - assert redirected_to(conn) == Routes.registration_path(conn, :edit) + conn = get(conn, ~p"/registrations/email/#{token}") + assert redirected_to(conn) == ~p"/registrations/edit" assert Flash.get(conn.assigns.flash, :info) =~ "Email changed successfully" refute Users.get_user_by_email(user.email) assert Users.get_user_by_email(email) - conn = get(conn, Routes.registration_email_path(conn, :show, token)) - assert redirected_to(conn) == Routes.registration_path(conn, :edit) + conn = get(conn, ~p"/registrations/email/#{token}") + assert redirected_to(conn) == ~p"/registrations/edit" assert Flash.get(conn.assigns.flash, :error) =~ "Email change link is invalid or it has expired" end test "does not update email with invalid token", %{conn: conn, user: user} do - conn = get(conn, Routes.registration_email_path(conn, :show, "oops")) - assert redirected_to(conn) == Routes.registration_path(conn, :edit) + conn = get(conn, ~p"/registrations/email/oops") + assert redirected_to(conn) == ~p"/registrations/edit" assert Flash.get(conn.assigns.flash, :error) =~ "Email change link is invalid or it has expired" @@ -70,8 +70,8 @@ defmodule PhilomenaWeb.Registration.EmailControllerTest do test "redirects if user is not logged in", %{token: token} do conn = build_conn() - conn = get(conn, Routes.registration_email_path(conn, :show, token)) - assert redirected_to(conn) == Routes.session_path(conn, :new) + conn = get(conn, ~p"/registrations/email/#{token}") + assert redirected_to(conn) == ~p"/sessions/new" end end end diff --git a/test/philomena_web/controllers/registration/password_controller_test.exs b/test/philomena_web/controllers/registration/password_controller_test.exs index 3e216805..b850e7af 100644 --- a/test/philomena_web/controllers/registration/password_controller_test.exs +++ b/test/philomena_web/controllers/registration/password_controller_test.exs @@ -10,7 +10,7 @@ defmodule PhilomenaWeb.Registration.PasswordControllerTest do describe "PUT /registrations/password" do test "updates the user password and resets tokens", %{conn: conn, user: user} do new_password_conn = - put(conn, Routes.registration_password_path(conn, :update), %{ + put(conn, ~p"/registrations/password", %{ "current_password" => valid_user_password(), "user" => %{ "password" => "new valid password", @@ -18,7 +18,7 @@ defmodule PhilomenaWeb.Registration.PasswordControllerTest do } }) - assert redirected_to(new_password_conn) == Routes.registration_path(conn, :edit) + assert redirected_to(new_password_conn) == ~p"/registrations/edit" assert get_session(new_password_conn, :user_token) != get_session(conn, :user_token) assert Flash.get(new_password_conn.assigns.flash, :info) =~ "Password updated successfully" assert Users.get_user_by_email_and_password(user.email, "new valid password", & &1) @@ -26,7 +26,7 @@ defmodule PhilomenaWeb.Registration.PasswordControllerTest do test "does not update password on invalid data", %{conn: conn} do old_password_conn = - put(conn, Routes.registration_password_path(conn, :update), %{ + put(conn, ~p"/registrations/password", %{ "current_password" => "invalid", "user" => %{ "password" => "too short", @@ -34,7 +34,7 @@ defmodule PhilomenaWeb.Registration.PasswordControllerTest do } }) - assert redirected_to(old_password_conn) == Routes.registration_path(conn, :edit) + assert redirected_to(old_password_conn) == ~p"/registrations/edit" assert Flash.get(old_password_conn.assigns.flash, :error) =~ "Failed to update password" assert get_session(old_password_conn, :user_token) == get_session(conn, :user_token) end diff --git a/test/philomena_web/controllers/registration_controller_test.exs b/test/philomena_web/controllers/registration_controller_test.exs index 0ee59d90..dc557666 100644 --- a/test/philomena_web/controllers/registration_controller_test.exs +++ b/test/philomena_web/controllers/registration_controller_test.exs @@ -5,13 +5,13 @@ defmodule PhilomenaWeb.RegistrationControllerTest do describe "GET /registrations/new" do test "renders registration page", %{conn: conn} do - conn = get(conn, Routes.registration_path(conn, :new)) + conn = get(conn, ~p"/registrations/new") html_response(conn, 200) end test "redirects if already logged in", %{conn: conn} do conn = - conn |> log_in_user(confirmed_user_fixture()) |> get(Routes.registration_path(conn, :new)) + conn |> log_in_user(confirmed_user_fixture()) |> get(~p"/registrations/new") assert redirected_to(conn) == "/" end @@ -23,7 +23,7 @@ defmodule PhilomenaWeb.RegistrationControllerTest do email = unique_user_email() conn = - post(conn, Routes.registration_path(conn, :create), %{ + post(conn, ~p"/registrations", %{ "user" => %{"name" => email, "email" => email, "password" => valid_user_password()} }) @@ -36,7 +36,7 @@ defmodule PhilomenaWeb.RegistrationControllerTest do test "render errors for invalid data", %{conn: conn} do conn = - post(conn, Routes.registration_path(conn, :create), %{ + post(conn, ~p"/registrations", %{ "user" => %{"email" => "with spaces", "password" => "too short"} }) @@ -50,15 +50,15 @@ defmodule PhilomenaWeb.RegistrationControllerTest do setup :register_and_log_in_user test "renders settings page", %{conn: conn} do - conn = get(conn, Routes.registration_path(conn, :edit)) + conn = get(conn, ~p"/registrations/edit") response = html_response(conn, 200) assert response =~ "Settings" end test "redirects if user is not logged in" do conn = build_conn() - conn = get(conn, Routes.registration_path(conn, :edit)) - assert redirected_to(conn) == Routes.session_path(conn, :new) + conn = get(conn, ~p"/registrations/edit") + assert redirected_to(conn) == ~p"/sessions/new" end end end diff --git a/test/philomena_web/controllers/session_controller_test.exs b/test/philomena_web/controllers/session_controller_test.exs index 78e14834..29d8d7f2 100644 --- a/test/philomena_web/controllers/session_controller_test.exs +++ b/test/philomena_web/controllers/session_controller_test.exs @@ -9,12 +9,12 @@ defmodule PhilomenaWeb.SessionControllerTest do describe "GET /sessions/new" do test "renders log in page", %{conn: conn} do - conn = get(conn, Routes.session_path(conn, :new)) + conn = get(conn, ~p"/sessions/new") html_response(conn, 200) end test "redirects if already logged in", %{conn: conn, user: user} do - conn = conn |> log_in_user(user) |> get(Routes.session_path(conn, :new)) + conn = conn |> log_in_user(user) |> get(~p"/sessions/new") assert redirected_to(conn) == "/" end end @@ -22,7 +22,7 @@ defmodule PhilomenaWeb.SessionControllerTest do describe "POST /sessions" do test "logs the user in", %{conn: conn, user: user} do conn = - post(conn, Routes.session_path(conn, :create), %{ + post(conn, ~p"/sessions", %{ "user" => %{"email" => user.email, "password" => valid_user_password()} }) @@ -39,7 +39,7 @@ defmodule PhilomenaWeb.SessionControllerTest do test "logs the user in with remember me", %{conn: conn, user: user} do conn = - post(conn, Routes.session_path(conn, :create), %{ + post(conn, ~p"/sessions", %{ "user" => %{ "email" => user.email, "password" => valid_user_password(), @@ -53,7 +53,7 @@ defmodule PhilomenaWeb.SessionControllerTest do test "emits error message with invalid credentials", %{conn: conn, user: user} do conn = - post(conn, Routes.session_path(conn, :create), %{ + post(conn, ~p"/sessions", %{ "user" => %{"email" => user.email, "password" => "invalid_password"} }) @@ -64,7 +64,7 @@ defmodule PhilomenaWeb.SessionControllerTest do describe "DELETE /sessions" do test "logs the user out", %{conn: conn, user: user} do - conn = conn |> log_in_user(user) |> delete(Routes.session_path(conn, :delete)) + conn = conn |> log_in_user(user) |> delete(~p"/sessions") assert redirected_to(conn) == "/" refute get_session(conn, :user_token) assert Phoenix.Flash.get(conn.assigns.flash, :info) =~ "Logged out successfully" diff --git a/test/philomena_web/controllers/unlock_controller_test.exs b/test/philomena_web/controllers/unlock_controller_test.exs index d506e90a..bc8df85e 100644 --- a/test/philomena_web/controllers/unlock_controller_test.exs +++ b/test/philomena_web/controllers/unlock_controller_test.exs @@ -12,7 +12,7 @@ defmodule PhilomenaWeb.UnlockControllerTest do describe "GET /unlocks/new" do test "renders the unlock page", %{conn: conn} do - conn = get(conn, Routes.unlock_path(conn, :new)) + conn = get(conn, ~p"/unlocks/new") response = html_response(conn, 200) assert response =~ "

Resend unlock instructions

" end @@ -22,7 +22,7 @@ defmodule PhilomenaWeb.UnlockControllerTest do @tag :capture_log test "sends a new unlock token", %{conn: conn, user: user} do conn = - post(conn, Routes.unlock_path(conn, :create), %{ + post(conn, ~p"/unlocks", %{ "user" => %{"email" => user.email} }) @@ -35,7 +35,7 @@ defmodule PhilomenaWeb.UnlockControllerTest do Repo.update!(Users.User.unlock_changeset(user)) conn = - post(conn, Routes.unlock_path(conn, :create), %{ + post(conn, ~p"/unlocks", %{ "user" => %{"email" => user.email} }) @@ -46,7 +46,7 @@ defmodule PhilomenaWeb.UnlockControllerTest do test "does not send unlock token if email is invalid", %{conn: conn} do conn = - post(conn, Routes.unlock_path(conn, :create), %{ + post(conn, ~p"/unlocks", %{ "user" => %{"email" => "unknown@example.com"} }) @@ -63,20 +63,20 @@ defmodule PhilomenaWeb.UnlockControllerTest do Users.deliver_user_unlock_instructions(user, url) end) - conn = get(conn, Routes.unlock_path(conn, :show, token)) + conn = get(conn, ~p"/unlocks/#{token}") assert redirected_to(conn) == "/" assert Flash.get(conn.assigns.flash, :info) =~ "Account unlocked successfully" refute Users.get_user!(user.id).locked_at refute get_session(conn, :user_token) assert Repo.all(Users.UserToken) == [] - conn = get(conn, Routes.unlock_path(conn, :show, token)) + conn = get(conn, ~p"/unlocks/#{token}") assert redirected_to(conn) == "/" assert Flash.get(conn.assigns.flash, :error) =~ "Unlock link is invalid or it has expired" end test "does not unlock with invalid token", %{conn: conn, user: user} do - conn = get(conn, Routes.unlock_path(conn, :show, "oops")) + conn = get(conn, ~p"/unlocks/oops") assert redirected_to(conn) == "/" assert Flash.get(conn.assigns.flash, :error) =~ "Unlock link is invalid or it has expired" assert Users.get_user!(user.id).locked_at diff --git a/test/philomena_web/user_auth_test.exs b/test/philomena_web/user_auth_test.exs index e03912fe..deeaeca7 100644 --- a/test/philomena_web/user_auth_test.exs +++ b/test/philomena_web/user_auth_test.exs @@ -162,7 +162,7 @@ defmodule PhilomenaWeb.UserAuthTest do test "redirects if user is not authenticated", %{conn: conn} do conn = conn |> fetch_flash() |> UserAuth.require_authenticated_user([]) assert conn.halted - assert redirected_to(conn) == Routes.session_path(conn, :new) + assert redirected_to(conn) == ~p"/sessions/new" assert Phoenix.Flash.get(conn.assigns.flash, :error) == "You must log in to access this page."