Skip to content

Instantly share code, notes, and snippets.

@lmarburger
Created August 30, 2011 03:38
Show Gist options
  • Save lmarburger/1180118 to your computer and use it in GitHub Desktop.
Save lmarburger/1180118 to your computer and use it in GitHub Desktop.
Hack Showoff to remotely drive presentation
require "showoff"
require 'pusher'
Pusher.app_id = 'insert Pusher app id here'
Pusher.key = 'insert Pusher key here'
Pusher.secret = 'insert Pusher secret here'
class PresentationController
def initialize(app)
@app = app
end
def call(env)
req = Rack::Request.new(env)
if req.path == '/slide'
if req.params['sekret'] == 'SecurityThroughObscurityFTW'
Pusher['presenter'].trigger('slide_change', {
'slide' => req.params['num']
})
end
[ 204, {}, [] ]
else
@app.call env
end
end
end
use PresentationController
run ShowOff.new
// Copy pusher.js from http://js.pusherapp.com/1.9/pusher.min.js and dump here.
var presenter = /presenter=(.*)/.exec(window.location.search),
sekret = presenter && presenter[1];
if (sekret) {
$(function() {
$('body').bind('showoff:show', function() {
$.post('/slide', { sekret: sekret, num: slidenum });
});
});
} else {
// Enable pusher logging - don't include this in production
Pusher.log = function(message) {
if (window.console && window.console.log) window.console.log(message);
};
new Pusher('insert Pusher key here')
.subscribe('presenter')
.bind('slide_change', function(data) {
Pusher.log('slide_change', data.slide);
gotoSlide(data.slide);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment