allowing plugins to define new sounds -- woot.

Also moving the core sounds into a separate package, soundpack-default
v1.18.x
Julian Lam 11 years ago
parent f8a6ab5cf4
commit df8728c785

@ -43,6 +43,7 @@
"nodebb-widget-essentials": "~0.0.21", "nodebb-widget-essentials": "~0.0.21",
"nodebb-theme-vanilla": "~0.0.19", "nodebb-theme-vanilla": "~0.0.19",
"nodebb-theme-lavender": "~0.0.25", "nodebb-theme-lavender": "~0.0.25",
"nodebb-plugin-soundpack-default": "~0.1.0",
"less": "~1.6.3", "less": "~1.6.3",
"daemon": "~1.1.0", "daemon": "~1.1.0",
"underscore": "~1.6.0", "underscore": "~1.6.0",

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -156,7 +156,7 @@ adminController.groups.get = function(req, res, next) {
}; };
adminController.sounds.get = function(req, res, next) { adminController.sounds.get = function(req, res, next) {
meta.sounds.getLocal(function(err, sounds) { meta.sounds.getFiles(function(err, sounds) {
sounds = Object.keys(sounds).map(function(name) { sounds = Object.keys(sounds).map(function(name) {
return { return {
name: name name: name

@ -8,6 +8,8 @@ var fs = require('fs'),
_ = require('underscore'), _ = require('underscore'),
less = require('less'), less = require('less'),
fork = require('child_process').fork, fork = require('child_process').fork,
rimraf = require('rimraf'),
mkdirp = require('mkdirp'),
utils = require('./../public/src/utils'), utils = require('./../public/src/utils'),
translator = require('./../public/src/translator'), translator = require('./../public/src/translator'),
@ -366,7 +368,42 @@ var fs = require('fs'),
/* Sounds */ /* Sounds */
Meta.sounds = {}; Meta.sounds = {};
Meta.sounds.getLocal = function(callback) { Meta.sounds.init = function() {
var soundsPath = path.join(__dirname, '../public/sounds');
plugins.fireHook('filter:sounds.get', [], function(err, filePaths) {
if (err) {
winston.error('Could not initialise sound files:' + err.message);
}
// Clear the sounds directory
async.series([
function(next) {
rimraf(soundsPath, next);
},
function(next) {
mkdirp(soundsPath, next);
}
], function(err) {
if (err) {
winston.error('Could not initialise sound files:' + err.message);
}
// Link paths
async.each(filePaths, function(filePath, next) {
fs.symlink(filePath, path.join(soundsPath, path.basename(filePath)), 'file', next);
}, function(err) {
if (!err) {
winston.info('[sounds] Sounds OK');
} else {
winston.error('[sounds] Could not initialise sounds: ' + err.message);
}
});
});
});
};
Meta.sounds.getFiles = function(callback) {
// todo: Possibly move these into a bundled module? // todo: Possibly move these into a bundled module?
fs.readdir(path.join(__dirname, '../public/sounds'), function(err, files) { fs.readdir(path.join(__dirname, '../public/sounds'), function(err, files) {
var localList = {}; var localList = {};

@ -54,14 +54,8 @@ module.exports = function(app, middleware, controllers) {
}); });
app.get('/test', function(req, res) { app.get('/test', function(req, res) {
var groups = require('../groups'); require('../meta').sounds.init();
res.send(200);
groups.list({
showAllGroups: true
}, function(err, groups) {
res.json(200, groups);
});
// res.send(200);
}); });
}); });
}; };

@ -224,7 +224,7 @@ SocketModules.notifications.mark_all_read = function(socket, data, callback) {
/* Sounds */ /* Sounds */
SocketModules.sounds.getSounds = function(socket, data, callback) { SocketModules.sounds.getSounds = function(socket, data, callback) {
// Read sounds from local directory // Read sounds from local directory
meta.sounds.getLocal(callback); meta.sounds.getFiles(callback);
}; };
SocketModules.sounds.getMapping = function(socket, data, callback) { SocketModules.sounds.getMapping = function(socket, data, callback) {

@ -42,6 +42,13 @@ if(nconf.get('ssl')) {
notifications.init(); notifications.init();
user.startJobs(); user.startJobs();
// Preparation dependent on plugins
plugins.ready(function() {
meta.js.minify(app.enabled('minification'));
meta.css.minify();
meta.sounds.init();
});
async.series({ async.series({
themesData: meta.themes.get, themesData: meta.themes.get,
currentThemeData: function(next) { currentThemeData: function(next) {
@ -89,12 +96,6 @@ if(nconf.get('ssl')) {
winston.info('Using ports 80 and 443 is not recommend; use a proxy instead. See README.md'); winston.info('Using ports 80 and 443 is not recommend; use a proxy instead. See README.md');
} }
// Front-end assets
plugins.ready(function() {
meta.js.minify(app.enabled('minification'));
meta.css.minify();
});
module.exports.server = server; module.exports.server = server;
module.exports.init = function () { module.exports.init = function () {
server.on("error", function(err){ server.on("error", function(err){

Loading…
Cancel
Save