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

Merge branch 'dd_file_lister_extended_info_update' into 'master'

DD File lister: Extended file info update (# times DL'd, last DL, description fix for some cases)

See merge request !229
parents 3b4f7b9d b1f08032
No related branches found
No related tags found
2 merge requests!463MRC mods by Codefenix (2024-10-20),!229DD File lister: Extended file info update (# times DL'd, last DL, description fix for some cases)
...@@ -47,6 +47,11 @@ ...@@ -47,6 +47,11 @@
* When extended file descriptions are enabled, the file * When extended file descriptions are enabled, the file
* date is now shown with the file description on the last * date is now shown with the file description on the last
* line. * line.
* 2022-12-02 Eric Oulashin Version 2.07
* In a file's extended description, added the number of times
* downloaded and date/time last downloaded. Also, fixed a bug
* where some descriptions were blank in the Frame object because
* of a leading normal attribute (the fix may be a kludge though).
*/ */
"use strict"; "use strict";
...@@ -104,8 +109,8 @@ if (system.version_num < 31900) ...@@ -104,8 +109,8 @@ if (system.version_num < 31900)
} }
// Lister version information // Lister version information
var LISTER_VERSION = "2.06"; var LISTER_VERSION = "2.07";
var LISTER_DATE = "2022-04-13"; var LISTER_DATE = "2022-12-02";
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -566,8 +571,19 @@ function showFileInfo(pFileList, pFileListMenu) ...@@ -566,8 +571,19 @@ function showFileInfo(pFileList, pFileListMenu)
else else
fileDesc = fileMetadata.desc; fileDesc = fileMetadata.desc;
// It's possible for fileDesc to be undefined (due to extDesc or desc being undefined), // It's possible for fileDesc to be undefined (due to extDesc or desc being undefined),
// so make sure it's a string // so make sure it's a string.
if (typeof(fileDesc) !== "string") // Also, if it's a string, reformat certain types of strings that don't look good in a
// Frame object
if (typeof(fileDesc) === "string")
{
// Check to see if it starts with a normal attribute and remove if so,
// since that seems to cause problems with displaying the description in a Frame object. This
// may be a kludge, and perhaps there's a better solution..
fileDesc = fileDesc.replace(/^\x01[nN]/, "");
// Fix line endings if necessary
fileDesc = fixStrLineEndings(fileDesc);
}
else
fileDesc = ""; fileDesc = "";
// This might be overkill, but just in case, convert any non-Synchronet // This might be overkill, but just in case, convert any non-Synchronet
// attribute codes to Synchronet attribute codes in the description. // attribute codes to Synchronet attribute codes in the description.
...@@ -583,10 +599,17 @@ function showFileInfo(pFileList, pFileListMenu) ...@@ -583,10 +599,17 @@ function showFileInfo(pFileList, pFileListMenu)
fileInfoStr += gColors.desc; fileInfoStr += gColors.desc;
if (fileDesc.length > 0) if (fileDesc.length > 0)
fileInfoStr += "Description:\r\n" + fileDesc; fileInfoStr += "Description:\r\n" + fileDesc; // Don't want to use strip_ctrl(fileDesc)
else else
fileInfoStr += "No description available"; fileInfoStr += "No description available";
fileInfoStr += "\r\n"; fileInfoStr += "\r\n";
// # of times downloaded and last downloaded date/time
var fieldFormatStr = "\r\n\x01n\x01c\x01h%s\x01g:\x01n\x01c %s";
var timesDownloaded = fileMetadata.hasOwnProperty("times_downloaded") ? fileMetadata.times_downloaded : 0;
fileInfoStr += format(fieldFormatStr, "Times downloaded", timesDownloaded);
if (fileMetadata.hasOwnProperty("last_downloaded"))
fileInfoStr += format(fieldFormatStr, "Last downloaded", strftime("%Y-%m-%d %H:%M", fileMetadata.last_downloaded));
// Some more fields for the sysop
if (user.is_sysop) if (user.is_sysop)
{ {
var sysopFields = [ "from", "cost", "added"]; var sysopFields = [ "from", "cost", "added"];
...@@ -598,11 +621,12 @@ function showFileInfo(pFileList, pFileListMenu) ...@@ -598,11 +621,12 @@ function showFileInfo(pFileList, pFileListMenu)
if (typeof(fileMetadata[prop]) === "string" && fileMetadata[prop].length == 0) if (typeof(fileMetadata[prop]) === "string" && fileMetadata[prop].length == 0)
continue; continue;
var propName = prop.charAt(0).toUpperCase() + prop.substr(1); var propName = prop.charAt(0).toUpperCase() + prop.substr(1);
fileInfoStr += "\r\n\x01n\x01c\x01h" + propName + "\x01g:\x01n\x01c "; var infoValue = "";
if (prop == "added") if (prop == "added")
fileInfoStr += strftime("%Y-%m-%d %H:%M:%S", fileMetadata.added); infoValue = strftime("%Y-%m-%d %H:%M:%S", fileMetadata.added);
else else
fileInfoStr += fileMetadata[prop].toString().substr(0, frameInnerWidth); infoValue = fileMetadata[prop].toString().substr(0, frameInnerWidth);
fileInfoStr += format(fieldFormatStr, propName, infoValue);
fileInfoStr += "\x01n\x01w"; fileInfoStr += "\x01n\x01w";
} }
} }
...@@ -642,6 +666,48 @@ function showFileInfo(pFileList, pFileListMenu) ...@@ -642,6 +666,48 @@ function showFileInfo(pFileList, pFileListMenu)
return retObj; return retObj;
} }
// Splits a string on a given string and then re-combines the string with \r\n (carriage return & newline)
// at the end of each line
//
// Parameters:
// pStr: The string to split & recombine
// pSplitStr: The string to split the first string on
//
// Return value: The string split on pSplitStr and re-combined with \r\n at the end of each line
function splitStrAndCombineWithRN(pStr, pSplitStr)
{
if (typeof(pStr) !== "string")
return "";
if (typeof(pSplitStr) !== "string")
return pStr;
var newStr = "";
var strs = pStr.split(pSplitStr);
if (strs.length > 0)
{
for (var i = 0; i < strs.length; ++i)
newStr += strs[i] + "\r\n";
newStr = newStr.replace(/\r\n$/, "");
}
else
newStr = pStr;
return newStr;
}
// Fixes line endings in a string
function fixStrLineEndings(pStr)
{
if (typeof(pStr) !== "string")
return "";
// If there's only a return or only a newline, split & recombine with \r\n
var newStr = pStr;
if (/[^\r]\n[^\r]/.test(newStr)) // Only a newline
newStr = splitStrAndCombineWithRN(newStr, "\n");
else if (/[^\n]\r[^\n]/.test(newStr)) // Only a carriage return
newStr = splitStrAndCombineWithRN(newStr, "\r");
return newStr;
}
// Lets the user view a file. // Lets the user view a file.
// //
...@@ -3158,7 +3224,11 @@ function populateFileList(pSearchMode) ...@@ -3158,7 +3224,11 @@ function populateFileList(pSearchMode)
{ {
gFileList[i].dirCode = bbs.curdir_code; gFileList[i].dirCode = bbs.curdir_code;
if (gFileList[i].hasOwnProperty("extdesc") && /\r\n$/.test(gFileList[i].extdesc)) if (gFileList[i].hasOwnProperty("extdesc") && /\r\n$/.test(gFileList[i].extdesc))
{
gFileList[i].extdesc = gFileList[i].extdesc.substr(0, gFileList[i].extdesc.length-2); gFileList[i].extdesc = gFileList[i].extdesc.substr(0, gFileList[i].extdesc.length-2);
// Fix line endings if necessary
gFileList[i].extdesc = fixStrLineEndings(gFileList[i].extdesc);
}
} }
} }
else else
......
Digital Distortion File Lister Digital Distortion File Lister
Version 2.06 Version 2.07
Release date: 2022-04-13 Release date: 2022-12-02
by by
......
...@@ -5,6 +5,11 @@ Revision History (change log) ...@@ -5,6 +5,11 @@ Revision History (change log)
============================= =============================
Version Date Description Version Date Description
------- ---- ----------- ------- ---- -----------
2.07 2022-12-02 In a file's extended description, added the number of
times downloaded and date/time last downloaded. Also,
fixed a bug where some descriptions were blank in the
extended description box because of a leading normal
attribute.
2.06 2022-04-13 When extended file descriptions are enabled, the file date 2.06 2022-04-13 When extended file descriptions are enabled, the file date
is now shown with the file description on the last line. is now shown with the file description on the last line.
2.05a 2022-03-13 Fix for "fileDesc is not defined" error when displaying 2.05a 2022-03-13 Fix for "fileDesc is not defined" error when displaying
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment