diff --git a/lib/clacks_web/controllers/frontend_controller.ex b/lib/clacks_web/controllers/frontend_controller.ex index 2a9bd68..3f373ed 100644 --- a/lib/clacks_web/controllers/frontend_controller.ex +++ b/lib/clacks_web/controllers/frontend_controller.ex @@ -119,7 +119,7 @@ defmodule ClacksWeb.FrontendController do case User.get_by_username(username) do nil -> - put_status(conn, 404) + resp(conn, 404, "Not Found") user -> user = Repo.preload(user, :actor) @@ -132,6 +132,22 @@ defmodule ClacksWeb.FrontendController do end end + def actor(conn, %{"id" => id} = params) do + current_user = conn.assigns[:user] |> Repo.preload(:actor) + + case Repo.get(Actor, id) do + nil -> + resp(conn, 404, "Not Found") + + actor -> + render(conn, "profile.html", %{ + current_user: current_user, + actor: actor, + statuses: actor_statuses(actor, params, only_public: true) + }) + end + end + def search(conn, %{"q" => q}) when is_binary(q) do current_user = conn.assigns[:user] diff --git a/lib/clacks_web/router.ex b/lib/clacks_web/router.ex index bcdf092..4dc04ac 100644 --- a/lib/clacks_web/router.ex +++ b/lib/clacks_web/router.ex @@ -60,6 +60,7 @@ defmodule ClacksWeb.Router do post "/post", FrontendController, :post_status get "/status/:id/reply", FrontendController, :reply get "/search", FrontendController, :search + get "/actors/:id", FrontendController, :actor end scope "/", ClacksWeb do diff --git a/lib/clacks_web/templates/frontend/_status.html.eex b/lib/clacks_web/templates/frontend/_status.html.eex index de1d726..20886b3 100644 --- a/lib/clacks_web/templates/frontend/_status.html.eex +++ b/lib/clacks_web/templates/frontend/_status.html.eex @@ -1,7 +1,7 @@