removed the other api_method routes

v1.18.x
Baris Soner Usakli 12 years ago
parent a5acf31fc6
commit 797d05a84a

@ -51,7 +51,6 @@ var user = require('./../user.js'),
}()); }());
//todo consolidate.
app.get('/admin', Admin.isAdmin, function(req, res) { app.get('/admin', Admin.isAdmin, function(req, res) {
res.send(Admin.build_header(res) + app.create_route('admin/index') + templates['admin/footer']); res.send(Admin.build_header(res) + app.create_route('admin/index') + templates['admin/footer']);
}); });
@ -60,106 +59,126 @@ var user = require('./../user.js'),
res.send(Admin.build_header(res) + app.create_route('admin/index') + templates['admin/footer']); res.send(Admin.build_header(res) + app.create_route('admin/index') + templates['admin/footer']);
}); });
app.get('/api/admin/index', function(req, res) {
res.json({version:pkg.version});
});
function api_method(req, res) { app.get('/api/admin/users/search', function(req, res) {
switch(req.params.method) { res.json({search_display: 'block', users: []});
case 'index': });
res.json({version:pkg.version});
break;
case 'users' :
if (req.params.tab == 'search') {
res.json({search_display: 'block', users: []});
}
else if(req.params.tab == 'latest') {
user.getUserList(function(data) {
data = data.sort(function(a, b) {
return b.joindate - a.joindate;
});
res.json({search_display: 'none', users:data, yourid:req.user.uid});
});
}
else if(req.params.tab == 'sort-posts') {
user.getUserList(function(data) {
data = data.sort(function(a, b) {
return b.postcount - a.postcount;
});
res.json({search_display: 'none', users:data, yourid:req.user.uid});
});
}
else if(req.params.tab == 'sort-reputation') {
user.getUserList(function(data) {
data = data.sort(function(a, b) {
return b.reputation - a.reputation;
});
res.json({search_display: 'none', users:data, yourid:req.user.uid});
});
}
else {
user.getUserList(function(data) {
res.json({search_display: 'none', users:data, yourid:req.user.uid});
});
}
break; app.get('/api/admin/users/latest', function(req, res) {
case 'categories': user.getUserList(function(data) {
if (req.params.tab == 'disabled') { data = data.sort(function(a, b) {
res.json({categories: []}); return b.joindate - a.joindate;
} else { });
categories.getAllCategories(function(data) { res.json({search_display: 'none', users:data, yourid:req.user.uid});
res.json(data); });
}); });
}
break;
case 'topics':
topics.getAllTopics(10, null, function(topics) {
res.json({
topics: topics
});
});
break;
case 'redis':
RDB.info(function(err, data) {
data = data.split("\r\n");
var finalData = {};
for(var i in data) { app.get('/api/admin/users/sort-posts', function(req, res) {
user.getUserList(function(data) {
data = data.sort(function(a, b) {
return b.postcount - a.postcount;
});
res.json({search_display: 'none', users:data, yourid:req.user.uid});
});
});
app.get('/api/admin/users/sort-reputation', function(req, res) {
user.getUserList(function(data) {
data = data.sort(function(a, b) {
return b.reputation - a.reputation;
});
res.json({search_display: 'none', users:data, yourid:req.user.uid});
});
});
app.get('/api/admin/users', function(req, res) {
user.getUserList(function(data) {
res.json({search_display: 'none', users:data, yourid:req.user.uid});
});
});
try { app.get('/api/admin/categories', function(req, res) {
data[i] = data[i].replace(/:/,"\":\""); categories.getAllCategories(function(data) {
var json = "{\"" + data[i] + "\"}"; res.json(data);
});
});
app.get('/api/admin/categories/disabled', function(req, res) {
res.json({categories: []});
});
app.get('/api/admin/topics', function(req, res) {
topics.getAllTopics(10, null, function(topics) {
res.json({
topics: topics
});
});
});
var jsonObject = JSON.parse(json); app.get('/api/admin/redis', function(req, res) {
for(var key in jsonObject) { RDB.info(function(err, data) {
finalData[key] = jsonObject[key]; data = data.split("\r\n");
} var finalData = {};
}catch(err){
} for(var i in data) {
try {
data[i] = data[i].replace(/:/,"\":\"");
var json = "{\"" + data[i] + "\"}";
var jsonObject = JSON.parse(json);
for(var key in jsonObject) {
finalData[key] = jsonObject[key];
} }
} catch(err){
console.log(err);
}
}
res.json(finalData);
});
});
res.json(finalData); app.get('/api/admin/plugins', function(req, res) {
}); plugins.showInstalled(function(err, plugins) {
break; if (err || !Array.isArray(plugins)) plugins = [];
case 'plugins':
plugins.showInstalled(function(err, plugins) {
if (err || !Array.isArray(plugins)) plugins = [];
res.json(200, {
plugins: plugins
});
});
break;
default :
res.json({});
}
}
app.get('/api/admin/:method/:tab?*', api_method); res.json(200, {
app.get('/api/admin/:method*', api_method); plugins: plugins
});
});
});
app.get('/api/admin/settings', function(req, res) {
res.json(200, {});
});
app.get('/api/admin/motd', function(req, res) {
res.json(200, {});
});
app.get('/api/admin/themes', function(req, res) {
res.json(200, {});
});
app.get('/api/admin/twitter', function(req, res) {
res.json(200, {});
});
app.get('/api/admin/facebook', function(req, res) {
res.json(200, {});
});
app.get('/api/admin/gplus', function(req, res) {
res.json(200, {});
});
app.get('/api/admin/testing/categories', function(req, res) {
res.json(200, {});
});
}; };

@ -24,20 +24,13 @@ var RDB = require('../redis.js');
res.send(templates['install/header'] + app.create_route('install/basic') + templates['install/footer']); res.send(templates['install/header'] + app.create_route('install/basic') + templates['install/footer']);
}); });
app.get('/api/install/basic', function(req, res) {
res.send('{}');
});
function api_method(req, res) { app.get('/api/install', function(req, res) {
switch(req.params.method) { res.send('{}');
case 'basic' : });
res.send('{}');
break;
default :
res.send('{}');
}
}
app.get('/api/install/:method/:tab?*', api_method);
app.get('/api/install/:method*', api_method);
}; };

Loading…
Cancel
Save