diff --git a/xtrn/DDMsgReader/DDMsgReader.cfg b/xtrn/DDMsgReader/DDMsgReader.example.cfg similarity index 100% rename from xtrn/DDMsgReader/DDMsgReader.cfg rename to xtrn/DDMsgReader/DDMsgReader.example.cfg diff --git a/xtrn/DDMsgReader/DDMsgReader.js b/xtrn/DDMsgReader/DDMsgReader.js index 41a64306efead9c1e58604e90c70de1f06f444a9..f12aa3b68c2f7e87115127f0346be810332690e3 100644 --- a/xtrn/DDMsgReader/DDMsgReader.js +++ b/xtrn/DDMsgReader/DDMsgReader.js @@ -249,6 +249,9 @@ * users' specific answers (in addition to just showing * who voted on the message/poll), via the new * configuration option showUserResponsesInTallyInfo + * 2025-04-20 Eric Oulashin Version 1.96q + * If DDMsgReader.cfg doesn't exist, read DDMsgReader.example.cfg + * (in the same directory as DDMsgreader.js) if it exists */ "use strict"; @@ -356,8 +359,8 @@ var hexdump = load('hexdump_lib.js'); // Reader version information -var READER_VERSION = "1.96p"; -var READER_DATE = "2025-04-19"; +var READER_VERSION = "1.96q"; +var READER_DATE = "2025-04-20"; // Keyboard key codes for displaying on the screen var UP_ARROW = ascii(24); @@ -1327,6 +1330,7 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs) this.msgSaveDir = ""; this.cfgFilename = "DDMsgReader.cfg"; + this.usingCmdLineSpecifiedFilename = false; // Check the command-line arguments for a custom configuration file name // before reading the configuration file. Defaults to the current user // number, but can be set by a loadable module command-line argument. Also, @@ -1336,7 +1340,10 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs) if (scriptArgsIsValid) { if (pScriptArgs.hasOwnProperty("configfilename")) + { this.cfgFilename = pScriptArgs.configfilename; + this.usingCmdLineSpecifiedFilename = true; + } if (pScriptArgs.hasOwnProperty("usernum") && user.is_sysop) this.personalMailUserNum = pScriptArgs.usernum; } @@ -9931,11 +9938,21 @@ function DigDistMsgReader_ReadConfigFile() // Open the main configuration file. First look for it in the sbbs/mods // directory, then sbbs/ctrl, then in the same directory as this script. + // this.cfgFilename is DDMsgReader.cfg by default, unless another filename + // is specified by the command line (which is probably rare). var cfgFilename = file_cfgname(system.mods_dir, this.cfgFilename); if (!file_exists(cfgFilename)) cfgFilename = file_cfgname(system.ctrl_dir, this.cfgFilename); if (!file_exists(cfgFilename)) cfgFilename = file_cfgname(js.exec_dir, this.cfgFilename); + // If the configuration file hasn't been found, look to see if there's a DDMsgReader.example.cfg file + // available in the same directory + if (!file_exists(cfgFilename)) + { + var exampleFileName = file_cfgname(js.exec_dir, "DDMsgReader.example.cfg"); + if (file_exists(exampleFileName)) + cfgFilename = exampleFileName; + } var cfgFile = new File(cfgFilename); if (cfgFile.open("r")) { diff --git a/xtrn/DDMsgReader/ddmr_cfg.js b/xtrn/DDMsgReader/ddmr_cfg.js index f6fd0f56e6f956af368a87a69f43bda445955fac..15693d76ade72415e816141914e7b48585c94ca8 100644 --- a/xtrn/DDMsgReader/ddmr_cfg.js +++ b/xtrn/DDMsgReader/ddmr_cfg.js @@ -5,7 +5,7 @@ // If you have DDMsgReader in a directory other than xtrn/DDMsgReader, then the changes to // DDMsgReader.cfg will be saved in that directory (assuming you're running ddmr_cfg.js from // that same directory). -// Currently for DDMsgReader 1.96p. +// Currently for DDMsgReader 1.96q. // // If you're running DDMsgReader from xtrn/DDMsgReader (the standard location) and you want // to save the configuration file there (rather than sbbs/mods), you can use one of the @@ -18,7 +18,7 @@ require("sbbsdefs.js", "P_NONE"); require("uifcdefs.js", "UIFC_INMSG"); -if (!uifc.init("DigDist. Message Reader 1.96p Configurator")) +if (!uifc.init("DigDist. Message Reader 1.96q Configurator")) { print("Failed to initialize uifc"); exit(1); @@ -27,12 +27,12 @@ js.on_exit("uifc.bail()"); // DDMsgReader base configuration filename, and help text wrap width -var gDDMRCfgFileName = "DDMsgReader.cfg"; +const gDDMRCfgFileName = "DDMsgReader.cfg"; var gHelpWrapWidth = uifc.screen_width - 10; // When saving the configuration file, always save it in the same directory // as DDMsgReader (or this script); don't copy to mods -var gAlwaysSaveCfgInOriginalDir = false; +var gAlwaysSaveCfgInOriginalDir = true; // Parse command-line arguments parseCmdLineArgs(); @@ -63,8 +63,10 @@ while (continueOn) uifc.msg("Failed to save settings!"); else { + var msg = "Changes were successfully saved"; if (saveRetObj.savedToModsDir) - uifc.msg("Changes were successfully saved (to the mods dir)"); + msg += " (to the mods dir)"; + uifc.msg(msg); } } continueOn = false; @@ -745,8 +747,8 @@ function parseCmdLineArgs() for (var i = 0; i < argv.length; ++i) { var argUpper = argv[i].toUpperCase(); - if (argUpper == "NOMODS" || argUpper == "NO_MODS" || argUpper == "-NOMODS" || argUpper == "-NO_MODS") - gAlwaysSaveCfgInOriginalDir = true; + if (argUpper == "-SAVE_TO_MODS") + gAlwaysSaveCfgInOriginalDir = false; } } @@ -770,10 +772,19 @@ function readDDMsgReaderCfgFile() cfgFilename = file_cfgname(system.ctrl_dir, gDDMRCfgFileName); if (!file_exists(cfgFilename)) cfgFilename = file_cfgname(js.exec_dir, gDDMRCfgFileName); + // If the configuration file hasn't been found, look to see if there's a DDMsgReader.example.cfg file + // available in the same directory + if (!file_exists(cfgFilename)) + { + var exampleFileName = file_cfgname(js.exec_dir, "DDMsgReader.example.cfg"); + if (file_exists(exampleFileName)) + cfgFilename = exampleFileName; + } + retObj.cfgFilename = cfgFilename; // Open and read the configuration file - var cfgFile = new File(retObj.cfgFilename); + var cfgFile = new File(cfgFilename); if (cfgFile.open("r")) { retObj.cfgOptions = cfgFile.iniGetObject(); @@ -867,23 +878,36 @@ function saveDDMsgReaderCfgFile() savedToModsDir: false }; - // If the configuration file was loaded from the standard location in - // the Git repository (xtrn/DDMsgReader), and the option to always save - // in the original directory is not set, then the configuration file - // should be copied to sbbs/mods to avoid custom settings being overwritten - // with an update. - var defaultDirRE = new RegExp("xtrn[\\\\/]DDMsgReader[\\\\/]" + gDDMRCfgFileName + "$"); + // If the configuration file was in the same directory as this configurator, + // then deal with it appropriately. var cfgFilename = gCfgInfo.cfgFilename; - if (defaultDirRE.test(cfgFilename) && !gAlwaysSaveCfgInOriginalDir) + if (gCfgInfo.cfgFilename.indexOf(js.exec_dir) > -1) { - cfgFilename = system.mods_dir + gDDMRCfgFileName; - if (!file_copy(gCfgInfo.cfgFilename, cfgFilename)) - return false; - retObj.savedToModsDir = true; + if (gAlwaysSaveCfgInOriginalDir) // Always save config in the original dir + { + // If the read configuration file was DDMsgReader.example.cfg, copy it + // to DDMsgReader.cfg. + if (cfgFilename.lastIndexOf("DDMsgReader.example.cfg") > -1) + { + var oldCfgFilename = gCfgInfo.cfgFilename; + cfgFilename = gCfgInfo.cfgFilename.replace("DDMsgReader.example.cfg", "DDMsgReader.cfg"); + if (!file_copy(oldCfgFilename, cfgFilename)) + return retObj; + } + } + else + { + // Copy to sbbs/mods + cfgFilename = system.mods_dir + gDDMRCfgFileName; + if (!file_copy(gCfgInfo.cfgFilename, cfgFilename)) + return retObj; + retObj.savedToModsDir = true; + } } var cfgFile = new File(cfgFilename); - if (cfgFile.open("r+")) // Reading and writing (file must exist) + var openMode = (file_exists(cfgFilename) ? "r+" : "w"); + if (cfgFile.open(openMode)) { for (var settingName in gCfgInfo.cfgOptions) cfgFile.iniSetValue(null, settingName, gCfgInfo.cfgOptions[settingName]); diff --git a/xtrn/DDMsgReader/readme.txt b/xtrn/DDMsgReader/readme.txt index feb6a0d062f45dd58fb4c2700ad3330d1cea7042..fe099fc910966262663edf9eb2b6682fbd969ccd 100644 --- a/xtrn/DDMsgReader/readme.txt +++ b/xtrn/DDMsgReader/readme.txt @@ -1,6 +1,6 @@ Digital Distortion Message Reader - Version 1.96p - Release date: 2025-04-19 + Version 1.96q + Release date: 2025-04-20 by @@ -594,6 +594,18 @@ user avatar. Digital Distortion Message Reader allows changing some settings, colors, and some of the text via configuration files. +DDMsgReader.example.cfg is an example of a configuration file for Digital +Distortion Message Reader. If you want to customize your configuration, copy +DDMsgReader.example.cfg to DDMsgReader.cfg (it can be in the same directory, +xtrn/DDMsgReader, or in sbbs/mods) and make your customizations. + +The configuration files are plain text and can be edited with any text editor. +These are the configuration files used by Digital Distortion Message Reader: +- DDMsgReader.cfg (or DDMsgReader.example.cfg): The main configuration file +- DefaultTheme.cfg: Defines colors & some text strings used in the reader. + The name of this file can be specified in DDMsgReader.cfg, so that alternate + "theme" configuration files can be used if desired. + Also, ddmr_cfg.js is a menu-driven configuration script to help with changing configuration options. You can run it at a command prompt in the DDMsgReader directory with the following command: @@ -601,16 +613,9 @@ jsexec ddmr_cfg Alternately (with the filename extension): jsexec ddmr_cfg.js -If you have DDMsgReader in the standard location (xtrn/DDMsgReader), ddmr_cfg -will copy the configuration file to your sbbs/mods directory to help prevent it -from being accidentally overridden by updating the standard Synchronet files. - -The configuration files are plain text and can be edited with any text editor. -These are the configuration files used by Digital Distortion Message Reader: -- DDMsgReader.cfg: The main configuration file -- DefaultTheme.cfg: Defines colors & some text strings used in the reader. - The name of this file can be specified in DDMsgReader.cfg, so that alternate - "theme" configuration files can be used if desired. +ddmr_cfg.js will by default save to DDMsgReader.cfg in the same directory; +you can give the -save_to_mods argument on the command line to have it save +to sbbs/mods instead. Each setting in the configuration files has the format setting=value, where "setting" is the name of the setting or color, and "value" is the corresponding diff --git a/xtrn/DDMsgReader/revision_history.txt b/xtrn/DDMsgReader/revision_history.txt index 128fbf402599f6fae28769e872f05328e9397c17..5c0d386eafe58b664a575e4fbc0893c3491e57fe 100644 --- a/xtrn/DDMsgReader/revision_history.txt +++ b/xtrn/DDMsgReader/revision_history.txt @@ -5,6 +5,14 @@ Revision History (change log) ============================= Version Date Description ------- ---- ----------- +1.96q 2025-04-20 If DDMsgReader.cfg doesn't exist, DDMsgReader will read + DDMsgReader.example.cfg (in the same directory as + DDMsgreader.js) if it exists. To make your own + configuration changes, copy DDMsgReader.example.cfg to + DDMsgReader.cfg in the same directory or to sbbs/mods. + ddmr_cfg.js will by default save to DDMsgReader.cfg in the + same directory; you can give the -save_to_mods argument on + the command line to have it save to sbbs/mods instead. 1.96p 2025-04-19 When viewing tally/vote information for a message (a sysop feature), DDMsgReader can now optionally show users' specific answers (in addition to just showing who voted on