2019-11-02 02:47:18 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Plugs.StaticFEPlug do
|
|
|
|
def init(options), do: options
|
|
|
|
|
2019-11-03 20:29:17 +00:00
|
|
|
def accepts_html?({"accept", a}), do: String.contains?(a, "text/html")
|
|
|
|
def accepts_html?({_, _}), do: false
|
|
|
|
|
2019-11-02 02:47:18 +00:00
|
|
|
def call(conn, _) do
|
2019-11-03 20:29:17 +00:00
|
|
|
with true <- Pleroma.Config.get([:instance, :static_fe], false),
|
|
|
|
{_, _} <- Enum.find(conn.req_headers, &accepts_html?/1) do
|
|
|
|
Pleroma.Web.StaticFE.StaticFEController.call(conn, :show)
|
|
|
|
else
|
2019-11-02 02:47:18 +00:00
|
|
|
_ -> conn
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|