some left over unfinished templates fixes from last week. deeper urls now take higher precedence.

v1.18.x
psychobunny 12 years ago
parent 7e7d8ac8a4
commit 47d491b266

@ -13,7 +13,7 @@ global.templates = {};
config['ROOT_DIRECTORY'] = __dirname; config['ROOT_DIRECTORY'] = __dirname;
templates.init([ templates.init([
'header', 'footer', 'logout', 'header', 'footer', 'logout', 'admin/header', 'admin/footer', 'admin/index',
'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext' 'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext'
]); ]);

@ -31,7 +31,7 @@
} }
templates.is_available = function(tpl) { templates.is_available = function(tpl) {
return !!jQuery.inArray(tpl, available_templates); return jQuery.inArray(tpl, available_templates) !== -1;
}; };
templates.ready = function(callback) { templates.ready = function(callback) {
@ -99,15 +99,17 @@
var api_url = (url === '' || url === '/') ? 'home' : url; var api_url = (url === '' || url === '/') ? 'home' : url;
var tpl_url = templates.get_custom_map(api_url); var tpl_url = templates.get_custom_map(api_url);
if (tpl_url === false) { var trimmed = api_url;
if (!available_templates[api_url]) { while (tpl_url == false && trimmed.length > 0) {
tpl_url = api_url.split('/')[0]; if (templates.is_available(trimmed)) {
} else { tpl_url = trimmed;
tpl_url = api_url;
} }
trimmed = trimmed.split('/');
trimmed.pop();
trimmed = trimmed.join('/');
} }

@ -5,7 +5,7 @@
"admin/users[^]*": "admin/users", "admin/users[^]*": "admin/users",
"users[^]*edit": "accountedit", "users[^]*edit": "accountedit",
"users[^]*friends": "friends", "users[^]*friends": "friends",
"users": "account", "users/[^]*": "account",
"latest": "category", "latest": "category",
"popular": "category", "popular": "category",
"active": "category" "active": "category"

@ -1,7 +1,8 @@
var user = require('./../user.js'), var user = require('./../user.js'),
topics = require('./../topics.js'), topics = require('./../topics.js'),
RDB = require('./../redis.js'); RDB = require('./../redis.js')
categories = require('./../categories.js');
(function(Admin) { (function(Admin) {
Admin.create_routes = function(app) { Admin.create_routes = function(app) {
@ -12,7 +13,6 @@ var user = require('./../user.js'),
for (var i=0, ii=routes.length; i<ii; i++) { for (var i=0, ii=routes.length; i<ii; i++) {
(function(route) { (function(route) {
app.get('/admin/' + route, function(req, res) { app.get('/admin/' + route, function(req, res) {
console.log("derp " +route);
res.send(templates['admin/header'] + app.create_route('admin/' + route) + templates['admin/footer']); res.send(templates['admin/header'] + app.create_route('admin/' + route) + templates['admin/footer']);
}); });
}(routes[i])); }(routes[i]));
@ -55,7 +55,6 @@ var user = require('./../user.js'),
}); });
break; break;
case 'redis': case 'redis':
console.log('going into redis');
RDB.info(function(err, data) { RDB.info(function(err, data) {
data = data.split("\r\n"); data = data.split("\r\n");
var finalData = {}; var finalData = {};
@ -75,7 +74,7 @@ var user = require('./../user.js'),
} }
} }
console.log(finalData);
res.send(JSON.stringify(finalData)); res.send(JSON.stringify(finalData));
}); });
break; break;

Loading…
Cancel
Save