Merge branch 'master' of ssh://numinibsd/git/base/enigma-bbs
This commit is contained in:
commit
6c67f0e024
1666
core/acs_parser.js
1666
core/acs_parser.js
File diff suppressed because it is too large
Load Diff
|
@ -32,6 +32,7 @@ exports.getFileEntryPath = getFileEntryPath;
|
|||
exports.changeFileAreaWithOptions = changeFileAreaWithOptions;
|
||||
exports.scanFile = scanFile;
|
||||
exports.scanFileAreaForChanges = scanFileAreaForChanges;
|
||||
exports.getDescFromFileName = getDescFromFileName;
|
||||
|
||||
const WellKnownAreaTags = exports.WellKnownAreaTags = {
|
||||
Invalid : '',
|
||||
|
@ -670,3 +671,11 @@ function scanFileAreaForChanges(areaInfo, options, iterator, cb) {
|
|||
return cb(err);
|
||||
});
|
||||
}
|
||||
|
||||
function getDescFromFileName(fileName) {
|
||||
// :TODO: this method could use some more logic to really be nice.
|
||||
const ext = paths.extname(fileName);
|
||||
const name = paths.basename(fileName, ext);
|
||||
|
||||
return _.upperFirst(name.replace(/[\-_.+]/g, ' ').replace(/\s+/g, ' '));
|
||||
}
|
|
@ -290,8 +290,9 @@ module.exports = class FileEntry {
|
|||
}
|
||||
}
|
||||
|
||||
// :TODO: Use static get accessor:
|
||||
static getWellKnownMetaValues() { return Object.keys(FILE_WELL_KNOWN_META); }
|
||||
static get WellKnownMetaValues() {
|
||||
return Object.keys(FILE_WELL_KNOWN_META);
|
||||
}
|
||||
|
||||
static findFileBySha(sha, cb) {
|
||||
// full or partial SHA-256
|
||||
|
|
|
@ -93,8 +93,9 @@ class PacketHeader {
|
|||
|
||||
// See FSC-48
|
||||
if(address.point) {
|
||||
this.auxNet = address.origNet;
|
||||
this.origNet = -1;
|
||||
this.auxNet = address.net;
|
||||
|
||||
} else {
|
||||
this.origNet = address.net;
|
||||
this.auxNet = 0;
|
||||
|
@ -296,7 +297,7 @@ function Packet(options) {
|
|||
|
||||
buffer.writeUInt16LE(packetHeader.baud, 16);
|
||||
buffer.writeUInt16LE(FTN_PACKET_HEADER_TYPE, 18);
|
||||
buffer.writeUInt16LE(-1 === packetHeader.origNet ? 0xff : packetHeader.origNet, 20);
|
||||
buffer.writeUInt16LE(-1 === packetHeader.origNet ? 0xffff : packetHeader.origNet, 20);
|
||||
buffer.writeUInt16LE(packetHeader.destNet, 22);
|
||||
buffer.writeUInt8(packetHeader.prodCodeLo, 24);
|
||||
buffer.writeUInt8(packetHeader.prodRevHi, 25);
|
||||
|
@ -334,7 +335,7 @@ function Packet(options) {
|
|||
|
||||
buffer.writeUInt16LE(packetHeader.baud, 16);
|
||||
buffer.writeUInt16LE(FTN_PACKET_HEADER_TYPE, 18);
|
||||
buffer.writeUInt16LE(-1 === packetHeader.origNet ? 0xff : packetHeader.origNet, 20);
|
||||
buffer.writeUInt16LE(-1 === packetHeader.origNet ? 0xffff : packetHeader.origNet, 20);
|
||||
buffer.writeUInt16LE(packetHeader.destNet, 22);
|
||||
buffer.writeUInt8(packetHeader.prodCodeLo, 24);
|
||||
buffer.writeUInt8(packetHeader.prodRevHi, 25);
|
||||
|
|
|
@ -23,7 +23,14 @@ const exitCodes = exports.ExitCodes = {
|
|||
BAD_ARGS : -3,
|
||||
};
|
||||
|
||||
const argv = exports.argv = require('minimist')(process.argv.slice(2));
|
||||
const argv = exports.argv = require('minimist')(process.argv.slice(2), {
|
||||
alias : {
|
||||
h : 'help',
|
||||
v : 'version',
|
||||
c : 'config',
|
||||
n : 'no-prompt',
|
||||
}
|
||||
});
|
||||
|
||||
function printUsageAndSetExitCode(errMsg, exitCode) {
|
||||
if(_.isUndefined(exitCode)) {
|
||||
|
|
|
@ -9,12 +9,14 @@ const initConfigAndDatabases = require('./oputil_common.js').initConfigAndDataba
|
|||
const getHelpFor = require('./oputil_help.js').getHelpFor;
|
||||
const getAreaAndStorage = require('./oputil_common.js').getAreaAndStorage;
|
||||
const Errors = require('../../core/enig_error.js').Errors;
|
||||
const getDescFromFileName = require('../../core/file_base_area.js').getDescFromFileName;
|
||||
|
||||
const async = require('async');
|
||||
const fs = require('fs');
|
||||
const paths = require('path');
|
||||
const _ = require('lodash');
|
||||
const moment = require('moment');
|
||||
const inq = require('inquirer');
|
||||
|
||||
exports.handleFileBaseCommand = handleFileBaseCommand;
|
||||
|
||||
|
@ -33,6 +35,40 @@ exports.handleFileBaseCommand = handleFileBaseCommand;
|
|||
|
||||
let fileArea; // required during init
|
||||
|
||||
function finalizeEntryAndPersist(fileEntry, cb) {
|
||||
async.series(
|
||||
[
|
||||
function getDescIfNeeded(callback) {
|
||||
if(false === argv.prompt || ( fileEntry.desc && fileEntry.desc.length > 0 ) ) {
|
||||
return callback(null);
|
||||
}
|
||||
|
||||
const questions = [
|
||||
{
|
||||
name : 'desc',
|
||||
message : `Description for ${fileEntry.fileName}:`,
|
||||
type : 'input',
|
||||
default : getDescFromFileName(fileEntry.fileName),
|
||||
}
|
||||
];
|
||||
|
||||
inq.prompt(questions).then( answers => {
|
||||
fileEntry.desc = answers.desc;
|
||||
return callback(null);
|
||||
});
|
||||
},
|
||||
function persist(callback) {
|
||||
fileEntry.persist( err => {
|
||||
return callback(err);
|
||||
});
|
||||
}
|
||||
],
|
||||
err => {
|
||||
return cb(err);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function scanFileAreaForChanges(areaInfo, options, cb) {
|
||||
|
||||
const storageLocations = fileArea.getAreaStorageLocations(areaInfo).filter(sl => {
|
||||
|
@ -94,7 +130,7 @@ function scanFileAreaForChanges(areaInfo, options, cb) {
|
|||
});
|
||||
}
|
||||
|
||||
fileEntry.persist( err => {
|
||||
finalizeEntryAndPersist(fileEntry, err => {
|
||||
return nextFile(err);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,13 +12,13 @@ const usageHelp = exports.USAGE_HELP = {
|
|||
<command> [<args>]
|
||||
|
||||
global args:
|
||||
--config PATH : specify config path (${getDefaultConfigPath()})
|
||||
--no-prompt : assume defaults/don't prompt for input where possible
|
||||
-c, --config PATH : specify config path (${getDefaultConfigPath()})
|
||||
-n, --no-prompt : assume defaults/don't prompt for input where possible
|
||||
|
||||
where <command> is one of:
|
||||
user : user utilities
|
||||
config : config file management
|
||||
fb : file base management
|
||||
user : user utilities
|
||||
config : config file management
|
||||
fb : file base management
|
||||
|
||||
`,
|
||||
User :
|
||||
|
|
|
@ -22,7 +22,7 @@ module.exports = function() {
|
|||
if(0 === argv._.length ||
|
||||
'help' === argv._[0])
|
||||
{
|
||||
printUsageAndSetExitCode(getHelpFor('General'), ExitCodes.SUCCESS);
|
||||
return printUsageAndSetExitCode(getHelpFor('General'), ExitCodes.SUCCESS);
|
||||
}
|
||||
|
||||
switch(argv._[0]) {
|
||||
|
|
|
@ -142,6 +142,8 @@ const OPTIONS = {
|
|||
//SSPI_LOGON : 139,
|
||||
//PRAGMA_HEARTBEAT : 140
|
||||
|
||||
ARE_YOU_THERE : 246, // aka 'AYT' RFC 854 @ https://tools.ietf.org/html/rfc854
|
||||
|
||||
EXTENDED_OPTIONS_LIST : 255, // RFC 861 (STD 32)
|
||||
};
|
||||
|
||||
|
@ -192,7 +194,7 @@ OPTION_IMPLS[OPTIONS.TERMINAL_SPEED] =
|
|||
OPTION_IMPLS[OPTIONS.REMOTE_FLOW_CONTROL] =
|
||||
OPTION_IMPLS[OPTIONS.X_DISPLAY_LOCATION] =
|
||||
OPTION_IMPLS[OPTIONS.SEND_LOCATION] =
|
||||
|
||||
OPTION_IMPLS[OPTIONS.ARE_YOU_THERE] =
|
||||
OPTION_IMPLS[OPTIONS.SUPPRESS_GO_AHEAD] = function(bufs, i, event) {
|
||||
event.buf = bufs.splice(0, i).toBuffer();
|
||||
return event;
|
||||
|
|
|
@ -44,12 +44,12 @@
|
|||
return client.node === value;
|
||||
},
|
||||
NP : function numberOfPosts() {
|
||||
// :TODO: implement me!!!!
|
||||
return false;
|
||||
const postCount = parseInt(user.properties.post_count, 10);
|
||||
return !isNaN(value) && postCount >= value;
|
||||
},
|
||||
NC : function numberOfCalls() {
|
||||
// :TODO: implement me!!
|
||||
return false;
|
||||
const loginCount = parseInt(user.properties.login_count, 10);
|
||||
return !isNaN(value) && loginCount >= value;
|
||||
},
|
||||
SC : function isSecureConnection() {
|
||||
return client.session.isSecure;
|
||||
|
|
|
@ -229,7 +229,7 @@ exports.getModule = class FileAreaList extends MenuModule {
|
|||
// We need the entry object to contain meta keys even if they are empty as
|
||||
// consumers may very likely attempt to use them
|
||||
//
|
||||
const metaValues = FileEntry.getWellKnownMetaValues();
|
||||
const metaValues = FileEntry.WellKnownMetaValues;
|
||||
metaValues.forEach(name => {
|
||||
const value = !_.isUndefined(currEntry.meta[name]) ? currEntry.meta[name] : 'N/A';
|
||||
entryInfo[_.camelCase(name)] = value;
|
||||
|
|
|
@ -8,6 +8,7 @@ const getSortedAvailableFileAreas = require('../core/file_base_area.js').getSor
|
|||
const getAreaDefaultStorageDirectory = require('../core/file_base_area.js').getAreaDefaultStorageDirectory;
|
||||
const scanFile = require('../core/file_base_area.js').scanFile;
|
||||
const getFileAreaByTag = require('../core/file_base_area.js').getFileAreaByTag;
|
||||
const getDescFromFileName = require('../core/file_base_area.js').getDescFromFileName;
|
||||
const ansiGoto = require('../core/ansi_term.js').goto;
|
||||
const moveFileWithCollisionHandling = require('../core/file_util.js').moveFileWithCollisionHandling;
|
||||
const pathWithTerminatingSeparator = require('../core/file_util.js').pathWithTerminatingSeparator;
|
||||
|
@ -673,7 +674,7 @@ exports.getModule = class UploadModule extends MenuModule {
|
|||
|
||||
tagsView.setText( Array.from(fileEntry.hashTags).join(',') ); // :TODO: optional 'hashTagsSep' like file list/browse
|
||||
yearView.setText(fileEntry.meta.est_release_year || '');
|
||||
|
||||
|
||||
if(self.fileEntryHasDetectedDesc(fileEntry)) {
|
||||
descView.setPropertyValue('mode', 'preview');
|
||||
descView.setText(fileEntry.desc);
|
||||
|
@ -681,7 +682,7 @@ exports.getModule = class UploadModule extends MenuModule {
|
|||
self.viewControllers.fileDetails.switchFocus(MciViewIds.fileDetails.tags);
|
||||
} else {
|
||||
descView.setPropertyValue('mode', 'edit');
|
||||
descView.setText('');
|
||||
descView.setText(getDescFromFileName(fileEntry.fileName)); // try to come up with something good as a default
|
||||
descView.acceptsFocus = true;
|
||||
self.viewControllers.fileDetails.switchFocus(MciViewIds.fileDetails.desc);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue