Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add super fancy, but super hacky, support for auto-playing videos

  • Loading branch information...
commit 3ac599726fb0280962ff72a3cb95e85a14922ea4 1 parent b45660f
@rtyler authored
View
4 features/support/data.rb
@@ -5,7 +5,9 @@ def jobs
jobs = []
10.times do |i|
jobs << {'id' => "cuke-#{i}",
- 'name' => "Cucumber Job #{i}"}
+ 'name' => "Cucumber Job #{i}",
+ 'end_time' => 30,
+ 'start_time' => 20}
end
jobs
end
View
41 lib/saucetv/app.rb
@@ -34,18 +34,53 @@ def api_for_session
redirect to('/watch')
end
+ get '/next/after/:id' do |id|
+ unless authenticated?
+ redirect to('/login')
+ end
+
+ api = api_for_session
+ jobs = []
+ begin
+ jobs =api.recent_jobs
+ rescue SauceTV::InvalidUserCredentials
+ redirect to('/login?invalid=true')
+ end
+
+ if jobs.empty?
+ redirect to('/watch')
+ end
+
+ previous = nil
+ jobs.each do |job|
+ break if id == job['id']
+ previous = job
+ end
+
+ unless previous.nil?
+ redirect to("/watch/#{previous['id']}")
+ end
+ redirect to('/watch')
+ end
+
get '/watch/:id' do |id|
unless authenticated?
redirect to('/login')
end
api = api_for_session
- info = api.info_for(id)
+ begin
+ info = api.info_for(id)
+ rescue SauceTV::InvalidUserCredentials
+ redirect to('/login?invalid=true')
+ end
haml :player, :locals => {
- :session => session[:username],
+ :username => session[:username],
:id => id,
- :info => info
+ :delay => info['end_time'] - info['start_time'],
+ :info => info,
+ :token => api.auth_token_for(id)
}
end
View
12 lib/saucetv/views/player.haml
@@ -1,7 +1,15 @@
%html
%head
+ %meta{'http-equiv' => 'refresh',
+ :content => "#{delay};url=/next/after/#{id}"}
+ %script{:type => 'text/javascript',
+ :src => '/flowplayer/flowplayer-3.2.11.min.js'}
%title
- SauceLabs.tv
+ SauceLabs.tv - #{info['name']}
%body
- Now watching: #{info['name']}
+ Now watching: #{info['name']} (#{delay}s)
+ %script{:type => 'text/javascript',
+ :src => "http://saucelabs.com/video-embed/#{id}.js?auth=#{token}"}
+ %script{:type => 'text/javascript'}
+ $f(0).play();
View
9 lib/saucetv/views/watch.haml
@@ -3,17 +3,16 @@
%title
SauceLabs.tv
%body
- Welcome #{username}
-
+ %div{:style => 'float: right; clear: all; font-weight: bold'}
+ Welcome #{username}
- unless jobs.empty?
%a{:href => "/watch/#{jobs[-1]['id']}"}
Auto-Play
- %ul#jobs
+ %ol#jobs
- jobs.compact.each do |job|
%li.job{:id => "job_#{job['id']}"}
- %a{:href => "https://saucelabs.com/jobs/#{job['id']}"}
+ %a{:href => "/watch/#{job['id']}"}
= job['name']
- &middot;
Please sign in to comment.
Something went wrong with that request. Please try again.