summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2012-08-06 16:21:00 -0500
committerKyle Kaminski <kyle@kkaminsk.com>2012-08-06 16:21:00 -0500
commit97683cdde3bfa29ed61850387c46f9a8dbc8da7f (patch)
tree972ac4b7bfb53aa2415d1740ebf5205b1fde6635
parent8197b662f43999304f853db21dc2bb18c2959a58 (diff)
downloadfubar-97683cdde3bfa29ed61850387c46f9a8dbc8da7f.tar.gz
fubar-97683cdde3bfa29ed61850387c46f9a8dbc8da7f.tar.bz2
fubar-97683cdde3bfa29ed61850387c46f9a8dbc8da7f.zip
adapt to new API changes
small and they were painful, stylus wasn't working, the way we pass in local variables to jade changed, e.g. now I had to pass {'foo': 'bar'} where previously I did { locals {'foo': 'bar'} }
-rw-r--r--notes.txt3
-rw-r--r--protoype/app.js14
-rw-r--r--protoype/package.json20
-rw-r--r--protoype/views/index.jade27
-rw-r--r--protoype/views/layout.jade4
5 files changed, 43 insertions, 25 deletions
diff --git a/notes.txt b/notes.txt
index 886fc00..97bef37 100644
--- a/notes.txt
+++ b/notes.txt
@@ -18,3 +18,6 @@ var bar = foo.slice(0);
who responds/listens to those, so we will see statements
such eventer.on('foo', somehandler)
+[mongodb]
+$ mongo; show dbs; use nodejs1; show collections; db.getCollectionNames(), db.users.find(), db.users.remove(), db.users.drop()
+
diff --git a/protoype/app.js b/protoype/app.js
index 2d55388..57d2f86 100644
--- a/protoype/app.js
+++ b/protoype/app.js
@@ -15,8 +15,9 @@ var crypto = require('crypto')
var driver = require('./router/driver.js');
/* var activeusers = require('./activeusers'); */
var connected_clients = {};
+var path = require('path');
-var app = express.createServer();
+var app = express();
app.configure(function() {
app.set('views', __dirname + '/views');
@@ -30,7 +31,8 @@ app.configure(function() {
app.use(express.cookieParser()); /* req.session can be populated with user defined vars */
app.use(express.session({ secret: "keyboard cat", store: new RedisStore() }));
app.use(app.router);
- app.use(express.static(__dirname + '/public'));
+ app.use(require('stylus').middleware(__dirname + '/public'));
+ app.use(express.static(path.join(__dirname, 'public')));
});
app.post('/create', function(req, res) {
@@ -47,6 +49,10 @@ app.post('/create', function(req, res) {
res.redirect('/');
});
+/*
+ * tets drive: curl -d 'tag=unclescotty&id=brotato' localhost:8081/login
+ *
+ */
app.post('/login', function(req, res) {
db.users.find({tag: req.param('tag')}, function(err, thing) {
if (err || !thing || thing.length == 0) {
@@ -131,10 +137,8 @@ app.get('/', function(req, res) {
util.log('[index pn] nothing in db or error retrieving');
res.render('index', {
- locals: {
title: 'Challenger 2.0',
users: items
- }
});
});
});
@@ -143,7 +147,7 @@ app.get('/', function(req, res) {
app.get('/newuser', driver.newuser);
app.listen(8081, function() {
- util.log(util.format('[server] listening on port %d in %s mode', this.address().port, this.settings.env));
+ util.log(util.format('[server] listening on port %d in %s mode', this.address().port, app.settings.env));
})
.on('error', function(e) {
util.log('[server] failed creating server, errno: ' + e.errno);
diff --git a/protoype/package.json b/protoype/package.json
index ce83489..4928e96 100644
--- a/protoype/package.json
+++ b/protoype/package.json
@@ -1,9 +1,15 @@
{
- "name": "application-name"
- , "version": "0.0.1"
- , "private": true
- , "dependencies": {
- "express": "2.5.11"
- , "jade": ">= 0.0.1"
+ "name": "challenger-2.0",
+ "version": "0.0.1",
+ "private": true,
+ "scripts": {
+ "start": "node app"
+ },
+ "dependencies": {
+ "express": "3.0.0rc2",
+ "jade": "*",
+ "stylus": "*",
+ "mongojs": "*",
+ "connect-redis": "*"
}
-} \ No newline at end of file
+}
diff --git a/protoype/views/index.jade b/protoype/views/index.jade
index fba191d..4c984bc 100644
--- a/protoype/views/index.jade
+++ b/protoype/views/index.jade
@@ -1,13 +1,16 @@
-h2(style='border-bottom: dashed #FF9900; letter-spacing: -2px')= title
-p Welcome to #{title}. Find your opponent, and get ready!
+extends layout
-h4(style='background-color: #99FF66; padding: 2px') User List
-- each user in users
- #listentry <u>#{user.tag}</u> >> #{user.location.loc} |
- - if (user.status == 'online')
- span(style='color: green; font-weight: bold')= user.status
- - else
- span(style='color: red; font-weight: bold')= user.status
- | <br />#{user.vehicle.year} #{user.vehicle.make} #{user.vehicle.model}
- | <br />mods: #{user.vehicle.desc}<br />
- span(style='color: gray; font-style: italic')= user.userinfo.sig
+block content
+ h2(style='border-bottom: dashed #FF9900; letter-spacing: -2px')= title
+ p Welcome to #{title}. Find your opponent, and get ready!
+
+ h4(style='background-color: #99FF66; padding: 2px') User List
+ - each user in users
+ #listentry <u>#{user.tag}</u> >> #{user.location.loc} |
+ - if (user.status == 'online')
+ span(style='color: green; font-weight: bold')= user.status
+ - else
+ span(style='color: red; font-weight: bold')= user.status
+ | <br />#{user.vehicle.year} #{user.vehicle.make} #{user.vehicle.model}
+ | <br />mods: #{user.vehicle.desc}<br />
+ span(style='color: gray; font-style: italic')= user.userinfo.sig
diff --git a/protoype/views/layout.jade b/protoype/views/layout.jade
index c7139b7..e44baef 100644
--- a/protoype/views/layout.jade
+++ b/protoype/views/layout.jade
@@ -5,5 +5,7 @@ html
meta(http-equiv='Content-Type', content='text/html; charset=UTF-8')
link(rel='stylesheet', href='/stylesheets/style.css')
// body gets passed in here from *.jade? the '!=' outputs unescaped
- body!= body
+ //body!= body
+ body
+ block content