Minor Gopher updates

This commit is contained in:
Bryan Ashby 2018-04-16 17:10:19 -06:00
parent 6de6150fdc
commit f557e5b6e0
2 changed files with 7 additions and 4 deletions

View File

@ -497,6 +497,7 @@ module.exports = class Message {
}); });
} }
// :TODO: this should only take a UUID...
load(options, cb) { load(options, cb) {
assert(_.isString(options.uuid)); assert(_.isString(options.uuid));

View File

@ -153,7 +153,7 @@ exports.getModule = class GopherModule extends ServerModule {
} }
defaultGenerator(selectorMatch, cb) { defaultGenerator(selectorMatch, cb) {
let bannerFile = _.get(Config, 'contentServers.gopher.banner', 'startup_banner.asc'); let bannerFile = _.get(Config, 'contentServers.gopher.bannerFile', 'startup_banner.asc');
bannerFile = paths.isAbsolute(bannerFile) ? bannerFile : paths.join(__dirname, '../../../misc', bannerFile); bannerFile = paths.isAbsolute(bannerFile) ? bannerFile : paths.join(__dirname, '../../../misc', bannerFile);
fs.readFile(bannerFile, 'utf8', (err, banner) => { fs.readFile(bannerFile, 'utf8', (err, banner) => {
if(err) { if(err) {
@ -194,6 +194,10 @@ exports.getModule = class GopherModule extends ServerModule {
} }
} }
shortenSubject(subject) {
return _.truncate(subject, { length : 30 } );
}
messageAreaGenerator(selectorMatch, cb) { messageAreaGenerator(selectorMatch, cb) {
// //
// Selector should be: // Selector should be:
@ -222,7 +226,6 @@ exports.getModule = class GopherModule extends ServerModule {
} }
this.prepareMessageBody(message.message, msgBody => { this.prepareMessageBody(message.message, msgBody => {
// :TODO: create DRY for subject trimming...
const response = `${'-'.repeat(70)} const response = `${'-'.repeat(70)}
To : ${message.toUserName} To : ${message.toUserName}
From : ${message.fromUserName} From : ${message.fromUserName}
@ -256,8 +259,7 @@ ${msgBody}
this.makeItem(ItemTypes.InfoMessage, '-'.repeat(70)), this.makeItem(ItemTypes.InfoMessage, '-'.repeat(70)),
...msgList.map(msg => this.makeItem( ...msgList.map(msg => this.makeItem(
ItemTypes.TextFile, ItemTypes.TextFile,
// :TODO: reasonably trim string `${moment(msg.modTimestamp).format('YYYY-MM-DD hh:mma')}: ${this.shortenSubject(msg.subject)} (${msg.fromUserName} to ${msg.toUserName})`,
`${moment(msg.modTimestamp).format('YYYY-MM-DD hh:mma')} ${msg.subject} (${msg.fromUserName} to ${msg.toUserName})`,
`/msgarea/${confTag}/${areaTag}/${msg.messageUuid}` `/msgarea/${confTag}/${areaTag}/${msg.messageUuid}`
)) ))
].join(''); ].join('');