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