1 var http = require('http');
2 var express = require('express');
3 var fs = require('fs');
4 var io = require('socket.io');
5 var _ = require('underscore');
6 var Mustache = require('mustache');
9 var staticDir = express.static;
10 var server = http.createServer(app);
16 baseDir : __dirname + '/../../'
19 io.on( 'connection', function( socket ) {
21 socket.on( 'new-subscriber', function( data ) {
22 socket.broadcast.emit( 'new-subscriber', data );
25 socket.on( 'statechanged', function( data ) {
26 socket.broadcast.emit( 'statechanged', data );
31 [ 'css', 'js', 'images', 'plugin', 'lib' ].forEach( function( dir ) {
32 app.use( '/' + dir, staticDir( opts.baseDir + dir ) );
35 app.get('/', function( req, res ) {
37 res.writeHead( 200, { 'Content-Type': 'text/html' } );
38 fs.createReadStream( opts.baseDir + '/index.html' ).pipe( res );
42 app.get( '/notes/:socketId', function( req, res ) {
44 fs.readFile( opts.baseDir + 'plugin/notes-server/notes.html', function( err, data ) {
45 res.send( Mustache.to_html( data.toString(), {
46 socketId : req.params.socketId
53 server.listen( opts.port || null );
55 var brown = '\033[33m',
59 var slidesLocation = 'http://localhost' + ( opts.port ? ( ':' + opts.port ) : '' );
61 console.log( brown + 'reveal.js - Speaker Notes' + reset );
62 console.log( '1. Open the slides at ' + green + slidesLocation + reset );
63 console.log( '2. Click on the link your JS console to go to the notes page' );
64 console.log( '3. Advance through your slides and your notes will advance automatically' );