2012-06-08 03:21:14 +00:00
|
|
|
var express = require('express');
|
|
|
|
var fs = require('fs');
|
|
|
|
var io = require('socket.io');
|
|
|
|
var _ = require('underscore');
|
2012-06-17 22:45:00 +00:00
|
|
|
var Mustache = require('mustache');
|
2012-06-08 03:21:14 +00:00
|
|
|
|
|
|
|
var app = express.createServer();
|
|
|
|
var staticDir = express.static;
|
|
|
|
|
|
|
|
io = io.listen(app);
|
|
|
|
|
|
|
|
var opts = {
|
2012-07-01 20:43:43 +00:00
|
|
|
port : 1947,
|
|
|
|
baseDir : __dirname + '/../../'
|
2012-06-08 03:21:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
io.sockets.on('connection', function(socket) {
|
2012-07-01 20:43:43 +00:00
|
|
|
socket.on('slidechanged', function(slideData) {
|
|
|
|
socket.broadcast.emit('slidedata', slideData);
|
|
|
|
});
|
2012-06-08 03:21:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
app.configure(function() {
|
2012-07-10 01:00:51 +00:00
|
|
|
[ 'css', 'js', 'plugin', 'lib' ].forEach(function(dir) {
|
2012-07-01 20:43:43 +00:00
|
|
|
app.use('/' + dir, staticDir(opts.baseDir + dir));
|
|
|
|
});
|
2012-06-08 03:21:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
app.get("/", function(req, res) {
|
2012-07-01 20:43:43 +00:00
|
|
|
fs.createReadStream(opts.baseDir + '/index.html').pipe(res);
|
2012-06-08 03:21:14 +00:00
|
|
|
});
|
|
|
|
|
2012-07-01 20:56:06 +00:00
|
|
|
app.get("/notes/:socketId", function(req, res) {
|
2012-06-17 22:45:00 +00:00
|
|
|
|
2012-07-10 01:30:54 +00:00
|
|
|
fs.readFile(opts.baseDir + 'plugin/speakernotes/notes.html', function(err, data) {
|
2012-07-01 20:43:43 +00:00
|
|
|
res.send(Mustache.to_html(data.toString(), {
|
|
|
|
socketId : req.params.socketId
|
|
|
|
}));
|
|
|
|
});
|
2012-07-10 01:30:54 +00:00
|
|
|
// fs.createReadStream(opts.baseDir + 'speakernotes/notes.html').pipe(res);
|
2012-06-08 03:21:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Actually listen
|
|
|
|
app.listen(opts.port || null);
|
|
|
|
|
2012-07-10 01:15:01 +00:00
|
|
|
var brown = '\033[33m',
|
|
|
|
green = '\033[32m',
|
|
|
|
reset = '\033[0m';
|
|
|
|
|
|
|
|
var slidesLocation = "http://localhost" + ( opts.port ? ( ':' + opts.port ) : '' );
|
|
|
|
|
2012-07-10 01:30:54 +00:00
|
|
|
console.log( brown + "reveal.js - Speaker Notes" + reset );
|
2012-07-10 01:15:01 +00:00
|
|
|
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" );
|