mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 15:35:47 +01:00
added template mapping, did users->account
This commit is contained in:
@@ -30,6 +30,7 @@ var ajaxify = {};
|
|||||||
|
|
||||||
var url = url.replace(/\/$/, "");
|
var url = url.replace(/\/$/, "");
|
||||||
var tpl_url = (url === '' || url === '/') ? 'home' : url.split('/')[0];
|
var tpl_url = (url === '' || url === '/') ? 'home' : url.split('/')[0];
|
||||||
|
tpl_url = templates.get_custom_map(tpl_url);
|
||||||
|
|
||||||
if (templates[tpl_url]) {
|
if (templates[tpl_url]) {
|
||||||
window.history.pushState({}, url, "/" + url);
|
window.history.pushState({}, url, "/" + url);
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
var templates = {};
|
var templates = {};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var ready_callback;
|
var ready_callback,
|
||||||
|
config;
|
||||||
|
|
||||||
|
templates.get_custom_map = function(tpl) {
|
||||||
|
return (config['custom_mapping'] && config['custom_mapping'][tpl]) ? config['custom_mapping'][tpl] : tpl;
|
||||||
|
}
|
||||||
|
|
||||||
templates.ready = function(callback) {
|
templates.ready = function(callback) {
|
||||||
//quick implementation because introducing a lib to handle several async callbacks
|
//quick implementation because introducing a lib to handle several async callbacks
|
||||||
@@ -21,6 +26,11 @@ var templates = {};
|
|||||||
var timestamp = new Date().getTime();
|
var timestamp = new Date().getTime();
|
||||||
var loaded = templatesToLoad.length;
|
var loaded = templatesToLoad.length;
|
||||||
|
|
||||||
|
$.getJSON('/templates/config.json', function(data) {
|
||||||
|
config = data;
|
||||||
|
console.log('loaded');
|
||||||
|
});
|
||||||
|
|
||||||
for (var t in templatesToLoad) {
|
for (var t in templatesToLoad) {
|
||||||
(function(file) {
|
(function(file) {
|
||||||
$.get('/templates/' + file + '.tpl?v=' + timestamp, function(html) {
|
$.get('/templates/' + file + '.tpl?v=' + timestamp, function(html) {
|
||||||
@@ -146,8 +156,10 @@ function load_template(callback) {
|
|||||||
url = (url === '' || url === '/') ? 'home' : url;
|
url = (url === '' || url === '/') ? 'home' : url;
|
||||||
|
|
||||||
jQuery.get(API_URL + url, function(data) {
|
jQuery.get(API_URL + url, function(data) {
|
||||||
console.log(data)
|
var tpl = url.split('/')[0];
|
||||||
document.getElementById('content').innerHTML = templates[url.split('/')[0]].parse(JSON.parse(data));
|
tpl = templates.get_custom_map(tpl);
|
||||||
|
|
||||||
|
document.getElementById('content').innerHTML = templates[tpl].parse(JSON.parse(data));
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ passport.deserializeUser(function(uid, done) {
|
|||||||
res.send(JSON.stringify(data));
|
res.send(JSON.stringify(data));
|
||||||
}, req.params.id);
|
}, req.params.id);
|
||||||
break;
|
break;
|
||||||
case 'account' :
|
case 'users' :
|
||||||
get_account_fn(req, res, function(userData) {
|
get_account_fn(req, res, function(userData) {
|
||||||
res.send(JSON.stringify(userData));
|
res.send(JSON.stringify(userData));
|
||||||
});
|
});
|
||||||
@@ -366,8 +366,7 @@ passport.deserializeUser(function(uid, done) {
|
|||||||
if(req.url.indexOf(data.username) == -1)
|
if(req.url.indexOf(data.username) == -1)
|
||||||
res.redirect(301, '/users/'+req.params.uid+'/'+data.username);
|
res.redirect(301, '/users/'+req.params.uid+'/'+data.username);
|
||||||
else
|
else
|
||||||
res.send(templates['header'] + '<pre>'+JSON.stringify(data, null, 4)+'</pre>' + templates['footer']);
|
res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("users/' + req.params.uid +'/'+data.username + '");});</script>' + templates['footer']);
|
||||||
// res.send(templates['header'] + '<script>templates.ready(function(){ajaxify.go("' + 'userprofile' + '");});</script>' + templates['footer']);
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user