Permalink
Browse files

Initial Commit

  • Loading branch information...
robrighter committed Aug 9, 2012
0 parents commit 1933df6f337f81e667a59dd1ffd80ff4b495a837
Showing with 820 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +10 −0 Makefile
  3. +1 −0 config.json
  4. +19 −0 package.json
  5. +89 −0 server.js
  6. +622 −0 static/css/style.css
  7. +15 −0 static/js/script.js
  8. +7 −0 test/stub.js
  9. +2 −0 views/404.jade
  10. +7 −0 views/500.jade
  11. +6 −0 views/index.jade
  12. +41 −0 views/layout.jade
@@ -0,0 +1 @@
+node_modules
@@ -0,0 +1,10 @@
+TESTS = test/*.js
+
+test:
+ @NODE_ENV=test ./node_modules/.bin/mocha \
+ --require should \
+ --reporter list \
+ --slow 20 \
+ --growl \
+ $(TESTS)
+.PHONY: test
@@ -0,0 +1 @@
+{ "version": "v0.6.6" }
@@ -0,0 +1,19 @@
+{
+ "name": "YOUR-PROJECT-NAME-HERE",
+ "description": "YOUR PROJECT DESCRIPTION HERE",
+ "author": "YOUR NAME <your@emailaddress.com>",
+ "version": "0.0.1",
+ "dependencies": {
+ "connect": "1.8.5",
+ "express": "2.5.2",
+ "jade": "0.20.0",
+ "mongoose": "2.4.8",
+ "socket.io": "0.8.7"
+ },
+ "devDependencies": {
+ "vows": "0.5.x",
+ "mocha": "*",
+ "should": "*"
+ },
+ "engine": "node >= 0.6.6"
+}
@@ -0,0 +1,89 @@
+//setup Dependencies
+var connect = require('connect')
+ , express = require('express')
+ , io = require('socket.io')
+ , port = (process.env.PORT || 8081);
+
+//Setup Express
+var server = express.createServer();
+server.configure(function(){
+ server.set('views', __dirname + '/views');
+ server.set('view options', { layout: false });
+ server.use(connect.bodyParser());
+ server.use(express.cookieParser());
+ server.use(express.session({ secret: "shhhhhhhhh!"}));
+ server.use(connect.static(__dirname + '/static'));
+ server.use(server.router);
+});
+
+//setup the errors
+server.error(function(err, req, res, next){
+ if (err instanceof NotFound) {
+ res.render('404.jade', { locals: {
+ title : '404 - Not Found'
+ ,description: ''
+ ,author: ''
+ ,analyticssiteid: 'XXXXXXX'
+ },status: 404 });
+ } else {
+ res.render('500.jade', { locals: {
+ title : 'The Server Encountered an Error'
+ ,description: ''
+ ,author: ''
+ ,analyticssiteid: 'XXXXXXX'
+ ,error: err
+ },status: 500 });
+ }
+});
+server.listen( port);
+
+//Setup Socket.IO
+var io = io.listen(server);
+io.sockets.on('connection', function(socket){
+ console.log('Client Connected');
+ socket.on('message', function(data){
+ socket.broadcast.emit('server_message',data);
+ socket.emit('server_message',data);
+ });
+ socket.on('disconnect', function(){
+ console.log('Client Disconnected.');
+ });
+});
+
+
+///////////////////////////////////////////
+// Routes //
+///////////////////////////////////////////
+
+/////// ADD ALL YOUR ROUTES HERE /////////
+
+server.get('/', function(req,res){
+ res.render('index.jade', {
+ locals : {
+ title : 'Your Page Title'
+ ,description: 'Your Page Description'
+ ,author: 'Your Name'
+ ,analyticssiteid: 'XXXXXXX'
+ }
+ });
+});
+
+
+//A Route for Creating a 500 Error (Useful to keep around)
+server.get('/500', function(req, res){
+ throw new Error('This is a 500 Error');
+});
+
+//The 404 Route (ALWAYS Keep this as the last route)
+server.get('/*', function(req, res){
+ throw new NotFound;
+});
+
+function NotFound(msg){
+ this.name = 'NotFound';
+ Error.call(this, msg);
+ Error.captureStackTrace(this, arguments.callee);
+}
+
+
+console.log('Listening on http://0.0.0.0:' + port );
Oops, something went wrong.

0 comments on commit 1933df6

Please sign in to comment.