Merge branch 'master' of ssh://numinibsd/git/base/enigma-bbs

This commit is contained in:
Bryan Ashby 2017-09-07 20:41:50 -06:00
commit 8acfa609f4
64 changed files with 2804 additions and 896 deletions

View file

@ -61,7 +61,6 @@ exports.getModule = class FileAreaFilterEdit extends MenuModule {
this.menuMethods = {
saveFilter : (formData, extraArgs, cb) => {
return this.saveCurrentFilter(formData, cb);
},
prevFilter : (formData, extraArgs, cb) => {
this.currentFilterIndex -= 1;
@ -93,7 +92,15 @@ exports.getModule = class FileAreaFilterEdit extends MenuModule {
return cb(null);
},
deleteFilter : (formData, extraArgs, cb) => {
const filterUuid = this.filtersArray[this.currentFilterIndex].uuid;
const selectedFilter = this.filtersArray[this.currentFilterIndex];
const filterUuid = selectedFilter.uuid;
// cannot delete built-in/system filters
if(true === selectedFilter.system) {
this.showError('Cannot delete built in filters!');
return cb(null);
}
this.filtersArray.splice(this.currentFilterIndex, 1); // remove selected entry
// remove from stored properties
@ -143,6 +150,17 @@ exports.getModule = class FileAreaFilterEdit extends MenuModule {
},
};
}
showError(errMsg) {
const errorView = this.viewControllers.editor.getView(MciViewIds.editor.error);
if(errorView) {
if(errMsg) {
errorView.setText(errMsg);
} else {
errorView.clearText();
}
}
}
mciReady(mciData, cb) {
super.mciReady(mciData, err => {

View file

@ -8,7 +8,6 @@ const ansi = require('../core/ansi_term.js');
const theme = require('../core/theme.js');
const FileEntry = require('../core/file_entry.js');
const stringFormat = require('../core/string_format.js');
const createCleanAnsi = require('../core/string_util.js').createCleanAnsi;
const FileArea = require('../core/file_base_area.js');
const Errors = require('../core/enig_error.js').Errors;
const ErrNotEnabled = require('../core/enig_error.js').ErrorReasons.NotEnabled;
@ -18,8 +17,7 @@ const DownloadQueue = require('../core/download_queue.js');
const FileAreaWeb = require('../core/file_area_web.js');
const FileBaseFilters = require('../core/file_base_filter.js');
const resolveMimeType = require('../core/mime_util.js').resolveMimeType;
const cleanControlCodes = require('../core/string_util.js').cleanControlCodes;
const isAnsi = require('../core/string_util.js').isAnsi;
// deps
const async = require('async');
@ -74,8 +72,12 @@ exports.getModule = class FileAreaList extends MenuModule {
constructor(options) {
super(options);
if(options.extraArgs) {
this.filterCriteria = options.extraArgs.filterCriteria;
this.filterCriteria = _.get(options, 'extraArgs.filterCriteria');
this.fileList = _.get(options, 'extraArgs.fileList');
if(this.fileList) {
// we'll need to adjust position as well!
this.fileListPosition = 0;
}
this.dlQueue = new DownloadQueue(this.client);
@ -116,7 +118,13 @@ exports.getModule = class FileAreaList extends MenuModule {
return this.displayDetailsPage(cb);
},
detailsQuit : (formData, extraArgs, cb) => {
this.viewControllers.details.setFocus(false);
[ 'detailsNfo', 'detailsFileList', 'details' ].forEach(n => {
const vc = this.viewControllers[n];
if(vc) {
vc.detachClientEvents();
}
});
return this.displayBrowsePage(true, cb); // true=clearScreen
},
toggleQueue : (formData, extraArgs, cb) => {
@ -212,8 +220,8 @@ exports.getModule = class FileAreaList extends MenuModule {
const entryInfo = currEntry.entryInfo = {
fileId : currEntry.fileId,
areaTag : currEntry.areaTag,
areaName : area.name || 'N/A',
areaDesc : area.desc || 'N/A',
areaName : _.get(area, 'name') || 'N/A',
areaDesc : _.get(area, 'desc') || 'N/A',
fileSha256 : currEntry.fileSha256,
fileName : currEntry.fileName,
desc : currEntry.desc || '',
@ -250,9 +258,9 @@ exports.getModule = class FileAreaList extends MenuModule {
const userRatingTicked = config.userRatingTicked || '*';
const userRatingUnticked = config.userRatingUnticked || '';
entryInfo.userRating = ~~Math.round(entryInfo.userRating) || 0; // be safe!
entryInfo.userRatingString = new Array(entryInfo.userRating + 1).join(userRatingTicked);
entryInfo.userRatingString = userRatingTicked.repeat(entryInfo.userRating);
if(entryInfo.userRating < 5) {
entryInfo.userRatingString += new Array( (5 - entryInfo.userRating) + 1).join(userRatingUnticked);
entryInfo.userRatingString += userRatingUnticked.repeat( (5 - entryInfo.userRating) );
}
FileAreaWeb.getExistingTempDownloadServeItem(this.client, this.currentFileEntry, (err, serveItem) => {
@ -348,7 +356,7 @@ exports.getModule = class FileAreaList extends MenuModule {
async.series(
[
function fetchEntryData(callback) {
if(self.fileList) {
if(self.fileList) {
return callback(null);
}
return self.loadFileIds(false, callback); // false=do not force
@ -373,31 +381,34 @@ exports.getModule = class FileAreaList extends MenuModule {
return self.populateCurrentEntryInfo(callback);
});
},
function populateViews(callback) {
function populateDesc(callback) {
if(_.isString(self.currentFileEntry.desc)) {
const descView = self.viewControllers.browse.getView(MciViewIds.browse.desc);
if(descView) {
createCleanAnsi(
self.currentFileEntry.desc,
{ height : self.client.termHeight, width : descView.dimens.width },
cleanDesc => {
// :TODO: use cleanDesc -- need to finish createCleanAnsi() !!
//descView.setText(cleanDesc);
descView.setText( self.currentFileEntry.desc );
self.updateQueueIndicator();
self.populateCustomLabels('browse', MciViewIds.browse.customRangeStart);
return callback(null);
}
);
if(descView) {
if(isAnsi(self.currentFileEntry.desc)) {
descView.setAnsi(
self.currentFileEntry.desc,
{
prepped : false,
forceLineTerm : true
},
() => {
return callback(null);
}
);
} else {
descView.setText(self.currentFileEntry.desc);
return callback(null);
}
}
} else {
self.updateQueueIndicator();
self.populateCustomLabels('browse', MciViewIds.browse.customRangeStart);
return callback(null);
}
},
function populateAdditionalViews(callback) {
self.updateQueueIndicator();
self.populateCustomLabels('browse', MciViewIds.browse.customRangeStart);
return callback(null);
}
],
err => {
@ -618,17 +629,37 @@ exports.getModule = class FileAreaList extends MenuModule {
case 'nfo' :
{
const nfoView = self.viewControllers.detailsNfo.getView(MciViewIds.detailsNfo.nfo);
if(nfoView) {
if(!nfoView) {
return callback(null);
}
if(isAnsi(self.currentFileEntry.entryInfo.descLong)) {
nfoView.setAnsi(
self.currentFileEntry.entryInfo.descLong,
{
prepped : false,
forceLineTerm : true,
},
() => {
return callback(null);
}
);
} else {
nfoView.setText(self.currentFileEntry.entryInfo.descLong);
return callback(null);
}
}
break;
case 'fileList' :
self.populateFileListing();
break;
}
return callback(null);
default :
return callback(null);
}
},
function setLabels(callback) {
self.populateCustomLabels(name, MciViewIds[name].customRangeStart);
return callback(null);
}

View file

@ -0,0 +1,84 @@
/* jslint node: true */
'use strict';
// enigma-bbs
const MenuModule = require('../core/menu_module.js').MenuModule;
const Config = require('../core/config.js').config;
const stringFormat = require('../core/string_format.js');
const ViewController = require('../core/view_controller.js').ViewController;
const getSortedAvailableFileAreas = require('../core/file_base_area.js').getSortedAvailableFileAreas;
// deps
const async = require('async');
const _ = require('lodash');
exports.moduleInfo = {
name : 'File Area Selector',
desc : 'Select from available file areas',
author : 'NuSkooler',
};
const MciViewIds = {
areaList : 1,
};
exports.getModule = class FileAreaSelectModule extends MenuModule {
constructor(options) {
super(options);
this.config = this.menuConfig.config || {};
this.loadAvailAreas();
this.menuMethods = {
selectArea : (formData, extraArgs, cb) => {
const area = this.availAreas[formData.value.areaSelect] || 0;
const filterCriteria = {
areaTag : area.areaTag,
};
const menuOpts = {
extraArgs : {
filterCriteria : filterCriteria,
},
menuFlags : [ 'noHistory' ],
};
return this.gotoMenu(this.menuConfig.config.fileBaseListEntriesMenu || 'fileBaseListEntries', menuOpts, cb);
}
};
}
loadAvailAreas() {
this.availAreas = getSortedAvailableFileAreas(this.client);
}
mciReady(mciData, cb) {
super.mciReady(mciData, err => {
if(err) {
return cb(err);
}
this.prepViewController('allViews', 0, { mciMap : mciData.menu }, (err, vc) => {
if(err) {
return cb(err);
}
const areaListView = vc.getView(MciViewIds.areaList);
const areaListFormat = this.config.areaListFormat || '{name}';
areaListView.setItems(this.availAreas.map(a => stringFormat(areaListFormat, a) ) );
if(this.config.areaListFocusFormat) {
areaListView.setFocusItems(this.availAreas.map(a => stringFormat(this.config.areaListFocusFormat, a) ) );
}
areaListView.redraw();
return cb(null);
});
});
}
};

View file

@ -472,7 +472,7 @@
0: {
mci: {
TL1: {
argName: from
argName: from
}
ET2: {
argName: to
@ -721,7 +721,7 @@
}
newScanMessageList: {
desc: Viewing New Message List
desc: New Messages
module: msg_list
art: NEWMSGS
config: {
@ -761,6 +761,166 @@
}
}
newScanFileBaseList: {
module: file_area_list
desc: New Files
config: {
art: {
browse: FNEWBRWSE
details: FDETAIL
detailsGeneral: FDETGEN
detailsNfo: FDETNFO
detailsFileList: FDETLST
help: FBHELP
}
}
form: {
0: {
mci: {
MT1: {
mode: preview
ansiView: true
}
HM2: {
focus: true
submit: true
argName: navSelect
items: [
"prev", "next", "details", "toggle queue", "rate", "help", "quit"
]
focusItemIndex: 1
}
// :TODO: these can be removed once the hack is not required:
TL10: {}
TL11: {}
TL12: {}
TL13: {}
TL14: {}
TL15: {}
TL16: {}
TL17: {}
TL18: {}
}
submit: {
*: [
{
value: { navSelect: 0 }
action: @method:prevFile
}
{
value: { navSelect: 1 }
action: @method:nextFile
}
{
value: { navSelect: 2 }
action: @method:viewDetails
}
{
value: { navSelect: 3 }
action: @method:toggleQueue
}
{
value: { navSelect: 4 }
action: @menu:fileBaseGetRatingForSelectedEntry
}
{
value: { navSelect: 5 }
action: @method:displayHelp
}
{
value: { navSelect: 6 }
action: @systemMethod:prevMenu
}
]
}
actionKeys: [
{
keys: [ "w", "shift + w" ]
action: @method:showWebDownloadLink
}
{
keys: [ "escape", "q", "shift + q" ]
action: @systemMethod:prevMenu
}
{
keys: [ "t", "shift + t" ]
action: @method:toggleQueue
}
{
keys: [ "v", "shift + v" ]
action: @method:viewDetails
}
{
keys: [ "r", "shift + r" ]
action: @menu:fileBaseGetRatingForSelectedEntry
}
{
keys: [ "?" ]
action: @method:displayHelp
}
]
}
1: {
mci: {
HM1: {
focus: true
submit: true
argName: navSelect
items: [
"general", "nfo/readme", "file listing"
]
}
// :TODO: these can be removed once the hack is not required:
TL10: {}
TL11: {}
TL12: {}
TL13: {}
TL14: {}
TL15: {}
TL16: {}
TL17: {}
TL18: {}
}
actionKeys: [
{
keys: [ "escape", "q", "shift + q" ]
action: @method:detailsQuit
}
]
}
2: {
// details - general
mci: {}
}
3: {
// details - nfo/readme
mci: {
MT1: {
mode: preview
}
}
}
4: {
// details - file listing
mci: {
VM1: {
}
}
}
}
}
///////////////////////////////////////////////////////////////////////
// Main Menu
///////////////////////////////////////////////////////////////////////
@ -1916,50 +2076,49 @@
}
}
submit: {
*: [
{
value: { 1: 0 }
action: @method:editModeMenuSave
}
{
value: { 1: 1 }
action: @systemMethod:prevMenu
}
{
value: { 1: 2 },
action: @method:editModeMenuQuote
}
{
value: { 1: 3 }
action: @method:editModeMenuHelp
}
]
}
actionKeys: [
submit: {
*: [
{
keys: [ "escape" ]
action: @method:editModeEscPressed
}
{
keys: [ "s", "shift + s" ]
value: { 1: 0 }
action: @method:editModeMenuSave
}
{
keys: [ "d", "shift + d" ]
value: { 1: 1 }
action: @systemMethod:prevMenu
}
{
keys: [ "q", "shift + q" ]
value: { 1: 2 },
action: @method:editModeMenuQuote
}
{
keys: [ "?" ]
value: { 1: 3 }
action: @method:editModeMenuHelp
}
]
}
actionKeys: [
{
keys: [ "escape" ]
action: @method:editModeEscPressed
}
{
keys: [ "s", "shift + s" ]
action: @method:editModeMenuSave
}
{
keys: [ "d", "shift + d" ]
action: @systemMethod:prevMenu
}
{
keys: [ "q", "shift + q" ]
action: @method:editModeMenuQuote
}
{
keys: [ "?" ]
action: @method:editModeMenuHelp
}
]
}
// Quote builder
@ -2313,9 +2472,13 @@
prompt: fileMenuCommand
submit: [
{
value: { menuOption: "B" }
value: { menuOption: "L" }
action: @menu:fileBaseListEntries
}
{
value: { menuOption: "B" }
action: @menu:fileBaseBrowseByAreaSelect
}
{
value: { menuOption: "F" }
action: @menu:fileAreaFilterEditor
@ -2510,6 +2673,38 @@
}
}
fileBaseBrowseByAreaSelect: {
desc: Browsing File Areas
module: file_base_area_select
art: FAREASEL
form: {
0: {
mci: {
VM1: {
focus: true
argName: areaSelect
}
}
submit: {
*: [
{
value: { areaSelect: null }
action: @method:selectArea
}
]
}
actionKeys: [
{
keys: [ "escape" ]
action: @systemMethod:prevMenu
}
]
}
}
}
fileBaseGetRatingForSelectedEntry: {
desc: Rating a File
prompt: fileBaseRateEntryPrompt

View file

@ -22,8 +22,9 @@ exports.getModule = class AreaViewFSEModule extends FullScreenEditorModule {
this.editorMode = 'view';
if(_.isObject(options.extraArgs)) {
this.messageList = options.extraArgs.messageList;
this.messageIndex = options.extraArgs.messageIndex;
this.messageList = options.extraArgs.messageList;
this.messageIndex = options.extraArgs.messageIndex;
this.lastMessageNextExit = options.extraArgs.lastMessageNextExit;
}
this.messageList = this.messageList || [];
@ -41,6 +42,12 @@ exports.getModule = class AreaViewFSEModule extends FullScreenEditorModule {
return self.loadMessageByUuid(self.messageList[self.messageIndex].messageUuid, cb);
}
// auto-exit if no more to go?
if(self.lastMessageNextExit) {
self.lastMessageReached = true;
return self.prevMenu(cb);
}
return cb(null);
},
@ -120,6 +127,9 @@ exports.getModule = class AreaViewFSEModule extends FullScreenEditorModule {
}
getMenuResult() {
return this.messageIndex;
return {
messageIndex : this.messageIndex,
lastMessageReached : this.lastMessageReached,
};
}
};

View file

@ -49,6 +49,8 @@ exports.getModule = class MessageListModule extends MessageAreaConfTempSwitcher(
this.messageAreaTag = config.messageAreaTag;
this.lastMessageReachedExit = _.get(options, 'lastMenuResult.lastMessageReached', false);
if(options.extraArgs) {
//
// |extraArgs| can override |messageAreaTag| provided by config
@ -73,6 +75,7 @@ exports.getModule = class MessageListModule extends MessageAreaConfTempSwitcher(
messageAreaTag : self.messageAreaTag,
messageList : self.messageList,
messageIndex : formData.value.message,
lastMessageNextExit : true,
}
};
@ -107,6 +110,10 @@ exports.getModule = class MessageListModule extends MessageAreaConfTempSwitcher(
}
enter() {
if(this.lastMessageReachedExit) {
return this.prevMenu();
}
super.enter();
//

Binary file not shown.

Binary file not shown.

View file

@ -3,6 +3,7 @@
name: Mystery Skull
author: Luciano Ayres
group: blocktronics
enabled: true
}
customization: {
@ -590,6 +591,124 @@
}
}
newScanFileBaseList: {
config: {
hashTagsSep: "|08, |07"
browseInfoFormat10: "|00|10{fileName} |08- |03{byteSize!sizeWithoutAbbr} |11{byteSize!sizeAbbr} |08- |03uploaded |11{uploadTimestamp}"
browseInfoFormat11: "|00|15{areaName}"
browseInfoFormat12: "|00|07{hashTags}"
browseInfoFormat13: "|00|07{estReleaseYear}"
browseInfoFormat14: "|00|07{dlCount}"
browseInfoFormat15: "{userRatingString}"
browseInfoFormat16: "{isQueued}"
browseInfoFormat17: "{webDlLink}{webDlExpire}"
webDlExpireTimeFormat: " [|08- |07exp] ddd, MMM Do @ h:mm a"
webDlLinkNeedsGenerated: "|08(|07press |10W |07to generate link|08)"
isQueuedIndicator: "|00|10YES"
isNotQueuedIndicator: "|00|07no"
userRatingTicked: "|00|15*"
userRatingUnticked: "|00|07-"
detailsGeneralInfoFormat10: "{fileName}"
detailsGeneralInfoFormat11: "|00|07{byteSize!sizeWithoutAbbr} |11{byteSize!sizeAbbr} |08(|03{byteSize:,} |11B|08)"
detailsGeneralInfoFormat12: "|00|07{hashTags}"
detailsGeneralInfoFormat13: "{estReleaseYear}"
detailsGeneralInfoFormat14: "{dlCount}"
detailsGeneralInfoFormat15: "{userRatingString}"
detailsGeneralInfoFormat16: "{fileCrc32}"
detailsGeneralInfoFormat17: "{fileMd5}"
detailsGeneralInfoFormat18: "{fileSha1}"
detailsGeneralInfoFormat19: "{fileSha256}"
detailsGeneralInfoFormat20: "{uploadByUsername}"
detailsGeneralInfoFormat21: "{uploadTimestamp}"
detailsGeneralInfoFormat22: "{archiveTypeDesc}"
fileListEntryFormat: "|00|03{fileName:<67.66} {byteSize!sizeWithoutAbbr:>7.6} |11{byteSize!sizeAbbr}"
focusFileListEntryFormat: "|00|19|15{fileName:<67.66} {byteSize!sizeWithoutAbbr:>7.6} {byteSize!sizeAbbr}"
notAnArchiveFormat: "|00|08( |07{fileName} is not an archive |08)"
}
0: {
mci: {
MT1: {
height: 16
width: 45
}
HM2: {
focusTextStyle: first lower
}
TL11: {
width: 21
textOverflow: ...
}
TL12: {
width: 21
textOverflow: ...
}
TL13: { width: 21 }
TL14: { width: 21 }
TL15: { width: 21 }
TL16: { width: 21 }
TL17: { width: 73 }
}
}
1: {
mci: {
HM1: {
focusTextStyle: first lower
}
}
}
2: {
}
3: {
// details - nfo/readme
mci: {
MT1: {
height: 19
width: 79
}
}
}
4: {
mci: {
VM1: {
height: 17
width: 79
}
}
}
}
fileBaseBrowseByAreaSelect: {
config: {
protListFormat: "|00|03{name}"
protListFocusFormat: "|00|19|15{name}"
}
0: {
mci: {
VM1: {
height: 15
width: 30
focusTextStyle: first lower
}
}
}
}
fileBaseSearch: {
mci: {
ET1: {

View file

@ -15,7 +15,6 @@ const pathWithTerminatingSeparator = require('../core/file_util.js').pathWithTe
const Log = require('../core/logger.js').log;
const Errors = require('../core/enig_error.js').Errors;
const FileEntry = require('../core/file_entry.js');
const enigmaToAnsi = require('../core/color_codes.js').enigmaToAnsi;
// deps
const async = require('async');