Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F21841708
frontend_static.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
frontend_static.ex
View Options
# 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
()
end
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
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Sat, Dec 27, 11:50 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
806803
Default Alt Text
frontend_static.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment