Node.js based forum software built for the modern web
added custom routing from server side, started moving hardcoded scripts into create_route
psychobunnye061fe061b0f
diff --git a/public/src/templates.js b/public/src/templates.jsindex 1c6bb44741..aa537ee080 100644--- a/public/src/templates.js+++ b/public/src/templates.js@@ -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();});diff --git a/src/webserver.js b/src/webserver.jsindex b1a38d1263..d3684d5d6c 100644--- a/src/webserver.js+++ b/src/webserver.js@@ -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']);+});});