rewrite: converted static pages, removed old unused static pages

This commit is contained in:
Tyler Renelle
2013-09-01 12:56:43 -04:00
parent b22ccc0a23
commit fb0ffd075e
16 changed files with 1000 additions and 1343 deletions
+9 -14
View File
@@ -2,30 +2,25 @@ var nconf = require('nconf');
var _ = require('lodash');
module.exports = function(req, res, next) {
/*
//splash = (req, res, next) ->
// isStatic = req.url.split('/')[1] is 'static'
// unless req.query?.play? or req.getModel().get('_userId') or isStatic
// res.redirect('/static/front')
// else
// next()
*/
/* Set _mobileDevice to true or false so view can exclude portions from mobile device*/
// show them the splash page if they're not logged in
var isStatic = req.url.split('/')[1] == 'static';
// if (!isStatic && !req.headers['x-api-user'] && !req.headers['x-api-key'] && req.headers.accept != 'application/json')
// return res.redirect('/static/front')
var _base;
_.defaults(((_base = res.locals).habitrpg != null ? (_base = res.locals).habitrpg : _base.habitrpg = {}), {
NODE_ENV: nconf.get('NODE_ENV'),
res.locals.habitrpg = res.locals.habitrpg || {}
_.defaults(res.locals.habitrpg, {
NODE_ENV: isStatic ? 'production' : nconf.get('NODE_ENV'), // Don't show debugging options on static pages
IS_MOBILE: /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(req.header('User-Agent')),
STRIPE_PUB_KEY: nconf.get('STRIPE_PUB_KEY')
});
/*CORS middleware*/
//CORS middleware
res.header("Access-Control-Allow-Origin", req.headers.origin || "*");
res.header("Access-Control-Allow-Methods", "OPTIONS,GET,POST,PUT,HEAD,DELETE");
res.header("Access-Control-Allow-Headers", "Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key");
/* wtf is this for?*/
//wtf is this for?
if (req.method === 'OPTIONS') {
return res.send(200);
}