From 16d0c5c449db69ef106be37104912d3a17ccc51d Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Wed, 16 Feb 2022 17:47:21 -0800 Subject: [PATCH] Don't include both normal and extended file descriptions by default As pointed out by DesotoFireflite (VALHALLA), both the file's short/normal description and the extended description were being included in all file listings. This is probably want most sysops will want since the extended description is often used as the content of the short/normal description, resulting in repeated content. So, by default, if there is an extended file description, don't output the short/normal file description. If you want to include *both* the short and extended descriptions (for files that have both), include both the -ext and -desc command line options. --- exec/filelist.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/exec/filelist.js b/exec/filelist.js index 75ce9fcb2c..e1f923acc5 100755 --- a/exec/filelist.js +++ b/exec/filelist.js @@ -33,6 +33,7 @@ var detail = -1; var dir_list = []; var filespec = ""; var extdesc_prefix; +var both_desc = false; var since = 0; var props = []; var fmt; @@ -140,11 +141,16 @@ for(var i = 0; i < argc; i++) { continue; } if(opt == "ext") { + if(detail == FileBase.DETAIL.NORM) + both_desc = true; detail = FileBase.DETAIL.EXTENDED; continue; } if(opt == "desc") { - detail = FileBase.DETAIL.NORM; + if(detail >= FileBase.DETAIL.EXTENDED) + both_desc = true; + else + detail = FileBase.DETAIL.NORM; continue; } if(opt.indexOf("p=") == 0) { @@ -218,7 +224,8 @@ if(fmt != "json") { props.push("extdesc"); if(extdesc_prefix === undefined) extdesc_prefix = format("%*s| ", offset - 1, ""); - f += "%s"; + if(both_desc) + f += "%s"; } if(!fmt) fmt = f; @@ -385,9 +392,13 @@ function list_file(file, fmt, props) case "string": if(name == 'name') a.push(FileBase().format_name(p, name_len, options.pad)); - else if(name == 'extdesc') - a.push(p.replace(/([^\n]+)/g, (extdesc_prefix + "$&")).trimRight()); - else + else if(name == 'extdesc') { + if(both_desc) + a.push(p.replace(/([^\n]+)/g, (extdesc_prefix + "$&")).trimRight()); + else + a.push(p.trim().replace(/\n/g, '\n' + extdesc_prefix).trimRight()); + } + else if(both_desc || name !== 'desc' || !file.extdesc) a.push(p); break; case "number": -- GitLab