Runtime configuration
Related to #85 Everything should now be configured at runtime, with the exception of the `Pleroma.HTML` scrubbers (the scrubbers used can be changed at runtime, but their configuration is compile-time) because it's building a module with a macro.
This commit is contained in:
parent
25512aa29c
commit
5bb88fd174
18 changed files with 190 additions and 163 deletions
|
|
@ -1,16 +1,16 @@
|
|||
defmodule Pleroma.Gopher.Server do
|
||||
use GenServer
|
||||
require Logger
|
||||
@gopher Application.get_env(:pleroma, :gopher)
|
||||
|
||||
def start_link() do
|
||||
ip = Keyword.get(@gopher, :ip, {0, 0, 0, 0})
|
||||
port = Keyword.get(@gopher, :port, 1234)
|
||||
config = Pleroma.Config.get(:gopher, [])
|
||||
ip = Keyword.get(config, :ip, {0, 0, 0, 0})
|
||||
port = Keyword.get(config, :port, 1234)
|
||||
GenServer.start_link(__MODULE__, [ip, port], [])
|
||||
end
|
||||
|
||||
def init([ip, port]) do
|
||||
if Keyword.get(@gopher, :enabled, false) do
|
||||
if Pleroma.Config.get([:gopher, :enabled], false) do
|
||||
Logger.info("Starting gopher server on #{port}")
|
||||
|
||||
:ranch.start_listener(
|
||||
|
|
@ -37,9 +37,6 @@ defmodule Pleroma.Gopher.Server.ProtocolHandler do
|
|||
alias Pleroma.Repo
|
||||
alias Pleroma.HTML
|
||||
|
||||
@instance Application.get_env(:pleroma, :instance)
|
||||
@gopher Application.get_env(:pleroma, :gopher)
|
||||
|
||||
def start_link(ref, socket, transport, opts) do
|
||||
pid = spawn_link(__MODULE__, :init, [ref, socket, transport, opts])
|
||||
{:ok, pid}
|
||||
|
|
@ -62,7 +59,7 @@ defmodule Pleroma.Gopher.Server.ProtocolHandler do
|
|||
|
||||
def link(name, selector, type \\ 1) do
|
||||
address = Pleroma.Web.Endpoint.host()
|
||||
port = Keyword.get(@gopher, :port, 1234)
|
||||
port = Pleroma.Config.get([:gopher, :port], 1234)
|
||||
"#{type}#{name}\t#{selector}\t#{address}\t#{port}\r\n"
|
||||
end
|
||||
|
||||
|
|
@ -85,7 +82,7 @@ defmodule Pleroma.Gopher.Server.ProtocolHandler do
|
|||
end
|
||||
|
||||
def response("") do
|
||||
info("Welcome to #{Keyword.get(@instance, :name, "Pleroma")}!") <>
|
||||
info("Welcome to #{Pleroma.Config.get([:instance, :name], "Pleroma")}!") <>
|
||||
link("Public Timeline", "/main/public") <>
|
||||
link("Federated Timeline", "/main/all") <> ".\r\n"
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue