Merge pull request #328 from NuSkooler/download-message-ability
Download message ability
This commit is contained in:
commit
e140c98c35
|
@ -8,6 +8,7 @@ This document attempts to track **major** changes and additions in ENiGMA½. For
|
||||||
* An explicit prompt file previously specified by `general.promptFile` in `config.hjson` is no longer necessary. Instead, this now simply part of the `prompts` section in `menu.hjson`. The default setup still creates a separate prompt HJSON file, but it is `includes`ed in `menu.hjson`. With the removal of prompts the `PromptsChanged` event will no longer be fired.
|
* An explicit prompt file previously specified by `general.promptFile` in `config.hjson` is no longer necessary. Instead, this now simply part of the `prompts` section in `menu.hjson`. The default setup still creates a separate prompt HJSON file, but it is `includes`ed in `menu.hjson`. With the removal of prompts the `PromptsChanged` event will no longer be fired.
|
||||||
* New `PV` ACS check for arbitrary user properties. See [ACS](./docs/configuration/acs.md) for details.
|
* New `PV` ACS check for arbitrary user properties. See [ACS](./docs/configuration/acs.md) for details.
|
||||||
* The `message` arg used by `msg_list` has been deprecated. Please starting using `messageIndex` for this purpose. Support for `message` will be removed in the future.
|
* The `message` arg used by `msg_list` has been deprecated. Please starting using `messageIndex` for this purpose. Support for `message` will be removed in the future.
|
||||||
|
* Added ability to export/download messages. This is enabled in the default menu. See `messageAreaViewPost` in [the default message base template](./misc/menu_templates/message_base.in.hjson) and look for the download options (`@method:addToDownloadQueue`, etc.) for details on adding to your system!
|
||||||
|
|
||||||
## 0.0.11-beta
|
## 0.0.11-beta
|
||||||
* Upgraded from `alpha` to `beta` -- The software is far along and mature enough at this point!
|
* Upgraded from `alpha` to `beta` -- The software is far along and mature enough at this point!
|
||||||
|
|
Binary file not shown.
107
core/fse.js
107
core/fse.js
|
@ -21,17 +21,25 @@ const {
|
||||||
isAnsi, stripAnsiControlCodes,
|
isAnsi, stripAnsiControlCodes,
|
||||||
insert
|
insert
|
||||||
} = require('./string_util.js');
|
} = require('./string_util.js');
|
||||||
|
const { stripMciColorCodes } = require('./color_codes.js');
|
||||||
const Config = require('./config.js').get;
|
const Config = require('./config.js').get;
|
||||||
const { getAddressedToInfo } = require('./mail_util.js');
|
const { getAddressedToInfo } = require('./mail_util.js');
|
||||||
const Events = require('./events.js');
|
const Events = require('./events.js');
|
||||||
const UserProps = require('./user_property.js');
|
const UserProps = require('./user_property.js');
|
||||||
const SysProps = require('./system_property.js');
|
const SysProps = require('./system_property.js');
|
||||||
|
const FileArea = require('./file_base_area.js');
|
||||||
|
const FileEntry = require('./file_entry.js');
|
||||||
|
const DownloadQueue = require('./download_queue.js');
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
|
const fse = require('fs-extra');
|
||||||
|
const fs = require('graceful-fs');
|
||||||
|
const paths = require('path');
|
||||||
|
const sanatizeFilename = require('sanitize-filename');
|
||||||
|
|
||||||
exports.moduleInfo = {
|
exports.moduleInfo = {
|
||||||
name : 'Full Screen Editor (FSE)',
|
name : 'Full Screen Editor (FSE)',
|
||||||
|
@ -255,7 +263,12 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
|
||||||
viewModeMenuHelp : function(formData, extraArgs, cb) {
|
viewModeMenuHelp : function(formData, extraArgs, cb) {
|
||||||
self.viewControllers.footerView.setFocus(false);
|
self.viewControllers.footerView.setFocus(false);
|
||||||
return self.displayHelp(cb);
|
return self.displayHelp(cb);
|
||||||
}
|
},
|
||||||
|
|
||||||
|
addToDownloadQueue : (formData, extraArgs, cb) => {
|
||||||
|
this.viewControllers.footerView.setFocus(false);
|
||||||
|
return this.addToDownloadQueue(cb);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -905,6 +918,98 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addToDownloadQueue(cb) {
|
||||||
|
const sysTempDownloadArea = FileArea.getFileAreaByTag(FileArea.WellKnownAreaTags.TempDownloads);
|
||||||
|
const sysTempDownloadDir = FileArea.getAreaDefaultStorageDirectory(sysTempDownloadArea);
|
||||||
|
|
||||||
|
const msgInfo = this.getHeaderFormatObj();
|
||||||
|
|
||||||
|
const outputFileName = paths.join(
|
||||||
|
sysTempDownloadDir,
|
||||||
|
sanatizeFilename(
|
||||||
|
`(${msgInfo.messageId}) ${msgInfo.subject}_(${this.message.modTimestamp.format('YYYY-MM-DD')}).txt`)
|
||||||
|
);
|
||||||
|
|
||||||
|
async.waterfall(
|
||||||
|
[
|
||||||
|
(callback) => {
|
||||||
|
const header =
|
||||||
|
`+${'-'.repeat(79)}
|
||||||
|
| To : ${msgInfo.toUserName}
|
||||||
|
| From : ${msgInfo.fromUserName}
|
||||||
|
| When : ${moment(this.message.modTimestamp).format('dddd, MMMM Do YYYY, h:mm:ss a (UTCZ)')}
|
||||||
|
| Subject : ${msgInfo.subject}
|
||||||
|
| ID : ${this.message.messageUuid} (${msgInfo.messageId})
|
||||||
|
+${'-'.repeat(79)}
|
||||||
|
`;
|
||||||
|
const body = this.viewControllers.body
|
||||||
|
.getView(MciViewIds.body.message)
|
||||||
|
.getData( { forceLineTerms : true } );
|
||||||
|
|
||||||
|
const cleanBody = stripMciColorCodes(
|
||||||
|
stripAnsiControlCodes(body, { all : true } )
|
||||||
|
);
|
||||||
|
|
||||||
|
const exportedMessage = `${header}\r\n${cleanBody}`;
|
||||||
|
|
||||||
|
fse.mkdirs(sysTempDownloadDir, err => {
|
||||||
|
return callback(err, exportedMessage);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
(exportedMessage, callback) => {
|
||||||
|
return fs.writeFile(outputFileName, exportedMessage, 'utf8', callback);
|
||||||
|
},
|
||||||
|
(callback) => {
|
||||||
|
fs.stat(outputFileName, (err, stats) => {
|
||||||
|
return callback(err, stats.size);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
(fileSize, callback) => {
|
||||||
|
const newEntry = new FileEntry({
|
||||||
|
areaTag : sysTempDownloadArea.areaTag,
|
||||||
|
fileName : paths.basename(outputFileName),
|
||||||
|
storageTag : sysTempDownloadArea.storageTags[0],
|
||||||
|
meta : {
|
||||||
|
upload_by_username : this.client.user.username,
|
||||||
|
upload_by_user_id : this.client.user.userId,
|
||||||
|
byte_size : fileSize,
|
||||||
|
session_temp_dl : 1, // download is valid until session is over
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
newEntry.desc = `${msgInfo.messageId} - ${msgInfo.subject}`;
|
||||||
|
|
||||||
|
newEntry.persist(err => {
|
||||||
|
if(!err) {
|
||||||
|
// queue it!
|
||||||
|
DownloadQueue.get(this.client).addTemporaryDownload(newEntry);
|
||||||
|
}
|
||||||
|
return callback(err);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
(callback) => {
|
||||||
|
const artSpec = this.menuConfig.config.art.expToDlQueue ||
|
||||||
|
Buffer.from('Exported message has been added to your download queue!');
|
||||||
|
this.displayAsset(
|
||||||
|
artSpec,
|
||||||
|
{ clearScreen : true },
|
||||||
|
() => {
|
||||||
|
this.client.waitForKeyPress( () => {
|
||||||
|
this.redrawScreen( () => {
|
||||||
|
this.viewControllers[this.getFooterName()].setFocus(true);
|
||||||
|
return callback(null);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
],
|
||||||
|
err => {
|
||||||
|
return cb(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
displayQuoteBuilder() {
|
displayQuoteBuilder() {
|
||||||
//
|
//
|
||||||
// Clear body area
|
// Clear body area
|
||||||
|
|
|
@ -102,11 +102,10 @@ exports.getModule = class AreaViewFSEModule extends FullScreenEditorModule {
|
||||||
|
|
||||||
self.client.log(extraArgs, 'Missing extraArgs.menu');
|
self.client.log(extraArgs, 'Missing extraArgs.menu');
|
||||||
return cb(null);
|
return cb(null);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
loadMessageByUuid(uuid, cb) {
|
loadMessageByUuid(uuid, cb) {
|
||||||
const msg = new Message();
|
const msg = new Message();
|
||||||
msg.load( { uuid : uuid, user : this.client.user }, () => {
|
msg.load( { uuid : uuid, user : this.client.user }, () => {
|
||||||
|
|
|
@ -477,10 +477,11 @@
|
||||||
module: msg_area_view_fse
|
module: msg_area_view_fse
|
||||||
config: {
|
config: {
|
||||||
art: {
|
art: {
|
||||||
header: MSGVHDR
|
header: MSGVHDR
|
||||||
body: MSGBODY
|
body: MSGBODY
|
||||||
footerView: MSGVFTR
|
footerView: MSGVFTR
|
||||||
help: MSGVHLP
|
help: MSGVHLP
|
||||||
|
expToDlQueue: mb_export_dl_queue
|
||||||
},
|
},
|
||||||
editorMode: view
|
editorMode: view
|
||||||
editorType: area
|
editorType: area
|
||||||
|
@ -525,7 +526,7 @@
|
||||||
mci: {
|
mci: {
|
||||||
HM1: {
|
HM1: {
|
||||||
// :TODO: (#)Jump/(L)Index (msg list)/Last
|
// :TODO: (#)Jump/(L)Index (msg list)/Last
|
||||||
items: [ "prev", "next", "reply", "quit", "help" ]
|
items: [ "prev", "next", "reply", "quit", "download", "help" ]
|
||||||
focusItemIndex: 1
|
focusItemIndex: 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -552,6 +553,10 @@
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
value: { 1: 4 }
|
value: { 1: 4 }
|
||||||
|
action: @method:addToDownloadQueue
|
||||||
|
}
|
||||||
|
{
|
||||||
|
value: { 1: 5 }
|
||||||
action: @method:viewModeMenuHelp
|
action: @method:viewModeMenuHelp
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -576,6 +581,10 @@
|
||||||
keys: [ "escape", "q", "shift + q" ]
|
keys: [ "escape", "q", "shift + q" ]
|
||||||
action: @systemMethod:prevMenu
|
action: @systemMethod:prevMenu
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
keys: [ "d", "shift + d" ]
|
||||||
|
action: @method:addToDownloadQueue
|
||||||
|
}
|
||||||
{
|
{
|
||||||
keys: [ "?" ]
|
keys: [ "?" ]
|
||||||
action: @method:viewModeMenuHelp
|
action: @method:viewModeMenuHelp
|
||||||
|
|
Loading…
Reference in New Issue