mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-28 13:36:16 +02:00
Major progress on revamp
* Deprecated explicit prompt.hjson/general.promptFile, etc.: menu.hjson can simply include any number of files * All menus and themes, their events, etc. are managed by ThemeManager allowing includes, refs, etc. and much cleaner code
This commit is contained in:
parent
1a96ad41d2
commit
4d4be5d6a9
15 changed files with 331 additions and 400 deletions
|
@ -1,17 +1,12 @@
|
|||
/* jslint node: true */
|
||||
'use strict';
|
||||
|
||||
const Config = require('./config.js').get;
|
||||
const ConfigCache = require('./config_cache.js');
|
||||
const Events = require('./events.js');
|
||||
const Config = require('./config.js').get;
|
||||
|
||||
// deps
|
||||
const paths = require('path');
|
||||
const async = require('async');
|
||||
const paths = require('path');
|
||||
|
||||
exports.init = init;
|
||||
exports.getConfigPath = getConfigPath;
|
||||
exports.getFullConfig = getFullConfig;
|
||||
exports.getConfigPath = getConfigPath;
|
||||
|
||||
function getConfigPath(filePath) {
|
||||
// |filePath| is assumed to be in the config path if it's only a file name
|
||||
|
@ -20,48 +15,3 @@ function getConfigPath(filePath) {
|
|||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
function init(cb) {
|
||||
// pre-cache menu.hjson and prompt.hjson + establish events
|
||||
const changed = ( { fileName, fileRoot } ) => {
|
||||
const reCachedPath = paths.join(fileRoot, fileName);
|
||||
if(reCachedPath === getConfigPath(Config().general.menuFile)) {
|
||||
Events.emit(Events.getSystemEvents().MenusChanged);
|
||||
} else if(reCachedPath === getConfigPath(Config().general.promptFile)) {
|
||||
Events.emit(Events.getSystemEvents().PromptsChanged);
|
||||
}
|
||||
};
|
||||
|
||||
const config = Config();
|
||||
async.series(
|
||||
[
|
||||
function menu(callback) {
|
||||
return ConfigCache.getConfigWithOptions(
|
||||
{
|
||||
filePath : getConfigPath(config.general.menuFile),
|
||||
callback : changed,
|
||||
},
|
||||
callback
|
||||
);
|
||||
},
|
||||
function prompt(callback) {
|
||||
return ConfigCache.getConfigWithOptions(
|
||||
{
|
||||
filePath : getConfigPath(config.general.promptFile),
|
||||
callback : changed,
|
||||
},
|
||||
callback
|
||||
);
|
||||
}
|
||||
],
|
||||
err => {
|
||||
return cb(err);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function getFullConfig(filePath, cb) {
|
||||
ConfigCache.getConfig(getConfigPath(filePath), (err, config) => {
|
||||
return cb(err, config);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue