From 4edd5ead9ea20e506c4aac34a47ed841acbf339d Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Sat, 28 Jul 2012 20:33:10 +0200 Subject: [PATCH] Play cast on homepage at 2x speed --- app/helpers/asciicasts_helper.rb | 2 +- app/views/asciicasts/_player.html.erb | 2 +- app/views/asciicasts/show.html.erb | 6 ++++-- app/views/home/show.html.erb | 6 ++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/helpers/asciicasts_helper.rb b/app/helpers/asciicasts_helper.rb index b8bc1de..0e2dad8 100644 --- a/app/helpers/asciicasts_helper.rb +++ b/app/helpers/asciicasts_helper.rb @@ -1,7 +1,7 @@ module AsciicastsHelper def player_script(asciicast, options = {}) - speed = (params[:speed] || 1).to_f + speed = (options[:speed] || 1).to_f benchmark = !!params[:bm] auto_play = options.key?(:auto_play) ? !!options[:auto_play] : false diff --git a/app/views/asciicasts/_player.html.erb b/app/views/asciicasts/_player.html.erb index 63e7a09..3230b84 100644 --- a/app/views/asciicasts/_player.html.erb +++ b/app/views/asciicasts/_player.html.erb @@ -1,2 +1,2 @@
-<%= player_script(asciicast, :auto_play => local_assigns[:auto_play]) %> +<%= player_script(asciicast, :speed => local_assigns[:speed]) %> diff --git a/app/views/asciicasts/show.html.erb b/app/views/asciicasts/show.html.erb index 6c3a50e..4e6f918 100644 --- a/app/views/asciicasts/show.html.erb +++ b/app/views/asciicasts/show.html.erb @@ -1,7 +1,9 @@
- <%= render :partial => 'asciicasts/player', - :locals => { :asciicast => @asciicast } %> + <%= render :partial => 'asciicasts/player', :locals => { + :asciicast => @asciicast, + :speed => params[:speed] + } %>
diff --git a/app/views/home/show.html.erb b/app/views/home/show.html.erb index 04d2c26..7765fb7 100644 --- a/app/views/home/show.html.erb +++ b/app/views/home/show.html.erb @@ -18,8 +18,10 @@
<% if @asciicast -%> - <%= render :partial => 'asciicasts/player', - :locals => { :asciicast => @asciicast } %> + <%= render :partial => 'asciicasts/player', :locals => { + :asciicast => @asciicast, + :speed => 2.0 + } %> <% end -%>