2012-06-08 05:21:14 +02:00
|
|
|
var express = require('express');
|
|
|
|
var fs = require('fs');
|
|
|
|
var io = require('socket.io');
|
|
|
|
var _ = require('underscore');
|
2012-06-18 00:45:00 +02:00
|
|
|
var Mustache = require('mustache');
|
2012-06-08 05:21:14 +02:00
|
|
|
|
|
|
|
var app = express.createServer();
|
|
|
|
var staticDir = express.static;
|
|
|
|
|
|
|
|
io = io.listen(app);
|
|
|
|
|
|
|
|
var opts = {
|
2012-07-01 22:43:43 +02:00
|
|
|
port : 1947,
|
|
|
|
baseDir : __dirname + '/../../'
|
2012-06-08 05:21:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
io.sockets.on('connection', function(socket) {
|
2012-07-01 22:43:43 +02:00
|
|
|
socket.on('slidechanged', function(slideData) {
|
|
|
|
socket.broadcast.emit('slidedata', slideData);
|
|
|
|
});
|
2012-06-08 05:21:14 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
app.configure(function() {
|
2012-07-10 03:00:51 +02:00
|
|
|
[ 'css', 'js', 'plugin', 'lib' ].forEach(function(dir) {
|
2012-07-01 22:43:43 +02:00
|
|
|
app.use('/' + dir, staticDir(opts.baseDir + dir));
|
|
|
|
});
|
2012-06-08 05:21:14 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
app.get("/", function(req, res) {
|
2012-07-01 22:43:43 +02:00
|
|
|
fs.createReadStream(opts.baseDir + '/index.html').pipe(res);
|
2012-06-08 05:21:14 +02:00
|
|
|
});
|
|
|
|
|
2012-07-01 22:56:06 +02:00
|
|
|
app.get("/notes/:socketId", function(req, res) {
|
2012-06-18 00:45:00 +02:00
|
|
|
|
2012-07-10 03:00:51 +02:00
|
|
|
fs.readFile(opts.baseDir + 'plugin/slidenotes/notes.html', function(err, data) {
|
2012-07-01 22:43:43 +02:00
|
|
|
res.send(Mustache.to_html(data.toString(), {
|
|
|
|
socketId : req.params.socketId
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
// fs.createReadStream(opts.baseDir + 'slidenotes/notes.html').pipe(res);
|
2012-06-08 05:21:14 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// Actually listen
|
|
|
|
app.listen(opts.port || null);
|
|
|
|
|
2012-07-02 00:37:29 +02:00
|
|
|
console.log("Open the slides at http://localhost" + (opts.port ? (':' + opts.port) : '') + " and look for a link to the speaker notes in the console");
|
|
|
|
console.log("Advance through your slides and your notes will advance automatically");
|