initial commit

This commit is contained in:
Rob Dodson 2012-06-04 22:45:50 -07:00
commit b3035dba55
9 changed files with 109 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules

41
app.js Normal file
View File

@ -0,0 +1,41 @@
var express = require('express'),
app = express.createServer(),
io = require('socket.io').listen(app),
routes = require('./routes');
// Configuration
app.configure(function() {
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.configure('development', function() {
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function() {
app.use(express.errorHandler());
});
// Routes
app.listen(3000, function() {
console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
});
app.get('/', routes.index);
var status = "All is well.";
io.sockets.on('connection', function (socket) {
socket.emit('status', { status: status });
socket.on('reset', function (data) {
status = "War is imminent!";
socket.emit('status', { status: status });
});
});

13
package.json Normal file
View File

@ -0,0 +1,13 @@
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "~2.5.8",
"ejs": "~0.7.1",
"socket.io": "~0.9.6"
},
"engines": {
"node": "0.6.x"
}
}

8
public/css/main.css Normal file
View File

@ -0,0 +1,8 @@
body {
padding: 50px;
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
}
a {
color: #00B7FF;
}

4
public/js/libs/jquery.js vendored Normal file

File diff suppressed because one or more lines are too long

9
public/js/main.js Normal file
View File

@ -0,0 +1,9 @@
var socket = io.connect('http://localhost');
socket.on('status', function (data) {
$('#status').html(data.status);
});
$('#reset').click(function() {
socket.emit('reset');
});

7
routes/index.js Normal file
View File

@ -0,0 +1,7 @@
/*
* GET home page.
*/
exports.index = function(req, res) {
res.render('index')
};

2
views/index.ejs Normal file
View File

@ -0,0 +1,2 @@
<div id="status"></div>
<button id="reset">Reset!</button>

24
views/layout.ejs Normal file
View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Title</title>
<meta name="description" content="">
<meta name="author" content="">
<!-- HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- styles -->
<link href="/css/main.css" rel="stylesheet">
</head>
<body>
<%- body %>
<script src="/socket.io/socket.io.js"></script>
<script src="/js/libs/jquery.js"></script>
<script src="/js/main.js"></script>
</body>
</html>