altum.rb |
|
---|---|
Altum uses the magic of Pusher and websockets to drive a ShowOff presentation remotely. Altum consists of a piece of Rack middleware and some JavaScript that keeps viewers in sync with the presenter. Getting started is easy. Install Altum with Rubygems:
ShowOff will create a
Next, download altum.js into your presentation directory. Copy the code
from the latest pusher.min.js and paste it at the top of Start the presentation locally with |
require 'altum/version'
require 'pusher' |
|
class Altum
def initialize(app, options)
@app = app
@key = options[:key] || 'sekret'
Pusher.url = options[:pusher_url]
end |
Listen for slide change commands from the presenter and send the current slide out to all those watching. Silently ignore requests from a presenter using an incorrect key. |
def call(env)
request = Rack::Request.new env
if slide_path? request
change_slide request if presenter?(request)
[ 204, {}, [] ]
else
@app.call env
end
end
protected |
Respond only to requests for |
def slide_path?(request)
request.path == '/slide'
end |
Match the key supplied in the request with the key used when the middlware was configured. |
def presenter?(request)
request.params['key'] == @key
end |
Grab the current slide number from the |
def change_slide(request)
Pusher['presenter'].trigger('slide_change', {
'slide' => request.params['number']
})
end
end |