Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tag: v1.2.1
Fetching contributors…

Cannot retrieve contributors at this time

executable file 52 lines (43 sloc) 1.085 kB
#!/usr/bin/env ruby
# encoding: utf-8
require 'rubygems'
require 'sinatra'
require 'haml'
$: << File.join(File.dirname(__FILE__), 'lib')
require 'sonice/artist_image'
require 'sonice/player'
require 'sonice/players/itunes'
require 'sonice/players/itunes_win'
require 'sonice/players/mpd'
require 'sonice/players/rhythmbox'
require 'sonice/players/xmms2'
require 'sonice/players/amarok'
set :environment, ENV['RACK_ENV'] || :production
configure do
set :controls, ENV['SONICE_CONTROLS'] != '0'
$player = Sonice::Player.launched or abort "Error: no music player launched!"
puts "Connected to #{$player.name}"
end
helpers do
include Rack::Utils
alias_method :h, :escape_html
end
post '/player' do
return if !settings.controls
params.each { |k, v| $player.send(k) if $player.respond_to?(k) }
if !request.xhr?
redirect '/'
end
end
get '/' do
@title = $player.track
@artist = $player.artist
@album = $player.album
@image_uri = Sonice::ArtistImage.new(@artist).uri
if request.xhr?
content_type :js
erb :indexjs
else
haml :index
end
end
Jump to Line
Something went wrong with that request. Please try again.