New frontend configuration mechanism.
This commit is contained in:
parent
b624b7a150
commit
e221c681dc
5 changed files with 68 additions and 0 deletions
|
@ -154,6 +154,7 @@ config :pleroma, :markup,
|
||||||
Pleroma.HTML.Scrubber.Default
|
Pleroma.HTML.Scrubber.Default
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Deprecated, will be gone in 1.0
|
||||||
config :pleroma, :fe,
|
config :pleroma, :fe,
|
||||||
theme: "pleroma-dark",
|
theme: "pleroma-dark",
|
||||||
logo: "/static/logo.png",
|
logo: "/static/logo.png",
|
||||||
|
@ -172,6 +173,24 @@ config :pleroma, :fe,
|
||||||
subject_line_behavior: "email",
|
subject_line_behavior: "email",
|
||||||
always_show_subject_input: true
|
always_show_subject_input: true
|
||||||
|
|
||||||
|
config :pleroma, :frontend_configurations,
|
||||||
|
pleroma_fe: %{
|
||||||
|
theme: "pleroma-dark",
|
||||||
|
logo: "/static/logo.png",
|
||||||
|
background: "/static/aurora_borealis.jpg",
|
||||||
|
redirectRootNoLogin: "/main/all",
|
||||||
|
redirectRootLogin: "/main/friends",
|
||||||
|
showInstanceSpecificPanel: true,
|
||||||
|
scopeOptionsEnabled: false,
|
||||||
|
formattingOptionsEnabled: false,
|
||||||
|
collapseMessageWithSubject: false,
|
||||||
|
hidePostStats: false,
|
||||||
|
hideUserStats: false,
|
||||||
|
scopeCopy: true,
|
||||||
|
subjectLineBehavior: "email",
|
||||||
|
alwaysShowSubjectInput: true
|
||||||
|
}
|
||||||
|
|
||||||
config :pleroma, :activitypub,
|
config :pleroma, :activitypub,
|
||||||
accept_blocks: true,
|
accept_blocks: true,
|
||||||
unfollow_blocked: true,
|
unfollow_blocked: true,
|
||||||
|
|
|
@ -101,7 +101,24 @@ config :pleroma, Pleroma.Mailer,
|
||||||
* `backends`: `:console` is used to send logs to stdout, `{ExSyslogger, :ex_syslogger}` to log to syslog
|
* `backends`: `:console` is used to send logs to stdout, `{ExSyslogger, :ex_syslogger}` to log to syslog
|
||||||
See: [logger’s documentation](https://hexdocs.pm/logger/Logger.html) and [ex_syslogger’s documentation](https://hexdocs.pm/ex_syslogger/)
|
See: [logger’s documentation](https://hexdocs.pm/logger/Logger.html) and [ex_syslogger’s documentation](https://hexdocs.pm/ex_syslogger/)
|
||||||
|
|
||||||
|
|
||||||
|
## :frontend_configurations
|
||||||
|
|
||||||
|
This can be used to configure a keyword list that keeps the configuration data for any kind of frontend. By default, settings for `pleroma_fe` are configured.
|
||||||
|
|
||||||
|
Frontends can access these settings at `/api/pleroma/frontend_configurations`
|
||||||
|
|
||||||
|
To add your own configuration for PleromaFE, use it like this:
|
||||||
|
|
||||||
|
`config :pleroma, :frontend_configurations, :pleroma_fe, %{theme: "my-theme", ...}`
|
||||||
|
|
||||||
|
These settings need to be complete, they will overide the defaults.
|
||||||
|
|
||||||
## :fe
|
## :fe
|
||||||
|
__THIS IS DEPRACTED__
|
||||||
|
|
||||||
|
If you are using this method, please change it to the `frontend_configurations` method.
|
||||||
|
|
||||||
This section is used to configure Pleroma-FE, unless ``:managed_config`` in ``:instance`` is set to false.
|
This section is used to configure Pleroma-FE, unless ``:managed_config`` in ``:instance`` is set to false.
|
||||||
|
|
||||||
* `theme`: Which theme to use, they are defined in ``styles.json``
|
* `theme`: Which theme to use, they are defined in ``styles.json``
|
||||||
|
|
|
@ -284,6 +284,7 @@ defmodule Pleroma.Web.Router do
|
||||||
post("/help/test", TwitterAPI.UtilController, :help_test)
|
post("/help/test", TwitterAPI.UtilController, :help_test)
|
||||||
get("/statusnet/config", TwitterAPI.UtilController, :config)
|
get("/statusnet/config", TwitterAPI.UtilController, :config)
|
||||||
get("/statusnet/version", TwitterAPI.UtilController, :version)
|
get("/statusnet/version", TwitterAPI.UtilController, :version)
|
||||||
|
get("/pleroma/frontend_configurations", TwitterAPI.UtilController, :frontend_configurations)
|
||||||
end
|
end
|
||||||
|
|
||||||
scope "/api", Pleroma.Web do
|
scope "/api", Pleroma.Web do
|
||||||
|
|
|
@ -216,6 +216,14 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def frontend_configurations(conn, _params) do
|
||||||
|
config =
|
||||||
|
Pleroma.Config.get(:frontend_configurations, %{})
|
||||||
|
|> Enum.into(%{})
|
||||||
|
|
||||||
|
json(conn, config)
|
||||||
|
end
|
||||||
|
|
||||||
def version(conn, _params) do
|
def version(conn, _params) do
|
||||||
version = Pleroma.Application.named_version()
|
version = Pleroma.Application.named_version()
|
||||||
|
|
||||||
|
|
|
@ -32,4 +32,27 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
||||||
assert response == "job started"
|
assert response == "job started"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "GET /api/pleroma/frontent_configurations" do
|
||||||
|
test "returns everything in :pleroma, :frontend_configurations", %{conn: conn} do
|
||||||
|
config = [
|
||||||
|
frontend_a: %{
|
||||||
|
x: 1,
|
||||||
|
y: 2
|
||||||
|
},
|
||||||
|
frontend_b: %{
|
||||||
|
z: 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
Pleroma.Config.put(:frontend_configurations, config)
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> get("/api/pleroma/frontend_configurations")
|
||||||
|
|> json_response(:ok)
|
||||||
|
|
||||||
|
assert response == Jason.encode!(config |> Enum.into(%{})) |> Jason.decode!()
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue