added custom routing from server side, started moving hardcoded scripts into create_route

v1.18.x
psychobunny 12 years ago
parent e75076caad
commit e061fe061b

@ -58,7 +58,7 @@ var templates = {};
function init() {
loadTemplates([
'header', 'footer', 'register', 'home', 'topic','account', 'category',
'header', 'footer', 'register', 'home', 'topic','account', 'category', 'users',
'login', 'reset', 'reset_code', 'account',
'confirm',
'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext'
@ -160,7 +160,7 @@ function load_template(callback, custom_tpl) {
tpl = templates.get_custom_map(tpl);
if (custom_tpl) tpl = custom_tpl;
document.getElementById('content').innerHTML = templates[tpl].parse(JSON.parse(data));
if (callback) callback();
});

@ -122,6 +122,10 @@ passport.deserializeUser(function(uid, done) {
});
function create_route(url, tpl) {
return '<script>templates.ready(function(){ajaxify.go("' + url + '", null, "' + tpl + '");});</script>';
}
// Basic Routes (entirely client-side parsed, goal is to move the rest of the crap in this file into this one section)
(function() {
@ -137,7 +141,7 @@ passport.deserializeUser(function(uid, done) {
return;
}
res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("' + route + '");});</script>' + templates['footer']);
res.send(templates['header'] + create_route(route) + templates['footer']);
});
}(routes[i]));
}
@ -217,7 +221,9 @@ passport.deserializeUser(function(uid, done) {
break;
case 'users' :
if (String(req.params.section).toLowerCase() === 'edit') {
get_account_fn(req, res, function(userData) {
res.send(JSON.stringify(userData));
});
} else {
get_account_fn(req, res, function(userData) {
res.send(JSON.stringify(userData));
@ -390,7 +396,8 @@ passport.deserializeUser(function(uid, done) {
console.log("ARE U HERE");
user.getUserList(function(data){
//res.send(data);
res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("users");});</script>' + templates['footer']);
res.send(templates['header'] + create_route("users", "users") + templates['footer']);
});
});

Loading…
Cancel
Save