logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git

static_fe_plug.ex (639B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.Plugs.StaticFEPlug do
  5. import Plug.Conn
  6. alias Pleroma.Web.StaticFE.StaticFEController
  7. def init(options), do: options
  8. def call(conn, _) do
  9. if enabled?() and requires_html?(conn) do
  10. conn
  11. |> StaticFEController.call(:show)
  12. |> halt()
  13. else
  14. conn
  15. end
  16. end
  17. defp enabled?, do: Pleroma.Config.get([:static_fe, :enabled], false)
  18. defp requires_html?(conn) do
  19. Phoenix.Controller.get_format(conn) == "html"
  20. end
  21. end