feat: override static_paths and add custom head view for theme injection
This commit is contained in:
@@ -8,7 +8,7 @@ services:
|
||||
volumes:
|
||||
- asciinema_data:/var/opt/asciinema
|
||||
- ./custom.exs:/opt/app/etc/custom.exs:ro
|
||||
- ./theme:/opt/app/priv/static/theme/custom:ro
|
||||
- ./theme:/opt/app/priv/static/theme:ro
|
||||
environment:
|
||||
SECRET_KEY_BASE: ${ASCIINEMA_SECRET_KEY}
|
||||
URL_HOST: ${ASCIINEMA_TRAEFIK_HOST}
|
||||
|
||||
@@ -16,9 +16,21 @@ config :asciinema, Asciinema.Emails.Mailer,
|
||||
versions: [:"tlsv1.2", :"tlsv1.3"]
|
||||
]
|
||||
|
||||
# Try to inject custom head HTML (if supported by asciinema)
|
||||
config :asciinema, AsciinemaWeb.Endpoint,
|
||||
extra_head_html: """
|
||||
<link rel="stylesheet" href="/theme/custom/custom.css">
|
||||
<link rel="icon" type="image/svg+xml" href="/theme/custom/favicon.svg">
|
||||
"""
|
||||
# Override static_paths to include our theme directory
|
||||
# This allows serving custom CSS and favicon from /theme path
|
||||
defmodule AsciinemaWeb do
|
||||
def static_paths, do: ~w(assets fonts images js favicon.ico robots.txt theme)
|
||||
end
|
||||
|
||||
# Define a custom layout view that injects our theme CSS and favicon
|
||||
defmodule AsciinemaWeb.CustomLayoutView do
|
||||
def head(_conn, _assigns) do
|
||||
Phoenix.HTML.raw("""
|
||||
<link rel="stylesheet" href="/theme/custom.css">
|
||||
<link rel="icon" type="image/svg+xml" href="/theme/favicon.svg">
|
||||
""")
|
||||
end
|
||||
end
|
||||
|
||||
# Override the layout view to use our custom head function
|
||||
config :asciinema, AsciinemaWeb.LayoutView, head: &AsciinemaWeb.CustomLayoutView.head/2
|
||||
|
||||
Reference in New Issue
Block a user