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