* Fix hard line feeds @ FTN import/export

* Retain Origin and tear lines in imported messages
This commit is contained in:
Bryan Ashby 2016-03-22 22:24:00 -06:00
parent 0a0468bb12
commit 4e21901be7
4 changed files with 32 additions and 21 deletions

View File

@ -169,8 +169,10 @@ exports.PacketHeader = PacketHeader;
// * Writeup on differences between type 2, 2.2, and 2+: // * Writeup on differences between type 2, 2.2, and 2+:
// http://walon.org/pub/fidonet/FTSC-nodelists-etc./pkt-types.txt // http://walon.org/pub/fidonet/FTSC-nodelists-etc./pkt-types.txt
// //
function Packet() { function Packet(options) {
var self = this; var self = this;
this.options = options || {};
this.parsePacketHeader = function(packetBuffer, cb) { this.parsePacketHeader = function(packetBuffer, cb) {
assert(Buffer.isBuffer(packetBuffer)); assert(Buffer.isBuffer(packetBuffer));
@ -574,6 +576,10 @@ function Packet() {
if(messageBodyData.tearLine) { if(messageBodyData.tearLine) {
msg.meta.FtnProperty.ftn_tear_line = messageBodyData.tearLine; msg.meta.FtnProperty.ftn_tear_line = messageBodyData.tearLine;
if(self.options.keepTearAndOrigin) {
msg.message += `\r\n${messageBodyData.tearLine}\r\n`;
}
} }
if(messageBodyData.seenBy.length > 0) { if(messageBodyData.seenBy.length > 0) {
@ -586,6 +592,10 @@ function Packet() {
if(messageBodyData.originLine) { if(messageBodyData.originLine) {
msg.meta.FtnProperty.ftn_origin = messageBodyData.originLine; msg.meta.FtnProperty.ftn_origin = messageBodyData.originLine;
if(self.options.keepTearAndOrigin) {
msg.message += `${messageBodyData.originLine}\r\n`;
}
} }
const nextBuf = packetBuffer.slice(read); const nextBuf = packetBuffer.slice(read);

View File

@ -69,6 +69,8 @@ function getSortedAvailMessageConferences(client, options) {
// Return an *object* of available areas within |confTag| // Return an *object* of available areas within |confTag|
function getAvailableMessageAreasByConfTag(confTag, options) { function getAvailableMessageAreasByConfTag(confTag, options) {
options = options || {}; options = options || {};
// :TODO: confTag === "" then find default
if(_.has(Config.messageConferences, [ confTag, 'areas' ])) { if(_.has(Config.messageConferences, [ confTag, 'areas' ])) {
const areas = Config.messageConferences[confTag].areas; const areas = Config.messageConferences[confTag].areas;

View File

@ -266,24 +266,21 @@ function MultiLineEditTextView(options) {
} }
return lines; return lines;
}; };
this.getOutputText = function(startIndex, endIndex, includeEol) { this.getOutputText = function(startIndex, endIndex, eolMarker) {
var lines = self.getTextLines(startIndex, endIndex); let lines = self.getTextLines(startIndex, endIndex);
let text = '';
// var re = new RegExp('\\t{1,' + (self.tabWidth) + '}', 'g');
// Convert lines to contiguous string -- all expanded
// tabs put back to single '\t' characters. lines.forEach(line => {
// text += line.text.replace(re, '\t');
var text = ''; if(eolMarker && line.eol) {
var re = new RegExp('\\t{1,' + (self.tabWidth) + '}', 'g'); text += eolMarker;
for(var i = 0; i < lines.length; ++i) { }
text += lines[i].text.replace(re, '\t'); });
if(includeEol && lines[i].eol) {
text += '\n'; return text;
} }
}
return text;
};
this.getContiguousText = function(startIndex, endIndex, includeEol) { this.getContiguousText = function(startIndex, endIndex, includeEol) {
var lines = self.getTextLines(startIndex, endIndex); var lines = self.getTextLines(startIndex, endIndex);
@ -1018,7 +1015,7 @@ MultiLineEditTextView.prototype.addText = function(text) {
}; };
MultiLineEditTextView.prototype.getData = function() { MultiLineEditTextView.prototype.getData = function() {
return this.getOutputText(0, this.textLines.length, true); return this.getOutputText(0, this.textLines.length, '\r\n');
}; };
MultiLineEditTextView.prototype.setPropertyValue = function(propName, value) { MultiLineEditTextView.prototype.setPropertyValue = function(propName, value) {

View File

@ -806,7 +806,9 @@ function FTNMessageScanTossModule() {
this.importMessagesFromPacketFile = function(packetPath, password, cb) { this.importMessagesFromPacketFile = function(packetPath, password, cb) {
let packetHeader; let packetHeader;
new ftnMailPacket.Packet().read(packetPath, (entryType, entryData, next) => { const packetOpts = { keepTearAndOrigin : true };
new ftnMailPacket.Packet(packetOpts).read(packetPath, (entryType, entryData, next) => {
if('header' === entryType) { if('header' === entryType) {
packetHeader = entryData; packetHeader = entryData;