diff --git a/UPGRADE.md b/UPGRADE.md index af9f124a..8cb98e13 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -60,6 +60,7 @@ webSocket: { * The module export `registerEvents` has been deprecated. If you have a module that depends on this, use the new more generic `moduleInitialize` export instead. * The `system.db` `user_event_log` table has been updated to include a unique session ID. Previously this table was not used, but you will need to perform a slight maintenance task before it can be properly used. After updating to `0.0.9-alpha`, please run the following: `sqlite3 db/system.db DROP TABLE user_event_log;`. The new table format will be created and used at startup. * If you have art configured for message conference or area selection via the `art` configuration value, you will need to include a `show_art` menu reference. Defaulted to `changeMessageConfPreArt` for conferences and `changeMessageAreaPreArt` for areas & included in the example `menu.hjson`. +* Config `defaults` section was theme related and as such, has been renamed to `theme`. `defaults.theme` is now `theme.default`, and `preLoginTheme` is now `theme.preLogin`. See `config.js` if this isn't clear as mud. # 0.0.7-alpha to 0.0.8-alpha diff --git a/core/config.js b/core/config.js index fe09b956..74148c69 100644 --- a/core/config.js +++ b/core/config.js @@ -141,9 +141,6 @@ function getDefaultConfig() { promptFile : 'prompt.hjson', // Override to use soemthing else, e.g. myprompt.hjson. Can be a full path (defaults to ./config) }, - // :TODO: see notes below about 'theme' section - move this! - preLoginTheme : 'luciano_blocktronics', - users : { usernameMin : 2, usernameMax : 16, // Note that FidoNet wants 36 max @@ -172,18 +169,10 @@ function getDefaultConfig() { ], }, - // :TODO: better name for "defaults"... which is redundant here! - /* - Concept - "theme" : { - "default" : "defaultThemeName", // or "*" - "preLogin" : "*", - "passwordChar" : "*", - ... - } - */ - defaults : { - theme : 'luciano_blocktronics', + theme : { + default : 'luciano_blocktronics', + preLogin : 'luciano_blocktronics', + passwordChar : '*', // TODO: move to user ? dateFormat : { short : 'MM/DD/YYYY', @@ -202,7 +191,7 @@ function getDefaultConfig() { cls : true, // Clear screen before each menu by default? }, - paths : { + paths : { config : paths.join(__dirname, './../config/'), mods : paths.join(__dirname, './../mods/'), loginServers : paths.join(__dirname, './servers/login/'), diff --git a/core/login_server_module.js b/core/login_server_module.js index 02cd4e41..d1a3552f 100644 --- a/core/login_server_module.js +++ b/core/login_server_module.js @@ -23,10 +23,11 @@ module.exports = class LoginServerModule extends ServerModule { // // Choose initial theme before we have user context // - if('*' === conf.config.preLoginTheme) { + const preLoginTheme = _.get(conf.config, 'theme.preLogin'); + if('*' === preLoginTheme) { client.user.properties.theme_id = theme.getRandomTheme() || ''; } else { - client.user.properties.theme_id = conf.config.preLoginTheme; + client.user.properties.theme_id = preLoginTheme; } theme.setClientTheme(client, client.user.properties.theme_id); diff --git a/core/nua.js b/core/nua.js index 18b9a719..2d838fcb 100644 --- a/core/nua.js +++ b/core/nua.js @@ -9,6 +9,9 @@ const login = require('./system_menu_method.js').login; const Config = require('./config.js').get; const messageArea = require('./message_area.js'); +// deps +const _ = require('lodash'); + exports.moduleInfo = { name : 'NUA', desc : 'New User Application', @@ -96,10 +99,11 @@ exports.getModule = class NewUserAppModule extends MenuModule { // :TODO: should probably have a place to create defaults/etc. }; - if('*' === config.defaults.theme) { + const defaultTheme = _.get(config, 'theme.default'); + if('*' === defaultTheme) { newUser.properties.theme_id = theme.getRandomTheme(); } else { - newUser.properties.theme_id = config.defaults.theme; + newUser.properties.theme_id = defaultTheme; } // :TODO: User.create() should validate email uniqueness! diff --git a/core/theme.js b/core/theme.js index bdba70bc..2f88027e 100644 --- a/core/theme.js +++ b/core/theme.js @@ -39,7 +39,7 @@ function refreshThemeHelpers(theme) { let pwChar = _.get( theme, 'customization.defaults.general.passwordChar', - Config().defaults.passwordChar + Config().theme.passwordChar ); if(_.isString(pwChar)) { @@ -51,15 +51,15 @@ function refreshThemeHelpers(theme) { return pwChar; }, getDateFormat : function(style = 'short') { - const format = Config().defaults.dateFormat[style] || 'MM/DD/YYYY'; + const format = Config().theme.dateFormat[style] || 'MM/DD/YYYY'; return _.get(theme, `customization.defaults.dateFormat.${style}`, format); }, getTimeFormat : function(style = 'short') { - const format = Config().defaults.timeFormat[style] || 'h:mm a'; + const format = Config().theme.timeFormat[style] || 'h:mm a'; return _.get(theme, `customization.defaults.timeFormat.${style}`, format); }, getDateTimeFormat : function(style = 'short') { - const format = Config().defaults.dateTimeFormat[style] || 'MM/DD/YYYY h:mm a'; + const format = Config().theme.dateTimeFormat[style] || 'MM/DD/YYYY h:mm a'; return _.get(theme, `customization.defaults.dateTimeFormat.${style}`, format); } }; @@ -402,9 +402,9 @@ function setClientTheme(client, themeId) { if(availThemes.has(themeId)) { msg = 'Set client theme'; setThemeId = themeId; - } else if(availThemes.has(config.defaults.theme)) { + } else if(availThemes.has(config.theme.default)) { msg = 'Failed setting theme by supplied ID; Using default'; - setThemeId = config.defaults.theme; + setThemeId = config.theme.default; } else { msg = 'Failed setting theme by system default ID; Using the first one we can find'; setThemeId = availThemes.keys().next().value; @@ -430,7 +430,7 @@ function getThemeArt(options, cb) { if(!options.themeId && _.has(options, 'client.user.properties.theme_id')) { options.themeId = options.client.user.properties.theme_id; } else { - options.themeId = config.defaults.theme; + options.themeId = config.theme.default; } // :TODO: replace asAnsi stuff with something like retrieveAs = 'ansi' | 'pipe' | ... @@ -477,11 +477,11 @@ function getThemeArt(options, cb) { }); }, function fromDefaultTheme(artInfo, callback) { - if(artInfo || config.defaults.theme === options.themeId) { + if(artInfo || config.theme.default === options.themeId) { return callback(null, artInfo); } - options.basePath = paths.join(config.paths.themes, config.defaults.theme); + options.basePath = paths.join(config.paths.themes, config.theme.default); art.getArt(options.name, options, (err, artInfo) => { return callback(null, artInfo); }); diff --git a/docs/configuration/config-hjson.md b/docs/configuration/config-hjson.md index 10ca119d..37d07beb 100644 --- a/docs/configuration/config-hjson.md +++ b/docs/configuration/config-hjson.md @@ -46,12 +46,10 @@ Below is a **sample** `config.hjson` illustrating various (but certainly not all menuFile: "your_bbs.hjson" // copy of menu.hjson file (and adapt to your needs) } - defaults: { - theme: "super-fancy-theme" // default-assigned theme (for new users) + theme: { + default: "super-fancy-theme" // default-assigned theme (for new users) } - preLoginTheme: "luciano_blocktronics" // theme used before a user logs in (matrix, NUA, etc.) - messageConferences: { local_general: { name: Local