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 = {
|
|
|
|
port : 1947,
|
2012-07-01 20:38:49 +00:00
|
|
|
baseDir : __dirname + '/../../'
|
2012-06-08 03:21:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
io.sockets.on('connection', function(socket) {
|
|
|
|
socket.on('slidechanged', function(slideData) {
|
|
|
|
socket.broadcast.emit('slidedata', slideData);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
app.configure(function() {
|
|
|
|
[ 'css', 'assets', 'js', 'lib' ].forEach(function(dir) {
|
|
|
|
app.use('/' + dir, staticDir(opts.baseDir + dir));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
app.get("/", function(req, res) {
|
|
|
|
fs.createReadStream(opts.baseDir + '/index.html').pipe(res);
|
|
|
|
});
|
|
|
|
|
2012-06-17 22:45:00 +00:00
|
|
|
app.get("/_notes/:socketId", function(req, res) {
|
|
|
|
|
|
|
|
fs.readFile(opts.baseDir + 'slidenotes/notes.html', function(err, data) {
|
|
|
|
res.send(Mustache.to_html(data.toString(), {
|
|
|
|
socketId : req.params.socketId
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
// fs.createReadStream(opts.baseDir + 'slidenotes/notes.html').pipe(res);
|
2012-06-08 03:21:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Actually listen
|
|
|
|
app.listen(opts.port || null);
|
|
|
|
|
|
|
|
console.log("Your slides are at http://localhost" + (opts.port ? (':' + opts.port) : ''));
|
|
|
|
console.log("Your notes are at http://localhost" + (opts.port ? (':' + opts.port) : '') + '/_notes');
|
2012-06-17 22:45:00 +00:00
|
|
|
console.log("Advance through your slides and your speaker notes will advance automatically");
|