Skip to content

Node.js based forum software built for the modern web

admin controllers

barisusakli244c75f809f8
diff --git a/src/controllers/admin.js b/src/controllers/admin.js
index 023df9c6b1..b620dce3d2 100644
--- a/src/controllers/admin.js
+++ b/src/controllers/admin.js
@@ -1,423 +1,31 @@
"use strict";
-var async = require('async'),
- fs = require('fs'),
- path = require('path'),
- nconf = require('nconf'),
-
- user = require('../user'),
- categories = require('../categories'),
- privileges = require('../privileges'),
- posts = require('../posts'),
- topics = require('../topics'),
- meta = require('../meta'),
- db = require('../database'),
- events = require('../events'),
- languages = require('../languages'),
- plugins = require('../plugins'),
- validator = require('validator');
-
-
var adminController = {
+ dashboard: require('./admin/dashboard'),
categories: require('./admin/categories'),
- tags: {},
- flags: {},
- topics: {},
+ tags: require('./admin/tags'),
+ flags: require('./admin/flags'),
groups: require('./admin/groups'),
- appearance: {},
+ appearance: require('./admin/appearance'),
extend: {
- widgets: {}
+ widgets: require('./admin/widgets'),
+ rewards: require('./admin/rewards')
},
- events: {},
- logs: {},
- database: {},
- postCache: {},
- plugins: {},
- languages: {},
- settings: {},
- logger: {},
- sounds: {},
- homepage: {},
- navigation: {},
- themes: {},
+ events: require('./admin/events'),
+ logs: require('./admin/logs'),
+ database: require('./admin/database'),
+ postCache: require('./admin/postCache'),
+ plugins: require('./admin/plugins'),
+ languages: require('./admin/languages'),
+ settings: require('./admin/settings'),
+ logger: require('./admin/logger'),
+ sounds: require('./admin/sounds'),
+ homepage: require('./admin/homepage'),
+ navigation: require('./admin/navigation'),
+ themes: require('./admin/themes'),
users: require('./admin/users'),
uploads: require('./admin/uploads')
};
-adminController.home = function(req, res, next) {
- async.parallel({
- stats: function(next) {
- getStats(next);
- },
- notices: function(next) {
- var notices = [
- {
- done: !meta.reloadRequired,
- doneText: 'Reload not required',
- notDoneText:'Reload required'
- },
- {
- done: plugins.hasListeners('action:email.send'),
- doneText: 'Emailer Installed',
- notDoneText:'Emailer not installed',
- tooltip:'Install an emailer plugin from the plugin page in order to activate registration emails and email digests',
- link:'/admin/extend/plugins'
- },
- {
- done: plugins.hasListeners('filter:search.query'),
- doneText: 'Search Plugin Installed',
- notDoneText:'Search Plugin not installed',
- tooltip: 'Install a search plugin from the plugin page in order to activate search functionality',
- link:'/admin/extend/plugins'
- }
- ];
- plugins.fireHook('filter:admin.notices', notices, next);
- }
- }, function(err, results) {
- if (err) {
- return next(err);
- }
- res.render('admin/general/dashboard', {
- version: nconf.get('version'),
- notices: results.notices,
- stats: results.stats
- });
- });
-};
-
-function getStats(callback) {
- async.parallel([
- function(next) {
- getStatsForSet('ip:recent', 'uniqueIPCount', next);
- },
- function(next) {
- getStatsForSet('users:joindate', 'userCount', next);
- },
- function(next) {
- getStatsForSet('posts:pid', 'postCount', next);
- },
- function(next) {
- getStatsForSet('topics:tid', 'topicCount', next);
- }
- ], function(err, results) {
- if (err) {
- return callback(err);
- }
- results[0].name = 'Unique Visitors';
- results[1].name = 'Users';
- results[2].name = 'Posts';
- results[3].name = 'Topics';
-
- callback(null, results);
- });
-}
-
-function getStatsForSet(set, field, callback) {
- var terms = {
- day: 86400000,
- week: 604800000,
- month: 2592000000
- };
-
- var now = Date.now();
- async.parallel({
- day: function(next) {
- db.sortedSetCount(set, now - terms.day, now, next);
- },
- week: function(next) {
- db.sortedSetCount(set, now - terms.week, now, next);
- },
- month: function(next) {
- db.sortedSetCount(set, now - terms.month, now, next);
- },
- alltime: function(next) {
- getGlobalField(field, next);
- }
- }, callback);
-}
-
-function getGlobalField(field, callback) {
- db.getObjectField('global', field, function(err, count) {
- callback(err, parseInt(count, 10) || 0);
- });
-}
-
-adminController.tags.get = function(req, res, next) {
- topics.getTags(0, 199, function(err, tags) {
- if (err) {
- return next(err);
- }
-
- res.render('admin/manage/tags', {tags: tags});
- });
-};
-
-adminController.flags.get = function(req, res, next) {
- function done(err, posts) {
- if (err) {
- return next(err);
- }
- res.render('admin/manage/flags', {posts: posts, next: stop + 1, byUsername: byUsername});
- }
-
- var sortBy = req.query.sortBy || 'count';
- var byUsername = req.query.byUsername || '';
- var start = 0;
- var stop = 19;
-
- if (byUsername) {
- posts.getUserFlags(byUsername, sortBy, req.uid, start, stop, done);
- } else {
- var set = sortBy === 'count' ? 'posts:flags:count' : 'posts:flagged';
- posts.getFlags(set, req.uid, start, stop, done);
- }
-};
-
-adminController.database.get = function(req, res, next) {
- async.parallel({
- redis: function(next) {
- if (nconf.get('redis')) {
- var rdb = require('../database/redis');
- var cxn = rdb.connect();
- rdb.info(cxn, next);
- } else {
- next();
- }
- },
- mongo: function(next) {
- if (nconf.get('mongo')) {
- var mdb = require('../database/mongo');
- mdb.info(mdb.client, next);
- } else {
- next();
- }
- }
- }, function(err, results) {
- if (err) {
- return next(err);
- }
- res.render('admin/advanced/database', results);
- });
-};
-
-adminController.events.get = function(req, res, next) {
- events.getEvents(0, 19, function(err, events) {
- if(err || !events) {
- return next(err);
- }
-
- res.render('admin/advanced/events', {
- events: events,
- next: 20
- });
- });
-};
-
-adminController.logs.get = function(req, res, next) {
- meta.logs.get(function(err, logs) {
- res.render('admin/advanced/logs', {
- data: validator.escape(logs)
- });
- });
-};
-
-adminController.postCache.get = function(req, res, next) {
- var cache = require('../posts/cache');
- var avgPostSize = 0;
- var percentFull = 0;
- if (cache.itemCount > 0) {
- avgPostSize = parseInt((cache.length / cache.itemCount), 10);
- percentFull = ((cache.length / cache.max) * 100).toFixed(2);
- }
-
- res.render('admin/advanced/post-cache', {
- cache: {
- length: cache.length,
- max: cache.max,
- itemCount: cache.itemCount,
- percentFull: percentFull,
- avgPostSize: avgPostSize
- }
- });
-};
-
-adminController.plugins.get = function(req, res, next) {
- async.parallel({
- compatible: function(next) {
- plugins.list(function(err, plugins) {
- if (err || !Array.isArray(plugins)) {
- plugins = [];
- }
-
- next(null, plugins);
- });
- },
- all: function(next) {
- plugins.list(false, function(err, plugins) {
- if (err || !Array.isArray(plugins)) {
- plugins = [];
- }
-
- next(null, plugins);
- });
- }
- }, function(err, payload) {
- var compatiblePkgNames = payload.compatible.map(function(pkgData) {
- return pkgData.name;
- });
-
- res.render('admin/extend/plugins' , {
- installed: payload.compatible.filter(function(plugin) {
- return plugin.installed;
- }),
- download: payload.compatible.filter(function(plugin) {
- return !plugin.installed;
- }),
- incompatible: payload.all.filter(function(plugin) {
- return compatiblePkgNames.indexOf(plugin.name) === -1;
- })
- });
- });
-};
-
-adminController.languages.get = function(req, res, next) {
- languages.list(function(err, languages) {
- if (err) {
- return next(err);
- }
-
- languages.forEach(function(language) {
- language.selected = language.code === (meta.config.defaultLang || 'en_GB');
- });
-
- res.render('admin/general/languages', {
- languages: languages
- });
- });
-};
-
-adminController.sounds.get = function(req, res, next) {
- meta.sounds.getFiles(function(err, sounds) {
- sounds = Object.keys(sounds).map(function(name) {
- return {
- name: name
- };
- });
-
- res.render('admin/general/sounds', {
- sounds: sounds
- });
- });
-};
-
-adminController.navigation.get = function(req, res, next) {
- require('../navigation/admin').getAdmin(function(err, data) {
- if (err) {
- return next(err);
- }
-
- res.render('admin/general/navigation', data);
- });
-};
-
-adminController.homepage.get = function(req, res, next) {
- async.waterfall([
- function(next) {
- db.getSortedSetRange('categories:cid', 0, -1, next);
- },
- function(cids, next) {
- privileges.categories.filterCids('find', cids, 0, next);
- },
- function(cids, next) {
- categories.getMultipleCategoryFields(cids, ['name', 'slug'], next);
- },
- function(categoryData, next) {
- categoryData = categoryData.map(function(category) {
- return {
- route: 'category/' + category.slug,
- name: 'Category: ' + category.name
- };
- });
- next(null, categoryData);
- }
- ], function(err, categoryData) {
- if (err || !categoryData) categoryData = [];
-
- plugins.fireHook('filter:homepage.get', {routes: [
- {
- route: 'categories',
- name: 'Categories'
- },
- {
- route: 'recent',
- name: 'Recent'
- },
- {
- route: 'popular',
- name: 'Popular'
- }
- ].concat(categoryData)}, function(err, data) {
- data.routes.push({
- route: '',
- name: 'Custom'
- });
-
- res.render('admin/general/homepage', data);
- });
- });
-};
-
-adminController.settings.get = function(req, res, next) {
- var term = req.params.term ? req.params.term : 'general';
-
- res.render('admin/settings/' + term);
-};
-
-adminController.logger.get = function(req, res, next) {
- res.render('admin/development/logger', {});
-};
-
-adminController.appearance.get = function(req, res, next) {
- var term = req.params.term ? req.params.term : 'themes';
-
- res.render('admin/appearance/' + term, {});
-};
-
-adminController.extend.widgets = function(req, res, next) {
- require('../widgets/admin').get(function(err, data) {
- if (err) {
- return next(err);
- }
-
- res.render('admin/extend/widgets', data);
- });
-};
-
-adminController.extend.rewards = function(req, res, next) {
- require('../rewards/admin').get(function(err, data) {
- if (err) {
- return next(err);
- }
-
- res.render('admin/extend/rewards', data);
- });
-};
-
-adminController.themes.get = function(req, res, next) {
- var themeDir = path.join(__dirname, '../../node_modules/' + req.params.theme);
- fs.exists(themeDir, function(exists) {
- if (exists) {
- var themeConfig = require(path.join(themeDir, 'theme.json')),
- screenshotPath = path.join(themeDir, themeConfig.screenshot);
- if (themeConfig.screenshot && fs.existsSync(screenshotPath)) {
- res.sendFile(screenshotPath);
- } else {
- res.sendFile(path.join(__dirname, '../../public/images/themes/default.png'));
- }
- } else {
- return next();
- }
- });
-};
module.exports = adminController;
diff --git a/src/controllers/admin/appearance.js b/src/controllers/admin/appearance.js
new file mode 100644
index 0000000000..8d60efda23
--- /dev/null
+++ b/src/controllers/admin/appearance.js
@@ -0,0 +1,12 @@
+"use strict";
+
+var appearanceController = {};
+
+appearanceController.get = function(req, res, next) {
+ var term = req.params.term ? req.params.term : 'themes';
+
+ res.render('admin/appearance/' + term, {});
+};
+
+
+module.exports = appearanceController;
diff --git a/src/controllers/admin/dashboard.js b/src/controllers/admin/dashboard.js
new file mode 100644
index 0000000000..7575a19411
--- /dev/null
+++ b/src/controllers/admin/dashboard.js
@@ -0,0 +1,111 @@
+'use strict';
+
+var async = require('async');
+var nconf = require('nconf');
+
+var db = require('../../database');
+var meta = require('../../meta');
+var plugins = require('../../plugins');
+
+var dashboardController = {};
+
+
+dashboardController.get = function(req, res, next) {
+ async.parallel({
+ stats: function(next) {
+ getStats(next);
+ },
+ notices: function(next) {
+ var notices = [
+ {
+ done: !meta.reloadRequired,
+ doneText: 'Reload not required',
+ notDoneText:'Reload required'
+ },
+ {
+ done: plugins.hasListeners('action:email.send'),
+ doneText: 'Emailer Installed',
+ notDoneText:'Emailer not installed',
+ tooltip:'Install an emailer plugin from the plugin page in order to activate registration emails and email digests',
+ link:'/admin/extend/plugins'
+ },
+ {
+ done: plugins.hasListeners('filter:search.query'),
+ doneText: 'Search Plugin Installed',
+ notDoneText:'Search Plugin not installed',
+ tooltip: 'Install a search plugin from the plugin page in order to activate search functionality',
+ link:'/admin/extend/plugins'
+ }
+ ];
+ plugins.fireHook('filter:admin.notices', notices, next);
+ }
+ }, function(err, results) {
+ if (err) {
+ return next(err);
+ }
+ res.render('admin/general/dashboard', {
+ version: nconf.get('version'),
+ notices: results.notices,
+ stats: results.stats
+ });
+ });
+};
+
+function getStats(callback) {
+ async.parallel([
+ function(next) {
+ getStatsForSet('ip:recent', 'uniqueIPCount', next);
+ },
+ function(next) {
+ getStatsForSet('users:joindate', 'userCount', next);
+ },
+ function(next) {
+ getStatsForSet('posts:pid', 'postCount', next);
+ },
+ function(next) {
+ getStatsForSet('topics:tid', 'topicCount', next);
+ }
+ ], function(err, results) {
+ if (err) {
+ return callback(err);
+ }
+ results[0].name = 'Unique Visitors';
+ results[1].name = 'Users';
+ results[2].name = 'Posts';
+ results[3].name = 'Topics';
+
+ callback(null, results);
+ });
+}
+
+function getStatsForSet(set, field, callback) {
+ var terms = {
+ day: 86400000,
+ week: 604800000,
+ month: 2592000000
+ };
+
+ var now = Date.now();
+ async.parallel({
+ day: function(next) {
+ db.sortedSetCount(set, now - terms.day, now, next);
+ },
+ week: function(next) {
+ db.sortedSetCount(set, now - terms.week, now, next);
+ },
+ month: function(next) {
+ db.sortedSetCount(set, now - terms.month, now, next);
+ },
+ alltime: function(next) {
+ getGlobalField(field, next);
+ }
+ }, callback);
+}
+
+function getGlobalField(field, callback) {
+ db.getObjectField('global', field, function(err, count) {
+ callback(err, parseInt(count, 10) || 0);
+ });
+}
+
+module.exports = dashboardController;
\ No newline at end of file
diff --git a/src/controllers/admin/database.js b/src/controllers/admin/database.js
new file mode 100644
index 0000000000..d15db3f09c
--- /dev/null
+++ b/src/controllers/admin/database.js
@@ -0,0 +1,37 @@
+'use strict';
+
+var async = require('async');
+var nconf = require('nconf');
+
+var databaseController = {};
+
+
+
+databaseController.get = function(req, res, next) {
+ async.parallel({
+ redis: function(next) {
+ if (nconf.get('redis')) {
+ var rdb = require('../../database/redis');
+ var cxn = rdb.connect();
+ rdb.info(cxn, next);
+ } else {
+ next();
+ }
+ },
+ mongo: function(next) {
+ if (nconf.get('mongo')) {
+ var mdb = require('../../database/mongo');
+ mdb.info(mdb.client, next);
+ } else {
+ next();
+ }
+ }
+ }, function(err, results) {
+ if (err) {
+ return next(err);
+ }
+ res.render('admin/advanced/database', results);
+ });
+};
+
+module.exports = databaseController;
\ No newline at end of file
diff --git a/src/controllers/admin/events.js b/src/controllers/admin/events.js
new file mode 100644
index 0000000000..ceee1e2a70
--- /dev/null
+++ b/src/controllers/admin/events.js
@@ -0,0 +1,22 @@
+'use strict';
+
+var events = require('../../events');
+
+var eventsController = {};
+
+
+eventsController.get = function(req, res, next) {
+ events.getEvents(0, 19, function(err, events) {
+ if (err) {
+ return next(err);
+ }
+
+ res.render('admin/advanced/events', {
+ events: events,
+ next: 20
+ });
+ });
+};
+
+
+module.exports = eventsController;
\ No newline at end of file
diff --git a/src/controllers/admin/flags.js b/src/controllers/admin/flags.js
new file mode 100644
index 0000000000..ee153bfffb
--- /dev/null
+++ b/src/controllers/admin/flags.js
@@ -0,0 +1,29 @@
+"use strict";
+
+var posts = require('../../posts');
+
+var flagsController = {};
+
+flagsController.get = function(req, res, next) {
+ function done(err, posts) {
+ if (err) {
+ return next(err);
+ }
+ res.render('admin/manage/flags', {posts: posts, next: stop + 1, byUsername: byUsername});
+ }
+
+ var sortBy = req.query.sortBy || 'count';
+ var byUsername = req.query.byUsername || '';
+ var start = 0;
+ var stop = 19;
+
+ if (byUsername) {
+ posts.getUserFlags(byUsername, sortBy, req.uid, start, stop, done);
+ } else {
+ var set = sortBy === 'count' ? 'posts:flags:count' : 'posts:flagged';
+ posts.getFlags(set, req.uid, start, stop, done);
+ }
+};
+
+
+module.exports = flagsController;
diff --git a/src/controllers/admin/homepage.js b/src/controllers/admin/homepage.js
new file mode 100644
index 0000000000..834ada501d
--- /dev/null
+++ b/src/controllers/admin/homepage.js
@@ -0,0 +1,62 @@
+'use strict';
+
+var async = require('async');
+
+var db = require('../../database');
+var categories = require('../../categories');
+var privileges = require('../../privileges');
+var plugins = require('../../plugins');
+
+var homePageController = {};
+
+
+homePageController.get = function(req, res, next) {
+ async.waterfall([
+ function(next) {
+ db.getSortedSetRange('categories:cid', 0, -1, next);
+ },
+ function(cids, next) {
+ privileges.categories.filterCids('find', cids, 0, next);
+ },
+ function(cids, next) {
+ categories.getMultipleCategoryFields(cids, ['name', 'slug'], next);
+ },
+ function(categoryData, next) {
+ categoryData = categoryData.map(function(category) {
+ return {
+ route: 'category/' + category.slug,
+ name: 'Category: ' + category.name
+ };
+ });
+ next(null, categoryData);
+ }
+ ], function(err, categoryData) {
+ if (err || !categoryData) {
+ categoryData = [];
+ }
+
+ plugins.fireHook('filter:homepage.get', {routes: [
+ {
+ route: 'categories',
+ name: 'Categories'
+ },
+ {
+ route: 'recent',
+ name: 'Recent'
+ },
+ {
+ route: 'popular',
+ name: 'Popular'
+ }
+ ].concat(categoryData)}, function(err, data) {
+ data.routes.push({
+ route: '',
+ name: 'Custom'
+ });
+
+ res.render('admin/general/homepage', data);
+ });
+ });
+};
+
+module.exports = homePageController;
\ No newline at end of file
diff --git a/src/controllers/admin/languages.js b/src/controllers/admin/languages.js
new file mode 100644
index 0000000000..85c6d60484
--- /dev/null
+++ b/src/controllers/admin/languages.js
@@ -0,0 +1,25 @@
+'use strict';
+
+var languages = require('../../languages');
+var meta = require('../../meta');
+
+var languagesController = {};
+
+
+languagesController.get = function(req, res, next) {
+ languages.list(function(err, languages) {
+ if (err) {
+ return next(err);
+ }
+
+ languages.forEach(function(language) {
+ language.selected = language.code === (meta.config.defaultLang || 'en_GB');
+ });
+
+ res.render('admin/general/languages', {
+ languages: languages
+ });
+ });
+};
+
+module.exports = languagesController;
\ No newline at end of file
diff --git a/src/controllers/admin/logger.js b/src/controllers/admin/logger.js
new file mode 100644
index 0000000000..45c9f246c9
--- /dev/null
+++ b/src/controllers/admin/logger.js
@@ -0,0 +1,9 @@
+'use strict';
+
+var loggerController = {};
+
+loggerController.get = function(req, res) {
+ res.render('admin/development/logger', {});
+};
+
+module.exports = loggerController;
\ No newline at end of file
diff --git a/src/controllers/admin/logs.js b/src/controllers/admin/logs.js
new file mode 100644
index 0000000000..f3ae601dd4
--- /dev/null
+++ b/src/controllers/admin/logs.js
@@ -0,0 +1,22 @@
+'use strict';
+
+var validator = require('validator');
+var meta = require('../../meta');
+
+
+var logsController = {};
+
+logsController.get = function(req, res, next) {
+ meta.logs.get(function(err, logs) {
+ if (err) {
+ return next(err);
+ }
+
+ res.render('admin/advanced/logs', {
+ data: validator.escape(logs)
+ });
+ });
+};
+
+
+module.exports = logsController;
\ No newline at end of file
diff --git a/src/controllers/admin/navigation.js b/src/controllers/admin/navigation.js
new file mode 100644
index 0000000000..a9ebb5e172
--- /dev/null
+++ b/src/controllers/admin/navigation.js
@@ -0,0 +1,15 @@
+'use strict';
+
+var navigationController = {};
+
+navigationController.get = function(req, res, next) {
+ require('../../navigation/admin').getAdmin(function(err, data) {
+ if (err) {
+ return next(err);
+ }
+
+ res.render('admin/general/navigation', data);
+ });
+};
+
+module.exports = navigationController;
\ No newline at end of file
diff --git a/src/controllers/admin/plugins.js b/src/controllers/admin/plugins.js
new file mode 100644
index 0000000000..a4733e4c51
--- /dev/null
+++ b/src/controllers/admin/plugins.js
@@ -0,0 +1,50 @@
+'use strict';
+
+var async = require('async');
+var plugins = require('../../plugins');
+
+var pluginsController = {};
+
+pluginsController.get = function(req, res, next) {
+ async.parallel({
+ compatible: function(next) {
+ plugins.list(function(err, plugins) {
+ if (err || !Array.isArray(plugins)) {
+ plugins = [];
+ }
+
+ next(null, plugins);
+ });
+ },
+ all: function(next) {
+ plugins.list(false, function(err, plugins) {
+ if (err || !Array.isArray(plugins)) {
+ plugins = [];
+ }
+
+ next(null, plugins);
+ });
+ }
+ }, function(err, payload) {
+ if (err) {
+ return next(err);
+ }
+ var compatiblePkgNames = payload.compatible.map(function(pkgData) {
+ return pkgData.name;
+ });
+
+ res.render('admin/extend/plugins' , {
+ installed: payload.compatible.filter(function(plugin) {
+ return plugin.installed;
+ }),
+ download: payload.compatible.filter(function(plugin) {
+ return !plugin.installed;
+ }),
+ incompatible: payload.all.filter(function(plugin) {
+ return compatiblePkgNames.indexOf(plugin.name) === -1;
+ })
+ });
+ });
+};
+
+module.exports = pluginsController;
\ No newline at end of file
diff --git a/src/controllers/admin/postCache.js b/src/controllers/admin/postCache.js
new file mode 100644
index 0000000000..bbfd222586
--- /dev/null
+++ b/src/controllers/admin/postCache.js
@@ -0,0 +1,26 @@
+'use strict';
+
+var postCacheController = {};
+
+postCacheController.get = function(req, res, next) {
+ var cache = require('../../posts/cache');
+ var avgPostSize = 0;
+ var percentFull = 0;
+ if (cache.itemCount > 0) {
+ avgPostSize = parseInt((cache.length / cache.itemCount), 10);
+ percentFull = ((cache.length / cache.max) * 100).toFixed(2);
+ }
+
+ res.render('admin/advanced/post-cache', {
+ cache: {
+ length: cache.length,
+ max: cache.max,
+ itemCount: cache.itemCount,
+ percentFull: percentFull,
+ avgPostSize: avgPostSize
+ }
+ });
+};
+
+
+module.exports = postCacheController;
\ No newline at end of file
diff --git a/src/controllers/admin/rewards.js b/src/controllers/admin/rewards.js
new file mode 100644
index 0000000000..063abb6807
--- /dev/null
+++ b/src/controllers/admin/rewards.js
@@ -0,0 +1,17 @@
+'use strict';
+
+var rewardsController = {};
+
+rewardsController.get = function(req, res, next) {
+ require('../../rewards/admin').get(function(err, data) {
+ if (err) {
+ return next(err);
+ }
+
+ res.render('admin/extend/rewards', data);
+ });
+};
+
+
+
+module.exports = rewardsController;
\ No newline at end of file
diff --git a/src/controllers/admin/settings.js b/src/controllers/admin/settings.js
new file mode 100644
index 0000000000..cf204a3d7c
--- /dev/null
+++ b/src/controllers/admin/settings.js
@@ -0,0 +1,11 @@
+'use strict';
+
+var settingsController = {};
+
+settingsController.get = function(req, res, next) {
+ var term = req.params.term ? req.params.term : 'general';
+
+ res.render('admin/settings/' + term);
+};
+
+module.exports = settingsController;
\ No newline at end of file
diff --git a/src/controllers/admin/sounds.js b/src/controllers/admin/sounds.js
new file mode 100644
index 0000000000..6e7ebf3f19
--- /dev/null
+++ b/src/controllers/admin/sounds.js
@@ -0,0 +1,21 @@
+'use strict';
+
+var meta = require('../../meta');
+
+var soundsController = {};
+
+soundsController.get = function(req, res, next) {
+ meta.sounds.getFiles(function(err, sounds) {
+ sounds = Object.keys(sounds).map(function(name) {
+ return {
+ name: name
+ };
+ });
+
+ res.render('admin/general/sounds', {
+ sounds: sounds
+ });
+ });
+};
+
+module.exports = soundsController;
\ No newline at end of file
diff --git a/src/controllers/admin/tags.js b/src/controllers/admin/tags.js
new file mode 100644
index 0000000000..22e3b32d67
--- /dev/null
+++ b/src/controllers/admin/tags.js
@@ -0,0 +1,18 @@
+"use strict";
+
+var topics = require('../../topics');
+
+var tagsController = {};
+
+tagsController.get = function(req, res, next) {
+ topics.getTags(0, 199, function(err, tags) {
+ if (err) {
+ return next(err);
+ }
+
+ res.render('admin/manage/tags', {tags: tags});
+ });
+};
+
+
+module.exports = tagsController;
diff --git a/src/controllers/admin/themes.js b/src/controllers/admin/themes.js
new file mode 100644
index 0000000000..00cb65f29f
--- /dev/null
+++ b/src/controllers/admin/themes.js
@@ -0,0 +1,25 @@
+'use strict';
+
+var path = require('path');
+var fs = require('fs');
+
+var themesController = {};
+
+themesController.get = function(req, res, next) {
+ var themeDir = path.join(__dirname, '../../node_modules/' + req.params.theme);
+ fs.exists(themeDir, function(exists) {
+ if (exists) {
+ var themeConfig = require(path.join(themeDir, 'theme.json')),
+ screenshotPath = path.join(themeDir, themeConfig.screenshot);
+ if (themeConfig.screenshot && fs.existsSync(screenshotPath)) {
+ res.sendFile(screenshotPath);
+ } else {
+ res.sendFile(path.join(__dirname, '../../public/images/themes/default.png'));
+ }
+ } else {
+ return next();
+ }
+ });
+};
+
+module.exports = themesController;
\ No newline at end of file
diff --git a/src/controllers/admin/widgets.js b/src/controllers/admin/widgets.js
new file mode 100644
index 0000000000..8dd93fbead
--- /dev/null
+++ b/src/controllers/admin/widgets.js
@@ -0,0 +1,16 @@
+'use strict';
+
+var widgetsController = {};
+
+widgetsController.get = function(req, res, next) {
+ require('../../widgets/admin').get(function(err, data) {
+ if (err) {
+ return next(err);
+ }
+
+ res.render('admin/extend/widgets', data);
+ });
+};
+
+
+module.exports = widgetsController;
\ No newline at end of file
diff --git a/src/routes/admin.js b/src/routes/admin.js
index cd5fc20daf..63cee2ceb4 100644
--- a/src/routes/admin.js
+++ b/src/routes/admin.js
@@ -40,8 +40,8 @@ function apiRouter(middleware, controllers) {
function addRoutes(router, middleware, controllers) {
var middlewares = [middleware.pluginHooks];
- router.get('/', middlewares, controllers.admin.home);
- router.get('/general/dashboard', middlewares, controllers.admin.home);
+ router.get('/', middlewares, controllers.admin.dashboard.get);
+ router.get('/general/dashboard', middlewares, controllers.admin.dashboard.get);
router.get('/general/languages', middlewares, controllers.admin.languages.get);
router.get('/general/sounds', middlewares, controllers.admin.sounds.get);
router.get('/general/navigation', middlewares, controllers.admin.navigation.get);
@@ -70,8 +70,8 @@ function addRoutes(router, middleware, controllers) {
router.get('/appearance/:term?', middlewares, controllers.admin.appearance.get);
router.get('/extend/plugins', middlewares, controllers.admin.plugins.get);
- router.get('/extend/widgets', middlewares, controllers.admin.extend.widgets);
- router.get('/extend/rewards', middlewares, controllers.admin.extend.rewards);
+ router.get('/extend/widgets', middlewares, controllers.admin.extend.widgets.get);
+ router.get('/extend/rewards', middlewares, controllers.admin.extend.rewards.get);
router.get('/advanced/database', middlewares, controllers.admin.database.get);
router.get('/advanced/events', middlewares, controllers.admin.events.get);