Skip to content

Commit 333d5e8

Browse files
committed
Init Project
0 parents  commit 333d5e8

20 files changed

+409
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea/
2+
*.iml

initproject.bat

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
REM @echo off
2+
echo "Creating necessary folders..."
3+
mkdir .\models
4+
mkdir .\lib
5+
6+
echo "moveing code..."
7+
move .\templates\app\server.js .\server.js
8+
move .\templates\app\package.json .\package.json
9+
move .\templates\app\.gitignore .\.gitignore
10+
move .\templates\app\config.json .\config.json
11+
move .\templates\app\Makefile .\Makefile
12+
move .\templates\test .\test
13+
move .\templates\views .\views
14+
move .\templates\public .\public
15+
REM TODO move over the models
16+
17+
echo "Setting up dependencies from NPM..."
18+
npm install
19+
20+
echo "Removing stuff you don't want..."
21+
del /S /F .git
22+
del /S /F templates
23+
del README.md
24+
del initproject.sh
25+
del initproject.bat
26+
27+
echo "Initializing new git project..."
28+
git init
29+
git add .
30+
git commit -m"Initial Commit"

initproject.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
echo "Creating necessary folders..."
3+
mkdir ./models
4+
mkdir ./lib
5+
6+
echo "Copying code..."
7+
mv ./templates/app/server.js ./server.js
8+
mv ./templates/app/package.json ./package.json
9+
mv ./templates/app/.gitignore ./.gitignore
10+
mv ./templates/app/config.json ./config.json
11+
mv ./templates/app/Makefile ./Makefile
12+
mv ./templates/test ./test/
13+
mv ./templates/views ./views
14+
mv ./templates/public ./public
15+
# TODO copy over the models
16+
17+
echo "Setting up dependencies from NPM..."
18+
npm install
19+
20+
echo "Removing stuff you don't want..."
21+
rm -rf .git
22+
rm -rf templates
23+
rm README.md
24+
rm initproject.sh
25+
rm initproject.bat
26+
27+
echo "Initializing new git project..."
28+
git init
29+
git add .
30+
git commit -m"Initial Commit"

templates/app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

templates/app/Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
TESTS = test/*.js
2+
3+
test:
4+
@NODE_ENV=test ./node_modules/.bin/mocha \
5+
--require should \
6+
--reporter list \
7+
--slow 20 \
8+
--growl \
9+
$(TESTS)
10+
.PHONY: test

templates/app/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "version": "v0.6.6" }

templates/app/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "YOUR-PROJECT-NAME-HERE",
3+
"description": "YOUR PROJECT DESCRIPTION HERE",
4+
"author": "YOUR NAME <your@emailaddress.com>",
5+
"version": "0.0.1",
6+
"dependencies": {
7+
"connect": "2.8.1",
8+
"express": "3.3.1",
9+
"ejs": "0.8.4",
10+
"mongoose": "3.6.13",
11+
"socket.io": "0.9.16"
12+
},
13+
"devDependencies": {
14+
"vows": "0.7.0",
15+
"mocha": "1.12.0",
16+
"should": "1.2.2",
17+
"assert": "0.4.9",
18+
"expect": "0.0.2"
19+
},
20+
"engine": "node >= 0.9.6"
21+
}

templates/app/server.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//setup Dependencies
2+
var express = require('express')
3+
, io = require('socket.io')
4+
, http = require('http')
5+
, port = (process.env.PORT || 8081);
6+
7+
//Setup Express
8+
var app = express();
9+
10+
app.configure(function(){
11+
app.set('views', __dirname + '/views');
12+
app.set('view options', { layout: false });
13+
app.set('view engine', 'ejs');
14+
app.use(express.bodyParser());
15+
app.use(express.cookieParser());
16+
app.use(express.session({secret: "shhhhhhhhh!"}));
17+
app.use(express.static(__dirname, + '/public'));
18+
app.use(app.router);
19+
app.use(function(err, req, res, next){
20+
res.render('404', {title: "Sorry, page not found"});
21+
});
22+
});
23+
var server = http.createServer(app);
24+
25+
server.listen(port);
26+
27+
//Setup Socket.IO
28+
var io = io.listen(server);
29+
io.sockets.on('connection', function(socket){
30+
console.log('Client Connected');
31+
socket.on('message', function(data){
32+
socket.broadcast.emit('server_message',data);
33+
socket.emit('server_message',data);
34+
});
35+
socket.on('disconnect', function(){
36+
console.log('Client Disconnected.');
37+
});
38+
});
39+
40+
41+
// # ROUTES #
42+
43+
app.get('/', function(req,res){
44+
res.render('index');
45+
});
46+
47+
//A Route for Creating a 500 Error (Useful to keep around)
48+
app.get('/500', function(req, res){
49+
res.render('500', {title: "Internal server error!"});
50+
});
51+
52+
////The 404 Route (ALWAYS Keep this as the last route)
53+
app.get('/*', function(req, res){
54+
throw new NotFound;
55+
});
56+
57+
function NotFound(msg){
58+
this.name = 'NotFound';
59+
Error.call(this, msg);
60+
Error.captureStackTrace(this, arguments.callee);
61+
}
62+
63+
console.log('Server listening on: http://localhost:' + port );

templates/public/css/bootstrap-responsive.min.css

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/public/css/bootstrap.min.css

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)