mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
import/export: Spelling fix: "convertor" -> "converter"
This commit is contained in:
parent
50fdadab7d
commit
3a11e97758
2 changed files with 17 additions and 17 deletions
|
@ -33,7 +33,7 @@ const util = require('util');
|
||||||
const fsp_writeFile = util.promisify(fs.writeFile);
|
const fsp_writeFile = util.promisify(fs.writeFile);
|
||||||
const fsp_unlink = util.promisify(fs.unlink);
|
const fsp_unlink = util.promisify(fs.unlink);
|
||||||
|
|
||||||
const convertor =
|
const converter =
|
||||||
settings.soffice != null ? require('../utils/LibreOffice')
|
settings.soffice != null ? require('../utils/LibreOffice')
|
||||||
: settings.abiword != null ? require('../utils/Abiword')
|
: settings.abiword != null ? require('../utils/Abiword')
|
||||||
: null;
|
: null;
|
||||||
|
@ -91,7 +91,7 @@ exports.doExport = async (req, res, padId, readOnlyId, type) => {
|
||||||
html = null;
|
html = null;
|
||||||
await TidyHtml.tidy(srcFile);
|
await TidyHtml.tidy(srcFile);
|
||||||
|
|
||||||
// send the convert job to the convertor (abiword, libreoffice, ..)
|
// send the convert job to the converter (abiword, libreoffice, ..)
|
||||||
const destFile = `${tempDirectory}/etherpad_export_${randNum}.${type}`;
|
const destFile = `${tempDirectory}/etherpad_export_${randNum}.${type}`;
|
||||||
|
|
||||||
// Allow plugins to overwrite the convert in export process
|
// Allow plugins to overwrite the convert in export process
|
||||||
|
@ -99,8 +99,8 @@ exports.doExport = async (req, res, padId, readOnlyId, type) => {
|
||||||
if (result.length > 0) {
|
if (result.length > 0) {
|
||||||
// console.log("export handled by plugin", destFile);
|
// console.log("export handled by plugin", destFile);
|
||||||
} else {
|
} else {
|
||||||
// @TODO no Promise interface for convertors (yet)
|
// @TODO no Promise interface for converters (yet)
|
||||||
await util.promisify(convertor.convertFile)(srcFile, destFile, type);
|
await util.promisify(converter.convertFile)(srcFile, destFile, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// send the file
|
// send the file
|
||||||
|
|
|
@ -55,17 +55,17 @@ const rm = async (path) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let convertor = null;
|
let converter = null;
|
||||||
let exportExtension = 'htm';
|
let exportExtension = 'htm';
|
||||||
|
|
||||||
// load abiword only if it is enabled and if soffice is disabled
|
// load abiword only if it is enabled and if soffice is disabled
|
||||||
if (settings.abiword != null && settings.soffice == null) {
|
if (settings.abiword != null && settings.soffice == null) {
|
||||||
convertor = require('../utils/Abiword');
|
converter = require('../utils/Abiword');
|
||||||
}
|
}
|
||||||
|
|
||||||
// load soffice only if it is enabled
|
// load soffice only if it is enabled
|
||||||
if (settings.soffice != null) {
|
if (settings.soffice != null) {
|
||||||
convertor = require('../utils/LibreOffice');
|
converter = require('../utils/LibreOffice');
|
||||||
exportExtension = 'html';
|
exportExtension = 'html';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +80,8 @@ const doImport = async (req, res, padId) => {
|
||||||
// set html in the pad
|
// set html in the pad
|
||||||
const randNum = Math.floor(Math.random() * 0xFFFFFFFF);
|
const randNum = Math.floor(Math.random() * 0xFFFFFFFF);
|
||||||
|
|
||||||
// setting flag for whether to use convertor or not
|
// setting flag for whether to use converter or not
|
||||||
let useConvertor = (convertor != null);
|
let useConverter = (converter != null);
|
||||||
|
|
||||||
const form = new formidable.IncomingForm();
|
const form = new formidable.IncomingForm();
|
||||||
form.keepExtensions = true;
|
form.keepExtensions = true;
|
||||||
|
@ -170,18 +170,18 @@ const doImport = async (req, res, padId) => {
|
||||||
// convert file to html if necessary
|
// convert file to html if necessary
|
||||||
if (!importHandledByPlugin && !directDatabaseAccess) {
|
if (!importHandledByPlugin && !directDatabaseAccess) {
|
||||||
if (fileIsTXT) {
|
if (fileIsTXT) {
|
||||||
// Don't use convertor for text files
|
// Don't use converter for text files
|
||||||
useConvertor = false;
|
useConverter = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// See https://github.com/ether/etherpad-lite/issues/2572
|
// See https://github.com/ether/etherpad-lite/issues/2572
|
||||||
if (fileIsHTML || !useConvertor) {
|
if (fileIsHTML || !useConverter) {
|
||||||
// if no convertor only rename
|
// if no converter only rename
|
||||||
await fs.rename(srcFile, destFile);
|
await fs.rename(srcFile, destFile);
|
||||||
} else {
|
} else {
|
||||||
// @TODO - no Promise interface for convertors (yet)
|
// @TODO - no Promise interface for converters (yet)
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
convertor.convertFile(srcFile, destFile, exportExtension, (err) => {
|
converter.convertFile(srcFile, destFile, exportExtension, (err) => {
|
||||||
// catch convert errors
|
// catch convert errors
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.warn(`Converting Error: ${err.stack || err}`);
|
logger.warn(`Converting Error: ${err.stack || err}`);
|
||||||
|
@ -193,7 +193,7 @@ const doImport = async (req, res, padId) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!useConvertor && !directDatabaseAccess) {
|
if (!useConverter && !directDatabaseAccess) {
|
||||||
// Read the file with no encoding for raw buffer access.
|
// Read the file with no encoding for raw buffer access.
|
||||||
const buf = await fs.readFile(destFile);
|
const buf = await fs.readFile(destFile);
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ const doImport = async (req, res, padId) => {
|
||||||
|
|
||||||
// change text of the pad and broadcast the changeset
|
// change text of the pad and broadcast the changeset
|
||||||
if (!directDatabaseAccess) {
|
if (!directDatabaseAccess) {
|
||||||
if (importHandledByPlugin || useConvertor || fileIsHTML) {
|
if (importHandledByPlugin || useConverter || fileIsHTML) {
|
||||||
try {
|
try {
|
||||||
await importHtml.setPadHTML(pad, text);
|
await importHtml.setPadHTML(pad, text);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in a new issue