Skip to content

Commit

Permalink
Show SVG thumbnails via <img> tag instead of inline
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed Mar 17, 2024
1 parent 269a36f commit 7b82f3b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="thumbnail" style={"border-right: 1ch solid #{theme(@asciicast).bg}"}>
<RecordingSVG.thumbnail asciicast={@asciicast} />
<img src={~p"/a/#{@asciicast}" <> ".svg?v=t"} />
</div>
8 changes: 7 additions & 1 deletion lib/asciinema_web/controllers/recording_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ defmodule AsciinemaWeb.RecordingController do
|> put_resp_content_type("image/png")
|> send_file(200, path)
else
render(conn, :show, asciicast: asciicast)
case conn.params["v"] do
"t" ->
render(conn, :thumbnail, asciicast: asciicast)

_ ->
render(conn, :show, asciicast: asciicast)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/asciinema_web/controllers/recording_html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule AsciinemaWeb.RecordingHTML do
import Scrivener.HTML
alias Asciinema.{Accounts, Fonts, Media, Recordings, Themes}
alias Asciinema.Recordings.{Markers, Snapshot}
alias AsciinemaWeb.{MediaView, RecordingSVG, UserHTML}
alias AsciinemaWeb.{MediaView, UserHTML}

embed_templates "recording/*.html"

Expand Down
1 change: 1 addition & 0 deletions lib/asciinema_web/controllers/recording_svg.ex
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ defmodule AsciinemaWeb.RecordingSVG do

def thumbnail(assigns) do
~H"""
<%= raw("<?xml version=\"1.0\"?>") %>
<.preview
snapshot={snapshot(@asciicast, {80, 15})}
cols={80}
Expand Down

0 comments on commit 7b82f3b

Please sign in to comment.