showoff-pusher 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source :rubygems
2
+
3
+ gem "showoff"
4
+ gem "pusher"
@@ -0,0 +1,58 @@
1
+ Remotely drive your ShowOff presentation on remote users' terminals.
2
+
3
+ ## Setup
4
+ This gem is preconfigured to use the Heroku addon format for Pusher configs. These instructions assume you've already set up your ShowOff presentation for Heroku (`showoff heroku`).
5
+
6
+ ### Install Pusher addon
7
+
8
+ ```bash
9
+ heroku addons:add pusher
10
+ heroku config
11
+ # => PUSHER_SOCKET_URL => ws://ws.pusherapp.com:80/app/PUSHER_SOCKET_ID
12
+ # => PUSHER_URL => http://PUSHER_KEY:PUSHER_SECRET@api.pusherapp.com/apps/PUSHER_APP_ID
13
+ ```
14
+
15
+ ### Add showoff-pusher to your Gemfile
16
+
17
+ ```ruby
18
+ gem 'showoff-pusher'
19
+ ```
20
+
21
+ ### Add ShowOff::Pusher to your config.ru rackup file
22
+
23
+ ```ruby
24
+ require "showoff"
25
+ require "showoff/pusher"
26
+
27
+ use ShowOff::Pusher
28
+ run ShowOff.new
29
+ ```
30
+
31
+ ### Load the required javascripts in your first slide
32
+
33
+ ```markdown
34
+ !SLIDE
35
+ # My Presentation #
36
+
37
+ <script src="http://js.pusherapp.com/1.9/pusher.min.js"></script>
38
+ <script src="/javascripts/pusher.js"></script>
39
+ ```
40
+
41
+ ### Optional: Customize your secret
42
+
43
+ ```bash
44
+ heroku config:add SHOWOFF_SECRET='some_super_secret_key'
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ In your browser, visit the following URL to control the presentation:
50
+
51
+ `http://myapp.herokuapp.com/presenter?presenter=SHOWOFF_SECRET`
52
+
53
+ By default, `SHOWOFF_SECRET` is `PleaseChangeMe`.
54
+
55
+ Your users will be able to follow along with the presentation by visiting `http://myapp.herokuapp.com/`
56
+
57
+ ## Notes
58
+ Adapted from lmarburger's gist: https://gist.github.com/1180118
@@ -0,0 +1,59 @@
1
+ require 'showoff'
2
+ require 'pusher'
3
+ require 'uri'
4
+
5
+ class ShowOff < Sinatra::Application
6
+ class Pusher
7
+ def initialize(app)
8
+ @app = app
9
+ @secret = ENV['SHOWOFF_SECRET'] || 'PleaseChangeMe'
10
+ if ENV['PUSHER_URL']
11
+ @pusher_uri = URI.parse(ENV['PUSHER_URL'])
12
+ ::Pusher.app_id = @pusher_uri.path.split('/').last
13
+ ::Pusher.key = @pusher_uri.user
14
+ ::Pusher.secret = @pusher_uri.password
15
+ else
16
+ log_disabled
17
+ end
18
+ end
19
+
20
+ def call(env)
21
+ req = Rack::Request.new(env)
22
+
23
+ if ENV['PUSHER_URL']
24
+ if req.path == '/slide'
25
+ if req.params['sekret'] == @secret
26
+ params = { 'slide' => req.params['num'].to_i }
27
+ params['incr'] = req.params['incr'].to_i if req.params['incr']
28
+ ::Pusher['presenter'].trigger('slide_change', params)
29
+ end
30
+
31
+ [ 204, {}, [] ]
32
+ elsif req.path == '/javascripts/pusher.js'
33
+ [200, {'Content-Type' => 'application/javascript'}, pusher_js]
34
+ else
35
+ @app.call env
36
+ end
37
+ else
38
+ log_disabled
39
+ @app.call env
40
+ end
41
+ end
42
+
43
+ def log_disabled
44
+ puts "PUSHER_URL is not defined. ShowOff::Pusher is disabled."
45
+ end
46
+
47
+ def pusher_js
48
+ @template ||= File.read(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'views', 'pusher.js.erb')))
49
+ ERB.new(@template).result
50
+ end
51
+
52
+ def self.socket
53
+ @pusher_socket ||= URI.parse(ENV['PUSHER_SOCKET_URL']).path.split('/').last
54
+ rescue
55
+ puts "Invalid PUSHER_SOCKET_URL"
56
+ ''
57
+ end
58
+ end
59
+ end
@@ -0,0 +1 @@
1
+ SHOWOFF_PUSHER_VERSION = "0.0.1"
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require 'showoff/pusher/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "showoff-pusher"
7
+ s.version = SHOWOFF_PUSHER_VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.summary = "Use Pusher to drive your Showoff presentations on remote machines."
10
+ s.email = "blakesgentry@gmail.com"
11
+ s.homepage = "http://github.com/bgentry/showoff-pusher"
12
+ s.description = "Use Pusher to drive your Showoff presentations on remote machines."
13
+ s.authors = ['Blake Gentry', 'Larry Marburger']
14
+
15
+ s.rubyforge_project = "showoff-pusher"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.require_paths = ["lib"]
19
+
20
+ s.add_dependency("showoff", "~> 0.7.0")
21
+ s.add_dependency("pusher", "~> 0.8.3")
22
+ end
@@ -0,0 +1,56 @@
1
+ function setupPusher(){
2
+ var presenter = /presenter=([^&]*)/.exec(window.location.search),
3
+ sekret = presenter && presenter[1];
4
+
5
+ if (sekret) {
6
+ $(function() {
7
+ $('body').bind('showoff:show', function(e) {
8
+ console.debug("EVENT: " + slidenum);
9
+ $.post('/slide', { sekret: sekret, num: slidenum });
10
+ });
11
+ $('body').bind('showoff:incr', function(e) {
12
+ console.debug("INCREMENT: " + e.slidenum + ' ' + e.incr);
13
+ $.post('/slide', { sekret: sekret, num: slidenum, incr: e.incr });
14
+ });
15
+ });
16
+
17
+ } else {
18
+ new Pusher('<%= ShowOff::Pusher.socket %>')
19
+ .subscribe('presenter')
20
+ .bind('slide_change', function(data) {
21
+ Pusher.log('slide_change', data.slide);
22
+ if (data.slide != slidenum){
23
+ if (data.slide == (slidenum - 1)) {
24
+ gotoSlideBack(data.slide);
25
+ } else {
26
+ gotoSlide(data.slide);
27
+ }
28
+ }
29
+ if (typeof data.incr != 'undefined') {
30
+ while(incrCurr <= data.incr) {
31
+ showIncremental(incrCurr);
32
+ incrCurr++;
33
+ }
34
+ }
35
+ });
36
+ }
37
+ }
38
+
39
+ function gotoSlideBack(slideNum) {
40
+ slidenum = parseInt(slideNum)
41
+ if (!isNaN(slidenum)) {
42
+ showSlide(true)
43
+ }
44
+ }
45
+
46
+ function checkForPusher() {
47
+ setTimeout(function(){
48
+ if (typeof Pusher != 'undefined') {
49
+ setupPusher();
50
+ } else {
51
+ checkForPusher()
52
+ }
53
+ }, 250);
54
+ }
55
+
56
+ checkForPusher();
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: showoff-pusher
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Blake Gentry
9
+ - Larry Marburger
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2011-09-27 00:00:00.000000000Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: showoff
17
+ requirement: &70251653980700 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 0.7.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *70251653980700
26
+ - !ruby/object:Gem::Dependency
27
+ name: pusher
28
+ requirement: &70251653980080 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.8.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *70251653980080
37
+ description: Use Pusher to drive your Showoff presentations on remote machines.
38
+ email: blakesgentry@gmail.com
39
+ executables: []
40
+ extensions: []
41
+ extra_rdoc_files: []
42
+ files:
43
+ - Gemfile
44
+ - Readme.md
45
+ - lib/showoff/pusher.rb
46
+ - lib/showoff/pusher/version.rb
47
+ - showoff-pusher.gemspec
48
+ - views/pusher.js.erb
49
+ homepage: http://github.com/bgentry/showoff-pusher
50
+ licenses: []
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ requirements: []
68
+ rubyforge_project: showoff-pusher
69
+ rubygems_version: 1.8.10
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Use Pusher to drive your Showoff presentations on remote machines.
73
+ test_files: []