Skip to content

Commit

Permalink
Add voting settings and button. Also add custom anyplayer gem
Browse files Browse the repository at this point in the history
  • Loading branch information
gdiggs committed May 10, 2011
1 parent 2f77b1c commit c3e79bd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ gem "sinatra"
gem "haml"
gem "xml-simple"
gem "json"
gem "anyplayer"
gem "anyplayer", :git => "git://github.com/GordonDiggs/anyplayer.git"

9 changes: 7 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
GIT
remote: git://github.com/GordonDiggs/anyplayer.git
revision: d8310ee2ec25e391034319d07622784e76ee1bb0
specs:
anyplayer (0.0.1)

GEM
remote: http://rubygems.org/
specs:
anyplayer (0.0.1)
haml (3.0.24)
json (1.4.6)
rack (1.2.1)
Expand All @@ -15,7 +20,7 @@ PLATFORMS
ruby

DEPENDENCIES
anyplayer
anyplayer!
haml
json
sinatra
Expand Down
3 changes: 2 additions & 1 deletion sonice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def artist_image(artist)

configure do
set :controls, ENV['SONICE_CONTROLS'] != '0'
set :voting, ENV['SONICE_VOTING'] != '0'
$player = Anyplayer::launched or abort "Error: no music player launched!"
puts "Connected to #{$player.name}"
end
Expand All @@ -43,7 +44,7 @@ def artist_image(artist)
end

post '/player' do
return if !settings.controls
return unless settings.controls || settings.voting
params.each { |k, v| $player.send(k) if $player.respond_to?(k) }
if !request.xhr?
redirect '/'
Expand Down
8 changes: 5 additions & 3 deletions views/index.haml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
%h2#artist= @artist
%h3#album= @album

- if settings.controls
%form{:method => 'post', :action => 'player'}
%p
%form{:method => 'post', :action => 'player'}
%p
- if settings.controls
%input#playpause{:type=>'submit', :value => '▸', :name=>'playpause', :title => "Play/Pause"}
%input#prev{ :type=>'submit', :value => '←', :name=>'prev', :title => "Previous"}
%input#next{ :type=>'submit', :value => '→', :name=>'next', :title => "Next"}
%input#voldown{ :type=>'submit', :value => '♪', :name=>'voldown', :title => "Quieter"}
%input#volup{ :type=>'submit', :value => '♫', :name=>'volup', :title => "Louder"}
- if settings.voting
%input#skip{ :type=>'submit', :value => '↡', :name=>'skip', :title => "Vote to Skip"}

%script{:src => '/jquery.min.js'}
%script{:src => '/script.js'}
Expand Down

0 comments on commit c3e79bd

Please sign in to comment.