svg preview renderer

This commit is contained in:
zack 2024-10-26 21:41:22 -04:00
parent 43a8412f06
commit faa9599849
No known key found for this signature in database
GPG key ID: 5F873416BCF59F35
29 changed files with 1027 additions and 254 deletions

View file

@ -0,0 +1,30 @@
defmodule ZoeyscomputerWeb.GistPreviewController do
use ZoeyscomputerWeb, :controller
require Logger
alias Zoeyscomputer.Gists
def show(conn, %{"id" => id}) do
gist = Gists.get_gist!(id)
{:ok, webp} = ZoeyscomputerWeb.GistLive.OgImage.get_webp(gist)
conn
|> put_resp_content_type("image/webp")
|> put_resp_header("cache-control", "public, max-age=300")
|> send_resp(200, webp)
|> halt()
end
def raw(conn, %{"id" => id}) do
gist = Gists.get_gist!(id)
webp = ZoeyscomputerWeb.GistLive.OgImage.generate_preview(gist)
conn
|> put_resp_content_type("image/svg+xml")
|> put_resp_header("cache-control", "public, max-age=300")
|> send_resp(200, webp)
|> halt()
end
end