mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
Merge branch 'master' into searchbox-ac
# Conflicts: # lib/philomena_web/templates/layout/_header.html.slime
This commit is contained in:
commit
f84e358eec
349 changed files with 1207 additions and 1187 deletions
10
assets/static/opensearch.xml
Normal file
10
assets/static/opensearch.xml
Normal file
|
@ -0,0 +1,10 @@
|
|||
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
|
||||
<ShortName>Derpibooru</ShortName>
|
||||
<Description>Derpibooru image search</Description>
|
||||
<InputEncoding>UTF-8</InputEncoding>
|
||||
<Image width="16" height="16" type="image/x-icon">https://derpibooru.org/favicon.ico</Image>
|
||||
<Image width="64" height="64" type="image/svg+xml">https://derpibooru.org/favicon.svg</Image>
|
||||
<Url type="text/html" method="get" template="https://derpibooru.org/search">
|
||||
<Param name="q" value="{searchTerms}"/>
|
||||
</Url>
|
||||
</OpenSearchDescription>
|
|
@ -2,6 +2,8 @@ defmodule Philomena.Autocomplete.Autocomplete do
|
|||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
|
||||
@type t :: %__MODULE__{}
|
||||
|
||||
@primary_key false
|
||||
schema "autocomplete" do
|
||||
field :content, :binary
|
||||
|
|
|
@ -57,7 +57,7 @@ defmodule Philomena.Conversations.Conversation do
|
|||
|> put_recipient()
|
||||
|> set_slug()
|
||||
|> set_last_message()
|
||||
|> cast_assoc(:messages, with: {Message, :creation_changeset, [from]})
|
||||
|> cast_assoc(:messages, with: &Message.creation_changeset(&1, &2, from))
|
||||
|> validate_length(:messages, is: 1)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,11 +1,27 @@
|
|||
defmodule Philomena.Sha512 do
|
||||
@spec file(String.t()) :: String.t()
|
||||
def file(file) do
|
||||
@chunk_size 10_485_760
|
||||
|
||||
@spec file(Path.t()) :: String.t()
|
||||
def file(path) do
|
||||
hash_ref = :crypto.hash_init(:sha512)
|
||||
|
||||
File.stream!(file, [], 10_485_760)
|
||||
path
|
||||
|> stream_file()
|
||||
|> Enum.reduce(hash_ref, &:crypto.hash_update(&2, &1))
|
||||
|> :crypto.hash_final()
|
||||
|> Base.encode16(case: :lower)
|
||||
end
|
||||
|
||||
if Version.match?(System.version(), ">= 1.16.0") do
|
||||
# `stream!/2` was added in Elixir 1.16 to accept a shortened form,
|
||||
# where we only need to specify the size of each stream chunk
|
||||
defp stream_file(file) do
|
||||
File.stream!(file, @chunk_size)
|
||||
end
|
||||
else
|
||||
# Use legacy stream/3 for older Elixir versions
|
||||
defp stream_file(file) do
|
||||
File.stream!(file, [], @chunk_size)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -59,7 +59,7 @@ defmodule Philomena.Topics.Topic do
|
|||
|> change(forum: forum, user: attribution[:user])
|
||||
|> validate_required(:forum)
|
||||
|> cast_assoc(:poll, with: &Poll.update_changeset/2)
|
||||
|> cast_assoc(:posts, with: {Post, :topic_creation_changeset, [attribution, anonymous?]})
|
||||
|> cast_assoc(:posts, with: &Post.topic_creation_changeset(&1, &2, attribution, anonymous?))
|
||||
|> validate_length(:posts, is: 1)
|
||||
|> unique_constraint(:slug, name: :index_topics_on_forum_id_and_slug)
|
||||
end
|
||||
|
|
|
@ -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: ...}}
|
||||
|
||||
"""
|
||||
|
|
|
@ -17,6 +17,8 @@ defmodule PhilomenaWeb do
|
|||
and import those modules here.
|
||||
"""
|
||||
|
||||
def static_paths, do: ~w(assets favicon.ico favicon.svg robots.txt opensearch.xml)
|
||||
|
||||
def controller do
|
||||
quote do
|
||||
use Phoenix.Controller, namespace: PhilomenaWeb
|
||||
|
@ -25,7 +27,8 @@ 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
|
||||
end
|
||||
|
||||
|
@ -43,10 +46,11 @@ defmodule PhilomenaWeb do
|
|||
|
||||
import PhilomenaWeb.ErrorHelpers
|
||||
import PhilomenaWeb.Gettext
|
||||
alias PhilomenaWeb.Router.Helpers, as: Routes
|
||||
|
||||
# Wrong way around for convenience
|
||||
import PhilomenaWeb.AppView
|
||||
|
||||
unquote(verified_routes())
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -65,6 +69,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.
|
||||
"""
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
defmodule PhilomenaWeb.Config do
|
||||
# Dialyzer only analyzes beam files directly and cannot see the compile-time variance in
|
||||
# the associated values, so it flags a false positive here.
|
||||
@dialyzer [:no_match]
|
||||
|
||||
@reload_enabled Application.compile_env(:philomena, :vite_reload, false)
|
||||
@csp_relaxed Application.compile_env(:philomena, :csp_relaxed, false)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
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
|
||||
|
|
|
@ -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
|
||||
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
|
||||
|
|
|
@ -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
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -17,7 +17,7 @@ defmodule PhilomenaWeb.Admin.Batch.TagController do
|
|||
removed_tag_names =
|
||||
tags
|
||||
|> Enum.filter(&String.starts_with?(&1, "-"))
|
||||
|> Enum.map(&String.slice(&1, 1..-1))
|
||||
|> Enum.map(&String.replace_leading(&1, "-", ""))
|
||||
|
||||
added_tags =
|
||||
Tag
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
@ -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}"
|
||||
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -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}"
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -32,13 +32,13 @@ 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}"
|
||||
: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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -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}"
|
||||
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
@ -81,10 +81,10 @@ defmodule PhilomenaWeb.Admin.UserController do
|
|||
assign(conn, :roles, Repo.all(Role))
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, user) do
|
||||
defp log_details(_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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -21,20 +21,20 @@ 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
|
||||
|
||||
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}",
|
||||
subject_path: Routes.image_path(conn, :show, report.image)
|
||||
subject_path: ~p"/images/#{report.image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,20 +21,20 @@ 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
|
||||
|
||||
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}",
|
||||
subject_path: Routes.image_path(conn, :show, report.image)
|
||||
subject_path: ~p"/images/#{report.image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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,10 +30,10 @@ 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
|
||||
defp log_details(_conn, action, _) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Claimed a duplicate report"
|
||||
|
@ -42,7 +42,7 @@ defmodule PhilomenaWeb.DuplicateReport.ClaimController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.duplicate_report_path(conn, :index)
|
||||
subject_path: ~p"/duplicate_reports"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -33,10 +33,10 @@ 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: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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)}
|
||||
defp log_details(_conn, _action, image) do
|
||||
%{body: "Approved image #{image.id}", subject_path: ~p"/images/#{image}"}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
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
|
||||
|
|
|
@ -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
|
||||
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
|
||||
|
|
|
@ -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,20 +33,16 @@ 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
|
||||
|
||||
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})"
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,10 +22,10 @@ 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
|
||||
defp log_details(_conn, action, image) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Locked comments on image >>#{image.id}"
|
||||
|
@ -34,7 +34,7 @@ defmodule PhilomenaWeb.Image.CommentLockController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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,10 +67,10 @@ 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
|
||||
defp log_details(_conn, action, image) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Hidden image >>#{image.id} (#{image.deletion_reason})"
|
||||
|
@ -80,7 +80,7 @@ defmodule PhilomenaWeb.Image.DeleteController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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,10 +22,10 @@ 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
|
||||
defp log_details(_conn, action, image) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Locked description editing on image >>#{image.id}"
|
||||
|
@ -34,7 +34,7 @@ defmodule PhilomenaWeb.Image.DescriptionLockController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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,15 +33,15 @@ defmodule PhilomenaWeb.Image.DestroyController do
|
|||
_false ->
|
||||
conn
|
||||
|> put_flash(:error, "Cannot destroy a non-hidden image!")
|
||||
|> redirect(to: Routes.image_path(conn, :show, conn.assigns.image))
|
||||
|> redirect(to: ~p"/images/#{conn.assigns.image}")
|
||||
|> halt()
|
||||
end
|
||||
end
|
||||
|
||||
defp log_details(conn, _action, image) do
|
||||
defp log_details(_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
|
||||
|
|
|
@ -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 ->
|
||||
|
@ -33,10 +33,10 @@ 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: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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 ->
|
||||
|
|
|
@ -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
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
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
|
||||
|
|
|
@ -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
|
||||
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
|
||||
|
|
|
@ -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"}),
|
||||
|
@ -58,10 +58,10 @@ defmodule PhilomenaWeb.Image.TagChangeController do
|
|||
defp added_filter(query, _params),
|
||||
do: query
|
||||
|
||||
defp log_details(conn, _action, %{image: image, details: details}) do
|
||||
defp log_details(_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
|
||||
|
||||
|
|
|
@ -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,10 +42,10 @@ 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
|
||||
defp log_details(_conn, action, image) do
|
||||
body =
|
||||
case action do
|
||||
:create -> "Locked tags on image >>#{image.id}"
|
||||
|
@ -55,7 +55,7 @@ defmodule PhilomenaWeb.Image.TagLockController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.image_path(conn, :show, image)
|
||||
subject_path: ~p"/images/#{image}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 ->
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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: Routes.report_path(conn, :index)
|
||||
defp redirect_path(nil), do: "/"
|
||||
defp redirect_path(_user), do: ~p"/reports"
|
||||
|
||||
defp max_reports do
|
||||
5
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,10 +37,10 @@ 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
|
||||
defp log_details(_conn, action, tag) do
|
||||
body =
|
||||
case action do
|
||||
:update -> "Updated image on tag '#{tag.name}'"
|
||||
|
@ -49,7 +49,7 @@ defmodule PhilomenaWeb.Tag.ImageController do
|
|||
|
||||
%{
|
||||
body: body,
|
||||
subject_path: Routes.tag_path(conn, :show, tag)
|
||||
subject_path: ~p"/tags/#{tag}"
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue