From 54f1fcf381dcf23e54f2b942268aa799969fa9ea Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Mon, 9 Jul 2012 21:30:54 -0400 Subject: slidenotes becomes speakernotes to match wording in readme --- plugin/speakernotes/client.js | 35 +++++++++++++ plugin/speakernotes/index.js | 55 +++++++++++++++++++++ plugin/speakernotes/notes.html | 109 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 199 insertions(+) create mode 100644 plugin/speakernotes/client.js create mode 100644 plugin/speakernotes/index.js create mode 100644 plugin/speakernotes/notes.html (limited to 'plugin/speakernotes') diff --git a/plugin/speakernotes/client.js b/plugin/speakernotes/client.js new file mode 100644 index 0000000..1aba8b8 --- /dev/null +++ b/plugin/speakernotes/client.js @@ -0,0 +1,35 @@ +(function() { + // don't emit events from inside the previews themselves + if ( window.location.search.match( /receiver/gi ) ) { return; } + + var socket = io.connect(window.location.origin); + var socketId = Math.random().toString().slice(2); + + console.log('View slide notes at ' + window.location.origin + '/notes/' + socketId); + + Reveal.addEventListener( 'slidechanged', function( event ) { + var nextindexh; + var nextindexv; + var slideElement = event.currentSlide; + + if (slideElement.nextElementSibling && slideElement.parentNode.nodeName == 'SECTION') { + nextindexh = event.indexh; + nextindexv = event.indexv + 1; + } else { + nextindexh = event.indexh + 1; + nextindexv = 0; + } + + var notes = slideElement.querySelector('aside.notes'); + var slideData = { + notes : notes ? notes.innerHTML : '', + indexh : event.indexh, + indexv : event.indexv, + nextindexh : nextindexh, + nextindexv : nextindexv, + socketId : socketId + }; + + socket.emit('slidechanged', slideData); + } ); +}()); diff --git a/plugin/speakernotes/index.js b/plugin/speakernotes/index.js new file mode 100644 index 0000000..e8c8023 --- /dev/null +++ b/plugin/speakernotes/index.js @@ -0,0 +1,55 @@ +var express = require('express'); +var fs = require('fs'); +var io = require('socket.io'); +var _ = require('underscore'); +var Mustache = require('mustache'); + +var app = express.createServer(); +var staticDir = express.static; + +io = io.listen(app); + +var opts = { + port : 1947, + baseDir : __dirname + '/../../' +}; + +io.sockets.on('connection', function(socket) { + socket.on('slidechanged', function(slideData) { + socket.broadcast.emit('slidedata', slideData); + }); +}); + +app.configure(function() { + [ 'css', 'js', 'plugin', 'lib' ].forEach(function(dir) { + app.use('/' + dir, staticDir(opts.baseDir + dir)); + }); +}); + +app.get("/", function(req, res) { + fs.createReadStream(opts.baseDir + '/index.html').pipe(res); +}); + +app.get("/notes/:socketId", function(req, res) { + + fs.readFile(opts.baseDir + 'plugin/speakernotes/notes.html', function(err, data) { + res.send(Mustache.to_html(data.toString(), { + socketId : req.params.socketId + })); + }); + // fs.createReadStream(opts.baseDir + 'speakernotes/notes.html').pipe(res); +}); + +// Actually listen +app.listen(opts.port || null); + +var brown = '\033[33m', + green = '\033[32m', + reset = '\033[0m'; + +var slidesLocation = "http://localhost" + ( opts.port ? ( ':' + opts.port ) : '' ); + +console.log( brown + "reveal.js - Speaker Notes" + reset ); +console.log( "1. Open the slides at " + green + slidesLocation + reset ); +console.log( "2. Click on the link your JS console to go to the notes page" ); +console.log( "3. Advance through your slides and your notes will advance automatically" ); diff --git a/plugin/speakernotes/notes.html b/plugin/speakernotes/notes.html new file mode 100644 index 0000000..88924c0 --- /dev/null +++ b/plugin/speakernotes/notes.html @@ -0,0 +1,109 @@ + + + + + + reveal.js - Slide Notes + + + + + + +
+ +
+ +
+ + UPCOMING: +
+
+ + + + + + + -- cgit v1.2.3