From dce10fb9711531b5327cb0a3f740860bb53970f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Sun, 9 Nov 2025 09:19:10 +0100 Subject: [PATCH] feat: override static_paths and add custom head view for theme injection --- asciinema/compose.yaml | 2 +- asciinema/custom.exs | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/asciinema/compose.yaml b/asciinema/compose.yaml index 15ac611..3c42064 100644 --- a/asciinema/compose.yaml +++ b/asciinema/compose.yaml @@ -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} diff --git a/asciinema/custom.exs b/asciinema/custom.exs index c929124..7969e6a 100644 --- a/asciinema/custom.exs +++ b/asciinema/custom.exs @@ -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: """ - - - """ +# 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(""" + + + """) + end +end + +# Override the layout view to use our custom head function +config :asciinema, AsciinemaWeb.LayoutView, head: &AsciinemaWeb.CustomLayoutView.head/2