Skip to content
Snippets Groups Projects
Commit b8a6a110 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Merge branch 'dd_msg_reader_example_config' into 'master'

DDMsgReader: The config file in the repo is now DDMsgReader.example.cfg. Copy to DDMsgReader.cfg to make config customizations (it can be in the same dir or in sbbs/mods).

See merge request !530
parents 0fef691a a20c0939
No related branches found
No related tags found
1 merge request!530DDMsgReader: The config file in the repo is now DDMsgReader.example.cfg. Copy to DDMsgReader.cfg to make config customizations (it can be in the same dir or in sbbs/mods).
...@@ -249,6 +249,9 @@ ...@@ -249,6 +249,9 @@
* users' specific answers (in addition to just showing * users' specific answers (in addition to just showing
* who voted on the message/poll), via the new * who voted on the message/poll), via the new
* configuration option showUserResponsesInTallyInfo * 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"; "use strict";
...@@ -356,8 +359,8 @@ var hexdump = load('hexdump_lib.js'); ...@@ -356,8 +359,8 @@ var hexdump = load('hexdump_lib.js');
   
   
// Reader version information // Reader version information
var READER_VERSION = "1.96p"; var READER_VERSION = "1.96q";
var READER_DATE = "2025-04-19"; var READER_DATE = "2025-04-20";
   
// Keyboard key codes for displaying on the screen // Keyboard key codes for displaying on the screen
var UP_ARROW = ascii(24); var UP_ARROW = ascii(24);
...@@ -1327,6 +1330,7 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs) ...@@ -1327,6 +1330,7 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs)
this.msgSaveDir = ""; this.msgSaveDir = "";
   
this.cfgFilename = "DDMsgReader.cfg"; this.cfgFilename = "DDMsgReader.cfg";
this.usingCmdLineSpecifiedFilename = false;
// Check the command-line arguments for a custom configuration file name // Check the command-line arguments for a custom configuration file name
// before reading the configuration file. Defaults to the current user // before reading the configuration file. Defaults to the current user
// number, but can be set by a loadable module command-line argument. Also, // number, but can be set by a loadable module command-line argument. Also,
...@@ -1336,7 +1340,10 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs) ...@@ -1336,7 +1340,10 @@ function DigDistMsgReader(pSubBoardCode, pScriptArgs)
if (scriptArgsIsValid) if (scriptArgsIsValid)
{ {
if (pScriptArgs.hasOwnProperty("configfilename")) if (pScriptArgs.hasOwnProperty("configfilename"))
{
this.cfgFilename = pScriptArgs.configfilename; this.cfgFilename = pScriptArgs.configfilename;
this.usingCmdLineSpecifiedFilename = true;
}
if (pScriptArgs.hasOwnProperty("usernum") && user.is_sysop) if (pScriptArgs.hasOwnProperty("usernum") && user.is_sysop)
this.personalMailUserNum = pScriptArgs.usernum; this.personalMailUserNum = pScriptArgs.usernum;
} }
...@@ -9931,11 +9938,21 @@ function DigDistMsgReader_ReadConfigFile() ...@@ -9931,11 +9938,21 @@ function DigDistMsgReader_ReadConfigFile()
   
// Open the main configuration file. First look for it in the sbbs/mods // 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. // 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); var cfgFilename = file_cfgname(system.mods_dir, this.cfgFilename);
if (!file_exists(cfgFilename)) if (!file_exists(cfgFilename))
cfgFilename = file_cfgname(system.ctrl_dir, this.cfgFilename); cfgFilename = file_cfgname(system.ctrl_dir, this.cfgFilename);
if (!file_exists(cfgFilename)) if (!file_exists(cfgFilename))
cfgFilename = file_cfgname(js.exec_dir, this.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); var cfgFile = new File(cfgFilename);
if (cfgFile.open("r")) if (cfgFile.open("r"))
{ {
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
// If you have DDMsgReader in a directory other than xtrn/DDMsgReader, then the changes to // 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 // DDMsgReader.cfg will be saved in that directory (assuming you're running ddmr_cfg.js from
// that same directory). // 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 // 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 // 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"); ...@@ -18,7 +18,7 @@ require("sbbsdefs.js", "P_NONE");
require("uifcdefs.js", "UIFC_INMSG"); 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"); print("Failed to initialize uifc");
exit(1); exit(1);
...@@ -27,12 +27,12 @@ js.on_exit("uifc.bail()"); ...@@ -27,12 +27,12 @@ js.on_exit("uifc.bail()");
// DDMsgReader base configuration filename, and help text wrap width // DDMsgReader base configuration filename, and help text wrap width
var gDDMRCfgFileName = "DDMsgReader.cfg"; const gDDMRCfgFileName = "DDMsgReader.cfg";
var gHelpWrapWidth = uifc.screen_width - 10; var gHelpWrapWidth = uifc.screen_width - 10;
// When saving the configuration file, always save it in the same directory // When saving the configuration file, always save it in the same directory
// as DDMsgReader (or this script); don't copy to mods // as DDMsgReader (or this script); don't copy to mods
var gAlwaysSaveCfgInOriginalDir = false; var gAlwaysSaveCfgInOriginalDir = true;
// Parse command-line arguments // Parse command-line arguments
parseCmdLineArgs(); parseCmdLineArgs();
...@@ -63,8 +63,10 @@ while (continueOn) ...@@ -63,8 +63,10 @@ while (continueOn)
uifc.msg("Failed to save settings!"); uifc.msg("Failed to save settings!");
else else
{ {
var msg = "Changes were successfully saved";
if (saveRetObj.savedToModsDir) if (saveRetObj.savedToModsDir)
uifc.msg("Changes were successfully saved (to the mods dir)"); msg += " (to the mods dir)";
uifc.msg(msg);
} }
} }
continueOn = false; continueOn = false;
...@@ -745,8 +747,8 @@ function parseCmdLineArgs() ...@@ -745,8 +747,8 @@ function parseCmdLineArgs()
for (var i = 0; i < argv.length; ++i) for (var i = 0; i < argv.length; ++i)
{ {
var argUpper = argv[i].toUpperCase(); var argUpper = argv[i].toUpperCase();
if (argUpper == "NOMODS" || argUpper == "NO_MODS" || argUpper == "-NOMODS" || argUpper == "-NO_MODS") if (argUpper == "-SAVE_TO_MODS")
gAlwaysSaveCfgInOriginalDir = true; gAlwaysSaveCfgInOriginalDir = false;
} }
} }
...@@ -770,10 +772,19 @@ function readDDMsgReaderCfgFile() ...@@ -770,10 +772,19 @@ function readDDMsgReaderCfgFile()
cfgFilename = file_cfgname(system.ctrl_dir, gDDMRCfgFileName); cfgFilename = file_cfgname(system.ctrl_dir, gDDMRCfgFileName);
if (!file_exists(cfgFilename)) if (!file_exists(cfgFilename))
cfgFilename = file_cfgname(js.exec_dir, gDDMRCfgFileName); 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; retObj.cfgFilename = cfgFilename;
// Open and read the configuration file // Open and read the configuration file
var cfgFile = new File(retObj.cfgFilename); var cfgFile = new File(cfgFilename);
if (cfgFile.open("r")) if (cfgFile.open("r"))
{ {
retObj.cfgOptions = cfgFile.iniGetObject(); retObj.cfgOptions = cfgFile.iniGetObject();
...@@ -867,23 +878,36 @@ function saveDDMsgReaderCfgFile() ...@@ -867,23 +878,36 @@ function saveDDMsgReaderCfgFile()
savedToModsDir: false savedToModsDir: false
}; };
// If the configuration file was loaded from the standard location in // If the configuration file was in the same directory as this configurator,
// the Git repository (xtrn/DDMsgReader), and the option to always save // then deal with it appropriately.
// 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 + "$");
var cfgFilename = gCfgInfo.cfgFilename; var cfgFilename = gCfgInfo.cfgFilename;
if (defaultDirRE.test(cfgFilename) && !gAlwaysSaveCfgInOriginalDir) if (gCfgInfo.cfgFilename.indexOf(js.exec_dir) > -1)
{ {
cfgFilename = system.mods_dir + gDDMRCfgFileName; if (gAlwaysSaveCfgInOriginalDir) // Always save config in the original dir
if (!file_copy(gCfgInfo.cfgFilename, cfgFilename)) {
return false; // If the read configuration file was DDMsgReader.example.cfg, copy it
retObj.savedToModsDir = true; // 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); 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) for (var settingName in gCfgInfo.cfgOptions)
cfgFile.iniSetValue(null, settingName, gCfgInfo.cfgOptions[settingName]); cfgFile.iniSetValue(null, settingName, gCfgInfo.cfgOptions[settingName]);
......
Digital Distortion Message Reader Digital Distortion Message Reader
Version 1.96p Version 1.96q
Release date: 2025-04-19 Release date: 2025-04-20
by by
...@@ -594,6 +594,18 @@ user avatar. ...@@ -594,6 +594,18 @@ user avatar.
Digital Distortion Message Reader allows changing some settings, colors, and Digital Distortion Message Reader allows changing some settings, colors, and
some of the text via configuration files. 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 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 configuration options. You can run it at a command prompt in the DDMsgReader
directory with the following command: directory with the following command:
...@@ -601,16 +613,9 @@ jsexec ddmr_cfg ...@@ -601,16 +613,9 @@ jsexec ddmr_cfg
Alternately (with the filename extension): Alternately (with the filename extension):
jsexec ddmr_cfg.js jsexec ddmr_cfg.js
If you have DDMsgReader in the standard location (xtrn/DDMsgReader), ddmr_cfg ddmr_cfg.js will by default save to DDMsgReader.cfg in the same directory;
will copy the configuration file to your sbbs/mods directory to help prevent it you can give the -save_to_mods argument on the command line to have it save
from being accidentally overridden by updating the standard Synchronet files. to sbbs/mods instead.
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.
Each setting in the configuration files has the format setting=value, where 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 "setting" is the name of the setting or color, and "value" is the corresponding
......
...@@ -5,6 +5,14 @@ Revision History (change log) ...@@ -5,6 +5,14 @@ Revision History (change log)
============================= =============================
Version Date Description 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 1.96p 2025-04-19 When viewing tally/vote information for a message (a sysop
feature), DDMsgReader can now optionally show users' feature), DDMsgReader can now optionally show users'
specific answers (in addition to just showing who voted on specific answers (in addition to just showing who voted on
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment