Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactored repository base, added account signup page

  • Loading branch information...
commit 195097d2cc769b563b2a3337ec81d055f5d5e30d 1 parent 9453a15
@toantran authored
View
4 app.js
@@ -71,6 +71,10 @@
}
};
+ app.get('/accountadd', routes.accountadd);
+
+ app.post('/accountadd', routes.createaccount);
+
app.get('/data', restrict, routes.data);
app.get('/customers', restrict, routes.customers);
View
2  coffee/app.coffee
@@ -55,6 +55,8 @@ restrict = (req, res, next) ->
# Routes
+app.get '/accountadd', routes.accountadd
+app.post '/accountadd', routes.createaccount
app.get '/data', restrict, routes.data
app.get '/customers', restrict, routes.customers
app.get '/login', routes.login
View
219 coffee/repository/base.coffee
@@ -1,13 +1,14 @@
GLOBAL.DEBUG = true
+root = global ? window
+
mongo = require 'mongodb'
{Db, ObjectID: ObjectId, Timestamp, Connection, Server} = mongo
dbName = 'whereartthoudb'
host = process.env['MONGO_NODE_DRIVER_HOST'] ? 'localhost'
port = process.env['MONGO_NODE_DRIVER_PORT'] ? Connection.DEFAULT_PORT
-
-exports.setCollectionName = (@collectionName) ->
+db_connector = new Db dbName, new Server(host, port, {}), native_parser:false
exports.Db = Db
exports.ObjectId = ObjectId
@@ -15,190 +16,154 @@ exports.Timestamp = Timestamp
exports.Connection = Connection
exports.Server = Server
+utils = require '../services/utils'
+###
+exports.Db = Db
+exports.ObjectId = ObjectId
+exports.Timestamp = Timestamp
+exports.Connection = Connection
+exports.Server = Server
+###
###
Default error handler
###
-exports.checkError = checkError = (error, errorFn, next = ->) ->
+checkError = (error, errorFn, next = ->) ->
if error?
console.log error
errorFn()
- else if next? and typeof next is 'function'
- next.call()
-
-
-m_db = null
-m_refcount = 0
-
-
-exports.closeDb = closeDb = ->
- m_refcount--
- if m_refcount <= 0 and m_db?
- m_db.close()
-
-
-###
-Return the default DB
-###
-exports.getDb = getDb = ->
- m_refcount++
- if not m_db?
- m_db = new Db dbName, new Server(host, port, {}), native_parser:false
- close = m_db.close
- m_db.close = ->
- m_db.close = close
- closeDb()
- m_db
-
-
+ else
+ next()
###
Return a default error handler
###
-exports.errorHandler = errorHandler = (db, callback = ->) ->
+errorHandler = errorHandler = (db, callback = ->) ->
(error) ->
- db.close
+ try
+ db.close() if db?
+ catch e
+ console.trace e
callback error
-repository = (@collectionName) ->
-repository::setCollectionName = (@collectionName) ->
+Repository = (@collectionName) ->
+
+
+Repository::setCollectionName = (@collectionName) ->
+
+
+Repository::getDb = (callback = ->) ->
+ console.log 'db = ', root?.db
+ if root?.db?.state isnt 'connected'
+ db_connector.open (err, db) =>
+ root.db = db
+ callback err, db
+ else
+ callback null, root.db
+
###
Return the default collection
###
-repository::getCollection = (db, callback = ->) ->
- errorFn = (error) ->
- callback error
-
+Repository::getCollection = (callback = ->) ->
try
- db.open (openErr, openDb) =>
- checkError openErr, errorFn, =>
- try
- openDb.collection @collectionName, (collectionErr, collection) ->
- if collectionErr?
- callback collectionErr
- db.close()
- else
- callback null, collection
- catch e2
- console.trace e2
- callback e2
- catch e
- console.trace e
- callback e
+ utils.execute( utils.bind(@getDb, @) )
+ .then (err, db, cb = ->) =>
+ return callback(err) if err
+ db?.collection @collectionName, callback
+ catch e2
+ console.trace e2
+ callback e2
-repository::create = (doc, callback = ->) ->
+Repository::create = (doc, callback = ->) ->
console?.assert doc?, 'Doc cannot be null'
throw 'doc null' unless doc?
- db = getDb()
- errorFn = errorHandler db, callback
doc.createdat = new Date()
- @getCollection db, (collectionErr, collection) ->
- checkError collectionErr, errorFn, ->
- try
- collection.insert doc, {safe: true}, () ->
- callback.apply this, arguments
- db.close()
- catch e
- db.close()
- console.trace e
- callback e
-
-
-repository::read = (findArgs..., callback = ->) ->
- db = getDb()
- errorFn = errorHandler db, callback
+ utils.execute( utils.bind(@getCollection, @) )
+ .then (err, collection, cb = ->) =>
+ return callback err if err
+ try
+ collection?.insert doc, {safe: true}, callback
+ catch e
+ console.trace e
+ callback e
+
+
+Repository::read = (findArgs..., callback = ->) ->
- @getCollection db, (collectionErr, collection) ->
- checkError collectionErr, errorFn, ->
- try
- cursor = collection.find.apply collection, findArgs
- callback null, cursor
-# cursor.toArray (toArrayErr, docs) ->
-# db.close()
-# console.log toArrayErr if toArrayErr
-# callback.apply this, arguments
- catch e
- console.trace e
- callback e
- db.close()
+ utils.execute( utils.bind(@getCollection, @) )
+ .then (err, collection, cb = ->) =>
+ return callback(err) if err
+ try
+ cursor = collection?.find.apply collection, findArgs
+ callback null, cursor
+ catch e
+ console.trace e
+ callback e
-repository::getById = (docid, callback = ->) ->
+Repository::getById = (docid, callback = ->) ->
console?.assert docid? and docid isnt 'undefined', 'docid must be defined'
throw 'Invalid id' unless docid? and docid isnt 'undefined'
docid = new ObjectId(docid) if typeof docid is 'string'
- @read _id: docid, (readErr, cursor) ->
+ @read _id: docid, (readErr, cursor) =>
return callback( readErr ) if readErr
- cursor.toArray (toArrayErr, docs) ->
+ cursor?.toArray (toArrayErr, docs) =>
return callback(toArrayErr) if toArrayErr
return callback('Not found') unless docs?.length
callback null, docs[0]
- db = cursor.db
cursor.close()
- db.close()
-repository::update = (criteria, objNew, options = {}, callback ) ->
- db = getDb()
- errorFn = errorHandler db, callback
+Repository::update = (criteria, objNew, options = {}, callback ) ->
options.safe ?= if callback? then true else false
options.multi ?= true
options.upsert ?= true
options['new'] ?= true
- @getCollection db, (collectionErr, collection) ->
- checkError collectionErr, errorFn, ->
- try
- collection.update criteria, objNew, options, () ->
- db.close()
- callback.apply this, arguments
- catch e
- db.close()
- console.trace e
- callback e if callback?
+ utils.execute( utils.bind(@getCollection, @) )
+ .then (err, collection, cb = ->) =>
+ return callback(err) if err
+ try
+ collection?.update criteria, objNew, options, callback
+ catch e
+ console.trace e
+ callback e if callback?
-repository::save = (doc, callback = ->) ->
+Repository::save = (doc, callback = ->) ->
+ console?.assert doc?, 'Doc must not be null'
throw 'Empty doc' unless doc?
- db = getDb()
- errorFn = errorHandler db, callback
- @getCollection db, (collectionErr, collection) ->
- checkError collectionErr, errorFn, ->
- try
- collection.save doc, {safe: true}, () ->
- db.close()
- callback.apply this, arguments
- catch e
- db.close()
- console.trace e
- callback e if callback?
+ utils.execute( utils.bind(@getCollection, @) )
+ .then (err, collection, cb = ->) =>
+ return callback(err) if err
+ try
+ collection?.save doc, {safe: true}, callback
+ catch e
+ console.trace e
+ callback e
-repository::remove = (criteria, callback = ->) ->
+Repository::remove = (criteria, callback = ->) ->
throw 'Criteria is empty' if Object.keys(criteria).length is 0
-
- db = getDb()
- errorFn = errorHandler db, callback
-
- @getCollection db, (collectionErr, collection) ->
- checkError collectionErr, errorFn, ->
- collection.remove criteria
- callback()
- db.close()
+
+ utils.execute( utils.bind(@getCollection, @) )
+ .then (err, collection, cb = ->) =>
+ collection?.remove criteria
+ callback()
-exports.repository = repository
+exports.Repository = Repository
View
4 coffee/repository/customers.coffee
@@ -1,7 +1,7 @@
baseDb = require('./base')
-baseRepo = new baseDb.repository('customers')
+baseRepo = new baseDb.Repository('customers')
-{Db, ObjectId, Timestamp, Connection, Server, checkError, errorHandler, getDb} = baseDb
+{Db, ObjectId, Timestamp, Connection, Server} = baseDb
exports.create = () ->
baseRepo.create.apply baseRepo, arguments
View
11 coffee/repository/users2.coffee
@@ -1,12 +1,7 @@
-#baseDb = require './base'
-#baseDb.setCollectionName 'users'
-#{getDb, checkError, getCollection, errorHandler, create, read, update, remove, getById, ObjectId} = baseDb
-#[exports.create, exports.read, exports.update, exports.remove, exports.getById, exports.ObjectId] = [create, read, update, remove, getById, ObjectId]
-
baseDb = require('./base')
-baseRepo = new baseDb.repository('users')
+baseRepo = new baseDb.Repository('users')
-{Db, ObjectId, Timestamp, Connection, Server, checkError, errorHandler, getDb} = baseDb
+{Db, ObjectId, Timestamp, Connection, Server} = baseDb
exports.create = () ->
baseRepo.create.apply baseRepo, arguments
@@ -30,7 +25,6 @@ exports.getByUsername = (username, callback = ->) ->
if err?
callback err
else if cursor?
- db = cursor.db
cursor.toArray (toArrayErr, users) ->
if toArrayErr?
callback toArrayErr
@@ -39,7 +33,6 @@ exports.getByUsername = (username, callback = ->) ->
else
callback null, null
cursor.close()
- db.close()
else
callback 'DB read failed'
View
38 coffee/routes/index.coffee
@@ -1,4 +1,38 @@
-
+exports.accountadd = (req, res, next) ->
+ res.render 'add',
+ layout: true
+ title: 'Where Art Thou - Sign Up'
+
+
+exports.createaccount = (req, res, next) ->
+ account = {}
+ account.name = req.param 'companyname', ''
+ account.username = req.param 'username', ''
+ account.password = req.param 'password', ''
+ account.passwordconfirm = req.param 'passwordconfirm' ,''
+
+ userSvc = require '../services/user'
+ try
+ userSvc.insert account, (err, user) ->
+ if err
+ req.flash 'error', err
+ res.redirect 'back'
+ else
+ # Regenerate session when signing in
+ # to prevent fixation
+ req.session?.regenerate ->
+ # Store the user's primary key
+ # in the session store to be retrieved,
+ # or in this case the entire user object
+ req.session.user = user
+
+ # return to the original url or home page
+ res.redirect '/'
+ catch e
+ console.trace e
+ req.flash 'error', e
+ res.redirect 'back'
+
exports.customeradd = (req, res, next) ->
customersvc = require '../services/customer'
@@ -25,6 +59,7 @@ exports.data = (req, res, next) ->
res.render 'data'
title: 'Where Art Thou - Data'
customers: customers
+ layout: true
catch e
console.trace e
next()
@@ -113,4 +148,5 @@ exports.authenticate = (req, res, next) ->
exports.index = (req, res) ->
res.render 'index',
title: 'Where Art Thou'
+ layout: true
View
247 coffee/services/user.coffee
@@ -1,6 +1,5 @@
crypto = require 'crypto'
newUserRepo = require '../repository/users2'
-teamRepo = require '../repository/teams2'
utils = require './utils'
hash = (msg, key) ->
@@ -8,60 +7,6 @@ hash = (msg, key) ->
.update(msg)
.digest('hex')
-loadChallenge = (challenge, callback) ->
- return callback() unless challenge?
- # load opponent team
- if challenge.teamid?
- teamRepo.getSimpleTeam String(challenge.teamid), (err, team) ->
- challenge.teamname = team?.teamname ? 'Unknown'
- callback null, challenge
- else
- callback null, challenge
-
-# load challenge with opponent team name
-loadChallenges = (challenges, callback) ->
- return callback(null, challenges) unless challenges? and challenges.length isnt 0
- utils.map challenges, loadChallenge, callback
-
-# load match with team name
-loadMatch = (hometeamid, m, callback) ->
- if m?.teams?.length isnt 0
- for team in m.teams
- if team?._id.equals( hometeamid )
- m.opponentteamid = team._id
- m.opponentteamname = team.teamname
- callback null, m
-
-# load all matches with team name
-loadMatches = (hometeamid, matches, callback) ->
- return callback(null, matches) unless matches? and matches.length isnt 0
- utils.map matches, (m, cb) ->
- loadMatch hometeamid, m, cb
- , callback
-
-
-###
-Load user's team with active matches and active challenges
-###
-loadUserTeam = (teamid, callback) ->
- return callback() unless teamid? and teamid isnt 'undefined'
-
- teamRepo.getFullTeam String(teamid), (err, team) ->
- return callback( err ) if err? or not team?
- # load full challenge list
- __loadChallengesFn = (lc_cb) ->
- loadChallenges team.challenges, (lc_err, challenges) ->
- team.challenges = challenges unless lc_err?
- lc_cb err, challenges
- # load full match list
- __loadMatchesFn = (lm_cb) ->
- loadMatches team._id, team.matches, (lm_err, matches) ->
- team.matches = matches.filter( (am) -> am.end >= new Date() ) unless lm_err?
- lm_cb err,matches
-
- utils.parallel [__loadChallengesFn, __loadMatchesFn], (parallel_err, results) ->
- callback err, team
-
createEmailContent = (tpl, data) ->
jade = require 'jade'
@@ -151,41 +96,6 @@ exports.authenticate = (username, password, callback) ->
###
-LOAD a user document with all neccessary properties re-populated in the root object
-###
-exports.loadMobileUser = (userid, callback = ->) ->
- console.assert userid, 'userid cannot be null or 0'
- throw 'userid is null or empty' unless userid?
-
- try
- newUserRepo.getById userid, (error, user) ->
- if error
- callback error
- else if user
- # populate property wins
- user.wins = user.stats?.win ? 0
- # populate property losses
- user.losses = user.stats?.loss ? 0
- # populate challenge count, match count
- try
- loadUserTeam user.team?._id, (err, team) ->
- user.challenges = team?.challenges
- user.challengeCount = team?.challenges?.length || 0
- user.matches = team?.matches
- console.dir user.matches
- user.matchCount = team?.matches?.length || 0
- callback null, user
- catch loadUserTeamEx
- console.trace loadUserTeamEx
- callback loadUserTeamEx
- else
- callback null, user
- catch e
- console.trace e
- callback e
-
-
-###
LOAD a user document by Id
###
exports.getById = (userid, callback = ->) ->
@@ -544,7 +454,13 @@ exports.sortingPlayers = (player1, player2) ->
exports.insert = (user, callback = ->) ->
console.assert user, 'user cannot be null'
throw 'user cannot be null' unless user?
-
+ console.assert user?.password is user?.passwordconfirm, 'Password do not match'
+ throw 'Passwords do not match' unless user?.password is user?.passwordconfirm
+ console.assert user?.username, 'Email address cannot be null or empty'
+ throw 'Email address cannot be null or empty' unless user?.username
+ console.assert user?.password, 'Password cannot be null or empty'
+ throw 'Password cannot be null or empty' unless user?.password
+
utils.execute(newUserRepo.getByUsername, user.username)
.then (err, existingUser, cb) ->
if err?
@@ -554,7 +470,6 @@ exports.insert = (user, callback = ->) ->
else
user.createdat = new Date()
user.pictureurl ?= '/images/player.jpg'
- user.statustext ?= 'Ready for some foos'
user.password = hash user.password, 'a little dog'
try
newUserRepo.create user, cb
@@ -675,153 +590,7 @@ exports.assignTeam = (userid, team, callback = ->) ->
newUserRepo.update findObj, updateObj, {}, callback
catch e
console.trace e
- callback e
-
-
-
-###
-take in a brief invite obj and return a full Invite object
-###
-loadFullInvite = (invite, callback = ->) ->
- teamid = invite?.teamid
- userid = invite?.invitor
-
- try
- utils.execute( teamRepo.getById, teamid )
- .then (err, team, cb = ->) ->
- invite.team = team
-
- try
- newUserRepo.getById userid, cb
- catch e
- console.trace e
- callback e
- .then (err, user, cb = ->) ->
- invite.invitor = user
- callback null, invite
- catch e
- console.trace e
- callback e
-
-###
-GET user object with all full properties
-###
-exports.getFullUser = (userid, callback = ->) ->
- console.assert userid, 'userid cannot be null or 0'
- throw 'userid cannot be null or 0' unless userid
-
- utils.execute( newUserRepo.getById, userid ) # load user
- .then (err, @user, cb = ->) =>
- # load team
- return callback( err ) if err
-
- if @user?.team?
- try
- teamRepo.getById @user?.team?._id, cb
- catch e
- console.trace e
- cb e
- else
- cb()
- .then (err, @team, cb = ->) =>
- # Load posts
- return callback( err ) if err
- @user?.team = @team
-
- if @user?.posts? and @user?.posts?.length
- try
- postGen = require './post'
- postGen.init()
- utils.mapAsync @user?.posts, postGen.makePostGen(@user), cb
- catch e
- console.trace e
- cb e
- else
- cb null, null
-
- .then (err, fullposts, cb = ->) =>
- if fullposts?
- posts = (post for post in fullposts when post?.desc?)
- else
- posts = fullposts
-
- if posts?
- posts.sort (p1, p2) ->
- p2?.createdat - p1?.createdat
-
- @user?.posts = posts
- # Load invites
- try
- if @user?.invites and @user?.invites?.length
- utils.mapAsync @user?.invites, loadFullInvite, cb
- else
- cb()
- catch e
- console.trace e
- cb e
- .then (err, invites, cb = ->) =>
- return callback( err ) if err
-
- @user?.invites = invites
-
- # Load challenges
- if @team?.challenges?.length
-
- loadChallenge = (challenge, loadChallengeCallback = ->) ->
- teamRepo.getById challenge?.teamid, (loadChallengeErr, team) ->
- challenge.teamname = team?.teamname
- loadChallengeCallback loadChallengeErr, challenge
-
- utils.mapAsync @team?.challenges, loadChallenge, cb
- else
- cb null, null
- .then ( err, challenges, cb = ->) =>
- @team?.challenges = challenges
- @user?.challenges = challenges
- allmatches = @team?.matches
- # Load pending matches
- matches = (match for match in allmatches when match?.status is 'pending') if allmatches?
-
- if matches?.length
- matchsvc = require './match'
- async = require 'async'
-
- loadMatch = (am, loadMatchCb = ->) =>
- matchsvc.getById am._id, (loadMatchErr, fullMatch) =>
- fullMatch?.hometeam = @team
-
- if fullMatch?.teams?
- for team in fullMatch?.teams
- do (team) =>
- if not team?._id?.equals( @team?._id )
- fullMatch.opponentteam = team
-
- if fullMatch?.votes?
- for vote in fullMatch?.votes
- do (vote) =>
- if String(vote?.playerid) is String(@user._id)
- fullMatch.voted = true
-
- loadVote = (vote, votecb = ->) ->
- newUserRepo.getById vote.playerid, (getByIdErr, user) ->
- vote.playername = user?.nickname
- votecb null, vote
-
- async.map fullMatch?.votes, loadVote, (loadVoteErr, fullVotes) ->
- fullMatch?.votes = fullVotes
- loadMatchCb loadMatchErr, fullMatch
- else
- loadMatchCb loadMatchErr, fullMatch
-
- async.map matches, loadMatch, ->
- cb.apply null, arguments
- #utils.mapAsync matches, loadMatch, cb
- else
- callback null, @user
- .then ( err, matches, cb = ->) =>
- @user.matches = matches
- callback null, @user
-
+ callback e
View
16 coffee/services/utils.coffee
@@ -89,7 +89,23 @@ exports.execute = (task, args...) ->
return wrapper;
+exports.bind = (fn, scope, args, appendArgs) ->
+ if arguments.length is 2
+ return ->
+ fn.apply scope, arguments
+
+ method = fn
+ ->
+ callArgs = args ? arguments
+ if appendArgs is true
+ callArgs = arguments[0..]
+ callArgs = callArgs.concat args
+
+ method.apply (scope ? global) ? window, callArgs
+
+
+
View
5 public/stylesheets/style.less
@@ -1,3 +1,8 @@
+body {
+ padding-top: 60px;
+ padding-bottom: 40px;
+}
+
@navbar-bgcolor: #1568db;
@navbar-color: #ffffff;
@footer-bgcolor: #dedede;
View
271 repository/base.js
@@ -1,9 +1,11 @@
(function() {
- var Connection, Db, ObjectId, Server, Timestamp, checkError, closeDb, dbName, errorHandler, getDb, host, m_db, m_refcount, mongo, port, repository, _ref, _ref2,
+ var Connection, Db, ObjectId, Repository, Server, Timestamp, checkError, dbName, db_connector, errorHandler, host, mongo, port, root, utils, _ref, _ref2,
__slice = Array.prototype.slice;
GLOBAL.DEBUG = true;
+ root = typeof global !== "undefined" && global !== null ? global : window;
+
mongo = require('mongodb');
Db = mongo.Db, ObjectId = mongo.ObjectID, Timestamp = mongo.Timestamp, Connection = mongo.Connection, Server = mongo.Server;
@@ -14,9 +16,9 @@
port = (_ref2 = process.env['MONGO_NODE_DRIVER_PORT']) != null ? _ref2 : Connection.DEFAULT_PORT;
- exports.setCollectionName = function(collectionName) {
- this.collectionName = collectionName;
- };
+ db_connector = new Db(dbName, new Server(host, port, {}), {
+ native_parser: false
+ });
exports.Db = Db;
@@ -28,154 +30,131 @@
exports.Server = Server;
+ utils = require('../services/utils');
+
+ /*
+ exports.Db = Db
+ exports.ObjectId = ObjectId
+ exports.Timestamp = Timestamp
+ exports.Connection = Connection
+ exports.Server = Server
+ */
+
/*
Default error handler
*/
- exports.checkError = checkError = function(error, errorFn, next) {
+ checkError = function(error, errorFn, next) {
if (next == null) next = function() {};
if (error != null) {
console.log(error);
return errorFn();
- } else if ((next != null) && typeof next === 'function') {
- return next.call();
+ } else {
+ return next();
}
};
- m_db = null;
-
- m_refcount = 0;
-
- exports.closeDb = closeDb = function() {
- m_refcount--;
- if (m_refcount <= 0 && (m_db != null)) return m_db.close();
- };
-
- /*
- Return the default DB
- */
-
- exports.getDb = getDb = function() {
- var close;
- m_refcount++;
- if (!(m_db != null)) {
- m_db = new Db(dbName, new Server(host, port, {}), {
- native_parser: false
- });
- }
- close = m_db.close;
- m_db.close = function() {
- m_db.close = close;
- return closeDb();
- };
- return m_db;
- };
-
/*
Return a default error handler
*/
- exports.errorHandler = errorHandler = function(db, callback) {
+ errorHandler = errorHandler = function(db, callback) {
if (callback == null) callback = function() {};
return function(error) {
- db.close;
+ try {
+ if (db != null) db.close();
+ } catch (e) {
+ console.trace(e);
+ }
return callback(error);
};
};
- repository = function(collectionName) {
+ Repository = function(collectionName) {
this.collectionName = collectionName;
};
- repository.prototype.setCollectionName = function(collectionName) {
+ Repository.prototype.setCollectionName = function(collectionName) {
this.collectionName = collectionName;
};
+ Repository.prototype.getDb = function(callback) {
+ var _ref3,
+ _this = this;
+ if (callback == null) callback = function() {};
+ console.log('db = ', root != null ? root.db : void 0);
+ if ((root != null ? (_ref3 = root.db) != null ? _ref3.state : void 0 : void 0) !== 'connected') {
+ return db_connector.open(function(err, db) {
+ root.db = db;
+ return callback(err, db);
+ });
+ } else {
+ return callback(null, root.db);
+ }
+ };
+
/*
Return the default collection
*/
- repository.prototype.getCollection = function(db, callback) {
- var errorFn,
- _this = this;
+ Repository.prototype.getCollection = function(callback) {
+ var _this = this;
if (callback == null) callback = function() {};
- errorFn = function(error) {
- return callback(error);
- };
try {
- return db.open(function(openErr, openDb) {
- return checkError(openErr, errorFn, function() {
- try {
- return openDb.collection(_this.collectionName, function(collectionErr, collection) {
- if (collectionErr != null) {
- callback(collectionErr);
- return db.close();
- } else {
- return callback(null, collection);
- }
- });
- } catch (e2) {
- console.trace(e2);
- return callback(e2);
- }
- });
+ return utils.execute(utils.bind(this.getDb, this)).then(function(err, db, cb) {
+ if (cb == null) cb = function() {};
+ if (err) return callback(err);
+ return db != null ? db.collection(_this.collectionName, callback) : void 0;
});
- } catch (e) {
- console.trace(e);
- return callback(e);
+ } catch (e2) {
+ console.trace(e2);
+ return callback(e2);
}
};
- repository.prototype.create = function(doc, callback) {
- var db, errorFn;
+ Repository.prototype.create = function(doc, callback) {
+ var _this = this;
if (callback == null) callback = function() {};
if (typeof console !== "undefined" && console !== null) {
console.assert(doc != null, 'Doc cannot be null');
}
if (doc == null) throw 'doc null';
- db = getDb();
- errorFn = errorHandler(db, callback);
doc.createdat = new Date();
- return this.getCollection(db, function(collectionErr, collection) {
- return checkError(collectionErr, errorFn, function() {
- try {
- return collection.insert(doc, {
- safe: true
- }, function() {
- callback.apply(this, arguments);
- return db.close();
- });
- } catch (e) {
- db.close();
- console.trace(e);
- return callback(e);
- }
- });
+ return utils.execute(utils.bind(this.getCollection, this)).then(function(err, collection, cb) {
+ if (cb == null) cb = function() {};
+ if (err) return callback(err);
+ try {
+ return collection != null ? collection.insert(doc, {
+ safe: true
+ }, callback) : void 0;
+ } catch (e) {
+ console.trace(e);
+ return callback(e);
+ }
});
};
- repository.prototype.read = function() {
- var callback, db, errorFn, findArgs, _i;
+ Repository.prototype.read = function() {
+ var callback, findArgs, _i,
+ _this = this;
findArgs = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), callback = arguments[_i++];
if (callback == null) callback = function() {};
- db = getDb();
- errorFn = errorHandler(db, callback);
- return this.getCollection(db, function(collectionErr, collection) {
- return checkError(collectionErr, errorFn, function() {
- var cursor;
- try {
- cursor = collection.find.apply(collection, findArgs);
- return callback(null, cursor);
- } catch (e) {
- console.trace(e);
- callback(e);
- return db.close();
- }
- });
+ return utils.execute(utils.bind(this.getCollection, this)).then(function(err, collection, cb) {
+ var cursor;
+ if (cb == null) cb = function() {};
+ if (err) return callback(err);
+ try {
+ cursor = collection != null ? collection.find.apply(collection, findArgs) : void 0;
+ return callback(null, cursor);
+ } catch (e) {
+ console.trace(e);
+ return callback(e);
+ }
});
};
- repository.prototype.getById = function(docid, callback) {
+ Repository.prototype.getById = function(docid, callback) {
+ var _this = this;
if (callback == null) callback = function() {};
if (typeof console !== "undefined" && console !== null) {
console.assert((docid != null) && docid !== 'undefined', 'docid must be defined');
@@ -186,82 +165,66 @@
_id: docid
}, function(readErr, cursor) {
if (readErr) return callback(readErr);
- return cursor.toArray(function(toArrayErr, docs) {
- var db;
+ return cursor != null ? cursor.toArray(function(toArrayErr, docs) {
if (toArrayErr) return callback(toArrayErr);
if (!(docs != null ? docs.length : void 0)) return callback('Not found');
callback(null, docs[0]);
- db = cursor.db;
- cursor.close();
- return db.close();
- });
+ return cursor.close();
+ }) : void 0;
});
};
- repository.prototype.update = function(criteria, objNew, options, callback) {
- var db, errorFn;
+ Repository.prototype.update = function(criteria, objNew, options, callback) {
+ var _this = this;
if (options == null) options = {};
- db = getDb();
- errorFn = errorHandler(db, callback);
if (options.safe == null) options.safe = callback != null ? true : false;
if (options.multi == null) options.multi = true;
if (options.upsert == null) options.upsert = true;
if (options['new'] == null) options['new'] = true;
- return this.getCollection(db, function(collectionErr, collection) {
- return checkError(collectionErr, errorFn, function() {
- try {
- return collection.update(criteria, objNew, options, function() {
- db.close();
- return callback.apply(this, arguments);
- });
- } catch (e) {
- db.close();
- console.trace(e);
- if (callback != null) return callback(e);
- }
- });
+ return utils.execute(utils.bind(this.getCollection, this)).then(function(err, collection, cb) {
+ if (cb == null) cb = function() {};
+ if (err) return callback(err);
+ try {
+ return collection != null ? collection.update(criteria, objNew, options, callback) : void 0;
+ } catch (e) {
+ console.trace(e);
+ if (callback != null) return callback(e);
+ }
});
};
- repository.prototype.save = function(doc, callback) {
- var db, errorFn;
+ Repository.prototype.save = function(doc, callback) {
+ var _this = this;
if (callback == null) callback = function() {};
+ if (typeof console !== "undefined" && console !== null) {
+ console.assert(doc != null, 'Doc must not be null');
+ }
if (doc == null) throw 'Empty doc';
- db = getDb();
- errorFn = errorHandler(db, callback);
- return this.getCollection(db, function(collectionErr, collection) {
- return checkError(collectionErr, errorFn, function() {
- try {
- return collection.save(doc, {
- safe: true
- }, function() {
- db.close();
- return callback.apply(this, arguments);
- });
- } catch (e) {
- db.close();
- console.trace(e);
- if (callback != null) return callback(e);
- }
- });
+ return utils.execute(utils.bind(this.getCollection, this)).then(function(err, collection, cb) {
+ if (cb == null) cb = function() {};
+ if (err) return callback(err);
+ try {
+ return collection != null ? collection.save(doc, {
+ safe: true
+ }, callback) : void 0;
+ } catch (e) {
+ console.trace(e);
+ return callback(e);
+ }
});
};
- repository.prototype.remove = function(criteria, callback) {
- var db, errorFn;
+ Repository.prototype.remove = function(criteria, callback) {
+ var _this = this;
if (callback == null) callback = function() {};
if (Object.keys(criteria).length === 0) throw 'Criteria is empty';
- db = getDb();
- errorFn = errorHandler(db, callback);
- return this.getCollection(db, function(collectionErr, collection) {
- return checkError(collectionErr, errorFn, function() {
- collection.remove(criteria);
- callback();
- return db.close();
- });
+ return utils.execute(utils.bind(this.getCollection, this)).then(function(err, collection, cb) {
+ if (cb == null) cb = function() {};
+ if (collection != null) collection.remove(criteria);
+ return callback();
});
};
- exports.repository = repository;
+ exports.Repository = Repository;
}).call(this);
View
6 repository/customers.js
@@ -1,11 +1,11 @@
(function() {
- var Connection, Db, ObjectId, Server, Timestamp, baseDb, baseRepo, checkError, errorHandler, getDb;
+ var Connection, Db, ObjectId, Server, Timestamp, baseDb, baseRepo;
baseDb = require('./base');
- baseRepo = new baseDb.repository('customers');
+ baseRepo = new baseDb.Repository('customers');
- Db = baseDb.Db, ObjectId = baseDb.ObjectId, Timestamp = baseDb.Timestamp, Connection = baseDb.Connection, Server = baseDb.Server, checkError = baseDb.checkError, errorHandler = baseDb.errorHandler, getDb = baseDb.getDb;
+ Db = baseDb.Db, ObjectId = baseDb.ObjectId, Timestamp = baseDb.Timestamp, Connection = baseDb.Connection, Server = baseDb.Server;
exports.create = function() {
return baseRepo.create.apply(baseRepo, arguments);
View
11 repository/users2.js
@@ -1,11 +1,11 @@
(function() {
- var Connection, Db, ObjectId, Server, Timestamp, baseDb, baseRepo, checkError, errorHandler, getDb;
+ var Connection, Db, ObjectId, Server, Timestamp, baseDb, baseRepo;
baseDb = require('./base');
- baseRepo = new baseDb.repository('users');
+ baseRepo = new baseDb.Repository('users');
- Db = baseDb.Db, ObjectId = baseDb.ObjectId, Timestamp = baseDb.Timestamp, Connection = baseDb.Connection, Server = baseDb.Server, checkError = baseDb.checkError, errorHandler = baseDb.errorHandler, getDb = baseDb.getDb;
+ Db = baseDb.Db, ObjectId = baseDb.ObjectId, Timestamp = baseDb.Timestamp, Connection = baseDb.Connection, Server = baseDb.Server;
exports.create = function() {
return baseRepo.create.apply(baseRepo, arguments);
@@ -39,11 +39,9 @@
return baseRepo.read({
username: username
}, function(err, cursor) {
- var db;
if (err != null) {
return callback(err);
} else if (cursor != null) {
- db = cursor.db;
return cursor.toArray(function(toArrayErr, users) {
if (toArrayErr != null) {
callback(toArrayErr);
@@ -52,8 +50,7 @@
} else {
callback(null, null);
}
- cursor.close();
- return db.close();
+ return cursor.close();
});
} else {
return callback('DB read failed');
View
41 routes/index.js
@@ -1,5 +1,40 @@
(function() {
+ exports.accountadd = function(req, res, next) {
+ return res.render('add', {
+ layout: true,
+ title: 'Where Art Thou - Sign Up'
+ });
+ };
+
+ exports.createaccount = function(req, res, next) {
+ var account, userSvc;
+ account = {};
+ account.name = req.param('companyname', '');
+ account.username = req.param('username', '');
+ account.password = req.param('password', '');
+ account.passwordconfirm = req.param('passwordconfirm', '');
+ userSvc = require('../services/user');
+ try {
+ return userSvc.insert(account, function(err, user) {
+ var _ref;
+ if (err) {
+ req.flash('error', err);
+ return res.redirect('back');
+ } else {
+ return (_ref = req.session) != null ? _ref.regenerate(function() {
+ req.session.user = user;
+ return res.redirect('/');
+ }) : void 0;
+ }
+ });
+ } catch (e) {
+ console.trace(e);
+ req.flash('error', e);
+ return res.redirect('back');
+ }
+ };
+
exports.customeradd = function(req, res, next) {
var customeraddress, customercontact, customername, customersvc;
customersvc = require('../services/customer');
@@ -31,7 +66,8 @@
return customersvc.getAll(req.user._id, '', function(err, customers) {
return res.render('data', {
title: 'Where Art Thou - Data',
- customers: customers
+ customers: customers,
+ layout: true
});
});
} catch (e) {
@@ -124,7 +160,8 @@
exports.index = function(req, res) {
return res.render('index', {
- title: 'Where Art Thou'
+ title: 'Where Art Thou',
+ layout: true
});
};
View
333 services/user.js
@@ -1,93 +1,16 @@
(function() {
- var createEmailContent, crypto, hash, loadChallenge, loadChallenges, loadFullInvite, loadMatch, loadMatches, loadUserTeam, newUserRepo, teamRepo, utils;
+ var createEmailContent, crypto, hash, newUserRepo, utils;
crypto = require('crypto');
newUserRepo = require('../repository/users2');
- teamRepo = require('../repository/teams2');
-
utils = require('./utils');
hash = function(msg, key) {
return crypto.createHmac('sha256', key).update(msg).digest('hex');
};
- loadChallenge = function(challenge, callback) {
- if (challenge == null) return callback();
- if (challenge.teamid != null) {
- return teamRepo.getSimpleTeam(String(challenge.teamid), function(err, team) {
- var _ref;
- challenge.teamname = (_ref = team != null ? team.teamname : void 0) != null ? _ref : 'Unknown';
- return callback(null, challenge);
- });
- } else {
- return callback(null, challenge);
- }
- };
-
- loadChallenges = function(challenges, callback) {
- if (!((challenges != null) && challenges.length !== 0)) {
- return callback(null, challenges);
- }
- return utils.map(challenges, loadChallenge, callback);
- };
-
- loadMatch = function(hometeamid, m, callback) {
- var team, _i, _len, _ref, _ref2;
- if ((m != null ? (_ref = m.teams) != null ? _ref.length : void 0 : void 0) !== 0) {
- _ref2 = m.teams;
- for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
- team = _ref2[_i];
- if (team != null ? team._id.equals(hometeamid) : void 0) {
- m.opponentteamid = team._id;
- m.opponentteamname = team.teamname;
- }
- }
- }
- return callback(null, m);
- };
-
- loadMatches = function(hometeamid, matches, callback) {
- if (!((matches != null) && matches.length !== 0)) {
- return callback(null, matches);
- }
- return utils.map(matches, function(m, cb) {
- return loadMatch(hometeamid, m, cb);
- }, callback);
- };
-
- /*
- Load user's team with active matches and active challenges
- */
-
- loadUserTeam = function(teamid, callback) {
- if (!((teamid != null) && teamid !== 'undefined')) return callback();
- return teamRepo.getFullTeam(String(teamid), function(err, team) {
- var __loadChallengesFn, __loadMatchesFn;
- if ((err != null) || !(team != null)) return callback(err);
- __loadChallengesFn = function(lc_cb) {
- return loadChallenges(team.challenges, function(lc_err, challenges) {
- if (lc_err == null) team.challenges = challenges;
- return lc_cb(err, challenges);
- });
- };
- __loadMatchesFn = function(lm_cb) {
- return loadMatches(team._id, team.matches, function(lm_err, matches) {
- if (lm_err == null) {
- team.matches = matches.filter(function(am) {
- return am.end >= new Date();
- });
- }
- return lm_cb(err, matches);
- });
- };
- return utils.parallel([__loadChallengesFn, __loadMatchesFn], function(parallel_err, results) {
- return callback(err, team);
- });
- });
- };
-
createEmailContent = function(tpl, data) {
var fn, fs, jade, path, str;
jade = require('jade');
@@ -197,46 +120,6 @@
};
/*
- LOAD a user document with all neccessary properties re-populated in the root object
- */
-
- exports.loadMobileUser = function(userid, callback) {
- if (callback == null) callback = function() {};
- console.assert(userid, 'userid cannot be null or 0');
- if (userid == null) throw 'userid is null or empty';
- try {
- return newUserRepo.getById(userid, function(error, user) {
- var _ref, _ref2, _ref3, _ref4, _ref5;
- if (error) {
- return callback(error);
- } else if (user) {
- user.wins = (_ref = (_ref2 = user.stats) != null ? _ref2.win : void 0) != null ? _ref : 0;
- user.losses = (_ref3 = (_ref4 = user.stats) != null ? _ref4.loss : void 0) != null ? _ref3 : 0;
- try {
- return loadUserTeam((_ref5 = user.team) != null ? _ref5._id : void 0, function(err, team) {
- var _ref6, _ref7;
- user.challenges = team != null ? team.challenges : void 0;
- user.challengeCount = (team != null ? (_ref6 = team.challenges) != null ? _ref6.length : void 0 : void 0) || 0;
- user.matches = team != null ? team.matches : void 0;
- console.dir(user.matches);
- user.matchCount = (team != null ? (_ref7 = team.matches) != null ? _ref7.length : void 0 : void 0) || 0;
- return callback(null, user);
- });
- } catch (loadUserTeamEx) {
- console.trace(loadUserTeamEx);
- return callback(loadUserTeamEx);
- }
- } else {
- return callback(null, user);
- }
- });
- } catch (e) {
- console.trace(e);
- return callback(e);
- }
- };
-
- /*
LOAD a user document by Id
*/
@@ -717,6 +600,18 @@
if (callback == null) callback = function() {};
console.assert(user, 'user cannot be null');
if (user == null) throw 'user cannot be null';
+ console.assert((user != null ? user.password : void 0) === (user != null ? user.passwordconfirm : void 0), 'Password do not match');
+ if ((user != null ? user.password : void 0) !== (user != null ? user.passwordconfirm : void 0)) {
+ throw 'Passwords do not match';
+ }
+ console.assert(user != null ? user.username : void 0, 'Email address cannot be null or empty');
+ if (!(user != null ? user.username : void 0)) {
+ throw 'Email address cannot be null or empty';
+ }
+ console.assert(user != null ? user.password : void 0, 'Password cannot be null or empty');
+ if (!(user != null ? user.password : void 0)) {
+ throw 'Password cannot be null or empty';
+ }
return utils.execute(newUserRepo.getByUsername, user.username).then(function(err, existingUser, cb) {
if (err != null) {
return callback(err);
@@ -725,7 +620,6 @@
} else {
user.createdat = new Date();
if (user.pictureurl == null) user.pictureurl = '/images/player.jpg';
- if (user.statustext == null) user.statustext = 'Ready for some foos';
user.password = hash(user.password, 'a little dog');
try {
return newUserRepo.create(user, cb);
@@ -878,205 +772,4 @@
}
};
- /*
- take in a brief invite obj and return a full Invite object
- */
-
- loadFullInvite = function(invite, callback) {
- var teamid, userid;
- if (callback == null) callback = function() {};
- teamid = invite != null ? invite.teamid : void 0;
- userid = invite != null ? invite.invitor : void 0;
- try {
- return utils.execute(teamRepo.getById, teamid).then(function(err, team, cb) {
- if (cb == null) cb = function() {};
- invite.team = team;
- try {
- return newUserRepo.getById(userid, cb);
- } catch (e) {
- console.trace(e);
- return callback(e);
- }
- }).then(function(err, user, cb) {
- if (cb == null) cb = function() {};
- invite.invitor = user;
- return callback(null, invite);
- });
- } catch (e) {
- console.trace(e);
- return callback(e);
- }
- };
-
- /*
- GET user object with all full properties
- */
-
- exports.getFullUser = function(userid, callback) {
- var _this = this;
- if (callback == null) callback = function() {};
- console.assert(userid, 'userid cannot be null or 0');
- if (!userid) throw 'userid cannot be null or 0';
- return utils.execute(newUserRepo.getById, userid).then(function(err, user, cb) {
- var _ref, _ref2, _ref3;
- _this.user = user;
- if (cb == null) cb = function() {};
- if (err) return callback(err);
- if (((_ref = _this.user) != null ? _ref.team : void 0) != null) {
- try {
- return teamRepo.getById((_ref2 = _this.user) != null ? (_ref3 = _ref2.team) != null ? _ref3._id : void 0 : void 0, cb);
- } catch (e) {
- console.trace(e);
- return cb(e);
- }
- } else {
- return cb();
- }
- }).then(function(err, team, cb) {
- var postGen, _ref, _ref2, _ref3, _ref4, _ref5;
- _this.team = team;
- if (cb == null) cb = function() {};
- if (err) return callback(err);
- if ((_ref = _this.user) != null) _ref.team = _this.team;
- if ((((_ref2 = _this.user) != null ? _ref2.posts : void 0) != null) && ((_ref3 = _this.user) != null ? (_ref4 = _ref3.posts) != null ? _ref4.length : void 0 : void 0)) {
- try {
- postGen = require('./post');
- postGen.init();
- return utils.mapAsync((_ref5 = _this.user) != null ? _ref5.posts : void 0, postGen.makePostGen(_this.user), cb);
- } catch (e) {
- console.trace(e);
- return cb(e);
- }
- } else {
- return cb(null, null);
- }
- }).then(function(err, fullposts, cb) {
- var post, posts, _ref, _ref2, _ref3, _ref4, _ref5;
- if (cb == null) cb = function() {};
- if (fullposts != null) {
- posts = (function() {
- var _i, _len, _results;
- _results = [];
- for (_i = 0, _len = fullposts.length; _i < _len; _i++) {
- post = fullposts[_i];
- if ((post != null ? post.desc : void 0) != null) _results.push(post);
- }
- return _results;
- })();
- } else {
- posts = fullposts;
- }
- if (posts != null) {
- posts.sort(function(p1, p2) {
- return (p2 != null ? p2.createdat : void 0) - (p1 != null ? p1.createdat : void 0);
- });
- }
- if ((_ref = _this.user) != null) _ref.posts = posts;
- try {
- if (((_ref2 = _this.user) != null ? _ref2.invites : void 0) && ((_ref3 = _this.user) != null ? (_ref4 = _ref3.invites) != null ? _ref4.length : void 0 : void 0)) {
- return utils.mapAsync((_ref5 = _this.user) != null ? _ref5.invites : void 0, loadFullInvite, cb);
- } else {
- return cb();
- }
- } catch (e) {
- console.trace(e);
- return cb(e);
- }
- }).then(function(err, invites, cb) {
- var _ref, _ref2, _ref3, _ref4;
- if (cb == null) cb = function() {};
- if (err) return callback(err);
- if ((_ref = _this.user) != null) _ref.invites = invites;
- if ((_ref2 = _this.team) != null ? (_ref3 = _ref2.challenges) != null ? _ref3.length : void 0 : void 0) {
- loadChallenge = function(challenge, loadChallengeCallback) {
- if (loadChallengeCallback == null) loadChallengeCallback = function() {};
- return teamRepo.getById(challenge != null ? challenge.teamid : void 0, function(loadChallengeErr, team) {
- challenge.teamname = team != null ? team.teamname : void 0;
- return loadChallengeCallback(loadChallengeErr, challenge);
- });
- };
- return utils.mapAsync((_ref4 = _this.team) != null ? _ref4.challenges : void 0, loadChallenge, cb);
- } else {
- return cb(null, null);
- }
- }).then(function(err, challenges, cb) {
- var allmatches, async, match, matches, matchsvc, _ref, _ref2, _ref3;
- if (cb == null) cb = function() {};
- if ((_ref = _this.team) != null) _ref.challenges = challenges;
- if ((_ref2 = _this.user) != null) _ref2.challenges = challenges;
- allmatches = (_ref3 = _this.team) != null ? _ref3.matches : void 0;
- if (allmatches != null) {
- matches = (function() {
- var _i, _len, _results;
- _results = [];
- for (_i = 0, _len = allmatches.length; _i < _len; _i++) {
- match = allmatches[_i];
- if ((match != null ? match.status : void 0) === 'pending') {
- _results.push(match);
- }
- }
- return _results;
- })();
- }
- if (matches != null ? matches.length : void 0) {
- matchsvc = require('./match');
- async = require('async');
- loadMatch = function(am, loadMatchCb) {
- if (loadMatchCb == null) loadMatchCb = function() {};
- return matchsvc.getById(am._id, function(loadMatchErr, fullMatch) {
- var loadVote, team, vote, _fn, _fn2, _i, _j, _len, _len2, _ref4, _ref5;
- if (fullMatch != null) fullMatch.hometeam = _this.team;
- if ((fullMatch != null ? fullMatch.teams : void 0) != null) {
- _ref4 = fullMatch != null ? fullMatch.teams : void 0;
- _fn = function(team) {
- var _ref5, _ref6;
- if (!(team != null ? (_ref5 = team._id) != null ? _ref5.equals((_ref6 = _this.team) != null ? _ref6._id : void 0) : void 0 : void 0)) {
- return fullMatch.opponentteam = team;
- }
- };
- for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
- team = _ref4[_i];
- _fn(team);
- }
- }
- if ((fullMatch != null ? fullMatch.votes : void 0) != null) {
- _ref5 = fullMatch != null ? fullMatch.votes : void 0;
- _fn2 = function(vote) {
- if (String(vote != null ? vote.playerid : void 0) === String(_this.user._id)) {
- return fullMatch.voted = true;
- }
- };
- for (_j = 0, _len2 = _ref5.length; _j < _len2; _j++) {
- vote = _ref5[_j];
- _fn2(vote);
- }
- loadVote = function(vote, votecb) {
- if (votecb == null) votecb = function() {};
- return newUserRepo.getById(vote.playerid, function(getByIdErr, user) {
- vote.playername = user != null ? user.nickname : void 0;
- return votecb(null, vote);
- });
- };
- return async.map(fullMatch != null ? fullMatch.votes : void 0, loadVote, function(loadVoteErr, fullVotes) {
- if (fullMatch != null) fullMatch.votes = fullVotes;
- return loadMatchCb(loadMatchErr, fullMatch);
- });
- } else {
- return loadMatchCb(loadMatchErr, fullMatch);
- }
- });
- };
- return async.map(matches, loadMatch, function() {
- return cb.apply(null, arguments);
- });
- } else {
- return callback(null, _this.user);
- }
- }).then(function(err, matches, cb) {
- if (cb == null) cb = function() {};
- _this.user.matches = matches;
- return callback(null, _this.user);
- });
- };
-
}).call(this);
View
19 services/utils.js
@@ -125,4 +125,23 @@
return wrapper;
};
+ exports.bind = function(fn, scope, args, appendArgs) {
+ var method;
+ if (arguments.length === 2) {
+ return function() {
+ return fn.apply(scope, arguments);
+ };
+ }
+ method = fn;
+ return function() {
+ var callArgs, _ref;
+ callArgs = args != null ? args : arguments;
+ if (appendArgs === true) {
+ callArgs = arguments.slice(0);
+ callArgs = callArgs.concat(args);
+ }
+ return method.apply((_ref = scope != null ? scope : global) != null ? _ref : window, callArgs);
+ };
+ };
+
}).call(this);
View
8 views/add.jade
@@ -12,17 +12,17 @@
.span4
form(method='POST')
fieldset
- legend WFL Sign Up
+ legend Sign Up
.space1
- label(for='form-signup-nickname') Name (real or nick name)
- input#form-signup-nickname(maxlength='255', name='nickname', size='25', type='text', required, value=nickname)
+ label(for='form-signup-nickname') Company Name
+ input#form-signup-nickname(maxlength='255', name='companyname', size='25', type='text', required, value=nickname, placeholder='Enter your company name')
label(for='form-login-username') Email address
input#form-login-username(maxlength='255', name='username', size='25', type='text', required, placeholder='Enter your email address')
label(for='form-login-password') Password
input#form-login-password(maxlength='16', name='password', size='25', type='password', required, placeholder='Enter your password')
label(for='form-login-password-confirm') Confirm Password
input#form-login-password-confirm(maxlength='16', name='passwordconfirm', size='25', type='password', required, placeholder='Re-enter your password')
- .message!= partial('../messages')
+ .message!= partial('messages')
button.btn.btn-primary(type='submit') Sign Up
.span2
.row.space3
View
4 views/index.jade
@@ -1,5 +1,7 @@
.row
- .span12
+ .span3
+ | Client list
+ .span9
.map-container
#map_canvas
View
10 views/layout.jade
@@ -1,7 +1,7 @@
- var loggedIn = (typeof request.session.user !== "undefined")
- var nickname = ''
- if (loggedIn)
- - var nickname = request.session.user.nickname || request.session.user.username
+ - var nickname = request.session.user.name || request.session.user.username
- var roles = []
- if (loggedIn)
roles = request.session.user.roles || []
@@ -18,14 +18,8 @@ html.nojs
//if lt IE 9
script(src="http://html5shim.googlecode.com/svn/trunk/html5.js")
title #{title || 'Where Art Thou'}
- //link(rel='stylesheet', href='/stylesheets/jquery-ui-1.8.17.custom.css')
link( href="/stylesheets/bootstrap.min.css", rel="stylesheet")
- | <style type="text/css">
- | body {
- | padding-top: 60px;
- | padding-bottom: 40px;
- | }
- | </style>
+ link( href="/stylesheets/bootstrap-responsive.min.css", rel="stylesheet")
link(rel="stylesheet/less", type="text/css", href="/stylesheets/style.less")
body
script
Please sign in to comment.
Something went wrong with that request. Please try again.