Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
83ae45b0
Verified
Commit
83ae45b0
authored
Oct 12, 2020
by
Alex Gleason
Browse files
Preload `/api/pleroma/frontend_configurations`, fixes
#1932
parent
42b4b954
Changes
4
Show whitespace changes
Inline
Side-by-side
lib/pleroma/web/preload/instance.ex
View file @
83ae45b0
...
...
@@ -7,11 +7,13 @@ defmodule Pleroma.Web.Preload.Providers.Instance do
alias
Pleroma
.
Web
.
MastodonAPI
.
InstanceView
alias
Pleroma
.
Web
.
Nodeinfo
.
Nodeinfo
alias
Pleroma
.
Web
.
Preload
.
Providers
.
Provider
alias
Pleroma
.
Web
.
TwitterAPI
.
UtilView
@behaviour
Provider
@instance_url
"/api/v1/instance"
@panel_url
"/instance/panel.html"
@nodeinfo_url
"/nodeinfo/2.0.json"
@fe_config_url
"/api/pleroma/frontend_configurations"
@impl
Provider
def
generate_terms
(
_params
)
do
...
...
@@ -19,6 +21,7 @@ def generate_terms(_params) do
|>
build_info_tag
()
|>
build_panel_tag
()
|>
build_nodeinfo_tag
()
|>
build_fe_config_tag
()
end
defp
build_info_tag
(
acc
)
do
...
...
@@ -47,4 +50,10 @@ defp build_nodeinfo_tag(acc) do
Map
.
put
(
acc
,
@nodeinfo_url
,
nodeinfo_data
)
end
end
defp
build_fe_config_tag
(
acc
)
do
fe_data
=
UtilView
.
render
(
"frontend_configurations.json"
,
%{})
Map
.
put
(
acc
,
@fe_config_url
,
fe_data
)
end
end
lib/pleroma/web/twitter_api/controllers/util_controller.ex
View file @
83ae45b0
...
...
@@ -74,11 +74,7 @@ def notifications_read(%{assigns: %{user: user}} = conn, %{"id" => notification_
end
def
frontend_configurations
(
conn
,
_params
)
do
config
=
Config
.
get
(
:frontend_configurations
,
%{})
|>
Enum
.
into
(%{})
json
(
conn
,
config
)
render
(
conn
,
"frontend_configurations.json"
)
end
def
emoji
(
conn
,
_params
)
do
...
...
lib/pleroma/web/twitter_api/views/util_view.ex
View file @
83ae45b0
...
...
@@ -5,6 +5,7 @@
defmodule
Pleroma
.
Web
.
TwitterAPI
.
UtilView
do
use
Pleroma
.
Web
,
:view
import
Phoenix
.
HTML
.
Form
alias
Pleroma
.
Config
alias
Pleroma
.
Web
def
status_net_config
(
instance
)
do
...
...
@@ -19,4 +20,9 @@ def status_net_config(instance) do
</config>
"""
end
def
render
(
"frontend_configurations.json"
,
_
)
do
Config
.
get
(
:frontend_configurations
,
%{})
|>
Enum
.
into
(%{})
end
end
test/web/preload/instance_test.exs
View file @
83ae45b0
...
...
@@ -45,4 +45,12 @@ test "it renders the node_info", %{"/nodeinfo/2.0.json" => nodeinfo} do
assert
metadata
.
private
==
false
assert
metadata
.
suggestions
==
%{
enabled:
false
}
end
test
"it renders the frontend configurations"
,
%{
"/api/pleroma/frontend_configurations"
=>
fe_configs
}
do
assert
%{
pleroma_fe:
%{
background:
"/images/city.jpg"
,
logo:
"/static/logo.png"
}
}
=
fe_configs
end
end
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment