From 81e684cdccc39e132e016e897066e666f1ac03cb Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Mon, 20 Jul 2015 22:56:48 -0600 Subject: [PATCH] * Work on Renegade style pipe codes * Change age -> birthday * Minor tweaks and tests --- core/ansi_term.js | 2 +- core/art.js | 3 ++- core/color_codes.js | 39 ++++++++++++++++++++++++--------- core/config.js | 4 ++++ core/connect.js | 9 +++++--- core/json_cache.js | 1 - core/logger.js | 4 ++-- mods/apply.js | 4 ++-- mods/menu.json | 12 +++++----- mods/themes/NU-MAYA/APPLY1.ANS | Bin 3924 -> 3924 bytes mods/themes/NU-MAYA/theme.json | 8 +++++-- 11 files changed, 58 insertions(+), 28 deletions(-) diff --git a/core/ansi_term.js b/core/ansi_term.js index c2cc1d48..c7eacb35 100644 --- a/core/ansi_term.js +++ b/core/ansi_term.js @@ -111,7 +111,7 @@ var SGRValues = { greenBG : 42, yellowBG : 43, blueBG : 44, - + magentaBG : 45, cyanBG : 46, whiteBG : 47, }; diff --git a/core/art.js b/core/art.js index 00e82b08..f9f5352b 100644 --- a/core/art.js +++ b/core/art.js @@ -457,7 +457,7 @@ function display(options, cb) { var nextPauseTermHeight = options.client.term.termHeight; var continous = false; - + /* parser.on('row update', function rowUpdate(row) { if(row >= nextPauseTermHeight) { if(!continous && 'termHeight' === options.pause) { @@ -474,6 +474,7 @@ function display(options, cb) { nextPauseTermHeight += options.client.term.termHeight; } }); +*/ parser.on('mci', function mciEncountered(mciInfo) { diff --git a/core/color_codes.js b/core/color_codes.js index 129c1a74..b1bcff93 100644 --- a/core/color_codes.js +++ b/core/color_codes.js @@ -7,6 +7,7 @@ var assert = require('assert'); exports.pipeToAnsi = exports.enigmaToAnsi = enigmaToAnsi; exports.stripPipeCodes = exports.stripEnigmaCodes = stripEnigmaCodes; +exports.renegadeToAnsi = renegadeToAnsi; // :TODO: Not really happy with the module name of "color_codes". Would like something better @@ -62,7 +63,6 @@ function enigmaToAnsi(s) { return result; } -// :TODO: NYI function renegadeToAnsi(s) { if(-1 == s.indexOf('|')) { return s; // no pipe codes present @@ -85,17 +85,36 @@ if(-1 == s.indexOf('|')) { if(isNaN(val)) { val = 0; } - assert(val >= 0 && val <= 23); - var attr = ''; - if(7 == val) { - attr = ansi.sgr('normal'); - } else if (val < 7 || val >= 16) { - attr = ansi.sgr(['normal', val]); - } else if (val <= 15) { - attr = ansi.sgr(['normal', val - 8, 'bold']); - } + var attr = ansi.sgr({ + 0 : [ 'reset', 'black' ], + 1 : [ 'reset', 'blue' ], + 2 : [ 'reset', 'green' ], + 3 : [ 'reset', 'cyan' ], + 4 : [ 'reset', 'red' ], + 5 : [ 'reset', 'magenta' ], + 6 : [ 'reset', 'yellow' ], + 7 : [ 'reset', 'white' ], + + 8 : [ 'bold', 'black' ], + 9 : [ 'bold', 'blue' ], + 10 : [ 'bold', 'green' ], + 11 : [ 'bold', 'cyan' ], + 12 : [ 'bold', 'red' ], + 13 : [ 'bold', 'magenta' ], + 14 : [ 'bold', 'yellow' ], + 15 : [ 'bold', 'white' ], + + 16 : [ 'blackBG' ], + 17 : [ 'blueBG' ], + 18 : [ 'greenBG' ], + 19 : [ 'cyanBG' ], + 20 : [ 'redBG' ], + 21 : [ 'magentaBG' ], + 22 : [ 'yellowBG' ], + 23 : [ 'whiteBG' ], + }[val] || 'normal'); result += s.substr(lastIndex, m.index - lastIndex) + attr; lastIndex = re.lastIndex; diff --git a/core/config.js b/core/config.js index 615d0dc0..bda34c26 100644 --- a/core/config.js +++ b/core/config.js @@ -137,5 +137,9 @@ function getDefaultConfig() { } */ }, + + logging : { + level : 'debug' + } }; } diff --git a/core/connect.js b/core/connect.js index 198f6e28..ac6e124e 100644 --- a/core/connect.js +++ b/core/connect.js @@ -124,11 +124,14 @@ function connectEntry(client) { // displayBanner(term); - /* - theme.displayThemeArt({client : client, name : 'DM-ENIG2.ANS'}, function onArt() { +/* var art1 = require('fs').readFileSync('/home/nuskooler/dev/enigma-bbs/mods/themes/NU-MAYA/APPLY1.ANS'); + term.rawWrite(art1); - });*/ + term.write(ansi.resetScreen()); + theme.displayThemeArt({client : client, name : 'APPLY1.ANS'}, function onArt() { + }); + */ setTimeout(function onTimeout() { client.gotoMenuModule( { name : Config.firstMenu }); }, 500); diff --git a/core/json_cache.js b/core/json_cache.js index 5859938e..da0356b1 100644 --- a/core/json_cache.js +++ b/core/json_cache.js @@ -50,7 +50,6 @@ function JSONCache() { JSONCache.prototype.getJSON = function(fileName, cb) { var self = this; var filePath = paths.join(Config.paths.mods, fileName); - console.log(filePath) if(filePath in this.cache) { cb(null, this.cache[filePath]); diff --git a/core/logger.js b/core/logger.js index 5ad445ec..dd918375 100644 --- a/core/logger.js +++ b/core/logger.js @@ -47,9 +47,9 @@ module.exports = { { type : 'rotating-file', path : logFile, - period : '1d', + period : Config.logging.period || '1d', count : 3, - level : 'trace' + level : Config.logging.level || 'debug', } /*, { diff --git a/mods/apply.js b/mods/apply.js index 82c85832..8ea55b7f 100644 --- a/mods/apply.js +++ b/mods/apply.js @@ -74,14 +74,14 @@ function submitApplication(callingMenu, formData, extraArgs) { menuViewController.switchFocus(viewIds[0]); } else { // Seems legit! - // :TODO: All of this should be a system API, not a mod + // :TODO: All of this should be a system API, not a mod, e.g. createNewUser(...) var newUser = new user.User(); newUser.username = formData.value.username; newUser.properties = { real_name : formData.value.realName, - age : formData.value.age, + birthday : formData.value.birthday, sex : formData.value.sex, location : formData.value.location, affiliation : formData.value.affils, diff --git a/mods/menu.json b/mods/menu.json index 38a8d08f..1021e846 100644 --- a/mods/menu.json +++ b/mods/menu.json @@ -110,7 +110,7 @@ "next" : "newUserActive", "form" : { "0" : { - "BT12BT13ET1ET10ET2ET3ET4ET5ET6ET7ET8ET9TL11" : { + "BT12BT13ET1ET10ET2ET4ET5ET6ET7ET8ET9ME3TL11" : { "mci" : { "ET1" : { "focus" : true, @@ -121,14 +121,14 @@ "argName" : "realName", "maxLength" : 32 }, - "ET3" : { - "argName" : "age", - "width" : 3, - "maxLength" : 3 + "ME3" : { + "argName" : "birthday", + //"width" : 8, + "maskPattern" : "####/##/##" }, "ET4" : { "argName" : "sex", - "width" : 1, + //"width" : 1, "maxLength" : 1 }, "ET5" : { diff --git a/mods/themes/NU-MAYA/APPLY1.ANS b/mods/themes/NU-MAYA/APPLY1.ANS index 1a7f05c5e68609df7c2145944e2d958f4d00a217..c6196ea4c1374c89c2ae254bbe311760eef0bc5e 100644 GIT binary patch delta 56 zcmca2cSUZ)V|HyP>1YFMW5e9cqLPf1#7gOCLu+G$Ts=KKpm?sTudA_!g(grC#N5os H;l>UC2xkyB delta 39 ucmca2cSUZ)V|Fe_>1YFMW5e9^)X9w;V%)|W#+uU6hPkS)A)EO)+}HvB$qOU^ diff --git a/mods/themes/NU-MAYA/theme.json b/mods/themes/NU-MAYA/theme.json index 7f829015..3124197a 100644 --- a/mods/themes/NU-MAYA/theme.json +++ b/mods/themes/NU-MAYA/theme.json @@ -26,8 +26,12 @@ "apply" : { "ET1" : { "width" : 21 }, "ET2" : { "width" : 21 }, - "ET3" : { "width" : 21 }, - "ET4" : { "width" : 21 }, + //"ET3" : { "width" : 21 }, + "ME3" : { + "styleSGR1" : "|00|30|01", + "styleSGR2" : "|00|37" + }, + "ET4" : { "width" : 1 }, "ET5" : { "width" : 21 }, "ET6" : { "width" : 21 }, "ET7" : { "width" : 21 },