73 lines
1.9 KiB
Elixir
73 lines
1.9 KiB
Elixir
import Config
|
|
|
|
# Configure Swoosh SMTP adapter to skip TLS certificate verification
|
|
# This is needed for IONOS SMTP server which has certificate key usage issues
|
|
config :asciinema, Asciinema.Emails.Mailer,
|
|
adapter: Swoosh.Adapters.SMTP,
|
|
relay: System.get_env("SMTP_HOST"),
|
|
username: System.get_env("SMTP_USERNAME"),
|
|
password: System.get_env("SMTP_PASSWORD"),
|
|
port: System.get_env("SMTP_PORT") || 587,
|
|
tls: :always,
|
|
auth: :always,
|
|
ssl: false,
|
|
tls_options: [
|
|
verify: :verify_none,
|
|
versions: [:"tlsv1.2", :"tlsv1.3"]
|
|
]
|
|
|
|
# Custom theme configuration - inject custom CSS and favicon
|
|
defmodule AsciinemaWeb.CustomThemePlug do
|
|
@moduledoc """
|
|
Plug to inject custom CSS and favicon into HTML responses
|
|
"""
|
|
import Plug.Conn
|
|
|
|
def init(opts), do: opts
|
|
|
|
def call(conn, _opts) do
|
|
register_before_send(conn, fn conn ->
|
|
if html_response?(conn) do
|
|
inject_custom_theme(conn)
|
|
else
|
|
conn
|
|
end
|
|
end)
|
|
end
|
|
|
|
defp html_response?(conn) do
|
|
case get_resp_header(conn, "content-type") do
|
|
[content_type | _] -> String.contains?(content_type, "text/html")
|
|
[] -> false
|
|
end
|
|
end
|
|
|
|
defp inject_custom_theme(conn) do
|
|
custom_head = """
|
|
<link rel="stylesheet" href="/theme/custom.css">
|
|
<link rel="icon" type="image/svg+xml" href="/theme/favicon.svg">
|
|
"""
|
|
|
|
case conn.resp_body do
|
|
body when is_binary(body) ->
|
|
new_body = String.replace(body, "</head>", "#{custom_head}</head>")
|
|
%{conn | resp_body: new_body}
|
|
_ ->
|
|
conn
|
|
end
|
|
end
|
|
end
|
|
|
|
# Configure Phoenix endpoint to serve custom theme files
|
|
config :asciinema, AsciinemaWeb.Endpoint,
|
|
# Serve theme files from /opt/app/etc/theme
|
|
static_dirs: %{
|
|
at: "/theme",
|
|
from: "/opt/app/etc/theme",
|
|
gzip: false
|
|
}
|
|
|
|
# Inject the custom theme Plug into the endpoint
|
|
config :asciinema, AsciinemaWeb.Endpoint,
|
|
plug: AsciinemaWeb.CustomThemePlug
|