svg preview renderer
This commit is contained in:
parent
43a8412f06
commit
faa9599849
29 changed files with 1027 additions and 254 deletions
30
lib/zoeyscomputer_web/controllers/gist_preview_controller.ex
Normal file
30
lib/zoeyscomputer_web/controllers/gist_preview_controller.ex
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue