Skip to content
Browse files

Initial Commit

  • Loading branch information...
0 parents commit d2133ebad94c28bfb5be0161b917319f4011f19c @robrighter committed Aug 9, 2012
Showing with 489 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. +291 −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
1 .gitignore
@@ -0,0 +1 @@
+node_modules
10 Makefile
@@ -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
1 config.json
@@ -0,0 +1 @@
+{ "version": "v0.6.6" }
19 package.json
@@ -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"
+}
89 server.js
@@ -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 );
291 static/css/style.css
@@ -0,0 +1,291 @@
+/*
+ * HTML5 Boilerplate
+ *
+ * What follows is the result of much research on cross-browser styling.
+ * Credit left inline and big thanks to Nicolas Gallagher, Jonathan Neal,
+ * Kroc Camen, and the H5BP dev community and team.
+ */
+
+/* ==========================================================================
+ Base styles: opinionated defaults
+ ========================================================================== */
+
+html,
+button,
+input,
+select,
+textarea {
+ color: #222;
+}
+
+body {
+ font-size: 1em;
+ line-height: 1.4;
+}
+
+a {
+ color: #00e;
+}
+
+a:visited {
+ color: #551a8b;
+}
+
+a:hover {
+ color: #06e;
+}
+
+/*
+ * Remove text-shadow in selection highlight: h5bp.com/i
+ * These selection declarations have to be separate.
+ * Customize the background color to match your design.
+ */
+
+::-moz-selection {
+ background: #b3d4fc;
+ text-shadow: none;
+}
+
+::selection {
+ background: #b3d4fc;
+ text-shadow: none;
+}
+
+/*
+ * A better looking default horizontal rule
+ */
+
+hr {
+ display: block;
+ height: 1px;
+ border: 0;
+ border-top: 1px solid #ccc;
+ margin: 1em 0;
+ padding: 0;
+}
+
+/*
+ * Remove the gap between images and the bottom of their containers: h5bp.com/i/440
+ */
+
+img {
+ vertical-align: middle;
+}
+
+/*
+ * Remove default fieldset styles.
+ */
+
+fieldset {
+ border: 0;
+ margin: 0;
+ padding: 0;
+}
+
+/*
+ * Allow only vertical resizing of textareas.
+ */
+
+textarea {
+ resize: vertical;
+}
+
+/* ==========================================================================
+ Chrome Frame prompt
+ ========================================================================== */
+
+.chromeframe {
+ margin: 0.2em 0;
+ background: #ccc;
+ color: #000;
+ padding: 0.2em 0;
+}
+
+/* ==========================================================================
+ Author's custom styles
+ ========================================================================== */
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* ==========================================================================
+ Helper classes
+ ========================================================================== */
+
+/*
+ * Image replacement
+ */
+
+.ir {
+ border: 0;
+ font: 0/0 a;
+ text-shadow: none;
+ color: transparent;
+ background-color: transparent;
+}
+
+/*
+ * Hide from both screenreaders and browsers: h5bp.com/u
+ */
+
+.hidden {
+ display: none !important;
+ visibility: hidden;
+}
+
+/*
+ * Hide only visually, but have it available for screenreaders: h5bp.com/v
+ */
+
+.visuallyhidden {
+ border: 0;
+ clip: rect(0 0 0 0);
+ height: 1px;
+ margin: -1px;
+ overflow: hidden;
+ padding: 0;
+ position: absolute;
+ width: 1px;
+}
+
+/*
+ * Extends the .visuallyhidden class to allow the element to be focusable
+ * when navigated to via the keyboard: h5bp.com/p
+ */
+
+.visuallyhidden.focusable:active,
+.visuallyhidden.focusable:focus {
+ clip: auto;
+ height: auto;
+ margin: 0;
+ overflow: visible;
+ position: static;
+ width: auto;
+}
+
+/*
+ * Hide visually and from screenreaders, but maintain layout
+ */
+
+.invisible {
+ visibility: hidden;
+}
+
+/**
+ * Clearfix helper
+ * Used to contain floats: h5bp.com/q
+ */
+
+.clearfix:before,
+.clearfix:after {
+ content: "";
+ display: table;
+}
+
+.clearfix:after {
+ clear: both;
+}
+
+/*
+ * For IE 6/7 only
+ * Include this rule to trigger hasLayout and contain floats.
+ */
+
+.clearfix {
+ *zoom: 1;
+}
+
+/* ==========================================================================
+ EXAMPLE Media Queries for Responsive Design.
+ Theses examples override the primary ('mobile first') styles.
+ Modify as content requires.
+ ========================================================================== */
+
+@media only screen and (min-width: 35em) {
+ /* Style adjustments for viewports that meet the condition */
+}
+
+/* ==========================================================================
+ Print styles.
+ Inlined to avoid required HTTP connection: h5bp.com/r
+ ========================================================================== */
+
+@media print {
+ * {
+ background: transparent !important;
+ color: #000 !important; /* Black prints faster: h5bp.com/s */
+ box-shadow:none !important;
+ text-shadow: none !important;
+ }
+
+ a,
+ a:visited {
+ text-decoration: underline;
+ }
+
+ a[href]:after {
+ content: " (" attr(href) ")";
+ }
+
+ abbr[title]:after {
+ content: " (" attr(title) ")";
+ }
+
+ /*
+ * Don't show links for images, or javascript/internal links
+ */
+
+ .ir a:after,
+ a[href^="javascript:"]:after,
+ a[href^="#"]:after {
+ content: "";
+ }
+
+ pre,
+ blockquote {
+ border: 1px solid #999;
+ page-break-inside: avoid;
+ }
+
+ thead {
+ display: table-header-group; /* h5bp.com/t */
+ }
+
+ tr,
+ img {
+ page-break-inside: avoid;
+ }
+
+ img {
+ max-width: 100% !important;
+ }
+
+ @page {
+ margin: 0.5cm;
+ }
+
+ p,
+ h2,
+ h3 {
+ orphans: 3;
+ widows: 3;
+ }
+
+ h2,
+ h3 {
+ page-break-after: avoid;
+ }
+}
15 static/js/script.js
@@ -0,0 +1,15 @@
+/* Author: YOUR NAME HERE
+*/
+
+$(document).ready(function() {
+
+ var socket = io.connect();
+
+ $('#sender').bind('click', function() {
+ socket.emit('message', 'Message Sent on ' + new Date());
+ });
+
+ socket.on('server_message', function(data){
+ $('#receiver').append('<li>' + data + '</li>');
+ });
+});
7 test/stub.js
@@ -0,0 +1,7 @@
+describe('stub', function(){
+
+ describe('#test', function(){
+ it('should have some units tests')
+ })
+
+})
2 views/404.jade
@@ -0,0 +1,2 @@
+h1='Not Found'
+div='Sorry, the page you are looking for does not exist.'
7 views/500.jade
@@ -0,0 +1,7 @@
+!!! 5
+html
+ head
+ title='500 Error'
+ body
+ h1='The Server Encountered and Error'
+ div=error
6 views/index.jade
@@ -0,0 +1,6 @@
+extends layout
+
+block content
+ div
+ a(id='sender')='Send a Message'
+ ul(id='receiver')
41 views/layout.jade
@@ -0,0 +1,41 @@
+!!! 5
+//if lt IE 7
+ html.no-js.ie6.oldie(lang='en')
+//if IE 7
+ html.no-js.ie7.oldie(lang='en')
+//if IE 8
+ html.no-js.ie8.oldie(lang='en')
+//[if gt IE 8]><!
+html.no-js(lang='en')
+ //<![end if]
+ head
+ meta(charset='utf-8')
+ meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1')
+ title=title
+ meta(name="description", content=description)
+ meta(name="author", content=author)
+ meta(name="viewport", content='width=device-width, initial-scale=1')
+ link(rel='stylesheet', href='/css/style.css')
+ //-script(src='js/libs/modernizr-2.0.6.min.js')
+ body
+ block header
+
+ block content
+
+ block footer
+ footer
+ script(src='//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js')
+ script
+ window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\\/script>')
+ //-script(defer, src='js/plugins.js')
+ script(defer, src='/js/script.js')
+ script(defer, src='/socket.io/socket.io.js')
+ script
+ var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview'],['_trackPageLoadTime']];
+ (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
+ g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
+ s.parentNode.insertBefore(g,s)}(document,'script'));
+ //if lt IE 7
+ script(defer, src='//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.3/CFInstall.min.js')
+ script(defer)
+ window.attachEvent('onload',function(){CFInstall.check({mode:'overlay'})})

0 comments on commit d2133eb

Please sign in to comment.
Something went wrong with that request. Please try again.