-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
library.js
69 lines (57 loc) · 1.8 KB
/
library.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
"use strict";
var plugin = {};
var async = require.main.require('async');
var topics = require.main.require('./src/topics');
var posts = require.main.require('./src/posts');
var categories = require.main.require('./src/categories');
var meta = require.main.require('./src/meta');
var privileges = require.main.require('./src/privileges');
var rewards = require.main.require('./src/rewards');
var user = require.main.require('./src/user');
var helpers = require.main.require('./src/controllers/helpers');
var db = require.main.require('./src/database');
var plugins = require.main.require('./src/plugins');
var SocketPlugins = require.main.require('./src/socket.io/plugins');
var pagination = require.main.require('./src/pagination');
plugin.init = function (params, callback) {
var app = params.router;
var middleware = params.middleware;
app.get('/admin/plugins/nsfw', middleware.admin.buildHeader, renderAdmin);
app.get('/api/admin/plugins/nsfw', renderAdmin);
handleSocketIO();
meta.settings.get('nsfw', function (err, settings) {
if (err) {
return callback(err);
}
plugin._settings = settings;
callback();
});
};
plugin.appendConfig = function (config, callback) {
config['nsfw'] = plugin._settings;
setImmediate(callback, null, config);
};
plugin.addAdminNavigation = function (header, callback) {
header.plugins.push({
route: '/plugins/nsfw',
icon: 'fa-minus-circle',
name: 'NSFW Categories',
});
callback(null, header);
};
function renderAdmin(req, res, next) {
async.waterfall([
async.apply(db.getSortedSetRange, 'categories:cid', 0, -1),
function (cids, next) {
categories.getCategoriesFields(cids, ['cid', 'name'], next);
},
], function (err, data) {
if (err) {
return next(err);
}
res.render('admin/plugins/nsfw', {
categories: data,
});
});
}
module.exports = plugin;