From f232f38d9193c19c8092592a1ed4f8461f5c26ac Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 27 Apr 2024 22:58:43 -0400 Subject: [PATCH 01/12] Add verified routes to web --- lib/philomena_web.ex | 15 +++++++++++++++ .../controllers/channel_controller.ex | 10 +++++----- lib/philomena_web/plugs/tor_plug.ex | 2 ++ lib/philomena_web/plugs/totp_plug.ex | 1 + lib/philomena_web/user_auth.ex | 2 ++ test/support/conn_case.ex | 2 ++ 6 files changed, 27 insertions(+), 5 deletions(-) diff --git a/lib/philomena_web.ex b/lib/philomena_web.ex index 8831505b1..4a8fbcb84 100644 --- a/lib/philomena_web.ex +++ b/lib/philomena_web.ex @@ -17,6 +17,8 @@ defmodule PhilomenaWeb do and import those modules here. """ + def static_paths, do: ~w(assets images favicon.ico favicon.svg robots.txt) + def controller do quote do use Phoenix.Controller, namespace: PhilomenaWeb @@ -26,6 +28,8 @@ defmodule PhilomenaWeb do import Canary.Plugs import PhilomenaWeb.ModerationLogPlug, only: [moderation_log: 2] alias PhilomenaWeb.Router.Helpers, as: Routes + + unquote(verified_routes()) end end @@ -47,6 +51,8 @@ defmodule PhilomenaWeb do # Wrong way around for convenience import PhilomenaWeb.AppView + + unquote(verified_routes()) end end @@ -65,6 +71,15 @@ defmodule PhilomenaWeb do end end + def verified_routes do + quote do + use Phoenix.VerifiedRoutes, + endpoint: PhilomenaWeb.Endpoint, + router: PhilomenaWeb.Router, + statics: PhilomenaWeb.static_paths() + end + end + @doc """ When used, dispatch to the appropriate controller/view/etc. """ diff --git a/lib/philomena_web/controllers/channel_controller.ex b/lib/philomena_web/controllers/channel_controller.ex index 24684dc46..973017d35 100644 --- a/lib/philomena_web/controllers/channel_controller.ex +++ b/lib/philomena_web/controllers/channel_controller.ex @@ -39,7 +39,7 @@ defmodule PhilomenaWeb.ChannelController do if user, do: Channels.clear_notification(channel, user) - redirect(conn, external: url(channel)) + redirect(conn, external: channel_url(channel)) end def new(conn, _params) do @@ -101,15 +101,15 @@ defmodule PhilomenaWeb.ChannelController do defp maybe_show_nsfw(query, true), do: query defp maybe_show_nsfw(query, _falsy), do: where(query, [c], c.nsfw == false) - defp url(%{type: "LivestreamChannel", short_name: short_name}), + defp channel_url(%{type: "LivestreamChannel", short_name: short_name}), do: "http://www.livestream.com/#{short_name}" - defp url(%{type: "PicartoChannel", short_name: short_name}), + defp channel_url(%{type: "PicartoChannel", short_name: short_name}), do: "https://picarto.tv/#{short_name}" - defp url(%{type: "PiczelChannel", short_name: short_name}), + defp channel_url(%{type: "PiczelChannel", short_name: short_name}), do: "https://piczel.tv/watch/#{short_name}" - defp url(%{type: "TwitchChannel", short_name: short_name}), + defp channel_url(%{type: "TwitchChannel", short_name: short_name}), do: "https://www.twitch.tv/#{short_name}" end diff --git a/lib/philomena_web/plugs/tor_plug.ex b/lib/philomena_web/plugs/tor_plug.ex index 1cd51f70a..8e6cc4e35 100644 --- a/lib/philomena_web/plugs/tor_plug.ex +++ b/lib/philomena_web/plugs/tor_plug.ex @@ -7,6 +7,8 @@ defmodule PhilomenaWeb.TorPlug do plug PhilomenaWeb.TorPlug """ alias PhilomenaWeb.Router.Helpers, as: Routes + use PhilomenaWeb, :verified_routes + alias Phoenix.Controller alias Plug.Conn diff --git a/lib/philomena_web/plugs/totp_plug.ex b/lib/philomena_web/plugs/totp_plug.ex index 9d8665c92..30f87378b 100644 --- a/lib/philomena_web/plugs/totp_plug.ex +++ b/lib/philomena_web/plugs/totp_plug.ex @@ -8,6 +8,7 @@ defmodule PhilomenaWeb.TotpPlug do """ alias PhilomenaWeb.Router.Helpers, as: Routes + use PhilomenaWeb, :verified_routes @doc false @spec init(any()) :: any() diff --git a/lib/philomena_web/user_auth.ex b/lib/philomena_web/user_auth.ex index 84b79a70f..af7166cfc 100644 --- a/lib/philomena_web/user_auth.ex +++ b/lib/philomena_web/user_auth.ex @@ -7,6 +7,8 @@ defmodule PhilomenaWeb.UserAuth do alias PhilomenaWeb.UserIpUpdater alias PhilomenaWeb.UserFingerprintUpdater + use PhilomenaWeb, :verified_routes + # Make the remember me cookie valid for 365 days. # If you want bump or reduce this value, also change # the token expiry itself in UserToken. diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index aafac2245..151ed056e 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -25,6 +25,8 @@ defmodule PhilomenaWeb.ConnCase do # The default endpoint for testing @endpoint PhilomenaWeb.Endpoint + + use PhilomenaWeb, :verified_routes end end From c64606ae024d0146ef8e8619f37ddbc6f804a866 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 28 Apr 2024 20:29:36 -0400 Subject: [PATCH 02/12] Fix comment routes --- lib/philomena/users.ex | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/philomena/users.ex b/lib/philomena/users.ex index 0ce7a8251..b971f0c95 100644 --- a/lib/philomena/users.ex +++ b/lib/philomena/users.ex @@ -213,12 +213,12 @@ defmodule Philomena.Users do |> Ecto.Multi.delete_all(:tokens, UserToken.user_and_contexts_query(user, [context])) end - @doc """ + @doc ~S""" Delivers the update email instructions to the given user. ## Examples - iex> deliver_update_email_instructions(user, current_email, &Routes.user_update_email_url(conn, :edit, &1)) + iex> deliver_update_email_instructions(user, current_email, &url(~p"/registrations/email/#{&1})") {:ok, %{to: ..., body: ...}} """ @@ -263,12 +263,12 @@ defmodule Philomena.Users do |> Repo.update() end - @doc """ + @doc ~S""" Delivers the unlock instructions to the given user. ## Examples - iex> deliver_user_unlock_instructions(user, &Routes.unlock_url(conn, :show, &1)) + iex> deliver_user_unlock_instructions(user, &url(~p"/unlocks/#{&1}")) {:ok, %{to: ..., body: ...}} """ @@ -379,15 +379,15 @@ defmodule Philomena.Users do ## Confirmation - @doc """ + @doc ~S""" Delivers the confirmation email instructions to the given user. ## Examples - iex> deliver_user_confirmation_instructions(user, &Routes.user_confirmation_url(conn, :confirm, &1)) + iex> deliver_user_confirmation_instructions(user, &url(~p"/confirmations/#{&1}")) {:ok, %{to: ..., body: ...}} - iex> deliver_user_confirmation_instructions(confirmed_user, &Routes.user_confirmation_url(conn, :confirm, &1)) + iex> deliver_user_confirmation_instructions(confirmed_user, &url(~p"/confirmations/#{&1}")) {:error, :already_confirmed} """ @@ -426,12 +426,12 @@ defmodule Philomena.Users do ## Reset password - @doc """ + @doc ~S""" Delivers the reset password email to the given user. ## Examples - iex> deliver_user_reset_password_instructions(user, &Routes.user_reset_password_url(conn, :edit, &1)) + iex> deliver_user_reset_password_instructions(user, &url(~p"/passwords/#{&1}/edit")) {:ok, %{to: ..., body: ...}} """ From 2f7f1b38029e67c20dacf0ef4eb1c10a9d1b9aff Mon Sep 17 00:00:00 2001 From: Liam Date: Sat, 27 Apr 2024 23:01:16 -0400 Subject: [PATCH 03/12] Remove static paths --- lib/philomena_web.ex | 2 +- lib/philomena_web/templates/error/show.html.slime | 4 ++-- .../templates/image/_image_target.html.slime | 2 +- lib/philomena_web/templates/layout/app.html.slime | 10 +++++----- .../templates/layout/two_factor.html.slime | 4 ++-- .../templates/setting/edit.html.slime | 2 +- lib/philomena_web/views/error_view.ex | 4 ++-- lib/philomena_web/views/layout_view.ex | 15 ++++----------- lib/philomena_web/views/setting_view.ex | 8 ++++---- 9 files changed, 22 insertions(+), 29 deletions(-) diff --git a/lib/philomena_web.ex b/lib/philomena_web.ex index 4a8fbcb84..f72344806 100644 --- a/lib/philomena_web.ex +++ b/lib/philomena_web.ex @@ -17,7 +17,7 @@ defmodule PhilomenaWeb do and import those modules here. """ - def static_paths, do: ~w(assets images favicon.ico favicon.svg robots.txt) + def static_paths, do: ~w(assets favicon.ico favicon.svg robots.txt) def controller do quote do diff --git a/lib/philomena_web/templates/error/show.html.slime b/lib/philomena_web/templates/error/show.html.slime index c0256043f..a48ae8f39 100644 --- a/lib/philomena_web/templates/error/show.html.slime +++ b/lib/philomena_web/templates/error/show.html.slime @@ -8,8 +8,8 @@ html lang="en" title => @status | - Philomena - link rel="stylesheet" href=stylesheet_path(@conn, nil) - link rel="stylesheet" href=dark_stylesheet_path(@conn) media="(prefers-color-scheme: dark)" + link rel="stylesheet" href=stylesheet_path(nil) + link rel="stylesheet" href=dark_stylesheet_path() media="(prefers-color-scheme: dark)" link rel="icon" href="/favicon.ico" type="image/x-icon" link rel="icon" href="/favicon.svg" type="image/svg+xml" diff --git a/lib/philomena_web/templates/image/_image_target.html.slime b/lib/philomena_web/templates/image/_image_target.html.slime index 453154043..3443c74ae 100644 --- a/lib/philomena_web/templates/image/_image_target.html.slime +++ b/lib/philomena_web/templates/image/_image_target.html.slime @@ -6,7 +6,7 @@ strong = link("This image is blocked by your current filter - click here to display it anyway", to: "#", data: [click_unfilter: @image.id]) p - = img_tag(Routes.static_path(PhilomenaWeb.Endpoint, "/images/tagblocked.svg"), width: 250, height: 250, data: [click_unfilter: @image.id]) + = 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") ' . diff --git a/lib/philomena_web/templates/layout/app.html.slime b/lib/philomena_web/templates/layout/app.html.slime index e86528eb0..29013972b 100644 --- a/lib/philomena_web/templates/layout/app.html.slime +++ b/lib/philomena_web/templates/layout/app.html.slime @@ -10,11 +10,11 @@ html lang="en" ' - Derpibooru - else ' Derpibooru - link rel="stylesheet" href=stylesheet_path(@conn, @current_user) + link rel="stylesheet" href=stylesheet_path(@current_user) = if is_nil(@current_user) do - link rel="stylesheet" href=dark_stylesheet_path(@conn) media="(prefers-color-scheme: dark)" - link rel="icon" href="/favicon.ico" type="image/x-icon" - link rel="icon" href="/favicon.svg" type="image/svg+xml" + link rel="stylesheet" href=dark_stylesheet_path() media="(prefers-color-scheme: dark)" + link rel="icon" href=~p"/favicon.ico" type="image/x-icon" + link rel="icon" href=~p"/favicon.svg" type="image/svg+xml" meta name="generator" content="philomena" meta name="theme-color" content="#618fc3" meta name="format-detection" content="telephone=no" @@ -24,7 +24,7 @@ html lang="en" script type="module" src="http://localhost:5173/@vite/client" script type="module" src="http://localhost:5173/js/app.js" - else - script type="text/javascript" src=Routes.static_path(@conn, "/js/app.js") async="async" + script type="text/javascript" src=~p"/js/app.js" async="async" = render PhilomenaWeb.LayoutView, "_opengraph.html", assigns body data-theme=theme_name(@current_user) data-vite-reload=to_string(vite_reload?()) = render PhilomenaWeb.LayoutView, "_burger.html", assigns diff --git a/lib/philomena_web/templates/layout/two_factor.html.slime b/lib/philomena_web/templates/layout/two_factor.html.slime index 2d2fc4bb1..416a8732c 100644 --- a/lib/philomena_web/templates/layout/two_factor.html.slime +++ b/lib/philomena_web/templates/layout/two_factor.html.slime @@ -6,8 +6,8 @@ html lang="en" = viewport_meta_tag(@conn) title Two Factor Authentication - Derpibooru - link rel="stylesheet" href=stylesheet_path(@conn, nil) - link rel="stylesheet" href=dark_stylesheet_path(@conn) media="(prefers-color-scheme: dark)" + link rel="stylesheet" href=stylesheet_path(nil) + link rel="stylesheet" href=dark_stylesheet_path() media="(prefers-color-scheme: dark)" link rel="icon" href="/favicon.ico" type="image/x-icon" link rel="icon" href="/favicon.svg" type="image/svg+xml" diff --git a/lib/philomena_web/templates/setting/edit.html.slime b/lib/philomena_web/templates/setting/edit.html.slime index 92e130385..2809de422 100644 --- a/lib/philomena_web/templates/setting/edit.html.slime +++ b/lib/philomena_web/templates/setting/edit.html.slime @@ -79,7 +79,7 @@ h1 Content Settings ' For 1080p monitors, try 24. .field => label f, :theme - => select f, :theme, theme_options(@conn), class: "input" + => select f, :theme, theme_options(), class: "input" = error_tag f, :theme .fieldlabel: i Preview themes by selecting one from the dropdown. Saving sets the currently selected theme. .field diff --git a/lib/philomena_web/views/error_view.ex b/lib/philomena_web/views/error_view.ex index 8bf8c1d08..9e1d8566c 100644 --- a/lib/philomena_web/views/error_view.ex +++ b/lib/philomena_web/views/error_view.ex @@ -3,8 +3,8 @@ defmodule PhilomenaWeb.ErrorView do import PhilomenaWeb.LayoutView, only: [ - stylesheet_path: 2, - dark_stylesheet_path: 1, + stylesheet_path: 1, + dark_stylesheet_path: 0, viewport_meta_tag: 1 ] diff --git a/lib/philomena_web/views/layout_view.ex b/lib/philomena_web/views/layout_view.ex index fe338f096..b9c2210bf 100644 --- a/lib/philomena_web/views/layout_view.ex +++ b/lib/philomena_web/views/layout_view.ex @@ -69,17 +69,10 @@ defmodule PhilomenaWeb.LayoutView do Config.get(:footer) end - def stylesheet_path(conn, %{theme: "dark"}), - do: Routes.static_path(conn, "/css/dark.css") - - def stylesheet_path(conn, %{theme: "red"}), - do: Routes.static_path(conn, "/css/red.css") - - def stylesheet_path(conn, _user), - do: Routes.static_path(conn, "/css/default.css") - - def dark_stylesheet_path(conn), - do: Routes.static_path(conn, "/css/dark.css") + def stylesheet_path(%{theme: "dark"}), do: ~p"/css/dark.css" + def stylesheet_path(%{theme: "red"}), do: ~p"/css/red.css" + def stylesheet_path(_user), do: ~p"/css/default.css" + def dark_stylesheet_path, do: ~p"/css/dark.css" def theme_name(%{theme: theme}), do: theme def theme_name(_user), do: "default" diff --git a/lib/philomena_web/views/setting_view.ex b/lib/philomena_web/views/setting_view.ex index df3133853..ac08b4fce 100644 --- a/lib/philomena_web/views/setting_view.ex +++ b/lib/philomena_web/views/setting_view.ex @@ -1,15 +1,15 @@ defmodule PhilomenaWeb.SettingView do use PhilomenaWeb, :view - def theme_options(conn) do + def theme_options do [ [ key: "Default", value: "default", - data: [theme_path: Routes.static_path(conn, "/css/default.css")] + data: [theme_path: ~p"/css/default.css"] ], - [key: "Dark", value: "dark", data: [theme_path: Routes.static_path(conn, "/css/dark.css")]], - [key: "Red", value: "red", data: [theme_path: Routes.static_path(conn, "/css/red.css")]] + [key: "Dark", value: "dark", data: [theme_path: ~p"/css/dark.css"]], + [key: "Red", value: "red", data: [theme_path: ~p"/css/red.css"]] ] end From 974d2109e2afbc066a2470ddea3f1c5e3ad44945 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 28 Apr 2024 17:30:30 -0400 Subject: [PATCH 04/12] Add automatic converter --- lib/mix/tasks/convert_to_verified_routes.ex | 233 ++++++++++++++++++++ 1 file changed, 233 insertions(+) create mode 100644 lib/mix/tasks/convert_to_verified_routes.ex diff --git a/lib/mix/tasks/convert_to_verified_routes.ex b/lib/mix/tasks/convert_to_verified_routes.ex new file mode 100644 index 000000000..ad643d2bf --- /dev/null +++ b/lib/mix/tasks/convert_to_verified_routes.ex @@ -0,0 +1,233 @@ +defmodule Mix.Tasks.ConvertToVerifiedRoutes do + @moduledoc """ + Replaces routes with verified routes. + Forked from + https://gist.github.com/andreaseriksson/e454b9244a734310d4ab74d8595f98cd + https://gist.github.com/jiegillet/e6357c82e36a848ad59295eb3d5a1135 + + This requires all routes to consistently be aliased with + alias PhilomenaWeb.Router.Helpers, as: Routes + + Run with + mix convert_to_verified_routes + """ + + use Mix.Task + + @regex ~r/(Routes\.)([a-zA-Z0-9_]+)(path|url)\(/ + @web_module PhilomenaWeb + + def run(_) do + Path.wildcard("test/**/*.ex*") + |> Enum.concat(Path.wildcard("lib/**/*.ex*")) + |> Enum.concat(Path.wildcard("lib/**/*.eex*")) + |> Enum.concat(Path.wildcard("lib/**/*.slime")) + |> Enum.sort() + |> Enum.reject(&String.contains?(&1, "convert_to_verified_routes.ex")) + |> Enum.filter(&(&1 |> File.read!() |> String.contains?("Routes."))) + |> Enum.each(&format_file/1) + + :ok + end + + def format_file(filename) do + Mix.shell().info(filename) + + formatted_content = + filename + |> File.read!() + |> format_string() + + File.write!(filename, [formatted_content]) + end + + def format_string(source) do + case Regex.run(@regex, source, capture: :first, return: :index) do + [{index, length}] -> + # Compute full length of expression + length = nibble_expression(source, index, length) + + # Convert to verified route format + route = format_route(String.slice(source, index, length)) + + # Split string around expression + prefix = String.slice(source, 0, index) + suffix = String.slice(source, index + length, String.length(source)) + + # Insert verified route and rerun + format_string("#{prefix}#{route}#{suffix}") + + _ -> + source + end + end + + defp nibble_expression(source, index, length) do + if index + length > String.length(source) do + raise "Failed to match route expression" + end + + case Code.string_to_quoted(String.slice(source, index, length)) do + {:ok, _macro} -> + length + + _ -> + nibble_expression(source, index, length + 1) + end + end + + defp format_route(route) do + ast = + Code.string_to_quoted!(route, + literal_encoder: &{:ok, {:__block__, &2, [&1]}}, + unescape: false, + token_metadata: true + ) + + ast + |> Macro.prewalk(&replace_route/1) + |> Code.quoted_to_algebra(escape: false) + |> Inspect.Algebra.format(:infinity) + end + + defp decode_literal(literal) when is_binary(literal) or is_integer(literal) do + {:ok, literal} + end + + defp decode_literal({:__block__, _, [literal]}) do + {:ok, literal} + end + + defp decode_literal(node), do: {:error, node} + + defp encode_literal(literal) do + {:__block__, [], [literal]} + end + + # Routes.url(MyAppWeb.Endpoint) + defp replace_route({{:., _, [{:__aliases__, _, [:Routes]}, :url]}, _, [_conn_or_endpoint]}) do + {:url, [], [{:sigil_p, [delimiter: "\""], [{:<<>>, [], ["/"]}, []]}]} + end + + # Routes.static_path(conn, "/images/favicon.ico") + defp replace_route({{:., _, [{:__aliases__, _, [:Routes]}, :static_path]}, _, args}) do + [_conn_or_endpoint, path] = args + + case decode_literal(path) do + {:ok, path} -> {:sigil_p, [delimiter: "\""], [{:<<>>, [], [path]}, []]} + _ -> {:sigil_p, [delimiter: "\""], [path, []]} + end + end + + # Routes.static_url(conn, "/images/favicon.ico") + defp replace_route({{:., _, [{:__aliases__, _, [:Routes]}, :static_url]}, _, args}) do + [_conn_or_endpoint, path] = args + + sigil = + case decode_literal(path) do + {:ok, path} -> {:sigil_p, [delimiter: "\""], [{:<<>>, [], [path]}, []]} + _ -> {:sigil_p, [delimiter: "\""], [path, []]} + end + + {:url, [], [sigil]} + end + + # Routes.some_path(conn, :action, "en", query_params) + defp replace_route( + {{:., _, [{:__aliases__, _, [:Routes]}, path_name]}, _, [_ | _] = args} = node + ) do + [_conn_or_endpoint, action | params] = args + + action = + case decode_literal(action) do + {:ok, action} -> action + _ -> action + end + + path_name = "#{path_name}" + + case find_verified_route(path_name, action, params) do + :ok -> node + route -> route + end + end + + defp replace_route(node), do: node + + defp find_verified_route(path_name, action, arguments) do + # pleaaaase don't have a route named Routes.product_url_path(conn, :index) + trimmed_path = path_name |> String.trim_trailing("_path") |> String.trim_trailing("_url") + + route = + Phoenix.Router.routes(@web_module.Router) + |> Enum.find(fn %{helper: helper, plug_opts: plug_opts} -> + plug_opts == action && is_binary(helper) && trimmed_path == helper + end) + + case route do + %{path: path} -> + {path_bits, query_params} = + path + |> String.split("/", trim: true) + |> replace_path_variables(arguments, []) + + path_bits = + path_bits + |> Enum.flat_map(fn bit -> ["/", bit] end) + |> format_for_sigil_binary_args(query_params) + + sigil = {:sigil_p, [delimiter: "\""], [{:<<>>, [], path_bits}, []]} + + if String.ends_with?(path_name, "_url") do + {:url, [], [sigil]} + else + sigil + end + + _ -> + Mix.shell().error( + "Could not find route #{path_name}, with action #{inspect(action)} and arguments #{inspect(arguments)}" + ) + end + end + + defp replace_path_variables([], arguments, path_bits) do + {Enum.reverse(path_bits), arguments} + end + + defp replace_path_variables(path, [], path_bits) do + {Enum.reverse(path_bits) ++ path, []} + end + + # conceptually /post/:post_id -> /post/#{id} + defp replace_path_variables([path_piece | rest], [arg | args], path_bits) do + if String.starts_with?(path_piece, ":") do + replace_path_variables(rest, args, [arg | path_bits]) + else + replace_path_variables(rest, [arg | args], [path_piece | path_bits]) + end + end + + defp format_for_sigil_binary_args(path_bits, [_ | _] = query_params) do + format_for_sigil_binary_args(path_bits ++ ["?" | query_params], []) + end + + defp format_for_sigil_binary_args(path_bits, []) do + path_bits + |> Enum.map(&decode_literal/1) + |> Enum.map(fn + {:ok, bit} when is_binary(bit) -> + bit + + {:ok, bit} when is_atom(bit) or is_integer(bit) -> + to_string(bit) + + {_, bit} -> + {:"::", [], + [ + {{:., [], [Kernel, :to_string]}, [from_interpolation: true], [encode_literal(bit)]}, + {:binary, [], Elixir} + ]} + end) + end +end From e84d451c2b6b3d9c3ed33d9ffa999e08566a5338 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 28 Apr 2024 20:55:27 -0400 Subject: [PATCH 05/12] mix convert_to_verified_routes && mix format --- .../admin/advert/image_controller.ex | 2 +- .../controllers/admin/advert_controller.ex | 6 +-- .../admin/artist_link/contact_controller.ex | 4 +- .../admin/artist_link/reject_controller.ex | 4 +- .../artist_link/verification_controller.ex | 4 +- .../admin/badge/image_controller.ex | 2 +- .../controllers/admin/badge_controller.ex | 4 +- .../controllers/admin/batch/tag_controller.ex | 2 +- .../admin/dnp_entry/transition_controller.ex | 4 +- .../controllers/admin/donation_controller.ex | 4 +- .../admin/fingerprint_ban_controller.ex | 8 +-- .../controllers/admin/forum_controller.ex | 4 +- .../controllers/admin/mod_note_controller.ex | 6 +-- .../admin/report/claim_controller.ex | 6 +-- .../admin/report/close_controller.ex | 2 +- .../admin/site_notice_controller.ex | 6 +-- .../admin/subnet_ban_controller.ex | 8 +-- .../admin/user/activation_controller.ex | 4 +- .../admin/user/api_key_controller.ex | 2 +- .../admin/user/avatar_controller.ex | 2 +- .../admin/user/downvote_controller.ex | 2 +- .../admin/user/force_filter_controller.ex | 4 +- .../admin/user/unlock_controller.ex | 2 +- .../admin/user/verification_controller.ex | 6 +-- .../controllers/admin/user/vote_controller.ex | 2 +- .../controllers/admin/user/wipe_controller.ex | 2 +- .../controllers/admin/user_ban_controller.ex | 8 +-- .../controllers/admin/user_controller.ex | 4 +- .../controllers/avatar_controller.ex | 4 +- .../controllers/channel/nsfw_controller.ex | 4 +- .../controllers/channel_controller.ex | 6 +-- .../controllers/confirmation_controller.ex | 2 +- .../conversation/hide_controller.ex | 4 +- .../conversation/message_controller.ex | 4 +- .../conversation/read_controller.ex | 4 +- .../conversation/report_controller.ex | 4 +- .../controllers/conversation_controller.ex | 2 +- .../controllers/dnp_entry_controller.ex | 4 +- .../duplicate_report/accept_controller.ex | 6 +-- .../accept_reverse_controller.ex | 6 +-- .../duplicate_report/claim_controller.ex | 6 +-- .../duplicate_report/reject_controller.ex | 4 +- .../duplicate_report_controller.ex | 4 +- .../controllers/filter/clear_recent.ex | 2 +- .../controllers/filter/public_controller.ex | 4 +- .../controllers/filter_controller.ex | 8 +-- .../controllers/gallery/report_controller.ex | 4 +- .../controllers/gallery_controller.ex | 6 +-- .../controllers/image/anonymous_controller.ex | 4 +- .../controllers/image/approve_controller.ex | 4 +- .../image/comment/approve_controller.ex | 4 +- .../image/comment/delete_controller.ex | 10 ++-- .../image/comment/hide_controller.ex | 18 ++----- .../image/comment/report_controller.ex | 4 +- .../controllers/image/comment_controller.ex | 8 ++- .../image/comment_lock_controller.ex | 6 +-- .../controllers/image/delete_controller.ex | 14 +++--- .../image/description_lock_controller.ex | 6 +-- .../controllers/image/destroy_controller.ex | 8 +-- .../controllers/image/feature_controller.ex | 6 +-- .../controllers/image/file_controller.ex | 6 +-- .../controllers/image/hash_controller.ex | 4 +- .../controllers/image/navigate_controller.ex | 6 +-- .../controllers/image/random_controller.ex | 4 +- .../controllers/image/repair_controller.ex | 4 +- .../controllers/image/report_controller.ex | 4 +- .../image/scratchpad_controller.ex | 4 +- .../image/source_history_controller.ex | 4 +- .../image/tag_change_controller.ex | 4 +- .../controllers/image/tag_lock_controller.ex | 8 +-- .../controllers/image/tamper_controller.ex | 4 +- .../controllers/image_controller.ex | 4 +- .../controllers/page_controller.ex | 4 +- .../controllers/password_controller.ex | 4 +- .../profile/artist_link_controller.ex | 8 +-- .../controllers/profile/award_controller.ex | 6 +-- .../profile/commission/item_controller.ex | 6 +-- .../profile/commission/report_controller.ex | 4 +- .../profile/commission_controller.ex | 8 +-- .../profile/description_controller.ex | 2 +- .../controllers/profile/report_controller.ex | 4 +- .../profile/scratchpad_controller.ex | 2 +- .../registration/email_controller.ex | 10 ++-- .../registration/name_controller.ex | 2 +- .../registration/password_controller.ex | 4 +- .../registration/totp_controller.ex | 4 +- .../controllers/registration_controller.ex | 2 +- .../controllers/report_controller.ex | 2 +- .../controllers/session_controller.ex | 2 +- .../controllers/setting_controller.ex | 2 +- .../controllers/tag/alias_controller.ex | 4 +- .../controllers/tag/image_controller.ex | 6 +-- .../controllers/tag/reindex_controller.ex | 2 +- .../controllers/tag_controller.ex | 6 +-- .../controllers/topic/hide_controller.ex | 10 ++-- .../controllers/topic/lock_controller.ex | 10 ++-- .../controllers/topic/move_controller.ex | 6 +-- .../controllers/topic/poll/vote_controller.ex | 8 +-- .../controllers/topic/poll_controller.ex | 4 +- .../topic/post/approve_controller.ex | 6 +-- .../topic/post/delete_controller.ex | 6 +-- .../controllers/topic/post/hide_controller.ex | 10 ++-- .../topic/post/report_controller.ex | 4 +- .../controllers/topic/post_controller.ex | 6 +-- .../controllers/topic/stick_controller.ex | 10 ++-- .../controllers/topic_controller.ex | 10 ++-- .../controllers/unlock_controller.ex | 2 +- lib/philomena_web/plugs/map_parameter_plug.ex | 2 +- lib/philomena_web/plugs/tor_plug.ex | 2 +- lib/philomena_web/plugs/totp_plug.ex | 2 +- .../activity/_channel_strip.html.slime | 2 +- .../activity/_topic_strip.html.slime | 6 +-- .../templates/activity/index.html.slime | 2 +- .../templates/admin/advert/_form.html.slime | 2 +- .../templates/admin/advert/edit.html.slime | 2 +- .../admin/advert/image/edit.html.slime | 2 +- .../templates/admin/advert/index.html.slime | 8 +-- .../templates/admin/advert/new.html.slime | 2 +- .../admin/approval/_approvals.html.slime | 8 +-- .../templates/admin/approval/index.html.slime | 2 +- .../admin/artist_link/index.html.slime | 18 +++---- .../templates/admin/badge/_form.html.slime | 2 +- .../templates/admin/badge/edit.html.slime | 4 +- .../admin/badge/image/edit.html.slime | 2 +- .../templates/admin/badge/index.html.slime | 8 +-- .../templates/admin/badge/new.html.slime | 4 +- .../admin/badge/user/index.html.slime | 4 +- .../admin/dnp_entry/index.html.slime | 36 ++++++------- .../admin/donation/_table.html.slime | 2 +- .../templates/admin/donation/index.html.slime | 2 +- .../admin/donation/user/index.html.slime | 2 +- .../admin/fingerprint_ban/edit.html.slime | 4 +- .../admin/fingerprint_ban/index.html.slime | 12 ++--- .../admin/fingerprint_ban/new.html.slime | 4 +- .../templates/admin/forum/edit.html.slime | 4 +- .../templates/admin/forum/index.html.slime | 6 +-- .../templates/admin/forum/new.html.slime | 4 +- .../admin/mod_note/_table.html.slime | 6 +-- .../templates/admin/mod_note/edit.html.slime | 2 +- .../templates/admin/mod_note/index.html.slime | 2 +- .../templates/admin/mod_note/new.html.slime | 2 +- .../admin/report/_reports.html.slime | 12 ++--- .../templates/admin/report/index.html.slime | 4 +- .../templates/admin/report/show.html.slime | 12 ++--- .../admin/site_notice/edit.html.slime | 2 +- .../admin/site_notice/index.html.slime | 8 +-- .../admin/site_notice/new.html.slime | 2 +- .../admin/subnet_ban/edit.html.slime | 4 +- .../admin/subnet_ban/index.html.slime | 12 ++--- .../templates/admin/subnet_ban/new.html.slime | 4 +- .../templates/admin/user/_form.html.slime | 2 +- .../templates/admin/user/edit.html.slime | 2 +- .../admin/user/force_filter/new.html.slime | 2 +- .../templates/admin/user/index.html.slime | 16 +++--- .../templates/admin/user_ban/edit.html.slime | 4 +- .../templates/admin/user_ban/index.html.slime | 12 ++--- .../templates/admin/user_ban/new.html.slime | 4 +- .../templates/advert/_box.html.slime | 2 +- .../templates/api/rss/watched/index.html.eex | 8 +-- .../templates/avatar/edit.html.slime | 8 +-- .../templates/channel/_channel_box.html.slime | 10 ++-- .../templates/channel/edit.html.slime | 2 +- .../templates/channel/index.html.slime | 10 ++-- .../templates/channel/new.html.slime | 2 +- .../subscription/_subscription.html.slime | 6 +-- .../templates/comment/_comment.html.slime | 10 ++-- .../comment/_comment_options.html.slime | 8 +-- .../comment/_comment_with_image.html.slime | 6 +-- .../templates/comment/index.html.slime | 18 +++---- .../commission/_directory_results.html.slime | 8 +-- .../commission/_directory_sidebar.html.slime | 2 +- .../templates/confirmation/new.html.slime | 2 +- .../templates/conversation/index.html.slime | 8 +-- .../conversation/message/_form.html.slime | 2 +- .../templates/conversation/new.html.slime | 4 +- .../templates/conversation/show.html.slime | 16 +++--- .../templates/dnp_entry/edit.html.slime | 2 +- .../templates/dnp_entry/index.html.slime | 10 ++-- .../templates/dnp_entry/new.html.slime | 2 +- .../templates/dnp_entry/show.html.slime | 22 ++++---- .../duplicate_report/_form.html.slime | 2 +- .../duplicate_report/_image_cell.html.slime | 4 +- .../duplicate_report/_list.html.slime | 8 +-- .../duplicate_report/index.html.slime | 18 +++---- .../templates/filter/_filter.html.slime | 8 +-- .../templates/filter/edit.html.slime | 4 +- .../templates/filter/index.html.slime | 32 ++++++------ .../templates/filter/new.html.slime | 2 +- .../templates/filter/show.html.slime | 8 +-- .../fingerprint_profile/show.html.slime | 22 ++++---- .../source_change/index.html.slime | 2 +- .../tag_change/index.html.slime | 8 +-- .../templates/forum/index.html.slime | 8 +-- .../templates/forum/show.html.slime | 14 +++--- .../subscription/_subscription.html.slime | 6 +-- .../templates/gallery/_gallery.html.slime | 2 +- .../templates/gallery/edit.html.slime | 2 +- .../templates/gallery/index.html.slime | 4 +- .../templates/gallery/new.html.slime | 2 +- .../templates/gallery/show.html.slime | 14 +++--- .../subscription/_subscription.html.slime | 6 +-- .../image/_add_to_gallery_dropdown.html.slime | 14 +++--- .../templates/image/_image_box.html.slime | 2 +- .../image/_image_container.html.slime | 2 +- .../templates/image/_image_meta.html.slime | 10 ++-- .../templates/image/_image_target.html.slime | 4 +- .../templates/image/_options.html.slime | 42 ++++++++-------- .../templates/image/_random_button.html.slime | 2 +- .../templates/image/_source.html.slime | 6 +-- .../templates/image/_tags.html.slime | 4 +- .../templates/image/_uploader.html.slime | 6 +-- .../templates/image/comment/_form.html.slime | 2 +- .../templates/image/comment/edit.html.slime | 2 +- .../image/comment/history/index.html.slime | 2 +- .../templates/image/comment/index.html.slime | 2 +- .../templates/image/deleted.html.slime | 2 +- .../image/description/_form.html.slime | 2 +- .../templates/image/favorite/index.html.slime | 12 ++--- .../templates/image/index.html.slime | 6 +-- .../templates/image/new.html.slime | 2 +- .../templates/image/related/index.html.slime | 2 +- .../templates/image/reporting/show.html.slime | 4 +- .../image/scratchpad/edit.html.slime | 4 +- .../templates/image/show.html.slime | 2 +- .../image/source_change/index.html.slime | 4 +- .../subscription/_subscription.html.slime | 6 +-- .../image/tag_change/index.html.slime | 10 ++-- .../templates/image/tag_lock/show.html.slime | 2 +- .../templates/ip_profile/show.html.slime | 22 ++++---- .../ip_profile/source_change/index.html.slime | 2 +- .../ip_profile/tag_change/index.html.slime | 8 +-- .../templates/layout/_header.html.slime | 22 ++++---- .../layout/_header_navigation.html.slime | 2 +- .../layout/_header_staff_links.html.slime | 32 ++++++------ .../templates/layout/_opengraph.html.slime | 6 +-- .../templates/message/_message.html.slime | 2 +- .../templates/moderation_log/index.html.slime | 2 +- .../notification/_channel.html.slime | 6 +-- .../templates/notification/_forum.html.slime | 8 +-- .../notification/_gallery.html.slime | 6 +-- .../templates/notification/_image.html.slime | 6 +-- .../templates/notification/_topic.html.slime | 6 +-- .../templates/notification/index.html.slime | 2 +- .../templates/page/edit.html.slime | 2 +- .../templates/page/history/index.html.slime | 4 +- .../templates/page/index.html.slime | 4 +- .../templates/page/new.html.slime | 2 +- .../templates/page/show.html.slime | 4 +- .../templates/password/edit.html.slime | 2 +- .../templates/password/new.html.slime | 2 +- .../templates/post/_post.html.slime | 10 ++-- .../templates/post/_post_options.html.slime | 8 +-- .../templates/post/index.html.slime | 32 ++++++------ .../templates/profile/_about_me.html.slime | 2 +- .../templates/profile/_admin_block.html.slime | 50 +++++++++---------- .../templates/profile/_commission.html.slime | 6 +-- .../profile/_recent_comments.html.slime | 2 +- .../profile/_recent_galleries.html.slime | 2 +- .../profile/_recent_posts.html.slime | 6 +-- .../profile/alias/_aliases.html.slime | 2 +- .../profile/artist_link/edit.html.slime | 2 +- .../profile/artist_link/index.html.slime | 4 +- .../profile/artist_link/new.html.slime | 2 +- .../profile/artist_link/show.html.slime | 10 ++-- .../templates/profile/award/edit.html.slime | 2 +- .../templates/profile/award/new.html.slime | 2 +- .../commission/_listing_items.html.slime | 8 +-- .../commission/_listing_sidebar.html.slime | 8 +-- .../profile/commission/edit.html.slime | 4 +- .../profile/commission/item/edit.html.slime | 4 +- .../profile/commission/item/new.html.slime | 4 +- .../profile/commission/new.html.slime | 4 +- .../profile/description/edit.html.slime | 2 +- .../templates/profile/detail/index.html.slime | 10 ++-- .../profile/fp_history/index.html.slime | 2 +- .../profile/ip_history/index.html.slime | 2 +- .../profile/scratchpad/edit.html.slime | 2 +- .../templates/profile/show.html.slime | 50 +++++++++---------- .../profile/source_change/index.html.slime | 4 +- .../profile/tag_change/index.html.slime | 12 ++--- .../templates/registration/edit.html.slime | 10 ++-- .../registration/name/edit.html.slime | 4 +- .../templates/registration/new.html.slime | 2 +- .../registration/totp/edit.html.slime | 4 +- .../templates/report/index.html.slime | 2 +- .../templates/search/_form.html.slime | 2 +- .../templates/search/index.html.slime | 2 +- .../templates/search/reverse/index.html.slime | 4 +- .../templates/session/new.html.slime | 8 +-- .../templates/session/totp/new.html.slime | 2 +- .../templates/setting/edit.html.slime | 6 +-- .../templates/source_change/index.html.slime | 2 +- .../templates/staff/index.html.slime | 4 +- .../templates/tag/_tag.html.slime | 12 ++--- .../templates/tag/_tag_info_row.html.slime | 24 ++++----- .../templates/tag/alias/edit.html.slime | 6 +-- .../templates/tag/detail/_filters.html.slime | 4 +- .../templates/tag/detail/index.html.slime | 4 +- .../templates/tag/edit.html.slime | 10 ++-- .../templates/tag/image/edit.html.slime | 6 +-- .../templates/tag/index.html.slime | 34 ++++++------- .../templates/tag/show.html.slime | 2 +- .../templates/tag/tag_change/index.html.slime | 10 ++-- .../templates/tag_change/index.html.slime | 6 +-- .../templates/topic/new.html.slime | 2 +- .../templates/topic/poll/_display.html.slime | 4 +- .../topic/poll/_vote_form.html.slime | 2 +- .../templates/topic/poll/edit.html.slime | 2 +- .../topic/poll/vote/index.html.slime | 4 +- .../templates/topic/post/_form.html.slime | 2 +- .../templates/topic/post/edit.html.slime | 2 +- .../topic/post/history/index.html.slime | 2 +- .../templates/topic/show.html.slime | 28 +++++------ .../subscription/_subscription.html.slime | 6 +-- .../templates/unlock/new.html.slime | 2 +- .../user_attribution/_anon_user.html.slime | 4 +- .../user_attribution/_user.html.slime | 2 +- lib/philomena_web/user_auth.ex | 2 +- .../views/admin/mod_note_view.ex | 8 +-- lib/philomena_web/views/admin/report_view.ex | 4 +- lib/philomena_web/views/conversation_view.ex | 2 +- lib/philomena_web/views/profile_view.ex | 2 +- lib/philomena_web/views/report_view.ex | 14 +++--- .../confirmation_controller_test.exs | 14 +++--- .../controllers/password_controller_test.exs | 18 +++---- .../registration/email_controller_test.exs | 22 ++++---- .../registration/password_controller_test.exs | 8 +-- .../registration_controller_test.exs | 14 +++--- .../controllers/session_controller_test.exs | 12 ++--- .../controllers/unlock_controller_test.exs | 14 +++--- test/philomena_web/user_auth_test.exs | 2 +- 331 files changed, 1034 insertions(+), 1056 deletions(-) diff --git a/lib/philomena_web/controllers/admin/advert/image_controller.ex b/lib/philomena_web/controllers/admin/advert/image_controller.ex index 8fe46022f..c3bae8c08 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 bb119f427..e058ce26f 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 98efb1f43..0e0ffc30e 100644 --- a/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex @@ -19,13 +19,13 @@ 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)) + |> redirect(to: ~p"/admin/artist_links") end defp log_details(conn, _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 9bf921394..168251fd2 100644 --- a/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex @@ -18,13 +18,13 @@ 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)) + |> redirect(to: ~p"/admin/artist_links") end defp log_details(conn, _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 a4cc1fcee..02a45ab4f 100644 --- a/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex @@ -19,13 +19,13 @@ 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)) + |> redirect(to: ~p"/admin/artist_links") end defp log_details(conn, _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 abdac0a23..069b8f0b9 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 2aa79e319..f253f6476 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 4ae3c7140..59371b6a0 100644 --- a/lib/philomena_web/controllers/admin/batch/tag_controller.ex +++ b/lib/philomena_web/controllers/admin/batch/tag_controller.ex @@ -71,7 +71,7 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do defp log_details(conn, _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/#{conn.assigns.current_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 a774ece0c..8f0fc52e0 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 91de59cf8..2274daff4 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 5cb4ccd07..2e1c20f9d 100644 --- a/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex @@ -48,7 +48,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do 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)) + |> redirect(to: ~p"/admin/fingerprint_bans") {:error, changeset} -> render(conn, "new.html", changeset: changeset) @@ -66,7 +66,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do 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)) + |> redirect(to: ~p"/admin/fingerprint_bans") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -79,7 +79,7 @@ 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)) + |> redirect(to: ~p"/admin/fingerprint_bans") end defp load_bans(queryable, conn) do @@ -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 7d9e01900..5c40e4c4a 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 23f71815a..f5b3999f1 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 93880a223..76702b2e3 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(:error, "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 dedb4d2d4..75f1e7ff5 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 11462540b..7612422eb 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 93c42807e..f2d0dbaa6 100644 --- a/lib/philomena_web/controllers/admin/subnet_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/subnet_ban_controller.ex @@ -50,7 +50,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do 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)) + |> redirect(to: ~p"/admin/subnet_bans") {:error, changeset} -> render(conn, "new.html", changeset: changeset) @@ -68,7 +68,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do 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)) + |> redirect(to: ~p"/admin/subnet_bans") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -81,7 +81,7 @@ 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)) + |> redirect(to: ~p"/admin/subnet_bans") end defp load_bans(queryable, conn) do @@ -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 e5f78aad2..f261ab1bc 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 e2987ff90..19b1eb64d 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 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 c04fdbcd7..80c1e2629 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 1dfdaff88..df5cb1455 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(:info, "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 049d68fbc..74266ef5e 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 0c36122ec..54610fdaa 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 982a520cd..9478bc42f 100644 --- a/lib/philomena_web/controllers/admin/user/verification_controller.ex +++ b/lib/philomena_web/controllers/admin/user/verification_controller.ex @@ -13,7 +13,7 @@ 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)) + |> redirect(to: ~p"/profiles/#{user}") end def delete(conn, _params) do @@ -22,7 +22,7 @@ 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)) + |> redirect(to: ~p"/profiles/#{user}") end defp verify_authorized(conn, _opts) do @@ -39,6 +39,6 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do :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 bcb9318a8..310f35755 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(:info, "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 86301f4d0..3bc64a82c 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 :info, "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 f98c33378..bbaf6b621 100644 --- a/lib/philomena_web/controllers/admin/user_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/user_ban_controller.ex @@ -51,7 +51,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do 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)) + |> redirect(to: ~p"/admin/user_bans") {:error, :user_ban, changeset, _changes} -> render(conn, "new.html", changeset: changeset) @@ -72,7 +72,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do 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)) + |> redirect(to: ~p"/admin/user_bans") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -85,7 +85,7 @@ 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)) + |> redirect(to: ~p"/admin/user_bans") end defp load_bans(queryable, conn) do @@ -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 fe31d2f43..672147f8e 100644 --- a/lib/philomena_web/controllers/admin/user_controller.ex +++ b/lib/philomena_web/controllers/admin/user_controller.ex @@ -63,7 +63,7 @@ defmodule PhilomenaWeb.Admin.UserController do conn |> put_flash(:info, "User successfully updated.") |> moderation_log(details: &log_details/3, data: user) - |> redirect(to: Routes.profile_path(conn, :show, user)) + |> redirect(to: ~p"/profiles/#{user}") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -84,7 +84,7 @@ defmodule PhilomenaWeb.Admin.UserController do defp log_details(conn, _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 50a30cf2b..9b6e45441 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 f695fb4d2..311251228 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 973017d35..6d88d257e 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 2186bb8e2..c22aa9edb 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 44bd8bada..71480de62 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_controller.ex b/lib/philomena_web/controllers/conversation/message_controller.ex index 7e2389023..8bd449406 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 93a5601e9..aa7772741 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 634bed1aa..dab814824 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 8b936f8e3..12784b424 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 ff3f1a075..d2e675b23 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 2b21e306b..a67760dc0 100644 --- a/lib/philomena_web/controllers/duplicate_report/accept_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/accept_controller.ex @@ -21,12 +21,12 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptController do 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)) + |> redirect(to: ~p"/duplicate_reports") _error -> conn |> put_flash(:error, "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 @@ -34,7 +34,7 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptController 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 d112ce275..7c04cc490 100644 --- a/lib/philomena_web/controllers/duplicate_report/accept_reverse_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/accept_reverse_controller.ex @@ -21,12 +21,12 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptReverseController do 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)) + |> redirect(to: ~p"/duplicate_reports") _error -> conn |> put_flash(:error, "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 @@ -34,7 +34,7 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptReverseController 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 31646f568..966eddae9 100644 --- a/lib/philomena_web/controllers/duplicate_report/claim_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/claim_controller.ex @@ -21,7 +21,7 @@ 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)) + |> redirect(to: ~p"/duplicate_reports") end def delete(conn, _params) do @@ -30,7 +30,7 @@ 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)) + |> redirect(to: ~p"/duplicate_reports") end defp log_details(conn, action, _) do @@ -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 e019fb2a9..83626c36c 100644 --- a/lib/philomena_web/controllers/duplicate_report/reject_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/reject_controller.ex @@ -22,13 +22,13 @@ 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)) + |> redirect(to: ~p"/duplicate_reports") end defp log_details(conn, _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 f30539a0e..5fd80e38a 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 f3aed68d7..24f321d32 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 80e23308b..e31a82194 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 86c218f88..9f19415fa 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(:error, "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 879fd8fd8..3d4b5fd5e 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 ee19d2300..2b298d2c2 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 d74b1682d..1855efc9e 100644 --- a/lib/philomena_web/controllers/image/anonymous_controller.ex +++ b/lib/philomena_web/controllers/image/anonymous_controller.ex @@ -23,7 +23,7 @@ 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)) + |> redirect(to: ~p"/images/#{image}") end defp verify_authorized(conn, _opts) do @@ -36,7 +36,7 @@ defmodule PhilomenaWeb.Image.AnonymousController do defp log_details(conn, _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 689339f82..1a44cb768 100644 --- a/lib/philomena_web/controllers/image/approve_controller.ex +++ b/lib/philomena_web/controllers/image/approve_controller.ex @@ -15,10 +15,10 @@ 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)) + |> 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)} + %{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 699d0cc2c..f6b05ca15 100644 --- a/lib/philomena_web/controllers/image/comment/approve_controller.ex +++ b/lib/philomena_web/controllers/image/comment/approve_controller.ex @@ -23,13 +23,13 @@ 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}") + |> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}") end defp log_details(conn, _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 4527e759f..21fc2c1f5 100644 --- a/lib/philomena_web/controllers/image/comment/delete_controller.ex +++ b/lib/philomena_web/controllers/image/comment/delete_controller.ex @@ -17,23 +17,19 @@ 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}" - ) + |> 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 %{ 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 1e55f86db..942411049 100644 --- a/lib/philomena_web/controllers/image/comment/hide_controller.ex +++ b/lib/philomena_web/controllers/image/comment/hide_controller.ex @@ -16,16 +16,12 @@ defmodule PhilomenaWeb.Image.Comment.HideController do 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}" - ) + |> 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 @@ -37,16 +33,12 @@ defmodule PhilomenaWeb.Image.Comment.HideController do 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}" - ) + |> 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 @@ -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 27725a4b0..d957abbd6 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 cfcda7776..ca0ff9adc 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 e913bdb69..c6c5b2b91 100644 --- a/lib/philomena_web/controllers/image/comment_lock_controller.ex +++ b/lib/philomena_web/controllers/image/comment_lock_controller.ex @@ -13,7 +13,7 @@ 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)) + |> redirect(to: ~p"/images/#{image}") end def delete(conn, _params) do @@ -22,7 +22,7 @@ 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)) + |> redirect(to: ~p"/images/#{image}") end defp log_details(conn, action, image) do @@ -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 adae818ce..3d86cfa68 100644 --- a/lib/philomena_web/controllers/image/delete_controller.ex +++ b/lib/philomena_web/controllers/image/delete_controller.ex @@ -20,12 +20,12 @@ defmodule PhilomenaWeb.Image.DeleteController do conn |> put_flash(:info, "Image successfully hidden.") |> moderation_log(details: &log_details/3, data: result.image) - |> redirect(to: Routes.image_path(conn, :show, 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 @@ -37,12 +37,12 @@ defmodule PhilomenaWeb.Image.DeleteController do conn |> put_flash(:info, "Hide reason updated.") |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, 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 @@ -67,7 +67,7 @@ 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)) + |> redirect(to: ~p"/images/#{image}") end defp log_details(conn, action, image) do @@ -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 ed8c9c872..bde327ac6 100644 --- a/lib/philomena_web/controllers/image/description_lock_controller.ex +++ b/lib/philomena_web/controllers/image/description_lock_controller.ex @@ -13,7 +13,7 @@ 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)) + |> redirect(to: ~p"/images/#{image}") end def delete(conn, _params) do @@ -22,7 +22,7 @@ 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)) + |> redirect(to: ~p"/images/#{image}") end defp log_details(conn, action, image) do @@ -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 fe2f3e6e0..8f4ed867d 100644 --- a/lib/philomena_web/controllers/image/destroy_controller.ex +++ b/lib/philomena_web/controllers/image/destroy_controller.ex @@ -16,12 +16,12 @@ defmodule PhilomenaWeb.Image.DestroyController do conn |> put_flash(:info, "Image contents destroyed.") |> moderation_log(details: &log_details/3, data: image) - |> redirect(to: Routes.image_path(conn, :show, 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,7 +33,7 @@ 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 @@ -41,7 +41,7 @@ defmodule PhilomenaWeb.Image.DestroyController do defp log_details(conn, _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 a16ee809c..74c19c057 100644 --- a/lib/philomena_web/controllers/image/feature_controller.ex +++ b/lib/philomena_web/controllers/image/feature_controller.ex @@ -17,7 +17,7 @@ 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)) + |> 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(:error, "Cannot feature a hidden image.") - |> redirect(to: Routes.image_path(conn, :show, conn.assigns.image)) + |> redirect(to: ~p"/images/#{conn.assigns.image}") |> halt() _false -> @@ -36,7 +36,7 @@ defmodule PhilomenaWeb.Image.FeatureController do defp log_details(conn, _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 8b3f0e3f3..f169d2f41 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(:error, "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 ad99b133d..233d5202c 100644 --- a/lib/philomena_web/controllers/image/hash_controller.ex +++ b/lib/philomena_web/controllers/image/hash_controller.ex @@ -13,13 +13,13 @@ 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)) + |> redirect(to: ~p"/images/#{image}") end defp log_details(conn, _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 ab74f0381..c0827caa5 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 f39d8c751..9bc293f76 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 7e40835ac..10d867736 100644 --- a/lib/philomena_web/controllers/image/repair_controller.ex +++ b/lib/philomena_web/controllers/image/repair_controller.ex @@ -14,13 +14,13 @@ 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)) + |> redirect(to: ~p"/images/#{conn.assigns.image}") end defp log_details(conn, _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 99e2bace8..6956832eb 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 863c0bc8b..4fddb1355 100644 --- a/lib/philomena_web/controllers/image/scratchpad_controller.ex +++ b/lib/philomena_web/controllers/image/scratchpad_controller.ex @@ -18,13 +18,13 @@ 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)) + |> redirect(to: ~p"/images/#{image}") end defp log_details(conn, _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 24bab27fc..85f061db4 100644 --- a/lib/philomena_web/controllers/image/source_history_controller.ex +++ b/lib/philomena_web/controllers/image/source_history_controller.ex @@ -15,13 +15,13 @@ 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)) + |> redirect(to: ~p"/images/#{image}") end defp log_details(conn, _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 6868ed969..b2716558c 100644 --- a/lib/philomena_web/controllers/image/tag_change_controller.ex +++ b/lib/philomena_web/controllers/image/tag_change_controller.ex @@ -46,7 +46,7 @@ defmodule PhilomenaWeb.Image.TagChangeController do details: &log_details/3, 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"}), @@ -61,7 +61,7 @@ defmodule PhilomenaWeb.Image.TagChangeController do defp log_details(conn, _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 2f71b4a3d..4e6a0e701 100644 --- a/lib/philomena_web/controllers/image/tag_lock_controller.ex +++ b/lib/philomena_web/controllers/image/tag_lock_controller.ex @@ -24,7 +24,7 @@ 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)) + |> redirect(to: ~p"/images/#{image}") end def create(conn, _params) do @@ -33,7 +33,7 @@ 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)) + |> redirect(to: ~p"/images/#{image}") end def delete(conn, _params) do @@ -42,7 +42,7 @@ 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)) + |> redirect(to: ~p"/images/#{image}") end defp log_details(conn, action, image) do @@ -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 8eb66309e..4ce1ac3c9 100644 --- a/lib/philomena_web/controllers/image/tamper_controller.ex +++ b/lib/philomena_web/controllers/image/tamper_controller.ex @@ -28,7 +28,7 @@ defmodule PhilomenaWeb.Image.TamperController do details: &log_details/3, data: %{vote: result, image: image} ) - |> 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 @@ -43,7 +43,7 @@ defmodule PhilomenaWeb.Image.TamperController do %{ body: "Deleted #{vote_type} by #{conn.assigns.user.name} on image >>#{data.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_controller.ex b/lib/philomena_web/controllers/image_controller.ex index 47e9e088c..30364cda3 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 :info, "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 1f8490a25..d9ebae27c 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 4a0a7bb12..597f0af02 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 3d48c308f..6362a1b7e 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 :info, "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 07df98199..4e6362366 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 90699b082..11cc0ab63 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 deleted successfully.") - |> 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 9c9d7ac27..0ad943efd 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 f934fc4dd..7cd2b8444 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 :error, "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 4a7836ba7..6dac8e889 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 0c326b8da..80a688956 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 117fb3b6e..3132436ec 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 e20a9bb0e..0c696906d 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 :info, "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(:error, "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 7b5cd0dda..e0023f892 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 909df6ebe..6e3ba04a8 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 3cea3279e..9316aeb26 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 389ae579f..8f3e2bbd2 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 3169cf02a..930ecf13d 100644 --- a/lib/philomena_web/controllers/report_controller.ex +++ b/lib/philomena_web/controllers/report_controller.ex @@ -101,7 +101,7 @@ defmodule PhilomenaWeb.ReportController do end defp redirect_path(_conn, nil), do: "/" - defp redirect_path(conn, _user), do: Routes.report_path(conn, :index) + defp redirect_path(conn, _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 ee15bc124..b5704501c 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 7c3d6db98..43d4d30a9 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 b7687b1c1..b0ed34838 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 2f43ebe82..21d069830 100644 --- a/lib/philomena_web/controllers/tag/image_controller.ex +++ b/lib/philomena_web/controllers/tag/image_controller.ex @@ -24,7 +24,7 @@ defmodule PhilomenaWeb.Tag.ImageController do conn |> put_flash(:info, "Tag image successfully updated.") |> moderation_log(details: &log_details/3, data: tag) - |> redirect(to: Routes.tag_path(conn, :show, tag)) + |> redirect(to: ~p"/tags/#{tag}") {:error, :tag, changeset, _changes} -> render(conn, "edit.html", changeset: changeset) @@ -37,7 +37,7 @@ 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)) + |> redirect(to: ~p"/tags/#{conn.assigns.tag}") end defp log_details(conn, action, tag) do @@ -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 70b7163c5..aee27c282 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 46eb95b7a..3fac85cdf 100644 --- a/lib/philomena_web/controllers/tag_controller.ex +++ b/lib/philomena_web/controllers/tag_controller.ex @@ -98,7 +98,7 @@ defmodule PhilomenaWeb.TagController do conn |> put_flash(:info, "Tag successfully updated.") |> moderation_log(details: &log_details/3, data: tag) - |> redirect(to: Routes.tag_path(conn, :show, tag)) + |> redirect(to: ~p"/tags/#{tag}") {:error, changeset} -> render(conn, "edit.html", changeset: changeset) @@ -167,7 +167,7 @@ defmodule PhilomenaWeb.TagController do :info, "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 @@ -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 3149501d9..247741d50 100644 --- a/lib/philomena_web/controllers/topic/hide_controller.ex +++ b/lib/philomena_web/controllers/topic/hide_controller.ex @@ -28,12 +28,12 @@ defmodule PhilomenaWeb.Topic.HideController do 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)) + |> 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 @@ -45,12 +45,12 @@ defmodule PhilomenaWeb.Topic.HideController do 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)) + |> 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 @@ -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 88bf115ba..aa4bf13f2 100644 --- a/lib/philomena_web/controllers/topic/lock_controller.ex +++ b/lib/philomena_web/controllers/topic/lock_controller.ex @@ -27,12 +27,12 @@ defmodule PhilomenaWeb.Topic.LockController do 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)) + |> 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 @@ -44,12 +44,12 @@ defmodule PhilomenaWeb.Topic.LockController do 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)) + |> 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 @@ -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 f12af72ec..d8c91c3f5 100644 --- a/lib/philomena_web/controllers/topic/move_controller.ex +++ b/lib/philomena_web/controllers/topic/move_controller.ex @@ -30,19 +30,19 @@ 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)) + |> 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 %{ 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 3af4f0111..4ffb4086a 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(: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 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 61cec7d98..b2fdbb81c 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 90bf39481..01e11dafd 100644 --- a/lib/philomena_web/controllers/topic/post/approve_controller.ex +++ b/lib/philomena_web/controllers/topic/post/approve_controller.ex @@ -23,7 +23,7 @@ defmodule PhilomenaWeb.Topic.Post.ApproveController do |> moderation_log(details: &log_details/3, 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.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 @@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Topic.Post.ApproveController 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 9e6d7a458..72e395362 100644 --- a/lib/philomena_web/controllers/topic/post/delete_controller.ex +++ b/lib/philomena_web/controllers/topic/post/delete_controller.ex @@ -22,7 +22,7 @@ defmodule PhilomenaWeb.Topic.Post.DeleteController do |> moderation_log(details: &log_details/3, 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,7 +31,7 @@ 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 @@ -41,7 +41,7 @@ defmodule PhilomenaWeb.Topic.Post.DeleteController 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 9e4499772..ed3f69d9e 100644 --- a/lib/philomena_web/controllers/topic/post/hide_controller.ex +++ b/lib/philomena_web/controllers/topic/post/hide_controller.ex @@ -23,7 +23,7 @@ defmodule PhilomenaWeb.Topic.Post.HideController do |> moderation_log(details: &log_details/3, 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 @@ -48,7 +48,7 @@ defmodule PhilomenaWeb.Topic.Post.HideController do |> moderation_log(details: &log_details/3, 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,7 +57,7 @@ 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 @@ -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 2d29f7b80..f09df5117 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 9570c0146..8f90abd03 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(:error, "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 27f921686..d413be6d2 100644 --- a/lib/philomena_web/controllers/topic/stick_controller.ex +++ b/lib/philomena_web/controllers/topic/stick_controller.ex @@ -26,12 +26,12 @@ defmodule PhilomenaWeb.Topic.StickController do 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)) + |> 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 @@ -43,12 +43,12 @@ defmodule PhilomenaWeb.Topic.StickController do 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)) + |> 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 @@ -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 4c433be2e..e88670a0e 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 9ee7b3c57..62e8dc4f5 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 93b7cce83..36fc7c049 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/tor_plug.ex b/lib/philomena_web/plugs/tor_plug.ex index 8e6cc4e35..bea6b9d2b 100644 --- a/lib/philomena_web/plugs/tor_plug.ex +++ b/lib/philomena_web/plugs/tor_plug.ex @@ -27,7 +27,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 30f87378b..6b8091239 100644 --- a/lib/philomena_web/plugs/totp_plug.ex +++ b/lib/philomena_web/plugs/totp_plug.ex @@ -33,7 +33,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 34acd120e..278cc6e99 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 68ae49138..8dc09e012 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 167296f97..f6f0a712a 100644 --- a/lib/philomena_web/templates/activity/index.html.slime +++ b/lib/philomena_web/templates/activity/index.html.slime @@ -51,4 +51,4 @@ ' Browse Watched Images .block__content.js-resizable-media-container = 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 df77528ee..9fcd46c74 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 fba601a05..a3764720f 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 6055e6a35..6374e9c37 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 1c7e34d39..609d468e8 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 ab27e617d..76472e475 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 b254f6ddd..f0448000b 100644 --- a/lib/philomena_web/templates/admin/approval/_approvals.html.slime +++ b/lib/philomena_web/templates/admin/approval/_approvals.html.slime @@ -12,13 +12,13 @@ .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) @@ -26,9 +26,9 @@ 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--state-success" + = button_to "Approve", ~p"/images/#{image}/approve", method: "post", class: "button button--state-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--state-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 818f7ae1d..d3f8e0980 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 b9d0e8db9..633ff2c18 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 d8af18abf..1e5dc79bb 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 01df2fba4..da713050a 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 ca0d7b4ad..90042dbb4 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 b46f6b71f..f39498588 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 729622479..57fc82732 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 dda58bc2e..bbb1c1163 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 bc646d592..bf932f69e 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.block__header__title 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 7bcd7ac6a..023369b45 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 f27ed0bbd..97ed6caca 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 dc45ab3e0..daf4f6c12 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 2e78f09b9..eb424776b 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 b173c39a4..209ad5096 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,7 +31,7 @@ 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 @@ -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 75db4f622..02d20b60e 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 4f513a095..8d0e959b3 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 fec3c55c6..c1423ecec 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 2d6fd0cd6..602d7d143 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 a47663a75..6c143079a 100644 --- a/lib/philomena_web/templates/admin/mod_note/_table.html.slime +++ b/lib/philomena_web/templates/admin/mod_note/_table.html.slime @@ -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 e9df55566..aed68f42c 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 5b14f76c2..580366fc2 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 1cb13aeac..09d7291e5 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 f43f531ad..743f51cb1 100644 --- a/lib/philomena_web/templates/admin/report/_reports.html.slime +++ b/lib/philomena_web/templates/admin/report/_reports.html.slime @@ -18,7 +18,7 @@ table.table = 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) @@ -34,20 +34,20 @@ table.table => pretty_state(report) = user_abbrv @conn, 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 23f626f1b..83c453126 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 f046aae37..d0d183a8b 100644 --- a/lib/philomena_web/templates/admin/report/show.html.slime +++ b/lib/philomena_web/templates/admin/report/show.html.slime @@ -31,18 +31,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 button--link" + => link "Send PM", to: ~p"/conversations/new?#{[recipient: @report.user.name]}", class: "button button--link" = 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 bd745654b..de39c73e4 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 1ff2ee3fd..21cac7671 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 b8c2f34b3..cf85b7933 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 98f356343..dc4519832 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 f6b4dc5da..ff139197f 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,7 +31,7 @@ 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 @@ -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 50d01a785..7732231b2 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 34275f4ad..faf4218a2 100644 --- a/lib/philomena_web/templates/admin/user/_form.html.slime +++ b/lib/philomena_web/templates/admin/user/_form.html.slime @@ -34,7 +34,7 @@ .table-list__label .table-list__label__text Avatar .table-list__label__input - = link "Remove avatar", to: Routes.admin_user_avatar_path(@conn, :delete, @user), class: "button", data: [method: "delete", confirm: "Are you really, really sure?"] + = link "Remove avatar", to: ~p"/admin/users/#{@user}/avatar", class: "button", data: [method: "delete", confirm: "Are you really, really sure?"] .block .block__header diff --git a/lib/philomena_web/templates/admin/user/edit.html.slime b/lib/philomena_web/templates/admin/user/edit.html.slime index bb1e6d029..e7a649de5 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 9d214dd1c..eda33725c 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 cf2401416..7157e7d97 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.fa-fw.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.fa-fw.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.fa-fw.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 ff4f23bb1..604f0ed60 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 c81d4ab21..3f76034dc 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,7 +31,7 @@ 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 @@ -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 468595cb0..cdd82ff88 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 652401c9f..0193d67c8 100644 --- a/lib/philomena_web/templates/advert/_box.html.slime +++ b/lib/philomena_web/templates/advert/_box.html.slime @@ -4,7 +4,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 de471d215..094512500 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 @@ Derpibooru Watchlist Your watched tags feed from Derpibooru - <%= 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 81bd63f58..3ee56bafb 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 8ca76dee5..5182f56c6 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.fa-fw.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.fa-fw.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.fa-fw.fa-trash> ' Delete diff --git a/lib/philomena_web/templates/channel/edit.html.slime b/lib/philomena_web/templates/channel/edit.html.slime index 47f0e53ba..6eb25d312 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 7fd24c1ca..50b0bbaa7 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 8a3551e90..a7361ef7c 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 362d91154..b0fdd6e3f 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.hide-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.hide-mobile ' Subscribe diff --git a/lib/philomena_web/templates/comment/_comment.html.slime b/lib/philomena_web/templates/comment/_comment.html.slime index 508202ef6..1ec574dd5 100644 --- a/lib/philomena_web/templates/comment/_comment.html.slime +++ b/lib/philomena_web/templates/comment/_comment.html.slime @@ -9,7 +9,7 @@ article.block.communication id="comment_#{@comment.id}" 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 @@ -17,7 +17,7 @@ article.block.communication id="comment_#{@comment.id}" 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" @@ -58,12 +58,12 @@ article.block.communication id="comment_#{@comment.id}" .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: "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 @@ -80,6 +80,6 @@ article.block.communication id="comment_#{@comment.id}" .communication__info.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_options.html.slime b/lib/philomena_web/templates/comment/_comment_options.html.slime index 5f8c36745..36167c770 100644 --- a/lib/philomena_web/templates/comment/_comment_options.html.slime +++ b/lib/philomena_web/templates/comment/_comment_options.html.slime @@ -2,13 +2,13 @@ div ' Posted => pretty_time(@comment.created_at) - a.communication__interaction href=Routes.image_comment_report_path(@conn, :new, @comment.image, @comment) + a.communication__interaction href=~p"/images/#{@comment.image}/comments/#{@comment}/reports/new" i.fa.fa-flag> ' Report = if not is_nil(@comment.edited_at) and can?(@conn, :show, @comment) do br - a href=Routes.image_comment_history_path(@conn, :index, @comment.image, @comment) + a href=~p"/images/#{@comment.image}/comments/#{@comment}/history" ' Edited => pretty_time(@comment.edited_at) @@ -17,7 +17,7 @@ div => @comment.edit_reason div - - 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 @@ -36,6 +36,6 @@ div = if can?(@conn, :edit, @comment) do span.owner-options strong - a.communication__interaction href=Routes.image_comment_path(@conn, :edit, @comment.image, @comment) + a.communication__interaction 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 8faaca314..fce128bf8 100644 --- a/lib/philomena_web/templates/comment/_comment_with_image.html.slime +++ b/lib/philomena_web/templates/comment/_comment_with_image.html.slime @@ -41,12 +41,12 @@ article.block.communication id="comment_#{@comment.id}" .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: "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 @@ -63,6 +63,6 @@ article.block.communication id="comment_#{@comment.id}" .communication__info.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 d8bb174f0..ae3e2eb04 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 b61eed566..a5e7ed0d2 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__options = 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 fcfcfe29f..6bf4c0a21 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.block__header__title 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 2f4a5177b..7972f5951 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 d8a5aed73..ea476547f 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.hide-mobile => count @@ -38,7 +38,7 @@ h1 My Conversations td.table--communication-list__options => link "Last message", to: last_message_path(@conn, 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 7234a3e76..cbaec375f 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 a68006521..595daccc3 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.block__header__title 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 9c69b9bc0..5af5ead9d 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 2761b3953..969f4ffdc 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 01952edef..b4463eb51 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 95c822d27..1bb616f8c 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 a672573a6..31b893ead 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.block__header__title 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 128de57b8..19d1ec648 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 1e262a350..9e52462c4 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 87de9fc0a..bb18bb509 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 b29595f7f..ef46cf6ac 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.block__header__title 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 859608f7d..ab4e92604 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 4ec942530..db0bf5d6b 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 1598658f5..3474b6fb1 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 de8810736..26dc5513d 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 156084828..6e1221f31 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 dae6b6a27..cfb36e1e2 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 d1dd14401..0c92e88d8 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 dd2b50ac8..9a486e91e 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.block__header__title | 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 3eaa978db..616376fc2 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.fa-fw.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.hide-mobile = forum.topic_count td.table--communication-list__stats.hide-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 23a6c6761..870427ff1 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.fa-fw.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.fa-fw.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.hide-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 f71096cd0..421721503 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.hide-mobile ' Unsubscribe - else - a href=Routes.session_path(@conn, :new) + a href=~p"/sessions/new" i.fa.fa-bell> span.hide-mobile ' Subscribe diff --git a/lib/philomena_web/templates/gallery/_gallery.html.slime b/lib/philomena_web/templates/gallery/_gallery.html.slime index d7c18a80f..60ae2d561 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 fe0fc4af3..80687435f 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 15b5312d8..9750364cf 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 7a555f675..3aa4a7f31 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 63ad508b3..3c61643a0 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__options = 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.hide-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.hide-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.hide-mobile Delete @@ -47,7 +47,7 @@ elixir: .block__header.block__header--light.block__header--sub span.block__header__title 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 b6c5d895d..cf40adf93 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.hide-mobile ' Unsubscribe - else - a href=Routes.session_path(@conn, :new) + a href=~p"/sessions/new" i.fa.fa-bell> span.hide-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 3c7b7659c..9c5174bbe 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.hide-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.hide-limited-desktop.hide-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.hide-limited-desktop.hide-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 e62108605..d8b16dca2 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 1a89d6131..a7ecf49da 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 9688ee8c8..23c88c19d 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__header .flex.flex--wrap.image-metabar.center--layout id="image_meta_#{@image.id}" .stretched-mobile-links - 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 .stretched-mobile-links a.interaction--fave href="#" rel="nofollow" data-image-id=@image.id @@ -34,7 +34,7 @@ .stretched-mobile-links = 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.hide-limited-desktop.hide-mobile Related .stretched-mobile-links diff --git a/lib/philomena_web/templates/image/_image_target.html.slime b/lib/philomena_web/templates/image/_image_target.html.slime index 3443c74ae..fba84b3a9 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 f15142922..a955e0634 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 href="#" data-click-tab="reporting" data-load-tab=Routes.image_reporting_path(@conn, :show, @image) + a href="#" data-click-tab="reporting" data-load-tab=~p"/images/#{@image}/reporting" i.fa.fa-exclamation-triangle> | Report a href="#" data-click-tab="sharing" i.fa.fa-share> | Share - a href="#" data-click-tab="favoriters" data-load-tab=Routes.image_favorite_path(@conn, :index, @image) + a href="#" data-click-tab="favoriters" data-load-tab=~p"/images/#{@image}/favorites" i.fa.fa-star> | List favoriters = if display_mod_tools? and not hide_staff_tools?(@conn) do @@ -56,7 +56,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 Derpibooru[/url]#{source_link}" + = "[img]#{thumb_url(@image, false, :full)}[/img]\n[url=#{url(~p"/images/#{@image}")}]View on Derpibooru[/url]#{source_link}" p strong> Thumbnailed BBcode a href="#" data-click-copy="#bbcode_embed_thumbnail_tag" @@ -64,11 +64,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 Derpibooru[/url]#{source_link}" + = "[img]#{thumb_url(@image, false, :medium)}[/img]\n[url=#{url(~p"/images/#{@image}")}]View on Derpibooru[/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 @@ -85,7 +85,7 @@ .block__tab.hidden data-tab="administration" .block.block--danger - a.button.button--link> href=Routes.image_scratchpad_path(@conn, :edit, @image) + a.button.button--link> href=~p"/images/#{@image}/scratchpad/edit" i.far.fa-edit = if present?(@image.scratchpad) do strong> Mod notes: @@ -94,13 +94,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--state-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 @@ -108,18 +108,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--state-success" - else - = button_to "Restore", Routes.image_delete_path(@conn, :delete, @image), method: "delete", class: "button button--state-success" + = button_to "Restore", ~p"/images/#{@image}/delete", method: "delete", class: "button button--state-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--state-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 @@ -128,24 +128,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--state-success", data: [confirm: "Are you sure?"] + = button_to "Approve image", ~p"/images/#{@image}/approve", method: "post", class: "button button--state-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--state-danger", data: [confirm: "This action is IRREVERSIBLE. Are you sure?"] + = button_to "Destroy image", ~p"/images/#{@image}/destroy", method: "post", class: "button button--state-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 d383a3e31..c613c85cf 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.hide-mobile.hide-limited-desktop Random Image diff --git a/lib/philomena_web/templates/image/_source.html.slime b/lib/philomena_web/templates/image/_source.html.slime index 2d39b3064..8fa328723 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.button--link.button--inline href=Routes.image_source_change_path(@conn, :index, @image) title="Source history" + a.button.button--link.button--inline 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--state-danger.button--inline 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 3c11c0c4f..c4efb08a3 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. @@ -66,7 +66,7 @@ i.fas.fa-edit> ' Edit = if @tag_change_count > 0 do - a.button.button--link.button--inline href=Routes.image_tag_change_path(@conn, :index, @image) title="Tag history" + a.button.button--link.button--inline 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 81d69284d..504ab4373 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 39b8a5190..731ba817f 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 d7183a608..1b17c96a4 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 3dd6e6428..bb27e8277 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 e0c3eee6c..5e87cfe33 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 4177b0a36..fc425b36d 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 6b4c4543a..e47b5d3ff 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 1e606aada..ed239797a 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 a61acf49c..ff5678cfd 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 0f2a98be4..ad596f174 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 1feabfa1b..421cee0a0 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 @@ .block__content.js-resizable-media-container = 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 5a18b6c8f..32216dbec 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.button--link 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 31e37f9f9..bd27ab6e0 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 0c566314f..2c2a8f238 100644 --- a/lib/philomena_web/templates/image/show.html.slime +++ b/lib/philomena_web/templates/image/show.html.slime @@ -24,5 +24,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 712f434a1..bd5f4a574 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 35c6883dc..323fc0d5e 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> ' Unsubscribe - else - a href=Routes.session_path(@conn, :new) + a href=~p"/sessions/new" i.fa.fa-bell> ' 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 82d78789b..cd79ec97b 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.block__header__title | 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 81a52cdfc..e5a9841d6 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 c752d9ffc..eb3ac25c5 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 5bf1bea10..d31a79680 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 7d86ae72d..4eb2f1145 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.block__header__title | 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 23935c9c3..27a837c49 100644 --- a/lib/philomena_web/templates/layout/_header.html.slime +++ b/lib/philomena_web/templates/layout/_header.html.slime @@ -11,7 +11,7 @@ header.header a.header__link.hide-mobile href="/images/new" title="Upload" i.fa.fa-upload - = form_for @conn, Routes.search_path(@conn, :index), [method: "get", class: "header__search flex flex--no-wrap flex--centered", enforce_utf8: false], fn f -> + = form_for @conn, ~p"/search", [method: "get", class: "header__search flex flex--no-wrap flex--centered", enforce_utf8: false], fn f -> input.input.header__input.header__input--search#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 @@ -51,18 +51,18 @@ header.header i.fa.fa-filter span.hide-limited-desktop< Filters - = 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" - = form_for @user_changeset, Routes.filter_spoiler_type_path(@conn, :update), [class: "header__filter-form hide-mobile hide-limited-desktop", id: "spoiler-quick-form"], fn f -> + = form_for @user_changeset, ~p"/filters/spoiler_type", [class: "header__filter-form hide-mobile hide-limited-desktop", 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.header__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--28px" span.header__link-user__dropdown-arrow.hide-mobile data-click-preventdefault="true" nav.dropdown__content.dropdown__content-right.hide-mobile.js-burger-links - a.header__link href=Routes.profile_path(@conn, :show, @current_user) + a.header__link href=~p"/profiles/#{@current_user}" = @current_user.name a.header__link href="/search?q=my:watched" i.fa.fa-fw.fa-eye> @@ -73,7 +73,7 @@ header.header a.header__link href="/search?q=my:upvotes" i.fa.fa-fw.fa-arrow-up> | Upvotes - a.header__link href=Routes.gallery_path(@conn, :index, gallery: [creator: @current_user.name]) + a.header__link href=~p"/galleries?#{[gallery: [creator: @current_user.name]]}" i.fa.fa-fw.fa-image> | Galleries a.header__link href="/search?q=my:uploads" @@ -85,7 +85,7 @@ header.header a.header__link href="/posts?pq=my:posts" i.fas.fa-fw.fa-pen-square> | Posts - a.header__link href=Routes.profile_artist_link_path(@conn, :index, @current_user) + a.header__link href=~p"/profiles/#{@current_user}/artist_links" i.fa.fa-fw.fa-link> | Links a.header__link href="/settings/edit" @@ -94,10 +94,10 @@ header.header a.header__link href="/conversations" i.fa.fa-fw.fa-envelope> | Messages - a.header__link href=Routes.registration_path(@conn, :edit) + a.header__link href=~p"/registrations/edit" i.fa.fa-fw.fa-user> | Account - a.header__link href=Routes.session_path(@conn, :delete) data-method="delete" + a.header__link href=~p"/sessions" data-method="delete" i.fa.fa-fw.fa-sign-out-alt> | Logout - else @@ -109,9 +109,9 @@ header.header a.header__link href="/settings/edit" i.fa.fa-fw.fa-cogs.hide-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.header--secondary diff --git a/lib/philomena_web/templates/layout/_header_navigation.html.slime b/lib/philomena_web/templates/layout/_header_navigation.html.slime index 112b0c576..af53a1637 100644 --- a/lib/philomena_web/templates/layout/_header_navigation.html.slime +++ b/lib/philomena_web/templates/layout/_header_navigation.html.slime @@ -22,7 +22,7 @@ i.fa.fa-caret-down< .dropdown__content = for forum <- @conn.assigns.forums do - a.header__link href=Routes.forum_path(@conn, :show, forum) + a.header__link href=~p"/forums/#{forum}" = forum.name a.header__link href="/posts" 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 52d6aef6e..59c6126b9 100644 --- a/lib/philomena_web/templates/layout/_header_staff_links.html.slime +++ b/lib/philomena_web/templates/layout/_header_staff_links.html.slime @@ -7,71 +7,71 @@ .dropdown__content.js-burger-links = if manages_site_notices?(@conn) do - = link to: Routes.admin_site_notice_path(@conn, :index), class: "header__link" do + = link to: ~p"/admin/site_notices", class: "header__link" do i.fa.fa-fw.fa-info-circle> ' Site Notices = if manages_users?(@conn) do - = link to: Routes.admin_user_path(@conn, :index), class: "header__link" do + = link to: ~p"/admin/users", class: "header__link" do i.fa.fa-fw.fa-users> ' Users = if manages_forums?(@conn) do - = link to: Routes.admin_forum_path(@conn, :index), class: "header__link" do + = link to: ~p"/admin/forums", class: "header__link" do i.fa.fa-fw.fa-paragraph> ' Forums = if manages_ads?(@conn) do - = link to: Routes.admin_advert_path(@conn, :index), class: "header__link" do + = link to: ~p"/admin/adverts", class: "header__link" do i.fa.fa-fw.fa-shopping-bag> ' Adverts = if manages_badges?(@conn) do - = link to: Routes.admin_badge_path(@conn, :index), class: "header__link" do + = link to: ~p"/admin/badges", class: "header__link" do i.fa.fa-fw.fa-trophy> ' Badges = if manages_static_pages?(@conn) do - = link to: Routes.page_path(@conn, :index), class: "header__link" do + = link to: ~p"/pages", class: "header__link" do i.fa.fa-fw.fa-sticky-note> ' Pages = if manages_mod_notes?(@conn) do - = link to: Routes.admin_mod_note_path(@conn, :index), class: "header__link" do + = link to: ~p"/admin/mod_notes", class: "header__link" do i.fa.fa-fw.fa-clipboard> ' Mod Notes = if can_see_moderation_log?(@conn) do - = link to: Routes.moderation_log_path(@conn, :index), class: "header__link" do + = link to: ~p"/moderation_logs", class: "header__link" do i.fa.fa-fw.fa-list-alt> ' 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 @@ -84,14 +84,14 @@ .dropdown__content.dropdown__content-right.js-burger-links - = link to: Routes.admin_user_ban_path(@conn, :index), class: "header__link" do + = link to: ~p"/admin/user_bans", class: "header__link" do i.fa.fa-fw.fa-user> ' User Bans - = link to: Routes.admin_subnet_ban_path(@conn, :index), class: "header__link" do + = link to: ~p"/admin/subnet_bans", class: "header__link" do i.fab.fa-fw.fa-internet-explorer> ' IP Bans - = link to: Routes.admin_fingerprint_ban_path(@conn, :index), class: "header__link" do + = link to: ~p"/admin/fingerprint_bans", class: "header__link" do i.fa.fa-fw.fa-desktop> ' FP Bans diff --git a/lib/philomena_web/templates/layout/_opengraph.html.slime b/lib/philomena_web/templates/layout/_opengraph.html.slime index 30ae65551..455851715 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/message/_message.html.slime b/lib/philomena_web/templates/message/_message.html.slime index 27f4bd961..9f7501219 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 a19273051..e2c81eefc 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 3e40d6f33..1fc57157c 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 512c49eae..f7edb1985 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 767cbc737..09e3eccc7 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 ebedb4229..89814c399 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 1a1c5ff64..5ecefcfd8 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 5478763b0..9cec10869 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 2ac4387b8..f141d06b5 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 cc7429f7b..805492eb0 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 88731d64e..5e535faa2 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 48ad0fd1f..c2b7b2086 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 9eadee5f0..f5bc82cce 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 0046b4d90..00cf1f717 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 20b84e858..3aac61b5c 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 d6f5c6a80..fc41fa73f 100644 --- a/lib/philomena_web/templates/post/_post.html.slime +++ b/lib/philomena_web/templates/post/_post.html.slime @@ -9,7 +9,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 @@ -17,7 +17,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" @@ -57,11 +57,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 @@ -78,6 +78,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 f17212b8d..214cf1d3e 100644 --- a/lib/philomena_web/templates/post/_post_options.html.slime +++ b/lib/philomena_web/templates/post/_post_options.html.slime @@ -2,13 +2,13 @@ div ' Posted => pretty_time(@post.created_at) - 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 = if not is_nil(@post.edited_at) and can?(@conn, :show, @post) do br - 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) @@ -17,7 +17,7 @@ div => @post.edit_reason 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 @@ -36,6 +36,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 507fbd699..6313a9dc7 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 e4c4a7822..5bad35b2b 100644 --- a/lib/philomena_web/templates/profile/_about_me.html.slime +++ b/lib/philomena_web/templates/profile/_about_me.html.slime @@ -6,6 +6,6 @@ - current?(@user, @conn.assigns.current_user) -> em ' Want to - => link "add some info about yourself?", to: Routes.profile_description_path(@conn, :edit, @user) + => link "add some info about yourself?", to: ~p"/profiles/#{@user}/description/edit" - true -> diff --git a/lib/philomena_web/templates/profile/_admin_block.html.slime b/lib/philomena_web/templates/profile/_admin_block.html.slime index 187772d29..ca2462ab5 100644 --- a/lib/philomena_web/templates/profile/_admin_block.html.slime +++ b/lib/philomena_web/templates/profile/_admin_block.html.slime @@ -7,7 +7,7 @@ i.fa.fa-fw.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) @@ -52,127 +52,127 @@ a.label.label--primary.label--block href="#" data-click-toggle=".js-admin__optio .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.fa-fw.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.fa-fw.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.fa-fw.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.fa-fw.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.fa-fw.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.fa-fw.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.fa-fw.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.fa-fw.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.fa-fw.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.fa-fw.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.admin_user_force_filter_path(@conn, :delete, @user), data: [confirm: "Are you really, really sure?", method: "delete"] do + = link to: ~p"/admin/users/#{@user}/force_filter", data: [confirm: "Are you really, really sure?", method: "delete"] do i.fas.fa-fw.fa-filter span.admin__button Remove Force Filter = if @user.deleted_at do li - = link to: Routes.admin_user_activation_path(@conn, :create, @user), data: [confirm: "Are you really, really sure?", method: "post"] do + = link to: ~p"/admin/users/#{@user}/activation", data: [confirm: "Are you really, really sure?", method: "post"] do i.fa.fa-fw.fa-check span.admin__button Reactivate Account - else li - = link to: Routes.admin_user_activation_path(@conn, :delete, @user), data: [confirm: "Are you really, really sure?", method: "delete"] do + = link to: ~p"/admin/users/#{@user}/activation", data: [confirm: "Are you really, really sure?", method: "delete"] do i.fa.fa-fw.fa-times span.admin__button Deactivate Account = if @user.locked_at do 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.fa-fw.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.fa-fw.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.fa-fw.fa-link span.admin__button Add Artist Link = if can?(@conn, :create, Philomena.Bans.User) do li - = 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.fa-fw.fa-ban span.admin__button Ban this sucker 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.fa-fw.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.fa-fw.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.fa-fw.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.fa-fw.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.fa-fw.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.fa-fw.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 db8e8d46f..be102740d 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 02f460a08..2752b333c 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.block__header__title 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 d67f10611..8aee5f981 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.block__header__title 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]]}" .block__content.js-resizable-media-container = 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 c7b916582..3b4b48143 100644 --- a/lib/philomena_web/templates/profile/_recent_posts.html.slime +++ b/lib/philomena_web/templates/profile/_recent_posts.html.slime @@ -2,13 +2,13 @@ .block .block__header span.block__header__title Recent Forum Posts - = link "View all", to: Routes.post_path(@conn, :index, pq: "user_id:#{@user.id}") + = link "View all", to: ~p"/posts?#{[pq: "user_id:#{@user.id}"]}" .block__content .block = 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}" diff --git a/lib/philomena_web/templates/profile/alias/_aliases.html.slime b/lib/philomena_web/templates/profile/alias/_aliases.html.slime index 53913aad7..38030e403 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 7c643cf48..c03ff4541 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 15f2999ba..7cb3be111 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 Derpibooru with tags about content you create and with accounts on sites elsewhere. This allows users to easily identify artists and staff to act more rapidly on takedown requests. @@ -17,7 +17,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 762d9be92..a2566378f 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 d38133d46..73aedd3f6 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 0216955ee..94a5f3b6f 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 489bc93e6..525e06cfe 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 778daa015..49ead8713 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.block__header__title 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 544ed9391..93db5128d 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.block__header__title 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.block__header__title 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 aa6bab716..514d03f0e 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 cb8124be1..46d4e28b2 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 b2a756904..6897a066e 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 98653d8dd..0e08e263c 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 bc09393a2..a59ced13c 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 2384a8552..7d51cdfc3 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 b67a9e3c8..182c30c58 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 3d494d787..d5ffc0ffa 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 bb4ca474a..9632e4459 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 21eacf748..3179e247d 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--125px" = 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.fa-fw.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 @@ -65,7 +65,7 @@ .block = if current?(@user, @conn.assigns.current_user) or manages_links?(@conn, @user) do - a.block__header--single-item href=Routes.profile_artist_link_path(@conn, :new, @user) Artist Links + a.block__header--single-item href=~p"/profiles/#{@user}/artist_links/new" Artist Links - else .block__header span.block__header__title Artist Links @@ -91,10 +91,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 @@ -103,7 +103,7 @@ .block = if manages_awards?(@conn) and not hide_staff_tools?(@conn) do - a.block__header--single-item href=Routes.profile_award_path(@conn, :new, @user) Badges + a.block__header--single-item href=~p"/profiles/#{@user}/awards/new" Badges - else .block__header span.block__header__title Badges @@ -120,16 +120,16 @@ = 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 .block .block__header = if can?(@conn, :edit_description, @user) do - a.block__header--single-item href=Routes.profile_description_path(@conn, :edit, @user) About Me + a.block__header--single-item href=~p"/profiles/#{@user}/description/edit" About Me - else span.block__header__title About Me @@ -137,7 +137,7 @@ = if can_read_mod_notes?(@conn) and not hide_staff_tools?(@conn) do .block - a.block__header--single-item href=Routes.profile_detail_path(@conn, :index, @user) Mod Notes + a.block__header--single-item href=~p"/profiles/#{@user}/details" Mod Notes table.table thead tr @@ -150,15 +150,15 @@ td = pretty_time(mod_note.created_at) = if can_index_user?(@conn) do .block - a.block__header--single-item href=Routes.profile_scratchpad_path(@conn, :edit, @user) Moderation Scratchpad + a.block__header--single-item href=~p"/profiles/#{@user}/scratchpad/edit" Moderation Scratchpad .block__content.profile-about = @scratchpad .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 906a2820e..d03fb4f5f 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 806d843a1..0cbc97dd7 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 88bfd1aae..a0134b6eb 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 529b57a1d..1f9bce281 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 99e49ab6a..82d8b8d52 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 9c95f2f80..8fd3028b9 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 48bb98b8a..a7e352240 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.block__header__title 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 diff --git a/lib/philomena_web/templates/search/_form.html.slime b/lib/philomena_web/templates/search/_form.html.slime index d5b524222..efc065af7 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 2c4cffe98..130d7dd41 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 a4c24e011..876be9133 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 112ebaaeb..3d856c2d1 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 0c3bf9ebd..0a632f9fb 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 2809de422..a2185cc04 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. @@ -184,7 +184,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 05971a763..fe4b37b24 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 64e43a2a5..c8373b59d 100644 --- a/lib/philomena_web/templates/staff/index.html.slime +++ b/lib/philomena_web/templates/staff/index.html.slime @@ -37,12 +37,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--125px" p b = user.name .staff-block__info - = link to: Routes.conversation_path(@conn, :new, recipient: user.name), class: "button" do + = link to: ~p"/conversations/new?#{[recipient: user.name]}", class: "button" 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 4bc778827..0de59b7ee 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 5e38db970..2bd36b424 100644 --- a/lib/philomena_web/templates/tag/_tag_info_row.html.slime +++ b/lib/philomena_web/templates/tag/_tag_info_row.html.slime @@ -7,12 +7,12 @@ .flex__grow = render PhilomenaWeb.TagView, "_tag.html", tag: @tag, conn: @conn - = 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 - = link "Edit details", to: Routes.tag_path(@conn, :edit, @tag), class: "detail-link" - = link "Usage", to: Routes.tag_detail_path(@conn, :index, @tag), class: "detail-link" + = link "Edit details", to: ~p"/tags/#{@tag}/edit", class: "detail-link" + = link "Usage", to: ~p"/tags/#{@tag}/details", class: "detail-link" = if manages_dnp?(@conn) do - = 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 @@ -29,14 +29,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 @@ -44,7 +44,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 @@ -70,18 +70,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 @@ -94,7 +94,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 @@ -117,5 +117,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 706545bcc..346aae09a 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 b09071a87..8dfdb6216 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 8a11358ab..5271cab28 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 ee2a6d4db..f5faedb79 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--state-danger", data: [confirm: "Are you really, really sure?", disable_with: raw("Deleting…")] + = button_to "Destroy tag", ~p"/tags/#{@tag}", method: "delete", class: "button button--state-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 c452561f3..778a9b87c 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 605dfa9b3..89931ceaa 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 a8b85c431..ad85fbed5 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 caf85dbdb..a91d1ede4 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.block__header__title | 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 a5f6b64bc..cfffd345c 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 5d42d130e..05236f7aa 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 eb253fbc8..780b63361 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--state-warning.js-staff-action> href=Routes.forum_topic_poll_path(@conn, :edit, @forum, @topic) + a.button.button--state-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 be90c184d..08f209ff2 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 1282a99eb..03cf0640e 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 5b71a1006..749d9cb3f 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 aa69b979a..dcb15f40a 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 5f815ff2d..b75441216 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 c2423ed69..e455ff57d 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 ff54dffd1..613db6d7e 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.fa-fw.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 3a2aa6cab..0772283ec 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.hide-mobile ' Unsubscribe - else - a href=Routes.session_path(@conn, :new) + a href=~p"/sessions/new" i.fa.fa-bell> span.hide-mobile ' Subscribe diff --git a/lib/philomena_web/templates/unlock/new.html.slime b/lib/philomena_web/templates/unlock/new.html.slime index 5d64af56a..9c8e05cca 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 b27abcb28..f5914b853 100644 --- a/lib/philomena_web/templates/user_attribution/_anon_user.html.slime +++ b/lib/philomena_web/templates/user_attribution/_anon_user.html.slime @@ -1,13 +1,13 @@ = cond do - not is_nil(@object.user) and not anonymous?(@object) -> strong<> - = 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 e58b85a42..efd160bb0 100644 --- a/lib/philomena_web/templates/user_attribution/_user.html.slime +++ b/lib/philomena_web/templates/user_attribution/_user.html.slime @@ -1,5 +1,5 @@ = if !!@object.user do strong<> - = 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 \ No newline at end of file diff --git a/lib/philomena_web/user_auth.ex b/lib/philomena_web/user_auth.ex index af7166cfc..bf45d8b69 100644 --- a/lib/philomena_web/user_auth.ex +++ b/lib/philomena_web/user_auth.ex @@ -196,7 +196,7 @@ defmodule PhilomenaWeb.UserAuth do conn |> put_flash(:error, "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/mod_note_view.ex b/lib/philomena_web/views/admin/mod_note_view.ex index a873208aa..463de66b3 100644 --- a/lib/philomena_web/views/admin/mod_note_view.ex +++ b/lib/philomena_web/views/admin/mod_note_view.ex @@ -6,19 +6,19 @@ defmodule PhilomenaWeb.Admin.ModNoteView do 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)) + 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)) + do: link("Report #{report.id}", to: ~p"/admin/reports/#{report}") def link_to_noted_thing(conn, %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)) + do: link("User #{user.name}", to: ~p"/profiles/#{user}") def link_to_noted_thing(_conn, _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 a9cd5bcc2..a192c4fdb 100644 --- a/lib/philomena_web/views/admin/report_view.ex +++ b/lib/philomena_web/views/admin/report_view.ex @@ -28,10 +28,10 @@ defmodule PhilomenaWeb.Admin.ReportView do def truncated_ip_link(conn, 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 4ce912831..c85902abc 100644 --- a/lib/philomena_web/views/conversation_view.ex +++ b/lib/philomena_web/views/conversation_view.ex @@ -35,6 +35,6 @@ defmodule PhilomenaWeb.ConversationView do def last_message_path(conn, 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 2a9fe461a..2470d5cf9 100644 --- a/lib/philomena_web/views/profile_view.ex +++ b/lib/philomena_web/views/profile_view.ex @@ -83,7 +83,7 @@ defmodule PhilomenaWeb.ProfileView do 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)") diff --git a/lib/philomena_web/views/report_view.ex b/lib/philomena_web/views/report_view.ex index 27f6f5a29..e33493bed 100644 --- a/lib/philomena_web/views/report_view.ex +++ b/lib/philomena_web/views/report_view.ex @@ -42,39 +42,39 @@ defmodule PhilomenaWeb.ReportView do 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)) + do: link("Image >>#{r.id}", to: ~p"/images/#{r}") def link_to_reported_thing(conn, %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), 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), 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)) + do: link("Gallery '#{r.title}' by #{r.creator.name}", to: ~p"/galleries/#{r}") def link_to_reported_thing(conn, %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)) + do: link("User '#{r.name}'", to: ~p"/profiles/#{r}") def link_to_reported_thing(_conn, _reportable) do "Reported item permanently destroyed." diff --git a/test/philomena_web/controllers/confirmation_controller_test.exs b/test/philomena_web/controllers/confirmation_controller_test.exs index 55cbb1726..049fd6d1f 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 4d421f723..b74cf0462 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 2107a80f0..756fea2e4 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 3e216805a..b850e7af4 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 0ee59d907..dc5576664 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 78e148342..29d8d7f2d 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 d506e90a6..bc8df85e4 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 e03912fe5..deeaeca7f 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." From c1fcfe1f6c524c72bf9cd0463d0dc90736f83ac8 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 28 Apr 2024 21:03:37 -0400 Subject: [PATCH 06/12] find lib/ -name '*.ex' -exec sed -i 's|defp log_details(conn, |defp log_details(_conn, |g' {} \; --- .../controllers/admin/artist_link/contact_controller.ex | 2 +- .../controllers/admin/artist_link/reject_controller.ex | 2 +- .../controllers/admin/artist_link/verification_controller.ex | 2 +- lib/philomena_web/controllers/admin/batch/tag_controller.ex | 2 +- .../controllers/admin/fingerprint_ban_controller.ex | 2 +- lib/philomena_web/controllers/admin/subnet_ban_controller.ex | 2 +- .../controllers/admin/user/verification_controller.ex | 2 +- lib/philomena_web/controllers/admin/user_ban_controller.ex | 2 +- lib/philomena_web/controllers/admin/user_controller.ex | 2 +- .../controllers/duplicate_report/accept_controller.ex | 2 +- .../controllers/duplicate_report/accept_reverse_controller.ex | 2 +- .../controllers/duplicate_report/claim_controller.ex | 2 +- .../controllers/duplicate_report/reject_controller.ex | 2 +- lib/philomena_web/controllers/image/anonymous_controller.ex | 2 +- lib/philomena_web/controllers/image/approve_controller.ex | 2 +- .../controllers/image/comment/approve_controller.ex | 2 +- .../controllers/image/comment/delete_controller.ex | 2 +- lib/philomena_web/controllers/image/comment/hide_controller.ex | 2 +- lib/philomena_web/controllers/image/comment_lock_controller.ex | 2 +- lib/philomena_web/controllers/image/delete_controller.ex | 2 +- .../controllers/image/description_lock_controller.ex | 2 +- lib/philomena_web/controllers/image/destroy_controller.ex | 2 +- lib/philomena_web/controllers/image/feature_controller.ex | 2 +- lib/philomena_web/controllers/image/hash_controller.ex | 2 +- lib/philomena_web/controllers/image/repair_controller.ex | 2 +- lib/philomena_web/controllers/image/scratchpad_controller.ex | 2 +- .../controllers/image/source_history_controller.ex | 2 +- lib/philomena_web/controllers/image/tag_change_controller.ex | 2 +- lib/philomena_web/controllers/image/tag_lock_controller.ex | 2 +- lib/philomena_web/controllers/image/tamper_controller.ex | 2 +- lib/philomena_web/controllers/tag/image_controller.ex | 2 +- lib/philomena_web/controllers/tag_controller.ex | 2 +- lib/philomena_web/controllers/topic/hide_controller.ex | 2 +- lib/philomena_web/controllers/topic/lock_controller.ex | 2 +- lib/philomena_web/controllers/topic/move_controller.ex | 2 +- lib/philomena_web/controllers/topic/post/approve_controller.ex | 2 +- lib/philomena_web/controllers/topic/post/delete_controller.ex | 2 +- lib/philomena_web/controllers/topic/post/hide_controller.ex | 2 +- lib/philomena_web/controllers/topic/stick_controller.ex | 2 +- 39 files changed, 39 insertions(+), 39 deletions(-) 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 0e0ffc30e..2f270db83 100644 --- a/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/contact_controller.ex @@ -22,7 +22,7 @@ defmodule PhilomenaWeb.Admin.ArtistLink.ContactController do |> redirect(to: ~p"/admin/artist_links") end - defp log_details(conn, _action, artist_link) do + defp log_details(_conn, _action, artist_link) do %{ body: "Contacted artist #{artist_link.user.name} at #{artist_link.uri}", subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}" 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 168251fd2..b238efcfd 100644 --- a/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/reject_controller.ex @@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Admin.ArtistLink.RejectController do |> redirect(to: ~p"/admin/artist_links") end - defp log_details(conn, _action, artist_link) do + defp log_details(_conn, _action, artist_link) do %{ body: "Rejected artist link #{artist_link.uri} created by #{artist_link.user.name}", subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}" 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 02a45ab4f..836b59d70 100644 --- a/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex +++ b/lib/philomena_web/controllers/admin/artist_link/verification_controller.ex @@ -22,7 +22,7 @@ defmodule PhilomenaWeb.Admin.ArtistLink.VerificationController do |> redirect(to: ~p"/admin/artist_links") end - defp log_details(conn, _action, artist_link) do + defp log_details(_conn, _action, artist_link) do %{ body: "Verified artist link #{artist_link.uri} created by #{artist_link.user.name}", subject_path: ~p"/profiles/#{artist_link.user}/artist_links/#{artist_link}" diff --git a/lib/philomena_web/controllers/admin/batch/tag_controller.ex b/lib/philomena_web/controllers/admin/batch/tag_controller.ex index 59371b6a0..512a0972c 100644 --- a/lib/philomena_web/controllers/admin/batch/tag_controller.ex +++ b/lib/philomena_web/controllers/admin/batch/tag_controller.ex @@ -68,7 +68,7 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do end end - defp log_details(conn, _action, data) do + defp log_details(_conn, _action, data) do %{ body: "Batch tagged '#{data.tag_list}' on #{data.image_count} images", subject_path: ~p"/profiles/#{conn.assigns.current_user}" diff --git a/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex b/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex index 2e1c20f9d..3ae575719 100644 --- a/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/fingerprint_ban_controller.ex @@ -110,7 +110,7 @@ defmodule PhilomenaWeb.Admin.FingerprintBanController do end end - defp log_details(conn, action, ban) do + defp log_details(_conn, action, ban) do body = case action do :create -> "Created a fingerprint ban #{ban.generated_ban_id}" diff --git a/lib/philomena_web/controllers/admin/subnet_ban_controller.ex b/lib/philomena_web/controllers/admin/subnet_ban_controller.ex index f2d0dbaa6..31f83b071 100644 --- a/lib/philomena_web/controllers/admin/subnet_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/subnet_ban_controller.ex @@ -112,7 +112,7 @@ defmodule PhilomenaWeb.Admin.SubnetBanController do end end - defp log_details(conn, action, ban) do + defp log_details(_conn, action, ban) do body = case action do :create -> "Created a subnet ban #{ban.generated_ban_id}" diff --git a/lib/philomena_web/controllers/admin/user/verification_controller.ex b/lib/philomena_web/controllers/admin/user/verification_controller.ex index 9478bc42f..5f8864ee7 100644 --- a/lib/philomena_web/controllers/admin/user/verification_controller.ex +++ b/lib/philomena_web/controllers/admin/user/verification_controller.ex @@ -32,7 +32,7 @@ defmodule PhilomenaWeb.Admin.User.VerificationController do end end - defp log_details(conn, action, user) do + defp log_details(_conn, action, user) do body = case action do :create -> "Granted verification to #{user.name}" diff --git a/lib/philomena_web/controllers/admin/user_ban_controller.ex b/lib/philomena_web/controllers/admin/user_ban_controller.ex index bbaf6b621..7def25414 100644 --- a/lib/philomena_web/controllers/admin/user_ban_controller.ex +++ b/lib/philomena_web/controllers/admin/user_ban_controller.ex @@ -116,7 +116,7 @@ defmodule PhilomenaWeb.Admin.UserBanController do end end - defp log_details(conn, action, ban) do + defp log_details(_conn, action, ban) do body = case action do :create -> "Created a user ban #{ban.generated_ban_id}" diff --git a/lib/philomena_web/controllers/admin/user_controller.ex b/lib/philomena_web/controllers/admin/user_controller.ex index 672147f8e..5f2361083 100644 --- a/lib/philomena_web/controllers/admin/user_controller.ex +++ b/lib/philomena_web/controllers/admin/user_controller.ex @@ -81,7 +81,7 @@ defmodule PhilomenaWeb.Admin.UserController do assign(conn, :roles, Repo.all(Role)) end - defp log_details(conn, _action, user) do + defp log_details(_conn, _action, user) do %{ body: "Updated user details for #{user.name}", subject_path: ~p"/profiles/#{user}" diff --git a/lib/philomena_web/controllers/duplicate_report/accept_controller.ex b/lib/philomena_web/controllers/duplicate_report/accept_controller.ex index a67760dc0..4462fb382 100644 --- a/lib/philomena_web/controllers/duplicate_report/accept_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/accept_controller.ex @@ -30,7 +30,7 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptController do end end - defp log_details(conn, _action, report) do + defp log_details(_conn, _action, report) do %{ body: "Accepted duplicate report, merged #{report.image.id} into #{report.duplicate_of_image.id}", 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 7c04cc490..873768ff7 100644 --- a/lib/philomena_web/controllers/duplicate_report/accept_reverse_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/accept_reverse_controller.ex @@ -30,7 +30,7 @@ defmodule PhilomenaWeb.DuplicateReport.AcceptReverseController do end end - defp log_details(conn, _action, report) do + defp log_details(_conn, _action, report) do %{ body: "Reverse-accepted duplicate report, merged #{report.image.id} into #{report.duplicate_of_image.id}", diff --git a/lib/philomena_web/controllers/duplicate_report/claim_controller.ex b/lib/philomena_web/controllers/duplicate_report/claim_controller.ex index 966eddae9..446fa3671 100644 --- a/lib/philomena_web/controllers/duplicate_report/claim_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/claim_controller.ex @@ -33,7 +33,7 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do |> redirect(to: ~p"/duplicate_reports") end - defp log_details(conn, action, _) do + defp log_details(_conn, action, _) do body = case action do :create -> "Claimed a duplicate report" diff --git a/lib/philomena_web/controllers/duplicate_report/reject_controller.ex b/lib/philomena_web/controllers/duplicate_report/reject_controller.ex index 83626c36c..7d428e52a 100644 --- a/lib/philomena_web/controllers/duplicate_report/reject_controller.ex +++ b/lib/philomena_web/controllers/duplicate_report/reject_controller.ex @@ -25,7 +25,7 @@ defmodule PhilomenaWeb.DuplicateReport.RejectController do |> redirect(to: ~p"/duplicate_reports") end - defp log_details(conn, _action, report) do + defp log_details(_conn, _action, report) do %{ body: "Rejected duplicate report (#{report.image.id} -> #{report.duplicate_of_image.id})", subject_path: ~p"/duplicate_reports" diff --git a/lib/philomena_web/controllers/image/anonymous_controller.ex b/lib/philomena_web/controllers/image/anonymous_controller.ex index 1855efc9e..feed3ff12 100644 --- a/lib/philomena_web/controllers/image/anonymous_controller.ex +++ b/lib/philomena_web/controllers/image/anonymous_controller.ex @@ -33,7 +33,7 @@ defmodule PhilomenaWeb.Image.AnonymousController do end end - defp log_details(conn, _action, image) do + defp log_details(_conn, _action, image) do %{ body: "Updated anonymity of image >>#{image.id}", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/approve_controller.ex b/lib/philomena_web/controllers/image/approve_controller.ex index 1a44cb768..b67b9619b 100644 --- a/lib/philomena_web/controllers/image/approve_controller.ex +++ b/lib/philomena_web/controllers/image/approve_controller.ex @@ -18,7 +18,7 @@ defmodule PhilomenaWeb.Image.ApproveController do |> redirect(to: ~p"/admin/approvals") end - defp log_details(conn, _action, image) do + defp log_details(_conn, _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 f6b05ca15..c55e734cd 100644 --- a/lib/philomena_web/controllers/image/comment/approve_controller.ex +++ b/lib/philomena_web/controllers/image/comment/approve_controller.ex @@ -26,7 +26,7 @@ defmodule PhilomenaWeb.Image.Comment.ApproveController do |> redirect(to: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}") end - defp log_details(conn, _action, comment) do + defp log_details(_conn, _action, comment) do %{ body: "Approved comment on image >>#{comment.image_id}", subject_path: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}" diff --git a/lib/philomena_web/controllers/image/comment/delete_controller.ex b/lib/philomena_web/controllers/image/comment/delete_controller.ex index 21fc2c1f5..65e80700c 100644 --- a/lib/philomena_web/controllers/image/comment/delete_controller.ex +++ b/lib/philomena_web/controllers/image/comment/delete_controller.ex @@ -26,7 +26,7 @@ defmodule PhilomenaWeb.Image.Comment.DeleteController do end end - defp log_details(conn, _action, comment) do + defp log_details(_conn, _action, comment) do %{ body: "Destroyed comment on image >>#{comment.image_id}", subject_path: ~p"/images/#{comment.image_id}" <> "#comment_#{comment.id}" diff --git a/lib/philomena_web/controllers/image/comment/hide_controller.ex b/lib/philomena_web/controllers/image/comment/hide_controller.ex index 942411049..50a10f577 100644 --- a/lib/philomena_web/controllers/image/comment/hide_controller.ex +++ b/lib/philomena_web/controllers/image/comment/hide_controller.ex @@ -42,7 +42,7 @@ defmodule PhilomenaWeb.Image.Comment.HideController do end end - defp log_details(conn, action, comment) do + defp log_details(_conn, action, comment) do body = case action do :create -> "Hidden comment on image >>#{comment.image_id} (#{comment.deletion_reason})" diff --git a/lib/philomena_web/controllers/image/comment_lock_controller.ex b/lib/philomena_web/controllers/image/comment_lock_controller.ex index c6c5b2b91..9256f9b69 100644 --- a/lib/philomena_web/controllers/image/comment_lock_controller.ex +++ b/lib/philomena_web/controllers/image/comment_lock_controller.ex @@ -25,7 +25,7 @@ defmodule PhilomenaWeb.Image.CommentLockController do |> redirect(to: ~p"/images/#{image}") end - defp log_details(conn, action, image) do + defp log_details(_conn, action, image) do body = case action do :create -> "Locked comments on image >>#{image.id}" diff --git a/lib/philomena_web/controllers/image/delete_controller.ex b/lib/philomena_web/controllers/image/delete_controller.ex index 3d86cfa68..a9ccbad8c 100644 --- a/lib/philomena_web/controllers/image/delete_controller.ex +++ b/lib/philomena_web/controllers/image/delete_controller.ex @@ -70,7 +70,7 @@ defmodule PhilomenaWeb.Image.DeleteController do |> redirect(to: ~p"/images/#{image}") end - defp log_details(conn, action, image) do + defp log_details(_conn, action, image) do body = case action do :create -> "Hidden image >>#{image.id} (#{image.deletion_reason})" diff --git a/lib/philomena_web/controllers/image/description_lock_controller.ex b/lib/philomena_web/controllers/image/description_lock_controller.ex index bde327ac6..e7ddc6281 100644 --- a/lib/philomena_web/controllers/image/description_lock_controller.ex +++ b/lib/philomena_web/controllers/image/description_lock_controller.ex @@ -25,7 +25,7 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do |> redirect(to: ~p"/images/#{image}") end - defp log_details(conn, action, image) do + defp log_details(_conn, action, image) do body = case action do :create -> "Locked description editing on image >>#{image.id}" diff --git a/lib/philomena_web/controllers/image/destroy_controller.ex b/lib/philomena_web/controllers/image/destroy_controller.ex index 8f4ed867d..986773d02 100644 --- a/lib/philomena_web/controllers/image/destroy_controller.ex +++ b/lib/philomena_web/controllers/image/destroy_controller.ex @@ -38,7 +38,7 @@ defmodule PhilomenaWeb.Image.DestroyController do end end - defp log_details(conn, _action, image) do + defp log_details(_conn, _action, image) do %{ body: "Hard-deleted image >>#{image.id}", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/feature_controller.ex b/lib/philomena_web/controllers/image/feature_controller.ex index 74c19c057..59df5b73d 100644 --- a/lib/philomena_web/controllers/image/feature_controller.ex +++ b/lib/philomena_web/controllers/image/feature_controller.ex @@ -33,7 +33,7 @@ defmodule PhilomenaWeb.Image.FeatureController do end end - defp log_details(conn, _action, image) do + defp log_details(_conn, _action, image) do %{ body: "Featured image >>#{image.id}", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/hash_controller.ex b/lib/philomena_web/controllers/image/hash_controller.ex index 233d5202c..ffbeb1091 100644 --- a/lib/philomena_web/controllers/image/hash_controller.ex +++ b/lib/philomena_web/controllers/image/hash_controller.ex @@ -16,7 +16,7 @@ defmodule PhilomenaWeb.Image.HashController do |> redirect(to: ~p"/images/#{image}") end - defp log_details(conn, _action, image) do + defp log_details(_conn, _action, image) do %{ body: "Cleared hash of image >>#{image.id}", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/repair_controller.ex b/lib/philomena_web/controllers/image/repair_controller.ex index 10d867736..80a050b75 100644 --- a/lib/philomena_web/controllers/image/repair_controller.ex +++ b/lib/philomena_web/controllers/image/repair_controller.ex @@ -17,7 +17,7 @@ defmodule PhilomenaWeb.Image.RepairController do |> redirect(to: ~p"/images/#{conn.assigns.image}") end - defp log_details(conn, _action, image) do + defp log_details(_conn, _action, image) do %{ body: "Repaired image >>#{image.id}", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/scratchpad_controller.ex b/lib/philomena_web/controllers/image/scratchpad_controller.ex index 4fddb1355..b3cd8e69c 100644 --- a/lib/philomena_web/controllers/image/scratchpad_controller.ex +++ b/lib/philomena_web/controllers/image/scratchpad_controller.ex @@ -21,7 +21,7 @@ defmodule PhilomenaWeb.Image.ScratchpadController do |> redirect(to: ~p"/images/#{image}") end - defp log_details(conn, _action, image) do + defp log_details(_conn, _action, image) do %{ body: "Updated mod notes on image >>#{image.id} (#{image.scratchpad})", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/source_history_controller.ex b/lib/philomena_web/controllers/image/source_history_controller.ex index 85f061db4..022a270d5 100644 --- a/lib/philomena_web/controllers/image/source_history_controller.ex +++ b/lib/philomena_web/controllers/image/source_history_controller.ex @@ -18,7 +18,7 @@ defmodule PhilomenaWeb.Image.SourceHistoryController do |> redirect(to: ~p"/images/#{image}") end - defp log_details(conn, _action, image) do + defp log_details(_conn, _action, image) do %{ body: "Deleted source history for image >>#{image.id}", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/tag_change_controller.ex b/lib/philomena_web/controllers/image/tag_change_controller.ex index b2716558c..b38735ca5 100644 --- a/lib/philomena_web/controllers/image/tag_change_controller.ex +++ b/lib/philomena_web/controllers/image/tag_change_controller.ex @@ -58,7 +58,7 @@ 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(_conn, _action, %{image: image, details: details}) do %{ body: "Deleted tag change #{details} on >>#{image.id} from history", subject_path: ~p"/images/#{image}" diff --git a/lib/philomena_web/controllers/image/tag_lock_controller.ex b/lib/philomena_web/controllers/image/tag_lock_controller.ex index 4e6a0e701..c80841c73 100644 --- a/lib/philomena_web/controllers/image/tag_lock_controller.ex +++ b/lib/philomena_web/controllers/image/tag_lock_controller.ex @@ -45,7 +45,7 @@ defmodule PhilomenaWeb.Image.TagLockController do |> redirect(to: ~p"/images/#{image}") end - defp log_details(conn, action, image) do + defp log_details(_conn, action, image) do body = case action do :create -> "Locked tags on image >>#{image.id}" diff --git a/lib/philomena_web/controllers/image/tamper_controller.ex b/lib/philomena_web/controllers/image/tamper_controller.ex index 4ce1ac3c9..482bb14a5 100644 --- a/lib/philomena_web/controllers/image/tamper_controller.ex +++ b/lib/philomena_web/controllers/image/tamper_controller.ex @@ -31,7 +31,7 @@ defmodule PhilomenaWeb.Image.TamperController do |> redirect(to: ~p"/images/#{conn.assigns.image}") end - defp log_details(conn, _action, data) do + defp log_details(_conn, _action, data) do image = data.image vote_type = diff --git a/lib/philomena_web/controllers/tag/image_controller.ex b/lib/philomena_web/controllers/tag/image_controller.ex index 21d069830..96ed38992 100644 --- a/lib/philomena_web/controllers/tag/image_controller.ex +++ b/lib/philomena_web/controllers/tag/image_controller.ex @@ -40,7 +40,7 @@ defmodule PhilomenaWeb.Tag.ImageController do |> redirect(to: ~p"/tags/#{conn.assigns.tag}") end - defp log_details(conn, action, tag) do + defp log_details(_conn, action, tag) do body = case action do :update -> "Updated image on tag '#{tag.name}'" diff --git a/lib/philomena_web/controllers/tag_controller.ex b/lib/philomena_web/controllers/tag_controller.ex index 3fac85cdf..2c94d3e5e 100644 --- a/lib/philomena_web/controllers/tag_controller.ex +++ b/lib/philomena_web/controllers/tag_controller.ex @@ -172,7 +172,7 @@ defmodule PhilomenaWeb.TagController do end end - defp log_details(conn, action, tag) do + defp log_details(_conn, action, tag) do body = case action do :update -> "Updated details on tag '#{tag.name}'" diff --git a/lib/philomena_web/controllers/topic/hide_controller.ex b/lib/philomena_web/controllers/topic/hide_controller.ex index 247741d50..8eb947cf0 100644 --- a/lib/philomena_web/controllers/topic/hide_controller.ex +++ b/lib/philomena_web/controllers/topic/hide_controller.ex @@ -54,7 +54,7 @@ defmodule PhilomenaWeb.Topic.HideController do end end - defp log_details(conn, action, topic) do + defp log_details(_conn, action, topic) do body = case action do :create -> diff --git a/lib/philomena_web/controllers/topic/lock_controller.ex b/lib/philomena_web/controllers/topic/lock_controller.ex index aa4bf13f2..9cb95c7fe 100644 --- a/lib/philomena_web/controllers/topic/lock_controller.ex +++ b/lib/philomena_web/controllers/topic/lock_controller.ex @@ -53,7 +53,7 @@ defmodule PhilomenaWeb.Topic.LockController do end end - defp log_details(conn, action, topic) do + defp log_details(_conn, action, topic) do body = case action do :create -> "Locked topic '#{topic.title}' (#{topic.lock_reason}) in #{topic.forum.name}" diff --git a/lib/philomena_web/controllers/topic/move_controller.ex b/lib/philomena_web/controllers/topic/move_controller.ex index d8c91c3f5..fcd17c210 100644 --- a/lib/philomena_web/controllers/topic/move_controller.ex +++ b/lib/philomena_web/controllers/topic/move_controller.ex @@ -39,7 +39,7 @@ defmodule PhilomenaWeb.Topic.MoveController do end end - defp log_details(conn, _action, topic) do + defp log_details(_conn, _action, topic) do %{ body: "Topic '#{topic.title}' moved to #{topic.forum.name}", subject_path: ~p"/forums/#{topic.forum}/topics/#{topic}" diff --git a/lib/philomena_web/controllers/topic/post/approve_controller.ex b/lib/philomena_web/controllers/topic/post/approve_controller.ex index 01e11dafd..1af98931a 100644 --- a/lib/philomena_web/controllers/topic/post/approve_controller.ex +++ b/lib/philomena_web/controllers/topic/post/approve_controller.ex @@ -38,7 +38,7 @@ defmodule PhilomenaWeb.Topic.Post.ApproveController do end end - defp log_details(conn, _action, post) do + defp log_details(_conn, _action, post) do %{ body: "Approved forum post ##{post.id} in topic '#{post.topic.title}'", subject_path: diff --git a/lib/philomena_web/controllers/topic/post/delete_controller.ex b/lib/philomena_web/controllers/topic/post/delete_controller.ex index 72e395362..9fa2b4903 100644 --- a/lib/philomena_web/controllers/topic/post/delete_controller.ex +++ b/lib/philomena_web/controllers/topic/post/delete_controller.ex @@ -37,7 +37,7 @@ defmodule PhilomenaWeb.Topic.Post.DeleteController do end end - defp log_details(conn, _action, post) do + defp log_details(_conn, _action, post) do %{ body: "Destroyed forum post ##{post.id} in topic '#{post.topic.title}'", subject_path: diff --git a/lib/philomena_web/controllers/topic/post/hide_controller.ex b/lib/philomena_web/controllers/topic/post/hide_controller.ex index ed3f69d9e..da423f3b3 100644 --- a/lib/philomena_web/controllers/topic/post/hide_controller.ex +++ b/lib/philomena_web/controllers/topic/post/hide_controller.ex @@ -63,7 +63,7 @@ defmodule PhilomenaWeb.Topic.Post.HideController do end end - defp log_details(conn, action, post) do + defp log_details(_conn, action, post) do body = case action do :create -> diff --git a/lib/philomena_web/controllers/topic/stick_controller.ex b/lib/philomena_web/controllers/topic/stick_controller.ex index d413be6d2..a6ee72c46 100644 --- a/lib/philomena_web/controllers/topic/stick_controller.ex +++ b/lib/philomena_web/controllers/topic/stick_controller.ex @@ -52,7 +52,7 @@ defmodule PhilomenaWeb.Topic.StickController do end end - defp log_details(conn, action, topic) do + defp log_details(_conn, action, topic) do body = case action do :create -> "Stickied topic '#{topic.title}' in #{topic.forum.name}" From e69f1bf3fa1dd33f0ff71bea1b3732de47fd87f8 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 28 Apr 2024 21:04:28 -0400 Subject: [PATCH 07/12] Fixup --- lib/philomena_web/controllers/admin/batch/tag_controller.ex | 2 +- lib/philomena_web/controllers/image/tamper_controller.ex | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/philomena_web/controllers/admin/batch/tag_controller.ex b/lib/philomena_web/controllers/admin/batch/tag_controller.ex index 512a0972c..59371b6a0 100644 --- a/lib/philomena_web/controllers/admin/batch/tag_controller.ex +++ b/lib/philomena_web/controllers/admin/batch/tag_controller.ex @@ -68,7 +68,7 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do end end - defp log_details(_conn, _action, data) do + defp log_details(conn, _action, data) do %{ body: "Batch tagged '#{data.tag_list}' on #{data.image_count} images", subject_path: ~p"/profiles/#{conn.assigns.current_user}" diff --git a/lib/philomena_web/controllers/image/tamper_controller.ex b/lib/philomena_web/controllers/image/tamper_controller.ex index 482bb14a5..4ce1ac3c9 100644 --- a/lib/philomena_web/controllers/image/tamper_controller.ex +++ b/lib/philomena_web/controllers/image/tamper_controller.ex @@ -31,7 +31,7 @@ defmodule PhilomenaWeb.Image.TamperController do |> redirect(to: ~p"/images/#{conn.assigns.image}") end - defp log_details(_conn, _action, data) do + defp log_details(conn, _action, data) do image = data.image vote_type = From c506ef884e759d6cfb787da7c65cf47179b67a45 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 28 Apr 2024 21:08:00 -0400 Subject: [PATCH 08/12] link_to_reported_thing, link_to_noted_thing --- .../templates/admin/mod_note/_table.html.slime | 2 +- .../templates/admin/report/_reports.html.slime | 2 +- .../templates/admin/report/show.html.slime | 2 +- .../templates/report/index.html.slime | 2 +- .../templates/report/new.html.slime | 2 +- lib/philomena_web/views/admin/mod_note_view.ex | 10 +++++----- lib/philomena_web/views/admin/report_view.ex | 4 ++-- lib/philomena_web/views/report_view.ex | 16 ++++++++-------- 8 files changed, 20 insertions(+), 20 deletions(-) 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 6c143079a..452078009 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 diff --git a/lib/philomena_web/templates/admin/report/_reports.html.slime b/lib/philomena_web/templates/admin/report/_reports.html.slime index 743f51cb1..9ac6563e1 100644 --- a/lib/philomena_web/templates/admin/report/_reports.html.slime +++ b/lib/philomena_web/templates/admin/report/_reports.html.slime @@ -12,7 +12,7 @@ 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) diff --git a/lib/philomena_web/templates/admin/report/show.html.slime b/lib/philomena_web/templates/admin/report/show.html.slime index d0d183a8b..20835cdd1 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 diff --git a/lib/philomena_web/templates/report/index.html.slime b/lib/philomena_web/templates/report/index.html.slime index a7e352240..2d7d65638 100644 --- a/lib/philomena_web/templates/report/index.html.slime +++ b/lib/philomena_web/templates/report/index.html.slime @@ -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 15f2a32a6..f78397834 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/views/admin/mod_note_view.ex b/lib/philomena_web/views/admin/mod_note_view.ex index 463de66b3..021e47211 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), + 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), + 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: ~p"/admin/reports/#{report}" ) - def link_to_noted_thing(conn, %User{} = 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 a192c4fdb..56337cd27 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) diff --git a/lib/philomena_web/views/report_view.ex b/lib/philomena_web/views/report_view.ex index e33493bed..35693434c 100644 --- a/lib/philomena_web/views/report_view.ex +++ b/lib/philomena_web/views/report_view.ex @@ -41,31 +41,31 @@ 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), + 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: ~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: ~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: ~p"/profiles/#{r.user}/commission" ) - def link_to_reported_thing(conn, %Gallery{} = 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: @@ -73,10 +73,10 @@ defmodule PhilomenaWeb.ReportView do "#post_#{r.id}" ) - def link_to_reported_thing(conn, %User{} = 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 From 42039491b63e5e674324c62647eab928073f44b7 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 28 Apr 2024 21:11:56 -0400 Subject: [PATCH 09/12] redirect_path, user_abbrv, last_message_path --- lib/philomena_web/controllers/report_controller.ex | 6 +++--- .../templates/admin/fingerprint_ban/index.html.slime | 2 +- .../templates/admin/report/_reports.html.slime | 2 +- .../templates/admin/subnet_ban/index.html.slime | 2 +- lib/philomena_web/templates/admin/user_ban/index.html.slime | 2 +- lib/philomena_web/templates/conversation/index.html.slime | 2 +- lib/philomena_web/templates/profile/show.html.slime | 2 +- lib/philomena_web/views/admin/ban_view.ex | 4 ++-- lib/philomena_web/views/admin/report_view.ex | 4 ++-- lib/philomena_web/views/conversation_view.ex | 2 +- lib/philomena_web/views/profile_view.ex | 4 ++-- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/philomena_web/controllers/report_controller.ex b/lib/philomena_web/controllers/report_controller.ex index 930ecf13d..7860a32ea 100644 --- a/lib/philomena_web/controllers/report_controller.ex +++ b/lib/philomena_web/controllers/report_controller.ex @@ -53,7 +53,7 @@ defmodule PhilomenaWeb.ReportController do :info, "Your report has been received and will be checked by staff shortly." ) - |> redirect(to: redirect_path(conn, conn.assigns.current_user)) + |> redirect(to: redirect_path(conn.assigns.current_user)) {:error, changeset} -> # Note that we are depending on the controller that called @@ -100,8 +100,8 @@ defmodule PhilomenaWeb.ReportController do reports_open >= max_reports() end - defp redirect_path(_conn, nil), do: "/" - defp redirect_path(conn, _user), do: ~p"/reports" + defp redirect_path(nil), do: "/" + defp redirect_path(_user), do: ~p"/reports" defp max_reports do 5 diff --git a/lib/philomena_web/templates/admin/fingerprint_ban/index.html.slime b/lib/philomena_web/templates/admin/fingerprint_ban/index.html.slime index 209ad5096..7e42314af 100644 --- a/lib/philomena_web/templates/admin/fingerprint_ban/index.html.slime +++ b/lib/philomena_web/templates/admin/fingerprint_ban/index.html.slime @@ -35,7 +35,7 @@ h1 Fingerprint Bans td => pretty_time ban.created_at - = user_abbrv @conn, ban.banning_user + = user_abbrv ban.banning_user td class=ban_row_class(ban) = pretty_time ban.valid_until diff --git a/lib/philomena_web/templates/admin/report/_reports.html.slime b/lib/philomena_web/templates/admin/report/_reports.html.slime index 9ac6563e1..a423d1e7a 100644 --- a/lib/philomena_web/templates/admin/report/_reports.html.slime +++ b/lib/philomena_web/templates/admin/report/_reports.html.slime @@ -32,7 +32,7 @@ table.table td class=report_row_class(report) => pretty_state(report) - = user_abbrv @conn, report.admin + = user_abbrv report.admin td => link "Show", to: ~p"/admin/reports/#{report}" diff --git a/lib/philomena_web/templates/admin/subnet_ban/index.html.slime b/lib/philomena_web/templates/admin/subnet_ban/index.html.slime index ff139197f..c051a10a1 100644 --- a/lib/philomena_web/templates/admin/subnet_ban/index.html.slime +++ b/lib/philomena_web/templates/admin/subnet_ban/index.html.slime @@ -35,7 +35,7 @@ h1 Subnet Bans td => pretty_time ban.created_at - = user_abbrv @conn, ban.banning_user + = user_abbrv ban.banning_user td class=ban_row_class(ban) = pretty_time ban.valid_until diff --git a/lib/philomena_web/templates/admin/user_ban/index.html.slime b/lib/philomena_web/templates/admin/user_ban/index.html.slime index 3f76034dc..5b60fc21b 100644 --- a/lib/philomena_web/templates/admin/user_ban/index.html.slime +++ b/lib/philomena_web/templates/admin/user_ban/index.html.slime @@ -35,7 +35,7 @@ h1 User Bans td => pretty_time ban.created_at - = user_abbrv @conn, ban.banning_user + = user_abbrv ban.banning_user td class=ban_row_class(ban) = pretty_time ban.valid_until diff --git a/lib/philomena_web/templates/conversation/index.html.slime b/lib/philomena_web/templates/conversation/index.html.slime index ea476547f..611610e0d 100644 --- a/lib/philomena_web/templates/conversation/index.html.slime +++ b/lib/philomena_web/templates/conversation/index.html.slime @@ -36,7 +36,7 @@ h1 My Conversations td.table--communication-list__stats = render PhilomenaWeb.UserAttributionView, "_user.html", object: %{user: other_party(@current_user, c)}, conn: @conn td.table--communication-list__options - => link "Last message", to: last_message_path(@conn, c, count) + => link "Last message", to: last_message_path(c, count) ' • => link "Hide", to: ~p"/conversations/#{c}/hide", data: [method: "post"], data: [confirm: "Are you really, really sure?"] diff --git a/lib/philomena_web/templates/profile/show.html.slime b/lib/philomena_web/templates/profile/show.html.slime index 3179e247d..6039a48db 100644 --- a/lib/philomena_web/templates/profile/show.html.slime +++ b/lib/philomena_web/templates/profile/show.html.slime @@ -116,7 +116,7 @@ .flex__grow.center => pretty_time(award.awarded_on) = if manages_awards?(@conn) do - = user_abbrv(@conn, award.awarded_by) + = user_abbrv(award.awarded_by) = if manages_awards?(@conn) do .flex__grow.center diff --git a/lib/philomena_web/views/admin/ban_view.ex b/lib/philomena_web/views/admin/ban_view.ex index 0df1e7305..59fbe1de1 100644 --- a/lib/philomena_web/views/admin/ban_view.ex +++ b/lib/philomena_web/views/admin/ban_view.ex @@ -1,8 +1,8 @@ defmodule PhilomenaWeb.Admin.BanView do alias PhilomenaWeb.ProfileView - def user_abbrv(conn, user), - do: ProfileView.user_abbrv(conn, user) + def user_abbrv(user), + do: ProfileView.user_abbrv(user) def ban_row_class(%{valid_until: until, enabled: enabled}) do now = DateTime.utc_now() diff --git a/lib/philomena_web/views/admin/report_view.ex b/lib/philomena_web/views/admin/report_view.ex index 56337cd27..7f81d93de 100644 --- a/lib/philomena_web/views/admin/report_view.ex +++ b/lib/philomena_web/views/admin/report_view.ex @@ -16,8 +16,8 @@ defmodule PhilomenaWeb.Admin.ReportView do defp pretty_state(report), do: ReportView.pretty_state(report) - defp user_abbrv(conn, user), - do: ProfileView.user_abbrv(conn, user) + defp user_abbrv(user), + do: ProfileView.user_abbrv(user) defp current?(current_user, user), do: ProfileView.current?(current_user, user) diff --git a/lib/philomena_web/views/conversation_view.ex b/lib/philomena_web/views/conversation_view.ex index c85902abc..97ce9c999 100644 --- a/lib/philomena_web/views/conversation_view.ex +++ b/lib/philomena_web/views/conversation_view.ex @@ -32,7 +32,7 @@ defmodule PhilomenaWeb.ConversationView do end end - def last_message_path(conn, conversation, count) do + def last_message_path(conversation, count) do page = trunc(Float.ceil(count / 25)) ~p"/conversations/#{conversation}?#{[page: page]}" diff --git a/lib/philomena_web/views/profile_view.ex b/lib/philomena_web/views/profile_view.ex index 2470d5cf9..916ba3344 100644 --- a/lib/philomena_web/views/profile_view.ex +++ b/lib/philomena_web/views/profile_view.ex @@ -77,7 +77,7 @@ defmodule PhilomenaWeb.ProfileView do def enabled_text(true), do: "Enabled" def enabled_text(_else), do: "Disabled" - def user_abbrv(conn, %{name: name} = user) do + def user_abbrv(%{name: name} = user) do abbrv = String.upcase(initials_abbrv(name) || uppercase_abbrv(name) || first_letters_abbrv(name)) @@ -86,7 +86,7 @@ defmodule PhilomenaWeb.ProfileView do link(abbrv, to: ~p"/profiles/#{user}") end - def user_abbrv(_conn, _user), do: content_tag(:span, "(n/a)") + def user_abbrv(_user), do: content_tag(:span, "(n/a)") defp initials_abbrv(name) do case String.split(name, " ", parts: 4) do From 9ba670c864e2959e5c256f7dbe01fd3b14ff725f Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 28 Apr 2024 21:13:51 -0400 Subject: [PATCH 10/12] truncated_ip_link --- .../templates/admin/approval/_approvals.html.slime | 2 +- lib/philomena_web/templates/admin/report/_reports.html.slime | 2 +- lib/philomena_web/views/admin/approval_view.ex | 3 +-- lib/philomena_web/views/admin/report_view.ex | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/philomena_web/templates/admin/approval/_approvals.html.slime b/lib/philomena_web/templates/admin/approval/_approvals.html.slime index f0448000b..d3d3f5fc1 100644 --- a/lib/philomena_web/templates/admin/approval/_approvals.html.slime +++ b/lib/philomena_web/templates/admin/approval/_approvals.html.slime @@ -21,7 +21,7 @@ = 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 diff --git a/lib/philomena_web/templates/admin/report/_reports.html.slime b/lib/philomena_web/templates/admin/report/_reports.html.slime index a423d1e7a..30b4ad36d 100644 --- a/lib/philomena_web/templates/admin/report/_reports.html.slime +++ b/lib/philomena_web/templates/admin/report/_reports.html.slime @@ -21,7 +21,7 @@ table.table = 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 diff --git a/lib/philomena_web/views/admin/approval_view.ex b/lib/philomena_web/views/admin/approval_view.ex index 03b0f3c2c..12d6284be 100644 --- a/lib/philomena_web/views/admin/approval_view.ex +++ b/lib/philomena_web/views/admin/approval_view.ex @@ -3,8 +3,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/report_view.ex b/lib/philomena_web/views/admin/report_view.ex index 7f81d93de..82de807dd 100644 --- a/lib/philomena_web/views/admin/report_view.ex +++ b/lib/philomena_web/views/admin/report_view.ex @@ -25,7 +25,7 @@ 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: ~p"/ip_profiles/#{ip}") From d9b3fe4fc8e6f350d8056d1b8f1eab71a874f404 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 28 Apr 2024 21:18:59 -0400 Subject: [PATCH 11/12] Remove old route helpers --- lib/philomena_web.ex | 2 -- lib/philomena_web/plugs/tor_plug.ex | 1 - lib/philomena_web/plugs/totp_plug.ex | 1 - lib/philomena_web/user_auth.ex | 1 - test/support/conn_case.ex | 1 - 5 files changed, 6 deletions(-) diff --git a/lib/philomena_web.ex b/lib/philomena_web.ex index f72344806..a4bccdf2e 100644 --- a/lib/philomena_web.ex +++ b/lib/philomena_web.ex @@ -27,7 +27,6 @@ defmodule PhilomenaWeb do import PhilomenaWeb.Gettext import Canary.Plugs import PhilomenaWeb.ModerationLogPlug, only: [moderation_log: 2] - alias PhilomenaWeb.Router.Helpers, as: Routes unquote(verified_routes()) end @@ -47,7 +46,6 @@ defmodule PhilomenaWeb do import PhilomenaWeb.ErrorHelpers import PhilomenaWeb.Gettext - alias PhilomenaWeb.Router.Helpers, as: Routes # Wrong way around for convenience import PhilomenaWeb.AppView diff --git a/lib/philomena_web/plugs/tor_plug.ex b/lib/philomena_web/plugs/tor_plug.ex index bea6b9d2b..57d5745ad 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 diff --git a/lib/philomena_web/plugs/totp_plug.ex b/lib/philomena_web/plugs/totp_plug.ex index 6b8091239..7f5e2d11b 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 diff --git a/lib/philomena_web/user_auth.ex b/lib/philomena_web/user_auth.ex index bf45d8b69..3665997cf 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 diff --git a/test/support/conn_case.ex b/test/support/conn_case.ex index 151ed056e..aa9df7513 100644 --- a/test/support/conn_case.ex +++ b/test/support/conn_case.ex @@ -21,7 +21,6 @@ defmodule PhilomenaWeb.ConnCase do import Plug.Conn import Phoenix.ConnTest import PhilomenaWeb.ConnCase - alias PhilomenaWeb.Router.Helpers, as: Routes # The default endpoint for testing @endpoint PhilomenaWeb.Endpoint From 9e79648e4450f2391b00fcc43fd75abf161ff4f3 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 28 Apr 2024 21:30:14 -0400 Subject: [PATCH 12/12] Remove converter --- lib/mix/tasks/convert_to_verified_routes.ex | 233 -------------------- 1 file changed, 233 deletions(-) delete mode 100644 lib/mix/tasks/convert_to_verified_routes.ex diff --git a/lib/mix/tasks/convert_to_verified_routes.ex b/lib/mix/tasks/convert_to_verified_routes.ex deleted file mode 100644 index ad643d2bf..000000000 --- a/lib/mix/tasks/convert_to_verified_routes.ex +++ /dev/null @@ -1,233 +0,0 @@ -defmodule Mix.Tasks.ConvertToVerifiedRoutes do - @moduledoc """ - Replaces routes with verified routes. - Forked from - https://gist.github.com/andreaseriksson/e454b9244a734310d4ab74d8595f98cd - https://gist.github.com/jiegillet/e6357c82e36a848ad59295eb3d5a1135 - - This requires all routes to consistently be aliased with - alias PhilomenaWeb.Router.Helpers, as: Routes - - Run with - mix convert_to_verified_routes - """ - - use Mix.Task - - @regex ~r/(Routes\.)([a-zA-Z0-9_]+)(path|url)\(/ - @web_module PhilomenaWeb - - def run(_) do - Path.wildcard("test/**/*.ex*") - |> Enum.concat(Path.wildcard("lib/**/*.ex*")) - |> Enum.concat(Path.wildcard("lib/**/*.eex*")) - |> Enum.concat(Path.wildcard("lib/**/*.slime")) - |> Enum.sort() - |> Enum.reject(&String.contains?(&1, "convert_to_verified_routes.ex")) - |> Enum.filter(&(&1 |> File.read!() |> String.contains?("Routes."))) - |> Enum.each(&format_file/1) - - :ok - end - - def format_file(filename) do - Mix.shell().info(filename) - - formatted_content = - filename - |> File.read!() - |> format_string() - - File.write!(filename, [formatted_content]) - end - - def format_string(source) do - case Regex.run(@regex, source, capture: :first, return: :index) do - [{index, length}] -> - # Compute full length of expression - length = nibble_expression(source, index, length) - - # Convert to verified route format - route = format_route(String.slice(source, index, length)) - - # Split string around expression - prefix = String.slice(source, 0, index) - suffix = String.slice(source, index + length, String.length(source)) - - # Insert verified route and rerun - format_string("#{prefix}#{route}#{suffix}") - - _ -> - source - end - end - - defp nibble_expression(source, index, length) do - if index + length > String.length(source) do - raise "Failed to match route expression" - end - - case Code.string_to_quoted(String.slice(source, index, length)) do - {:ok, _macro} -> - length - - _ -> - nibble_expression(source, index, length + 1) - end - end - - defp format_route(route) do - ast = - Code.string_to_quoted!(route, - literal_encoder: &{:ok, {:__block__, &2, [&1]}}, - unescape: false, - token_metadata: true - ) - - ast - |> Macro.prewalk(&replace_route/1) - |> Code.quoted_to_algebra(escape: false) - |> Inspect.Algebra.format(:infinity) - end - - defp decode_literal(literal) when is_binary(literal) or is_integer(literal) do - {:ok, literal} - end - - defp decode_literal({:__block__, _, [literal]}) do - {:ok, literal} - end - - defp decode_literal(node), do: {:error, node} - - defp encode_literal(literal) do - {:__block__, [], [literal]} - end - - # Routes.url(MyAppWeb.Endpoint) - defp replace_route({{:., _, [{:__aliases__, _, [:Routes]}, :url]}, _, [_conn_or_endpoint]}) do - {:url, [], [{:sigil_p, [delimiter: "\""], [{:<<>>, [], ["/"]}, []]}]} - end - - # Routes.static_path(conn, "/images/favicon.ico") - defp replace_route({{:., _, [{:__aliases__, _, [:Routes]}, :static_path]}, _, args}) do - [_conn_or_endpoint, path] = args - - case decode_literal(path) do - {:ok, path} -> {:sigil_p, [delimiter: "\""], [{:<<>>, [], [path]}, []]} - _ -> {:sigil_p, [delimiter: "\""], [path, []]} - end - end - - # Routes.static_url(conn, "/images/favicon.ico") - defp replace_route({{:., _, [{:__aliases__, _, [:Routes]}, :static_url]}, _, args}) do - [_conn_or_endpoint, path] = args - - sigil = - case decode_literal(path) do - {:ok, path} -> {:sigil_p, [delimiter: "\""], [{:<<>>, [], [path]}, []]} - _ -> {:sigil_p, [delimiter: "\""], [path, []]} - end - - {:url, [], [sigil]} - end - - # Routes.some_path(conn, :action, "en", query_params) - defp replace_route( - {{:., _, [{:__aliases__, _, [:Routes]}, path_name]}, _, [_ | _] = args} = node - ) do - [_conn_or_endpoint, action | params] = args - - action = - case decode_literal(action) do - {:ok, action} -> action - _ -> action - end - - path_name = "#{path_name}" - - case find_verified_route(path_name, action, params) do - :ok -> node - route -> route - end - end - - defp replace_route(node), do: node - - defp find_verified_route(path_name, action, arguments) do - # pleaaaase don't have a route named Routes.product_url_path(conn, :index) - trimmed_path = path_name |> String.trim_trailing("_path") |> String.trim_trailing("_url") - - route = - Phoenix.Router.routes(@web_module.Router) - |> Enum.find(fn %{helper: helper, plug_opts: plug_opts} -> - plug_opts == action && is_binary(helper) && trimmed_path == helper - end) - - case route do - %{path: path} -> - {path_bits, query_params} = - path - |> String.split("/", trim: true) - |> replace_path_variables(arguments, []) - - path_bits = - path_bits - |> Enum.flat_map(fn bit -> ["/", bit] end) - |> format_for_sigil_binary_args(query_params) - - sigil = {:sigil_p, [delimiter: "\""], [{:<<>>, [], path_bits}, []]} - - if String.ends_with?(path_name, "_url") do - {:url, [], [sigil]} - else - sigil - end - - _ -> - Mix.shell().error( - "Could not find route #{path_name}, with action #{inspect(action)} and arguments #{inspect(arguments)}" - ) - end - end - - defp replace_path_variables([], arguments, path_bits) do - {Enum.reverse(path_bits), arguments} - end - - defp replace_path_variables(path, [], path_bits) do - {Enum.reverse(path_bits) ++ path, []} - end - - # conceptually /post/:post_id -> /post/#{id} - defp replace_path_variables([path_piece | rest], [arg | args], path_bits) do - if String.starts_with?(path_piece, ":") do - replace_path_variables(rest, args, [arg | path_bits]) - else - replace_path_variables(rest, [arg | args], [path_piece | path_bits]) - end - end - - defp format_for_sigil_binary_args(path_bits, [_ | _] = query_params) do - format_for_sigil_binary_args(path_bits ++ ["?" | query_params], []) - end - - defp format_for_sigil_binary_args(path_bits, []) do - path_bits - |> Enum.map(&decode_literal/1) - |> Enum.map(fn - {:ok, bit} when is_binary(bit) -> - bit - - {:ok, bit} when is_atom(bit) or is_integer(bit) -> - to_string(bit) - - {_, bit} -> - {:"::", [], - [ - {{:., [], [Kernel, :to_string]}, [from_interpolation: true], [encode_literal(bit)]}, - {:binary, [], Elixir} - ]} - end) - end -end