-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
switched for rendering to express framework
- Loading branch information
1 parent
4d89110
commit f0777d9
Showing
4 changed files
with
40 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
TODO: finish me |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<html> | ||
<head> | ||
<script src="/socket.io/socket.io.js"></script> | ||
<script> | ||
var socket = io.connect('http://localhost'); | ||
socket.on('entry', function (data) { | ||
console.log(data); | ||
}); | ||
</script> | ||
</head> | ||
|
||
<body> | ||
<%- body %> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,34 @@ | ||
var app = require('http').createServer(handler) | ||
var express = require('express') | ||
, app = express.createServer() | ||
, io = require('socket.io').listen(app) | ||
, fs = require('fs'); | ||
|
||
var stalker = require("./lib/stalker"); | ||
|
||
var port = process.env['PORT'] || 4444 ; | ||
|
||
app.listen(port); | ||
app.configure('development', function(){ | ||
app.use(express.static(__dirname + '/public')); | ||
app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); | ||
app.set('view engine', 'ejs'); | ||
}); | ||
|
||
function handler (req, res) { | ||
fs.readFile(__dirname + '/public/index.html', | ||
function (err, data) { | ||
if (err) { | ||
res.writeHead(500); | ||
return res.end('Error loading index.html'); | ||
} | ||
app.configure('production', function(){ | ||
app.use(express.static(__dirname + '/public')); | ||
app.use(express.errorHandler()); | ||
app.set('view engine', 'ejs'); | ||
}); | ||
|
||
res.writeHead(200); | ||
res.end(data); | ||
}); | ||
} | ||
app.listen(port); | ||
|
||
app.get('/', function (req, res) { | ||
res.render('index.ejs'); | ||
}); | ||
|
||
io.sockets.on('connection', function (socket) { | ||
new stalker("test.file", function(content){ | ||
socket.emit('entry', { content: content }); | ||
}); | ||
}); | ||
}); | ||
|
||
|