Merge branch 'hj-happiness-improvement' into 'develop'
New frontend configuration mechanism. Closes #445 See merge request pleroma/pleroma!700
This commit is contained in:
commit
d03a116654
|
@ -154,6 +154,7 @@
|
||||||
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 @@
|
||||||
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: "/images/city.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 DEPRECATED__
|
||||||
|
|
||||||
|
If you are using this method, please change it to the `frontend_configurations` method. Please set this option to false in your config like this: `config :pleroma, :fe, false`.
|
||||||
|
|
||||||
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``
|
||||||
|
|
|
@ -22,6 +22,8 @@ def user_agent() do
|
||||||
def start(_type, _args) do
|
def start(_type, _args) do
|
||||||
import Cachex.Spec
|
import Cachex.Spec
|
||||||
|
|
||||||
|
Pleroma.Config.DeprecationWarnings.warn()
|
||||||
|
|
||||||
# Define workers and child supervisors to be supervised
|
# Define workers and child supervisors to be supervised
|
||||||
children =
|
children =
|
||||||
[
|
[
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Config.DeprecationWarnings do
|
||||||
|
require Logger
|
||||||
|
|
||||||
|
def check_frontend_config_mechanism() do
|
||||||
|
if Pleroma.Config.get(:fe) do
|
||||||
|
Logger.warn("""
|
||||||
|
!!!DEPRECATION WARNING!!!
|
||||||
|
You are using the old configuration mechanism for the frontend. Please check config.md.
|
||||||
|
""")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def warn do
|
||||||
|
check_frontend_config_mechanism()
|
||||||
|
end
|
||||||
|
end
|
|
@ -278,6 +278,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
|
||||||
|
|
|
@ -183,7 +183,9 @@ def config(conn, _params) do
|
||||||
invitesEnabled: if(Keyword.get(instance, :invites_enabled, false), do: "1", else: "0")
|
invitesEnabled: if(Keyword.get(instance, :invites_enabled, false), do: "1", else: "0")
|
||||||
}
|
}
|
||||||
|
|
||||||
pleroma_fe = %{
|
pleroma_fe =
|
||||||
|
if instance_fe do
|
||||||
|
%{
|
||||||
theme: Keyword.get(instance_fe, :theme),
|
theme: Keyword.get(instance_fe, :theme),
|
||||||
background: Keyword.get(instance_fe, :background),
|
background: Keyword.get(instance_fe, :background),
|
||||||
logo: Keyword.get(instance_fe, :logo),
|
logo: Keyword.get(instance_fe, :logo),
|
||||||
|
@ -195,13 +197,17 @@ def config(conn, _params) do
|
||||||
showInstanceSpecificPanel: Keyword.get(instance_fe, :show_instance_panel),
|
showInstanceSpecificPanel: Keyword.get(instance_fe, :show_instance_panel),
|
||||||
scopeOptionsEnabled: Keyword.get(instance_fe, :scope_options_enabled),
|
scopeOptionsEnabled: Keyword.get(instance_fe, :scope_options_enabled),
|
||||||
formattingOptionsEnabled: Keyword.get(instance_fe, :formatting_options_enabled),
|
formattingOptionsEnabled: Keyword.get(instance_fe, :formatting_options_enabled),
|
||||||
collapseMessageWithSubject: Keyword.get(instance_fe, :collapse_message_with_subject),
|
collapseMessageWithSubject:
|
||||||
|
Keyword.get(instance_fe, :collapse_message_with_subject),
|
||||||
hidePostStats: Keyword.get(instance_fe, :hide_post_stats),
|
hidePostStats: Keyword.get(instance_fe, :hide_post_stats),
|
||||||
hideUserStats: Keyword.get(instance_fe, :hide_user_stats),
|
hideUserStats: Keyword.get(instance_fe, :hide_user_stats),
|
||||||
scopeCopy: Keyword.get(instance_fe, :scope_copy),
|
scopeCopy: Keyword.get(instance_fe, :scope_copy),
|
||||||
subjectLineBehavior: Keyword.get(instance_fe, :subject_line_behavior),
|
subjectLineBehavior: Keyword.get(instance_fe, :subject_line_behavior),
|
||||||
alwaysShowSubjectInput: Keyword.get(instance_fe, :always_show_subject_input)
|
alwaysShowSubjectInput: Keyword.get(instance_fe, :always_show_subject_input)
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Pleroma.Config.get([:frontend_configurations, :pleroma_fe])
|
||||||
|
end
|
||||||
|
|
||||||
managed_config = Keyword.get(instance, :managed_config)
|
managed_config = Keyword.get(instance, :managed_config)
|
||||||
|
|
||||||
|
@ -216,6 +222,14 @@ def config(conn, _params) 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()
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 3.0 MiB |
|
@ -32,4 +32,71 @@ test "it returns HTTP 200", %{conn: conn} do
|
||||||
assert response == "job started"
|
assert response == "job started"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "GET /api/statusnet/config.json" do
|
||||||
|
test "it returns the managed config", %{conn: conn} do
|
||||||
|
Pleroma.Config.put([:instance, :managed_config], false)
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> get("/api/statusnet/config.json")
|
||||||
|
|> json_response(:ok)
|
||||||
|
|
||||||
|
refute response["site"]["pleromafe"]
|
||||||
|
|
||||||
|
Pleroma.Config.put([:instance, :managed_config], true)
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> get("/api/statusnet/config.json")
|
||||||
|
|> json_response(:ok)
|
||||||
|
|
||||||
|
assert response["site"]["pleromafe"]
|
||||||
|
end
|
||||||
|
|
||||||
|
test "if :pleroma, :fe is false, it returns the new style config settings", %{conn: conn} do
|
||||||
|
Pleroma.Config.put([:instance, :managed_config], true)
|
||||||
|
Pleroma.Config.put([:fe, :theme], "rei-ayanami-towel")
|
||||||
|
Pleroma.Config.put([:frontend_configurations, :pleroma_fe], %{theme: "asuka-hospital"})
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> get("/api/statusnet/config.json")
|
||||||
|
|> json_response(:ok)
|
||||||
|
|
||||||
|
assert response["site"]["pleromafe"]["theme"] == "rei-ayanami-towel"
|
||||||
|
|
||||||
|
Pleroma.Config.put([:fe], false)
|
||||||
|
|
||||||
|
response =
|
||||||
|
conn
|
||||||
|
|> get("/api/statusnet/config.json")
|
||||||
|
|> json_response(:ok)
|
||||||
|
|
||||||
|
assert response["site"]["pleromafe"]["theme"] == "asuka-hospital"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "GET /api/pleroma/frontend_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 New Issue