mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-13 23:42:12 +00:00
merge
This commit is contained in:
commit
0fa00b2c1e
13 changed files with 53 additions and 49 deletions
|
|
@ -24,11 +24,10 @@
|
|||
"nconf": "*",
|
||||
"icalendar": "git://github.com/lefnire/node-icalendar#master",
|
||||
"nodetime": "*",
|
||||
"resolve": "~0.2.3",
|
||||
"request": "~2.14.0",
|
||||
"querystring": "~0.1.0",
|
||||
"nock": "~0.15.2",
|
||||
"superagent": "~0.12.4"
|
||||
"superagent": "~0.12.4",
|
||||
"resolve": "~0.2.3",
|
||||
"browserify": "1.17.3"
|
||||
},
|
||||
"private": true,
|
||||
"subdomain": "habitrpg",
|
||||
|
|
|
|||
|
|
@ -36,15 +36,8 @@
|
|||
<div class='container'>
|
||||
<div class='marketing'>
|
||||
<img class='rotate-img' src="/img/BrowserQuest/habitrpg_mods/armor3_m.png" />
|
||||
<h2>The server is under heavy load or is experiencing issues.</h2>
|
||||
<p><a href="/">Try again</a> in a few, the developer has been notified. In the meantime, Habit could use your support to get these issues squared away - please consider backing the Kickstarter Campaign.</p>
|
||||
<a href="http://kck.st/XoA3Yg" class='btn btn-success btn-large'>Kickstarter</a>
|
||||
<div class='container'>
|
||||
<div class='marketing'>
|
||||
<p> </p>
|
||||
<p><iframe src="http://player.vimeo.com/video/57639356" width="960" height="539" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
|
||||
</div>
|
||||
</div>
|
||||
<h2>The server is experiencing issues.</h2>
|
||||
<p><a href="/">Try again</a> in a few, the developer has been notified. The most likely culprit is <a href="https://github.com/lefnire/habitrpg/issues/165">this issue</a> which Tyler is working frantically to fix. (Any memory leak experts?)</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@
|
|||
<div class='jumbotron masthead'>
|
||||
<div class='container'>
|
||||
<h1><img src="/img/logo/habitrpg_pixel.png" alt="HabitRPG"/></h1>
|
||||
<p>A habit tracker app which treats your goals like a Role Playing Game. Level up as you succeed, lose HP as you fail, earn money to buy weapons and armor.</p>
|
||||
<a href="http://kck.st/XoA3Yg" class='btn btn-success btn-large'>Kickstarter</a>
|
||||
<p>Habit tracking which treats your goals like a Role Playing Game. Level up as you succeed, lose HP as you fail, earn money to buy weapons and armor.</p>
|
||||
<a href="/?play=1" class='btn btn-primary btn-small'>Play</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -19,14 +19,6 @@ process.env.SMTP_PASS = conf.get("SMTP_PASS");
|
|||
process.env.SMTP_SERVICE = conf.get("SMTP_SERVICE");
|
||||
process.env.STRIPE_API_KEY = conf.get("STRIPE_API_KEY");
|
||||
process.env.STRIPE_PUB_KEY = conf.get("STRIPE_PUB_KEY");
|
||||
process.env.NODETIME_KEY = conf.get("NODETIME_KEY");
|
||||
|
||||
if (process.env.NODETIME_KEY) {
|
||||
require('nodetime').profile({
|
||||
accountKey: process.env.NODETIME_KEY,
|
||||
appName: 'HabitRPG'
|
||||
});
|
||||
}
|
||||
|
||||
process.on('uncaughtException', function (error) {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ _ = require('underscore')
|
|||
# ========== ROUTES ==========
|
||||
|
||||
get '/', (page, model, next) ->
|
||||
return page.redirect '/' if page.params?.query?.play?
|
||||
|
||||
# temporary view variables, so we don't call model.set() too fast
|
||||
_view = model.get '_view' || {}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ items = module.exports.items =
|
|||
]
|
||||
shield: [
|
||||
{index: 0, text: "No Shield", classes: 'shield_0', notes:'No Shield.', modifier: 0.00, value:0}
|
||||
{index: 1, text: "Wooden Shield", classes: 'shield_1', notes:'Decreases HP loss by 2%', modifier: 0.02, value:20}
|
||||
{index: 1, text: "Wooden Shield", classes: 'shield_1', notes:'Decreases HP loss by 3%', modifier: 0.03, value:20}
|
||||
{index: 2, text: "Buckler", classes: 'shield_2', notes:'Decreases HP loss by 4%.', modifier: 0.04, value:35}
|
||||
{index: 3, text: "Enforced Shield", classes: 'shield_3', notes:'Decreases HP loss by 5%.', modifier: 0.05, value:55}
|
||||
{index: 4, text: "Red Shield", classes: 'shield_4', notes:'Decreases HP loss by 7%.', modifier: 0.07, value:70}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ module.exports.partySubscribe = partySubscribe = (model, cb) ->
|
|||
# partyUnsubscribe model, ->
|
||||
|
||||
# Restart subscription to the main user
|
||||
selfQ = model.query('users').withId(model.get('_userId') or model.session.userId)
|
||||
selfQ = model.query('users').withId model.get('_userId') #or model.session.userId # see http://goo.gl/TPYIt
|
||||
selfQ.subscribe (err, self) ->
|
||||
throw err if err
|
||||
u = self.at(0)
|
||||
|
|
@ -166,7 +166,7 @@ module.exports.app = (appExports, model) ->
|
|||
# model.set '_party', null
|
||||
# model.set '_partyMembers', null
|
||||
# partyUnsubscribe model, ->
|
||||
# selfQ = model.query('users').withId(model.get('_userId') or model.session.userId)
|
||||
# selfQ = model.query('users').withId model.get('_userId') #or model.session.userId # see http://goo.gl/TPYIt
|
||||
# selfQ.subscribe (err, u) ->
|
||||
# model.ref '_user', u.at(0)
|
||||
# browser.resetDom model
|
||||
|
|
@ -43,8 +43,8 @@ module.exports.app = (appExports, model) ->
|
|||
list = model.at "_#{type}List"
|
||||
newModel = model.at('_new' + type.charAt(0).toUpperCase() + type.slice(1))
|
||||
text = newModel.get()
|
||||
# Don't add a blank task
|
||||
if /^(\s)*$/.test(text)
|
||||
# Don't add a blank task; 20/02/13 Added a check for undefined value, more at issue #463 -lancemanfv
|
||||
if /^(\s)*$/.test(text) || text == undefined
|
||||
console.error "Task text entered was an empty string."
|
||||
return
|
||||
|
||||
|
|
@ -171,4 +171,4 @@ module.exports.app = (appExports, model) ->
|
|||
direction = 'up' if direction == 'true/'
|
||||
direction = 'down' if direction == 'false/'
|
||||
task = model.at $(el).parents('li')[0]
|
||||
scoring.score(task.get('id'), direction)
|
||||
scoring.score(task.get('id'), direction)
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ router.post '/user/tasks', (req, res) ->
|
|||
|
||||
return res.json task
|
||||
|
||||
router.get '/user/calendar.ics', (req, res) ->
|
||||
router.get '/users/:uid/calendar.ics', (req, res) ->
|
||||
#return next() #disable for now
|
||||
{uid} = req.params
|
||||
{apiToken} = req.query
|
||||
|
|
|
|||
|
|
@ -69,10 +69,10 @@ mongo_store = new MongoStore {url: process.env.NODE_DB_URI}, ->
|
|||
cookie: { maxAge: TWO_WEEKS } # defaults to 2 weeks? aka, can delete this line?
|
||||
store: mongo_store
|
||||
)
|
||||
# Show splash page for newcomers
|
||||
.use(middleware.splash)
|
||||
# Adds req.getModel method
|
||||
.use(store.modelMiddleware())
|
||||
# Show splash page for newcomers
|
||||
.use(middleware.splash)
|
||||
.use(priv.middleware)
|
||||
.use(middleware.view)
|
||||
.use(auth.middleware(strategies, options))
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
module.exports.splash = (req, res, next) ->
|
||||
# This was an API call, not a page load
|
||||
return next() if /^\/api/.test req.path
|
||||
if !req.session.userId? and !req.query?.play?
|
||||
res.redirect('/splash.html')
|
||||
else
|
||||
next()
|
||||
return next() if /^\/(api)|(v1)/.test req.path
|
||||
|
||||
unless req.query?.play? or req.getModel().get('_userId')
|
||||
res.redirect('/splash.html')
|
||||
else
|
||||
next()
|
||||
|
||||
module.exports.view = (req, res, next) ->
|
||||
model = req.getModel()
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ module.exports.routes = (expressApp) ->
|
|||
return res.send(500, err.response.error.message)
|
||||
else
|
||||
model = req.getModel()
|
||||
userId = model.session.userId
|
||||
userId = model.get('_userId') #or model.session.userId # see http://goo.gl/TPYIt
|
||||
req._isServer = true
|
||||
model.fetch "users.#{userId}", (err, user) ->
|
||||
model.ref '_user', "users.#{userId}"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
derbyAuth = require('derby-auth/store')
|
||||
|
||||
###
|
||||
Setup read / write access
|
||||
@param store
|
||||
|
|
@ -14,14 +16,21 @@ module.exports.customAccessControl = (store) ->
|
|||
userAccess = (store) ->
|
||||
|
||||
store.readPathAccess "users.*", -> # captures, accept, err ->
|
||||
accept = arguments[arguments.length-2]
|
||||
err = arguments[arguments.length - 1]
|
||||
# return err(derbyAuth.SESSION_INVALIDATED_ERROR) if derbyAuth.bustedSession(@)
|
||||
return accept(false) if derbyAuth.bustedSession(@)
|
||||
|
||||
accept = arguments[arguments.length - 2]
|
||||
return accept(true) unless @session?.userId # https://github.com/codeparty/racer/issues/37
|
||||
uid = arguments[0]
|
||||
accept (uid is @session.userId) or @session.req?._isServer
|
||||
accept (uid is @session.userId) or derbyAuth.isServer(@)
|
||||
|
||||
store.writeAccess "*", "users.*", -> # captures, value, accept, err ->
|
||||
accept = arguments[arguments.length-2]
|
||||
return accept(true) unless @session?.userId # https://github.com/codeparty/racer/issues/37
|
||||
err = arguments[arguments.length - 1]
|
||||
# return err(derbyAuth.SESSION_INVALIDATED_ERROR) if derbyAuth.bustedSession(@)
|
||||
return accept(false) if derbyAuth.bustedSession(@)
|
||||
|
||||
captures = arguments[0].split('.')
|
||||
uid = captures.shift()
|
||||
attrPath = captures.join('.') # new array shifted left, after shift() was run
|
||||
|
|
@ -31,21 +40,25 @@ userAccess = (store) ->
|
|||
return accept(true)
|
||||
|
||||
# Same session (user.id = this.session.userId)
|
||||
if (uid is @session.userId) or @session.req?._isServer
|
||||
if (uid is @session.userId) or derbyAuth.isServer(@)
|
||||
return accept(true)
|
||||
|
||||
accept(false)
|
||||
|
||||
store.writeAccess "*", "users.*.balance", (id, newBalance, accept, err) ->
|
||||
return accept(true) unless @session?.userId # https://github.com/codeparty/racer/issues/37
|
||||
# return err(derbyAuth.SESSION_INVALIDATED_ERROR) if derbyAuth.bustedSession(@)
|
||||
return accept(false) if derbyAuth.bustedSession(@)
|
||||
|
||||
oldBalance = @session.req?._racerModel?.get("users.#{id}.balance") || 0
|
||||
purchasingSomethingOnClient = newBalance < oldBalance
|
||||
accept(purchasingSomethingOnClient or @session.req?._isServer)
|
||||
|
||||
store.writeAccess "*", "users.*.flags.ads", -> # captures, value, accept, err ->
|
||||
accept = arguments[arguments.length - 1]
|
||||
return accept(true) unless @session?.userId # https://github.com/codeparty/racer/issues/37
|
||||
accept(@session.req?._isServer)
|
||||
err = arguments[arguments.length - 1]
|
||||
# return err(derbyAuth.SESSION_INVALIDATED_ERROR) if derbyAuth.bustedSession(@)
|
||||
return accept(false) if derbyAuth.bustedSession(@)
|
||||
|
||||
accept(derbyAuth.isServer(@))
|
||||
|
||||
|
||||
###
|
||||
|
|
@ -56,14 +69,12 @@ REST = (store) ->
|
|||
store.query.expose "users", "withIdAndToken", (uid, token) ->
|
||||
@byId(uid)
|
||||
.where('apiToken').equals(token)
|
||||
.limit(1)
|
||||
.one
|
||||
|
||||
store.queryAccess "users", "withIdAndToken", (uid, token, accept, err) ->
|
||||
return accept(true) if uid && token
|
||||
accept(false) # only user has id & token
|
||||
|
||||
#store.query.expose
|
||||
|
||||
|
||||
###
|
||||
Party permissions
|
||||
|
|
@ -79,11 +90,15 @@ partySystem = (store) ->
|
|||
'auth.facebook.displayName')
|
||||
|
||||
store.queryAccess "users", "party", (ids, accept, err) ->
|
||||
# return err(derbyAuth.SESSION_INVALIDATED_ERROR) if derbyAuth.bustedSession(@)
|
||||
return accept(false) if derbyAuth.bustedSession(@)
|
||||
accept(true) # no harm in public user stats
|
||||
|
||||
store.query.expose "parties", "withId", (id) ->
|
||||
@where("id").equals(id)
|
||||
store.queryAccess "parties", "withId", (id, accept, err) ->
|
||||
# return err(derbyAuth.SESSION_INVALIDATED_ERROR) if derbyAuth.bustedSession(@)
|
||||
return accept(false) if derbyAuth.bustedSession(@)
|
||||
accept(true)
|
||||
|
||||
store.readPathAccess "parties.*", ->
|
||||
|
|
@ -92,4 +107,7 @@ partySystem = (store) ->
|
|||
|
||||
store.writeAccess "*", "parties.*", ->
|
||||
accept = arguments[arguments.length-2]
|
||||
err = arguments[arguments.length - 1]
|
||||
# return err(derbyAuth.SESSION_INVALIDATED_ERROR) if derbyAuth.bustedSession(@)
|
||||
return accept(false) if derbyAuth.bustedSession(@)
|
||||
accept(true)
|
||||
|
|
|
|||
Loading…
Reference in a new issue