feat: patch HTML template to inject custom theme
This commit is contained in:
36
asciinema/app.html.heex
Normal file
36
asciinema/app.html.heex
Normal file
@@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
|
||||
<meta name="csrf-token" content={Plug.CSRFProtection.get_csrf_token()} />
|
||||
<title>{page_title(@conn)}</title>
|
||||
<link phx-track-static rel="stylesheet" href={Routes.static_path(@conn, "/assets/app.css")} />
|
||||
<link rel="shortcut icon" href={Routes.static_path(@conn, "/images/favicon.png")} />
|
||||
|
||||
<%= if function_exported?(view_module(@conn), :head, 2) do %>
|
||||
{view_module(@conn).head(view_template(@conn), assigns)}
|
||||
<% end %>
|
||||
|
||||
<!-- Custom Pivoine Rose Theme -->
|
||||
<link rel="stylesheet" href="/theme/custom.css" />
|
||||
<link rel="icon" type="image/svg+xml" href="/theme/favicon.svg" />
|
||||
</head>
|
||||
|
||||
<body class={"l-app " <> body_class(@conn)}>
|
||||
{render("_header.html", conn: @conn, current_user: @current_user)}
|
||||
{render("_flash.html", flash: @flash)}
|
||||
|
||||
<main role="main">
|
||||
{@inner_content}
|
||||
</main>
|
||||
|
||||
{render("_footer.html", conn: @conn)}
|
||||
<script>
|
||||
window.__asciinema__workerUrl = '<%= Routes.static_path(@conn, "/js/player-worker.min.js") %>';
|
||||
</script>
|
||||
<script phx-track-static src={Routes.static_path(@conn, "/assets/app.js")}>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,6 +9,7 @@ services:
|
||||
- asciinema_data:/var/opt/asciinema
|
||||
- ./custom.exs:/opt/app/etc/custom.exs:ro
|
||||
- ./theme:/opt/app/priv/static/theme:ro
|
||||
- ./app.html.heex:/opt/app/lib/asciinema_web-*/eex/layout/app.html.heex:ro
|
||||
environment:
|
||||
SECRET_KEY_BASE: ${ASCIINEMA_SECRET_KEY}
|
||||
URL_HOST: ${ASCIINEMA_TRAEFIK_HOST}
|
||||
|
||||
@@ -15,22 +15,3 @@ config :asciinema, Asciinema.Emails.Mailer,
|
||||
verify: :verify_none,
|
||||
versions: [:"tlsv1.2", :"tlsv1.3"]
|
||||
]
|
||||
|
||||
# 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