asciinema.org/app/helpers/asciicasts_helper.rb

37 lines
1.1 KiB
Ruby
Raw Normal View History

2011-11-23 21:30:09 +00:00
module AsciicastsHelper
2011-11-27 12:54:10 +00:00
def player(asciicast, options = {})
if params[:fallback]
player_class = "AsciiIo.FallbackPlayer"
else
player_class = "window.Worker && $.browser.webkit ? " \
2012-08-25 13:15:13 +00:00
"AsciiIo.Player : AsciiIo.FallbackPlayer"
end
2012-03-15 08:53:26 +00:00
if custom_renderer = params[:renderer]
renderer_class = "AsciiIo.Renderer.#{custom_renderer.capitalize}"
else
renderer_class = "AsciiIo.Renderer.Pre"
end
render :partial => 'asciicasts/player', :locals => {
player_class: player_class,
cols: asciicast.terminal_columns,
lines: asciicast.terminal_lines,
speed: (options[:speed] || params[:speed] || 1).to_f,
benchmark: !!params[:bm],
asciicast_id: asciicast.id,
renderer_class: renderer_class,
auto_play: options.key?(:auto_play) ? !!options[:auto_play] : false,
hud: options.key?(:hud) ? !!options[:hud] : true,
snapshot: asciicast.snapshot
}
2011-11-27 12:54:10 +00:00
end
2012-11-19 21:27:52 +00:00
def link_to_delete_asciicast(name, asciicast)
link_to name, asciicast_path(asciicast),
:method => :delete, :confirm => 'Really delete this asciicast?'
end
2011-11-23 21:30:09 +00:00
end