mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-12 01:27:38 +01:00
allowing plugins to define new sounds -- woot.
Also moving the core sounds into a separate package, soundpack-default
This commit is contained in:
@@ -43,6 +43,7 @@
|
||||
"nodebb-widget-essentials": "~0.0.21",
|
||||
"nodebb-theme-vanilla": "~0.0.19",
|
||||
"nodebb-theme-lavender": "~0.0.25",
|
||||
"nodebb-plugin-soundpack-default": "~0.1.0",
|
||||
"less": "~1.6.3",
|
||||
"daemon": "~1.1.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) {
|
||||
meta.sounds.getLocal(function(err, sounds) {
|
||||
meta.sounds.getFiles(function(err, sounds) {
|
||||
sounds = Object.keys(sounds).map(function(name) {
|
||||
return {
|
||||
name: name
|
||||
|
||||
39
src/meta.js
39
src/meta.js
@@ -8,6 +8,8 @@ var fs = require('fs'),
|
||||
_ = require('underscore'),
|
||||
less = require('less'),
|
||||
fork = require('child_process').fork,
|
||||
rimraf = require('rimraf'),
|
||||
mkdirp = require('mkdirp'),
|
||||
|
||||
utils = require('./../public/src/utils'),
|
||||
translator = require('./../public/src/translator'),
|
||||
@@ -366,7 +368,42 @@ var fs = require('fs'),
|
||||
|
||||
/* 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?
|
||||
fs.readdir(path.join(__dirname, '../public/sounds'), function(err, files) {
|
||||
var localList = {};
|
||||
|
||||
@@ -54,14 +54,8 @@ module.exports = function(app, middleware, controllers) {
|
||||
});
|
||||
|
||||
app.get('/test', function(req, res) {
|
||||
var groups = require('../groups');
|
||||
|
||||
groups.list({
|
||||
showAllGroups: true
|
||||
}, function(err, groups) {
|
||||
res.json(200, groups);
|
||||
});
|
||||
// res.send(200);
|
||||
require('../meta').sounds.init();
|
||||
res.send(200);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -224,7 +224,7 @@ SocketModules.notifications.mark_all_read = function(socket, data, callback) {
|
||||
/* Sounds */
|
||||
SocketModules.sounds.getSounds = function(socket, data, callback) {
|
||||
// Read sounds from local directory
|
||||
meta.sounds.getLocal(callback);
|
||||
meta.sounds.getFiles(callback);
|
||||
};
|
||||
|
||||
SocketModules.sounds.getMapping = function(socket, data, callback) {
|
||||
|
||||
@@ -42,6 +42,13 @@ if(nconf.get('ssl')) {
|
||||
notifications.init();
|
||||
user.startJobs();
|
||||
|
||||
// Preparation dependent on plugins
|
||||
plugins.ready(function() {
|
||||
meta.js.minify(app.enabled('minification'));
|
||||
meta.css.minify();
|
||||
meta.sounds.init();
|
||||
});
|
||||
|
||||
async.series({
|
||||
themesData: meta.themes.get,
|
||||
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');
|
||||
}
|
||||
|
||||
// Front-end assets
|
||||
plugins.ready(function() {
|
||||
meta.js.minify(app.enabled('minification'));
|
||||
meta.css.minify();
|
||||
});
|
||||
|
||||
module.exports.server = server;
|
||||
module.exports.init = function () {
|
||||
server.on("error", function(err){
|
||||
|
||||
Reference in New Issue
Block a user