mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-16 18:56:15 +01:00
changed res.send(JSON.stringify()); to res.json(). closes #25
This commit is contained in:
@@ -168,7 +168,8 @@
|
||||
function parse_template() {
|
||||
if (!templates[tpl_url] || !template_data) return;
|
||||
|
||||
document.getElementById('content').innerHTML = templates[tpl_url].parse(JSON.parse(template_data));
|
||||
//document.getElementById('content').innerHTML = templates[tpl_url].parse(JSON.parse(template_data));
|
||||
document.getElementById('content').innerHTML = templates[tpl_url].parse(template_data);
|
||||
|
||||
jQuery('#content [template-variable]').each(function(index, element) {
|
||||
var value = null;
|
||||
@@ -289,9 +290,6 @@
|
||||
})(data, "", template);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ('undefined' !== typeof window) {
|
||||
window.templates = module.exports;
|
||||
templates.init();
|
||||
|
||||
@@ -39,27 +39,26 @@ var user = require('./../user.js'),
|
||||
switch(req.params.method) {
|
||||
case 'users' :
|
||||
if (req.params.tab == 'search') {
|
||||
res.send(JSON.stringify({search_display: 'block', users: []}))
|
||||
res.json({search_display: 'block', users: []});
|
||||
} else {
|
||||
user.getUserList(function(data){
|
||||
|
||||
res.send(JSON.stringify({search_display: 'none', users:data, yourid:req.user.uid}));
|
||||
res.json({search_display: 'none', users:data, yourid:req.user.uid});
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
case 'categories':
|
||||
if (req.params.tab == 'disabled') {
|
||||
res.send(JSON.stringify({categories: []}));
|
||||
res.json({categories: []});
|
||||
} else {
|
||||
categories.getAllCategories(function(data) {
|
||||
res.send(JSON.stringify(data));
|
||||
res.json(data);
|
||||
});
|
||||
}
|
||||
break;
|
||||
case 'topics' :
|
||||
categories.getCategoryById(0, 0, function(data) {
|
||||
res.send(JSON.stringify(data));
|
||||
res.json(data);
|
||||
});
|
||||
break;
|
||||
case 'redis':
|
||||
@@ -83,11 +82,11 @@ var user = require('./../user.js'),
|
||||
}
|
||||
|
||||
|
||||
res.send(JSON.stringify(finalData));
|
||||
res.json(finalData);
|
||||
});
|
||||
break;
|
||||
default :
|
||||
res.send('{}');
|
||||
res.json({});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -246,9 +246,7 @@ var user = require('./../user.js'),
|
||||
if (!req.params.section && !req.params.username) {
|
||||
|
||||
user.getUserList(function(data){
|
||||
|
||||
res.send(JSON.stringify({users:data}));
|
||||
|
||||
res.json({users:data});
|
||||
});
|
||||
}
|
||||
else if(String(req.params.section).toLowerCase() === 'following') {
|
||||
@@ -258,7 +256,7 @@ var user = require('./../user.js'),
|
||||
user.getFollowing(userData.uid, function(followingData){
|
||||
userData.following = followingData;
|
||||
userData.followingCount = followingData.length;
|
||||
res.send(JSON.stringify(userData));
|
||||
res.json(userData);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -269,13 +267,13 @@ var user = require('./../user.js'),
|
||||
user.getFollowers(userData.uid, function(followersData){
|
||||
userData.followers = followersData;
|
||||
userData.followersCount = followersData.length;
|
||||
res.send(JSON.stringify(userData));
|
||||
res.json(userData);
|
||||
});
|
||||
});
|
||||
}
|
||||
else if (String(req.params.section).toLowerCase() === 'edit') {
|
||||
getUserDataByUserName(req.params.username, callerUID, function(userData) {
|
||||
res.send(JSON.stringify(userData));
|
||||
res.json(userData);
|
||||
});
|
||||
} else {
|
||||
getUserDataByUserName(req.params.username, callerUID, function(userData) {
|
||||
@@ -285,7 +283,7 @@ var user = require('./../user.js'),
|
||||
|
||||
userData.signature = marked(userData.signature || '');
|
||||
|
||||
res.send(JSON.stringify(userData));
|
||||
res.json(userData);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -178,14 +178,14 @@ var express = require('express'),
|
||||
switch(req.params.method) {
|
||||
case 'get_templates_listing' :
|
||||
utils.walk(global.configuration.ROOT_DIRECTORY + '/public/templates', function(err, data) {
|
||||
res.send(JSON.stringify(data));
|
||||
res.json(data);
|
||||
});
|
||||
break;
|
||||
case 'home' :
|
||||
categories.getAllCategories(function(data) {
|
||||
data.motd_class = (config.show_motd === '1' || config.show_motd === undefined) ? '' : 'none';
|
||||
data.motd = marked(config.motd || "# NodeBB v0.1\nWelcome to NodeBB, the discussion platform of the future.\n\n<a target=\"_blank\" href=\"http://www.nodebb.org\" class=\"btn btn-large\"><i class=\"icon-comment\"></i> Get NodeBB</a> <a target=\"_blank\" href=\"https://github.com/designcreateplay/NodeBB\" class=\"btn btn-large\"><i class=\"icon-github-alt\"></i> Fork us on Github</a> <a target=\"_blank\" href=\"https://twitter.com/dcplabs\" class=\"btn btn-large\"><i class=\"icon-twitter\"></i> @dcplabs</a>");
|
||||
res.send(JSON.stringify(data));
|
||||
res.json(data);
|
||||
}, uid);
|
||||
break;
|
||||
case 'login' :
|
||||
@@ -210,7 +210,7 @@ var express = require('express'),
|
||||
|
||||
data.token = res.locals.csrf_token;
|
||||
|
||||
res.send(JSON.stringify(data));
|
||||
res.json(data);
|
||||
break;
|
||||
case 'register' :
|
||||
var data = {},
|
||||
@@ -234,52 +234,52 @@ var express = require('express'),
|
||||
|
||||
data.token = res.locals.csrf_token;
|
||||
|
||||
res.send(JSON.stringify(data));
|
||||
res.json(data);
|
||||
break;
|
||||
case 'topic' :
|
||||
topics.getTopicById(req.params.id, uid, function(data) {
|
||||
res.send(data ? JSON.stringify(data) : false);
|
||||
res.json(data);
|
||||
});
|
||||
break;
|
||||
case 'category' :
|
||||
categories.getCategoryById(req.params.id, uid, function(data) {
|
||||
res.send(data ? JSON.stringify(data) : false);
|
||||
res.json(data);
|
||||
}, req.params.id, uid);
|
||||
break;
|
||||
case 'latest' :
|
||||
categories.getLatestTopics(uid, 0, 9, function(data) {
|
||||
res.send(JSON.stringify(data));
|
||||
res.json(data);
|
||||
});
|
||||
break;
|
||||
case 'popular' :
|
||||
categories.getLatestTopics(uid, 0, 9, function(data) {
|
||||
res.send(JSON.stringify(data));
|
||||
res.json(data);
|
||||
});
|
||||
break;
|
||||
case 'active' :
|
||||
categories.getLatestTopics(uid, 0, 9, function(data) {
|
||||
res.send(JSON.stringify(data));
|
||||
res.json(data);
|
||||
});
|
||||
break;
|
||||
case 'confirm':
|
||||
user.email.confirm(req.params.id, function(data) {
|
||||
if (data.status === 'ok') {
|
||||
res.send(JSON.stringify({
|
||||
res.json({
|
||||
'alert-class': 'alert-success',
|
||||
title: 'Email Confirmed',
|
||||
text: 'Thank you for vaidating your email. Your account is now fully activated.'
|
||||
}));
|
||||
});
|
||||
} else {
|
||||
res.send(JSON.stringify({
|
||||
res.json({
|
||||
'alert-class': 'alert-error',
|
||||
title: 'An error occurred...',
|
||||
text: 'There was a problem validating your email address. Perhaps the code was invalid or has expired.'
|
||||
}));
|
||||
});
|
||||
}
|
||||
});
|
||||
break;
|
||||
default :
|
||||
res.send('{}');
|
||||
res.json({});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user