cleaned up requires

v1.18.x
Baris Soner Usakli 12 years ago
parent bfe081f672
commit 140f90f7f3

@ -1,6 +1,6 @@
var RDB = require('./../redis.js'), var RDB = require('./../redis'),
utils = require('./../../public/src/utils.js'), utils = require('./../../public/src/utils'),
categories = require('./../categories.js'); categories = require('./../categories');
(function(CategoriesAdmin) { (function(CategoriesAdmin) {

@ -1,15 +1,15 @@
var RDB = require('../redis'), var RDB = require('../redis'),
utils = require('../../public/src/utils'), utils = require('../../public/src/utils'),
user = require('../user'), user = require('../user'),
Groups = require('../groups'); groups = require('../groups');
(function(UserAdmin) { (function(UserAdmin) {
UserAdmin.makeAdmin = function(uid, theirid, socket) { UserAdmin.makeAdmin = function(uid, theirid, socket) {
user.isAdministrator(uid, function(err, isAdmin) { user.isAdministrator(uid, function(err, isAdmin) {
if (isAdmin) { if (isAdmin) {
Groups.getGidFromName('Administrators', function(err, gid) { groups.getGidFromName('Administrators', function(err, gid) {
Groups.join(gid, theirid, function(err) { groups.join(gid, theirid, function(err) {
if (!err) { if (!err) {
socket.emit('event:alert', { socket.emit('event:alert', {
title: 'User Modified', title: 'User Modified',
@ -34,8 +34,8 @@ var RDB = require('../redis'),
UserAdmin.removeAdmin = function(uid, theirid, socket) { UserAdmin.removeAdmin = function(uid, theirid, socket) {
user.isAdministrator(uid, function(err, isAdmin) { user.isAdministrator(uid, function(err, isAdmin) {
if (isAdmin) { if (isAdmin) {
Groups.getGidFromName('Administrators', function(err, gid) { groups.getGidFromName('Administrators', function(err, gid) {
Groups.leave(gid, theirid, function(err) { groups.leave(gid, theirid, function(err) {
if (!err) { if (!err) {
socket.emit('event:alert', { socket.emit('event:alert', {

@ -1,15 +1,18 @@
var user = require('./../user.js'), var nconf = require('nconf'),
Groups = require('../groups'),
topics = require('./../topics.js'),
RDB = require('./../redis.js'),
pkg = require('./../../package.json'),
categories = require('./../categories.js'),
Meta = require('../meta'),
plugins = require('../plugins'),
winston = require('winston'),
nconf = require('nconf'),
fs = require('fs'), fs = require('fs'),
path = require('path'); path = require('path'),
winston = require('winston'),
RDB = require('./../redis'),
user = require('./../user'),
groups = require('../groups'),
topics = require('./../topics'),
pkg = require('./../../package.json'),
categories = require('./../categories'),
meta = require('../meta'),
plugins = require('../plugins');
(function (Admin) { (function (Admin) {
Admin.isAdmin = function (req, res, next) { Admin.isAdmin = function (req, res, next) {
@ -291,7 +294,7 @@ var user = require('./../user.js'),
}); });
// app.get('/export', function (req, res) { // app.get('/export', function (req, res) {
// Meta.db.getFile(function (err, dbFile) { // meta.db.getFile(function (err, dbFile) {
// if (!err) { // if (!err) {
// res.download(dbFile, 'redis.rdb', function (err) { // res.download(dbFile, 'redis.rdb', function (err) {
// console.log(err); // console.log(err);
@ -356,7 +359,7 @@ var user = require('./../user.js'),
}); });
app.get('/groups', function (req, res) { app.get('/groups', function (req, res) {
Groups.list({ groups.list({
expand: true expand: true
}, function (err, groups) { }, function (err, groups) {
res.json(200, { res.json(200, {

@ -1,17 +1,16 @@
var user = require('../user'), var path = require('path'),
nconf = require('nconf'),
async = require('async'),
user = require('../user'),
auth = require('./authentication'), auth = require('./authentication'),
topics = require('../topics'), topics = require('../topics'),
posts = require('../posts'), posts = require('../posts'),
categories = require('../categories'), categories = require('../categories'),
CategoryTools = require('../categoryTools') categoryTools = require('../categoryTools')
Groups = require('../groups'),
utils = require('../../public/src/utils'), utils = require('../../public/src/utils'),
pkg = require('../../package.json'), pkg = require('../../package.json'),
meta = require('../meta'), meta = require('../meta');
path = require('path'),
nconf = require('nconf'),
async = require('async');
(function (Api) { (function (Api) {
@ -130,7 +129,7 @@ var user = require('../user'),
var uid = (req.user) ? req.user.uid : 0; var uid = (req.user) ? req.user.uid : 0;
// Category Whitelisting // Category Whitelisting
CategoryTools.privileges(req.params.id, uid, function(err, privileges) { categoryTools.privileges(req.params.id, uid, function(err, privileges) {
if (!err && privileges.read) { if (!err && privileges.read) {
categories.getCategoryById(req.params.id, uid, function (err, data) { categories.getCategoryById(req.params.id, uid, function (err, data) {
if (!err && data && data.disabled === "0") if (!err && data && data.disabled === "0")
@ -176,7 +175,9 @@ var user = require('../user'),
notifications: notifications notifications: notifications
}); });
}); });
} else res.send(403); } else {
res.send(403);
}
}); });
app.get('/confirm/:id', function (req, res) { app.get('/confirm/:id', function (req, res) {
@ -236,12 +237,14 @@ var user = require('../user'),
function searchPosts(callback) { function searchPosts(callback) {
search(postSearch, function (err, pids) { search(postSearch, function (err, pids) {
if (err) if (err) {
return callback(err, null); return callback(err, null);
}
posts.getPostSummaryByPids(pids, function (err, posts) { posts.getPostSummaryByPids(pids, function (err, posts) {
if (err) if (err){
return callback(err, null); return callback(err, null);
}
callback(null, posts); callback(null, posts);
}); });
}) })
@ -249,8 +252,9 @@ var user = require('../user'),
function searchTopics(callback) { function searchTopics(callback) {
search(topicSearch, function (err, tids) { search(topicSearch, function (err, tids) {
if (err) if (err) {
return callback(err, null); return callback(err, null);
}
topics.getTopicsByTids(tids, 0, function (topics) { topics.getTopicsByTids(tids, 0, function (topics) {
callback(null, topics); callback(null, topics);
@ -259,8 +263,9 @@ var user = require('../user'),
} }
async.parallel([searchPosts, searchTopics], function (err, results) { async.parallel([searchPosts, searchTopics], function (err, results) {
if (err) if (err) {
return next(); return next();
}
return res.json({ return res.json({
show_no_topics: results[1].length ? 'hide' : '', show_no_topics: results[1].length ? 'hide' : '',

@ -10,7 +10,7 @@
user = require('../user'), user = require('../user'),
plugins = require('../plugins'), plugins = require('../plugins'),
winston = require('winston'), winston = require('winston'),
login_module = require('./../login.js'); login_module = require('./../login');
passport.use(new passportLocal(function(user, password, next) { passport.use(new passportLocal(function(user, password, next) {
login_module.loginViaLocal(user, password, function(err, login) { login_module.loginViaLocal(user, password, function(err, login) {

@ -4,7 +4,7 @@ var nconf = require('nconf'),
path = require('path'), path = require('path'),
fs = require('fs'), fs = require('fs'),
validator = require('validator'), validator = require('validator'),
Plugins = require('../plugins'), plugins = require('../plugins'),
PluginRoutes = function(app) { PluginRoutes = function(app) {
app.get('/plugins/fireHook', function(req, res) { app.get('/plugins/fireHook', function(req, res) {
@ -20,7 +20,7 @@ var nconf = require('nconf'),
app.put('/plugins/fireHook', function(req, res) { app.put('/plugins/fireHook', function(req, res) {
// PUT = action // PUT = action
Plugins.fireHook('action:' + req.body.hook, req.body.args); plugins.fireHook('action:' + req.body.hook, req.body.args);
res.send(200); res.send(200);
}); });

Loading…
Cancel
Save