forked from AkkomaGang/akkoma
Switch to aliasing Router.Helpers
instead of importing
This commit is contained in:
parent
b221d77a6d
commit
07fed0fda2
21 changed files with 33 additions and 31 deletions
|
@ -35,9 +35,10 @@ def controller do
|
||||||
import Plug.Conn
|
import Plug.Conn
|
||||||
|
|
||||||
import Pleroma.Web.Gettext
|
import Pleroma.Web.Gettext
|
||||||
import Pleroma.Web.Router.Helpers
|
|
||||||
import Pleroma.Web.TranslationHelpers
|
import Pleroma.Web.TranslationHelpers
|
||||||
|
|
||||||
|
alias Pleroma.Web.Router.Helpers, as: Routes
|
||||||
|
|
||||||
plug(:set_put_layout)
|
plug(:set_put_layout)
|
||||||
|
|
||||||
defp set_put_layout(conn, _) do
|
defp set_put_layout(conn, _) do
|
||||||
|
@ -131,7 +132,8 @@ def view do
|
||||||
|
|
||||||
import Pleroma.Web.ErrorHelpers
|
import Pleroma.Web.ErrorHelpers
|
||||||
import Pleroma.Web.Gettext
|
import Pleroma.Web.Gettext
|
||||||
import Pleroma.Web.Router.Helpers
|
|
||||||
|
alias Pleroma.Web.Router.Helpers, as: Routes
|
||||||
|
|
||||||
require Logger
|
require Logger
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ def feed_redirect(%{assigns: %{format: format}} = conn, _params)
|
||||||
|
|
||||||
def feed_redirect(conn, %{"nickname" => nickname}) do
|
def feed_redirect(conn, %{"nickname" => nickname}) do
|
||||||
with {_, %User{} = user} <- {:fetch_user, User.get_cached_by_nickname(nickname)} do
|
with {_, %User{} = user} <- {:fetch_user, User.get_cached_by_nickname(nickname)} do
|
||||||
redirect(conn, external: "#{user_feed_url(conn, :feed, user.nickname)}.atom")
|
redirect(conn, external: "#{Routes.user_feed_url(conn, :feed, user.nickname)}.atom")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ def login(conn, params) do
|
||||||
defp redirect_to_oauth_form(conn, _params) do
|
defp redirect_to_oauth_form(conn, _params) do
|
||||||
with {:ok, app} <- local_mastofe_app() do
|
with {:ok, app} <- local_mastofe_app() do
|
||||||
path =
|
path =
|
||||||
o_auth_path(conn, :authorize,
|
Routes.o_auth_path(conn, :authorize,
|
||||||
response_type: "code",
|
response_type: "code",
|
||||||
client_id: app.client_id,
|
client_id: app.client_id,
|
||||||
redirect_uri: ".",
|
redirect_uri: ".",
|
||||||
|
@ -90,7 +90,7 @@ def password_reset(conn, params) do
|
||||||
defp local_mastodon_post_login_path(conn) do
|
defp local_mastodon_post_login_path(conn) do
|
||||||
case get_session(conn, :return_to) do
|
case get_session(conn, :return_to) do
|
||||||
nil ->
|
nil ->
|
||||||
masto_fe_path(conn, :index, ["getting-started"])
|
Routes.masto_fe_path(conn, :index, ["getting-started"])
|
||||||
|
|
||||||
return_to ->
|
return_to ->
|
||||||
delete_session(conn, :return_to)
|
delete_session(conn, :return_to)
|
||||||
|
|
|
@ -427,7 +427,7 @@ def prepare_request(%Plug.Conn{} = conn, %{
|
||||||
|> Map.put("state", state)
|
|> Map.put("state", state)
|
||||||
|
|
||||||
# Handing the request to Ueberauth
|
# Handing the request to Ueberauth
|
||||||
redirect(conn, to: o_auth_path(conn, :request, provider, params))
|
redirect(conn, to: Routes.o_auth_path(conn, :request, provider, params))
|
||||||
end
|
end
|
||||||
|
|
||||||
def request(%Plug.Conn{} = conn, params) do
|
def request(%Plug.Conn{} = conn, params) do
|
||||||
|
@ -601,7 +601,7 @@ def login(%User{} = user, %App{} = app, requested_scopes) when is_list(requested
|
||||||
end
|
end
|
||||||
|
|
||||||
# Special case: Local MastodonFE
|
# Special case: Local MastodonFE
|
||||||
defp redirect_uri(%Plug.Conn{} = conn, "."), do: auth_url(conn, :login)
|
defp redirect_uri(%Plug.Conn{} = conn, "."), do: Routes.auth_url(conn, :login)
|
||||||
|
|
||||||
defp redirect_uri(%Plug.Conn{}, redirect_uri), do: redirect_uri
|
defp redirect_uri(%Plug.Conn{}, redirect_uri), do: redirect_uri
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,13 @@
|
||||||
xmlns:ostatus="http://ostatus.org/schema/1.0"
|
xmlns:ostatus="http://ostatus.org/schema/1.0"
|
||||||
xmlns:statusnet="http://status.net/schema/api/1/">
|
xmlns:statusnet="http://status.net/schema/api/1/">
|
||||||
|
|
||||||
<id><%= '#{tag_feed_url(@conn, :feed, @tag)}.rss' %></id>
|
<id><%= '#{Routes.tag_feed_url(@conn, :feed, @tag)}.rss' %></id>
|
||||||
<title>#<%= @tag %></title>
|
<title>#<%= @tag %></title>
|
||||||
|
|
||||||
<subtitle>These are public toots tagged with #<%= @tag %>. You can interact with them if you have an account anywhere in the fediverse.</subtitle>
|
<subtitle>These are public toots tagged with #<%= @tag %>. You can interact with them if you have an account anywhere in the fediverse.</subtitle>
|
||||||
<logo><%= feed_logo() %></logo>
|
<logo><%= feed_logo() %></logo>
|
||||||
<updated><%= most_recent_update(@activities) %></updated>
|
<updated><%= most_recent_update(@activities) %></updated>
|
||||||
<link rel="self" href="<%= '#{tag_feed_url(@conn, :feed, @tag)}.atom' %>" type="application/atom+xml"/>
|
<link rel="self" href="<%= '#{Routes.tag_feed_url(@conn, :feed, @tag)}.atom' %>" type="application/atom+xml"/>
|
||||||
<%= for activity <- @activities do %>
|
<%= for activity <- @activities do %>
|
||||||
<%= render @view_module, "_tag_activity.atom", Map.merge(assigns, prepare_activity(activity, actor: true)) %>
|
<%= render @view_module, "_tag_activity.atom", Map.merge(assigns, prepare_activity(activity, actor: true)) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<title>#<%= @tag %></title>
|
<title>#<%= @tag %></title>
|
||||||
<description>These are public toots tagged with #<%= @tag %>. You can interact with them if you have an account anywhere in the fediverse.</description>
|
<description>These are public toots tagged with #<%= @tag %>. You can interact with them if you have an account anywhere in the fediverse.</description>
|
||||||
<link><%= '#{tag_feed_url(@conn, :feed, @tag)}.rss' %></link>
|
<link><%= '#{Routes.tag_feed_url(@conn, :feed, @tag)}.rss' %></link>
|
||||||
<webfeeds:logo><%= feed_logo() %></webfeeds:logo>
|
<webfeeds:logo><%= feed_logo() %></webfeeds:logo>
|
||||||
<webfeeds:accentColor>2b90d9</webfeeds:accentColor>
|
<webfeeds:accentColor>2b90d9</webfeeds:accentColor>
|
||||||
<%= for activity <- @activities do %>
|
<%= for activity <- @activities do %>
|
||||||
|
|
|
@ -6,16 +6,16 @@
|
||||||
xmlns:poco="http://portablecontacts.net/spec/1.0"
|
xmlns:poco="http://portablecontacts.net/spec/1.0"
|
||||||
xmlns:ostatus="http://ostatus.org/schema/1.0">
|
xmlns:ostatus="http://ostatus.org/schema/1.0">
|
||||||
|
|
||||||
<id><%= user_feed_url(@conn, :feed, @user.nickname) <> ".atom" %></id>
|
<id><%= Routes.user_feed_url(@conn, :feed, @user.nickname) <> ".atom" %></id>
|
||||||
<title><%= @user.nickname <> "'s timeline" %></title>
|
<title><%= @user.nickname <> "'s timeline" %></title>
|
||||||
<updated><%= most_recent_update(@activities, @user) %></updated>
|
<updated><%= most_recent_update(@activities, @user) %></updated>
|
||||||
<logo><%= logo(@user) %></logo>
|
<logo><%= logo(@user) %></logo>
|
||||||
<link rel="self" href="<%= '#{user_feed_url(@conn, :feed, @user.nickname)}.atom' %>" type="application/atom+xml"/>
|
<link rel="self" href="<%= '#{Routes.user_feed_url(@conn, :feed, @user.nickname)}.atom' %>" type="application/atom+xml"/>
|
||||||
|
|
||||||
<%= render @view_module, "_author.atom", assigns %>
|
<%= render @view_module, "_author.atom", assigns %>
|
||||||
|
|
||||||
<%= if last_activity(@activities) do %>
|
<%= if last_activity(@activities) do %>
|
||||||
<link rel="next" href="<%= '#{user_feed_url(@conn, :feed, @user.nickname)}.atom?max_id=#{last_activity(@activities).id}' %>" type="application/atom+xml"/>
|
<link rel="next" href="<%= '#{Routes.user_feed_url(@conn, :feed, @user.nickname)}.atom?max_id=#{last_activity(@activities).id}' %>" type="application/atom+xml"/>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= for activity <- @activities do %>
|
<%= for activity <- @activities do %>
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<rss version="2.0">
|
<rss version="2.0">
|
||||||
<channel>
|
<channel>
|
||||||
<guid><%= user_feed_url(@conn, :feed, @user.nickname) <> ".rss" %></guid>
|
<guid><%= Routes.user_feed_url(@conn, :feed, @user.nickname) <> ".rss" %></guid>
|
||||||
<title><%= @user.nickname <> "'s timeline" %></title>
|
<title><%= @user.nickname <> "'s timeline" %></title>
|
||||||
<updated><%= most_recent_update(@activities, @user) %></updated>
|
<updated><%= most_recent_update(@activities, @user) %></updated>
|
||||||
<image><%= logo(@user) %></image>
|
<image><%= logo(@user) %></image>
|
||||||
<link><%= '#{user_feed_url(@conn, :feed, @user.nickname)}.rss' %></link>
|
<link><%= '#{Routes.user_feed_url(@conn, :feed, @user.nickname)}.rss' %></link>
|
||||||
|
|
||||||
<%= render @view_module, "_author.rss", assigns %>
|
<%= render @view_module, "_author.rss", assigns %>
|
||||||
|
|
||||||
<%= if last_activity(@activities) do %>
|
<%= if last_activity(@activities) do %>
|
||||||
<link rel="next"><%= '#{user_feed_url(@conn, :feed, @user.nickname)}.rss?max_id=#{last_activity(@activities).id}' %></link>
|
<link rel="next"><%= '#{Routes.user_feed_url(@conn, :feed, @user.nickname)}.rss?max_id=#{last_activity(@activities).id}' %></link>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= for activity <- @activities do %>
|
<%= for activity <- @activities do %>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<%= Config.get([:instance, :name]) %>
|
<%= Config.get([:instance, :name]) %>
|
||||||
</title>
|
</title>
|
||||||
<link rel="icon" type="image/png" href="/favicon.png"/>
|
<link rel="icon" type="image/png" href="/favicon.png"/>
|
||||||
<link rel="manifest" type="applicaton/manifest+json" href="<%= masto_fe_path(Pleroma.Web.Endpoint, :manifest) %>" />
|
<link rel="manifest" type="applicaton/manifest+json" href="<%= Routes.masto_fe_path(Pleroma.Web.Endpoint, :manifest) %>" />
|
||||||
|
|
||||||
<meta name="theme-color" content="<%= Config.get([:manifest, :theme_color]) %>" />
|
<meta name="theme-color" content="<%= Config.get([:manifest, :theme_color]) %>" />
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<h2>Two-factor recovery</h2>
|
<h2>Two-factor recovery</h2>
|
||||||
|
|
||||||
<%= form_for @conn, mfa_verify_path(@conn, :verify), [as: "mfa"], fn f -> %>
|
<%= form_for @conn, Routes.mfa_verify_path(@conn, :verify), [as: "mfa"], fn f -> %>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<%= label f, :code, "Recovery code" %>
|
<%= label f, :code, "Recovery code" %>
|
||||||
<%= text_input f, :code, [autocomplete: false, autocorrect: "off", autocapitalize: "off", autofocus: true, spellcheck: false] %>
|
<%= text_input f, :code, [autocomplete: false, autocorrect: "off", autocapitalize: "off", autofocus: true, spellcheck: false] %>
|
||||||
|
@ -19,6 +19,6 @@
|
||||||
|
|
||||||
<%= submit "Verify" %>
|
<%= submit "Verify" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<a href="<%= mfa_path(@conn, :show, %{challenge_type: "totp", mfa_token: @mfa_token, state: @state, redirect_uri: @redirect_uri}) %>">
|
<a href="<%= Routes.mfa_path(@conn, :show, %{challenge_type: "totp", mfa_token: @mfa_token, state: @state, redirect_uri: @redirect_uri}) %>">
|
||||||
Enter a two-factor code
|
Enter a two-factor code
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<h2>Two-factor authentication</h2>
|
<h2>Two-factor authentication</h2>
|
||||||
|
|
||||||
<%= form_for @conn, mfa_verify_path(@conn, :verify), [as: "mfa"], fn f -> %>
|
<%= form_for @conn, Routes.mfa_verify_path(@conn, :verify), [as: "mfa"], fn f -> %>
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<%= label f, :code, "Authentication code" %>
|
<%= label f, :code, "Authentication code" %>
|
||||||
<%= text_input f, :code, [autocomplete: false, autocorrect: "off", autocapitalize: "off", autofocus: true, pattern: "[0-9]*", spellcheck: false] %>
|
<%= text_input f, :code, [autocomplete: false, autocorrect: "off", autocapitalize: "off", autofocus: true, pattern: "[0-9]*", spellcheck: false] %>
|
||||||
|
@ -19,6 +19,6 @@
|
||||||
|
|
||||||
<%= submit "Verify" %>
|
<%= submit "Verify" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<a href="<%= mfa_path(@conn, :show, %{challenge_type: "recovery", mfa_token: @mfa_token, state: @state, redirect_uri: @redirect_uri}) %>">
|
<a href="<%= Routes.mfa_path(@conn, :show, %{challenge_type: "recovery", mfa_token: @mfa_token, state: @state, redirect_uri: @redirect_uri}) %>">
|
||||||
Enter a two-factor recovery code
|
Enter a two-factor recovery code
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<h2>Sign in with external provider</h2>
|
<h2>Sign in with external provider</h2>
|
||||||
|
|
||||||
<%= form_for @conn, o_auth_path(@conn, :prepare_request), [as: "authorization", method: "get"], fn f -> %>
|
<%= form_for @conn, Routes.o_auth_path(@conn, :prepare_request), [as: "authorization", method: "get"], fn f -> %>
|
||||||
<div style="display: none">
|
<div style="display: none">
|
||||||
<%= render @view_module, "_scopes.html", Map.merge(assigns, %{form: f}) %>
|
<%= render @view_module, "_scopes.html", Map.merge(assigns, %{form: f}) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<h2>Registration Details</h2>
|
<h2>Registration Details</h2>
|
||||||
|
|
||||||
<p>If you'd like to register a new account, please provide the details below.</p>
|
<p>If you'd like to register a new account, please provide the details below.</p>
|
||||||
<%= form_for @conn, o_auth_path(@conn, :register), [as: "authorization"], fn f -> %>
|
<%= form_for @conn, Routes.o_auth_path(@conn, :register), [as: "authorization"], fn f -> %>
|
||||||
|
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<%= label f, :nickname, "Nickname" %>
|
<%= label f, :nickname, "Nickname" %>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
|
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= form_for @conn, o_auth_path(@conn, :authorize), [as: "authorization"], fn f -> %>
|
<%= form_for @conn, Routes.o_auth_path(@conn, :authorize), [as: "authorization"], fn f -> %>
|
||||||
|
|
||||||
<%= if @user do %>
|
<%= if @user do %>
|
||||||
<div class="account-header">
|
<div class="account-header">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<h2>Password Reset for <%= @user.nickname %></h2>
|
<h2>Password Reset for <%= @user.nickname %></h2>
|
||||||
<%= form_for @conn, reset_password_path(@conn, :do_reset), [as: "data"], fn f -> %>
|
<%= form_for @conn, Routes.reset_password_path(@conn, :do_reset), [as: "data"], fn f -> %>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<%= label f, :password, "Password" %>
|
<%= label f, :password, "Password" %>
|
||||||
<%= password_input f, :password %>
|
<%= password_input f, :password %>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<h2>Remote follow</h2>
|
<h2>Remote follow</h2>
|
||||||
<img height="128" width="128" src="<%= avatar_url(@followee) %>">
|
<img height="128" width="128" src="<%= avatar_url(@followee) %>">
|
||||||
<p><%= @followee.nickname %></p>
|
<p><%= @followee.nickname %></p>
|
||||||
<%= form_for @conn, remote_follow_path(@conn, :do_follow), [as: "user"], fn f -> %>
|
<%= form_for @conn, Routes.remote_follow_path(@conn, :do_follow), [as: "user"], fn f -> %>
|
||||||
<%= hidden_input f, :id, value: @followee.id %>
|
<%= hidden_input f, :id, value: @followee.id %>
|
||||||
<%= submit "Authorize" %>
|
<%= submit "Authorize" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<h2>Log in to follow</h2>
|
<h2>Log in to follow</h2>
|
||||||
<p><%= @followee.nickname %></p>
|
<p><%= @followee.nickname %></p>
|
||||||
<img height="128" width="128" src="<%= avatar_url(@followee) %>">
|
<img height="128" width="128" src="<%= avatar_url(@followee) %>">
|
||||||
<%= form_for @conn, remote_follow_path(@conn, :do_follow), [as: "authorization"], fn f -> %>
|
<%= form_for @conn, Routes.remote_follow_path(@conn, :do_follow), [as: "authorization"], fn f -> %>
|
||||||
<%= text_input f, :name, placeholder: "Username", required: true %>
|
<%= text_input f, :name, placeholder: "Username", required: true %>
|
||||||
<br>
|
<br>
|
||||||
<%= password_input f, :password, placeholder: "Password", required: true %>
|
<%= password_input f, :password, placeholder: "Password", required: true %>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<h2>Two-factor authentication</h2>
|
<h2>Two-factor authentication</h2>
|
||||||
<p><%= @followee.nickname %></p>
|
<p><%= @followee.nickname %></p>
|
||||||
<img height="128" width="128" src="<%= avatar_url(@followee) %>">
|
<img height="128" width="128" src="<%= avatar_url(@followee) %>">
|
||||||
<%= form_for @conn, remote_follow_path(@conn, :do_follow), [as: "mfa"], fn f -> %>
|
<%= form_for @conn, Routes.remote_follow_path(@conn, :do_follow), [as: "mfa"], fn f -> %>
|
||||||
<%= text_input f, :code, placeholder: "Authentication code", required: true %>
|
<%= text_input f, :code, placeholder: "Authentication code", required: true %>
|
||||||
<br>
|
<br>
|
||||||
<%= hidden_input f, :id, value: @followee.id %>
|
<%= hidden_input f, :id, value: @followee.id %>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<h2>Error: <%= @error %></h2>
|
<h2>Error: <%= @error %></h2>
|
||||||
<% else %>
|
<% else %>
|
||||||
<h2>Remotely follow <%= @nickname %></h2>
|
<h2>Remotely follow <%= @nickname %></h2>
|
||||||
<%= form_for @conn, util_path(@conn, :remote_subscribe), [as: "user"], fn f -> %>
|
<%= form_for @conn, Routes.util_path(@conn, :remote_subscribe), [as: "user"], fn f -> %>
|
||||||
<%= hidden_input f, :nickname, value: @nickname %>
|
<%= hidden_input f, :nickname, value: @nickname %>
|
||||||
<%= text_input f, :profile, placeholder: "Your account ID, e.g. lain@quitter.se" %>
|
<%= text_input f, :profile, placeholder: "Your account ID, e.g. lain@quitter.se" %>
|
||||||
<%= submit "Follow" %>
|
<%= submit "Follow" %>
|
||||||
|
|
|
@ -38,7 +38,7 @@ def follow(%{assigns: %{user: user}} = conn, %{"acct" => acct}) do
|
||||||
defp follow_status(conn, _user, acct) do
|
defp follow_status(conn, _user, acct) do
|
||||||
with {:ok, object} <- Fetcher.fetch_object_from_id(acct),
|
with {:ok, object} <- Fetcher.fetch_object_from_id(acct),
|
||||||
%Activity{id: activity_id} <- Activity.get_create_by_object_ap_id(object.data["id"]) do
|
%Activity{id: activity_id} <- Activity.get_create_by_object_ap_id(object.data["id"]) do
|
||||||
redirect(conn, to: o_status_path(conn, :notice, activity_id))
|
redirect(conn, to: Routes.o_status_path(conn, :notice, activity_id))
|
||||||
else
|
else
|
||||||
error ->
|
error ->
|
||||||
handle_follow_error(conn, error)
|
handle_follow_error(conn, error)
|
||||||
|
|
|
@ -79,7 +79,7 @@ def render("manifest.json", _params) do
|
||||||
background_color: Config.get([:manifest, :background_color]),
|
background_color: Config.get([:manifest, :background_color]),
|
||||||
display: "standalone",
|
display: "standalone",
|
||||||
scope: Pleroma.Web.base_url(),
|
scope: Pleroma.Web.base_url(),
|
||||||
start_url: masto_fe_path(Pleroma.Web.Endpoint, :index, ["getting-started"]),
|
start_url: Routes.masto_fe_path(Pleroma.Web.Endpoint, :index, ["getting-started"]),
|
||||||
categories: [
|
categories: [
|
||||||
"social"
|
"social"
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue