plug(:accepts, ["html", "json"])
end
+ pipeline :mailbox_preview do
+ plug(:accepts, ["html"])
+
+ plug(:put_secure_browser_headers, %{
+ "content-security-policy" =>
+ "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline' 'unsafe-eval'"
+ })
+ end
+
scope "/api/pleroma", Pleroma.Web.TwitterAPI do
pipe_through(:pleroma_api)
get("/password_reset/:token", UtilController, :show_password_reset)
get("/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation)
post("/account/register", TwitterAPI.Controller, :register)
+ post("/account/password_reset", TwitterAPI.Controller, :password_reset)
get("/search", TwitterAPI.Controller, :search)
get("/statusnet/tags/timeline/:tag", TwitterAPI.Controller, :public_and_external_timeline)
get("/:sig/:url/:filename", MediaProxyController, :remote)
end
+ if Mix.env() == :dev do
+ scope "/dev" do
+ pipe_through([:mailbox_preview])
+
+ forward("/mailbox", Plug.Swoosh.MailboxPreview, base_path: "/dev/mailbox")
+ end
+ end
+
scope "/", Fallback do
get("/registration/:token", RedirectController, :registration_page)
get("/*path", RedirectController, :redirector)
def redirector(conn, _params) do
conn
|> put_resp_content_type("text/html")
- |> send_file(200, Application.app_dir(:pleroma, "priv/static/index.html"))
+ |> send_file(200, index_file_path())
end
def redirector_with_meta(conn, params) do
- {:ok, index_content } = File.read(Application.app_dir(:pleroma, "priv/static/index.html"))
- tags = Metadata.build_tags(request_url(conn), params)
+ {:ok, index_content} = File.read(index_file_path())
+ tags = Metadata.build_tags(params)
response = String.replace(index_content, "<!--server-generated-meta-->", tags)
conn
|> send_resp(200, response)
end
+ def index_file_path do
+ Application.app_dir(:pleroma, "priv/static/index.html")
+ end
+
def registration_page(conn, params) do
redirector(conn, params)
end