aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/plugs/frontend_static.ex
diff options
context:
space:
mode:
authorAlex Gleason <alex@alexgleason.me>2022-01-03 13:40:19 -0600
committerAlex Gleason <alex@alexgleason.me>2022-01-03 13:40:19 -0600
commit4081be0001332bac402faec7565807df088b0117 (patch)
treea5305404e9bb31b3613dbc9631d36f8827be81c2 /lib/pleroma/plugs/frontend_static.ex
parentd00f74e036735c1c238f661076f2925b39daa6ac (diff)
parenta3094b64df344622f1bcb03091ef2ff4dce6da82 (diff)
downloadpleroma-matrix.tar.gz
Merge remote-tracking branch 'origin/develop' into matrixmatrix
Diffstat (limited to 'lib/pleroma/plugs/frontend_static.ex')
-rw-r--r--lib/pleroma/plugs/frontend_static.ex58
1 files changed, 0 insertions, 58 deletions
diff --git a/lib/pleroma/plugs/frontend_static.ex b/lib/pleroma/plugs/frontend_static.ex
deleted file mode 100644
index 3ff1bf016..000000000
--- a/lib/pleroma/plugs/frontend_static.ex
+++ /dev/null
@@ -1,58 +0,0 @@
-# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
-# SPDX-License-Identifier: AGPL-3.0-only
-
-defmodule Pleroma.Plugs.FrontendStatic do
- require Pleroma.Constants
-
- @moduledoc """
- This is a shim to call `Plug.Static` but with runtime `from` configuration`. It dispatches to the different frontends.
- """
- @behaviour Plug
-
- def file_path(path, frontend_type \\ :primary) do
- if configuration = Pleroma.Config.get([:frontends, frontend_type]) do
- instance_static_path = Pleroma.Config.get([:instance, :static_dir], "instance/static")
-
- Path.join([
- instance_static_path,
- "frontends",
- configuration["name"],
- configuration["ref"],
- path
- ])
- else
- nil
- end
- end
-
- def init(opts) do
- opts
- |> Keyword.put(:from, "__unconfigured_frontend_static_plug")
- |> Plug.Static.init()
- |> Map.put(:frontend_type, opts[:frontend_type])
- end
-
- def call(%{path_info: ["_matrix" | _]} = conn, _opts), do: conn
- def call(%{path_info: ["api" | _]} = conn, _opts), do: conn
-
- def call(conn, opts) do
- frontend_type = Map.get(opts, :frontend_type, :primary)
- path = file_path("", frontend_type)
-
- if path do
- conn
- |> call_static(opts, path)
- else
- conn
- end
- end
-
- defp call_static(conn, opts, from) do
- opts =
- opts
- |> Map.put(:from, from)
-
- Plug.Static.call(conn, opts)
- end
-end