Favor poster from options over precomputed one

docker-smtp
Marcin Kulik 8 years ago
parent baf1c96c7e
commit 0e42b82e5d

@ -13,7 +13,7 @@ module AsciicastsHelper
src: asciicast.url,
cols: asciicast.width,
rows: asciicast.height,
poster: 'data:application/json;base64,' + Base64.encode64(asciicast.snapshot.to_json),
poster: options.poster || base64_poster(asciicast),
speed: options.speed,
autoplay: options.autoplay,
loop: options.loop,
@ -72,4 +72,8 @@ module AsciicastsHelper
}
end
def base64_poster(asciicast)
'data:application/json;base64,' + Base64.encode64(asciicast.snapshot.to_json)
end
end

@ -1,12 +1,3 @@
class EmbedPlaybackOptions < PlaybackOptions
attribute :autoplay, Boolean, default: false
def as_json(*)
if !poster && t && t > 0
super.merge({ poster: "npt:#{t}" })
else
super
end
end
end

@ -24,22 +24,19 @@ class PlaybackOptions
attribute :v0, Boolean, default: false
attribute :poster, String
def as_json(*)
opts = {
speed: speed,
autoPlay: autoplay.nil? ? !!t : autoplay,
loop: loop,
preload: preload,
fontSize: size,
theme: theme,
poster: poster,
}
if t
opts = opts.merge(startAt: t)
end
def autoplay()
ap = super
ap.nil? ? !!t : ap
end
opts
def poster()
p = super
if !p && t && t > 0 && !autoplay
"npt:#{t}"
else
p
end
end
end

Loading…
Cancel
Save