add selection UI
[akkoma] / lib / pleroma / web / akkoma_api / controllers / frontend_switcher.ex
1 defmodule Pleroma.Web.AkkomaAPI.FrontendSwitcherController do
2 use Pleroma.Web, :controller
3 alias Pleroma.Config
4
5 @doc "GET /akkoma/frontend"
6 def switch(conn, _params) do
7 pickable = Config.get([:frontends, :pickable], [])
8
9 conn
10 |> put_view(Pleroma.Web.AkkomaAPI.FrontendSwitcherView)
11 |> render("switch.html", choices: pickable)
12 end
13
14 @doc "POST /akkoma/frontend"
15 def do_switch(conn, params) do
16 conn
17 |> put_resp_cookie("preferred_frontend", params["frontend"])
18 |> html("<meta http-equiv=\"refresh\" content=\"0; url=/\">")
19 end
20 end