check for soffice before removing export paths

pull/2859/head
Chris Birk 2015-12-17 21:54:04 -06:00
parent e98821cef7
commit 7f517eca0b
3 changed files with 51 additions and 12 deletions

View File

@ -1234,6 +1234,8 @@ function handleClientReady(client, message)
"serverTimestamp": new Date().getTime(), "serverTimestamp": new Date().getTime(),
"userId": author, "userId": author,
"abiwordAvailable": settings.abiwordAvailable(), "abiwordAvailable": settings.abiwordAvailable(),
"sofficeAvailable": settings.sofficeAvailable(),
"exportAvailable": settings.exportAvailable(),
"plugins": { "plugins": {
"plugins": plugins.plugins, "plugins": plugins.plugins,
"parts": plugins.parts, "parts": plugins.parts,

View File

@ -222,6 +222,27 @@ exports.abiwordAvailable = function()
} }
}; };
exports.sofficeAvailable = function () {
if(exports.soffice != null) {
return os.type().indexOf("Windows") != -1 ? "withoutPDF": "yes";
} else {
return "no";
}
};
exports.exportAvailable = function () {
var abiword = exports.abiwordAvailable();
var soffice = exports.sofficeAvailable();
if(abiword == "no" && soffice == "no") {
return "no";
} else if ((abiword == "withoutPDF" && soffice == "no") || (abiword == "no" && soffice == "withoutPDF")) {
return "withoutPDF";
} else {
return "yes";
}
};
// Provide git version if available // Provide git version if available
exports.getGitCommit = function() { exports.getGitCommit = function() {
var version = ""; var version = "";
@ -375,6 +396,20 @@ exports.reloadSettings = function reloadSettings() {
} }
} }
if(exports.soffice) {
fs.exists(exports.soffice, function (exists) {
if(!exists) {
var sofficeError = "SOffice does not exist at this path, check your settings file";
if(!exports.suppressErrorsInPadText) {
exports.defaultPadText = exports.defaultPadText + "\nError: " + sofficeError + suppressDisableMsg;
}
console.error(sofficeError);
exports.soffice = null;
}
});
}
if (!exports.sessionKey) { if (!exports.sessionKey) {
try { try {
exports.sessionKey = fs.readFileSync("./SESSIONKEY.txt","utf8"); exports.sessionKey = fs.readFileSync("./SESSIONKEY.txt","utf8");

View File

@ -1,5 +1,5 @@
/** /**
* This code is mostly from the old Etherpad. Please help us to comment this code. * This code is mostly from the old Etherpad. Please help us to comment this code.
* This helps other people to understand this code better and helps them to improve it. * This helps other people to understand this code better and helps them to improve it.
* TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED
*/ */
@ -46,7 +46,7 @@ var padimpexp = (function()
$('#importmessagefail').fadeOut("fast"); $('#importmessagefail').fadeOut("fast");
var ret = window.confirm(html10n.get("pad.impexp.confirmimport")); var ret = window.confirm(html10n.get("pad.impexp.confirmimport"));
if (ret) if (ret)
{ {
currentImportTimer = window.setTimeout(function() currentImportTimer = window.setTimeout(function()
{ {
if (!currentImportTimer) if (!currentImportTimer)
@ -61,7 +61,7 @@ var padimpexp = (function()
{ {
disabled: true disabled: true
}).val(html10n.get("pad.impexp.importing")); }).val(html10n.get("pad.impexp.importing"));
window.setTimeout(function() window.setTimeout(function()
{ {
$('#importfileinput').attr( $('#importfileinput').attr(
@ -104,7 +104,7 @@ var padimpexp = (function()
function importErrorMessage(status) function importErrorMessage(status)
{ {
var msg=""; var msg="";
if(status === "convertFailed"){ if(status === "convertFailed"){
msg = html10n.get("pad.impexp.convertFailed"); msg = html10n.get("pad.impexp.convertFailed");
} else if(status === "uploadFailed"){ } else if(status === "uploadFailed"){
@ -112,7 +112,7 @@ var padimpexp = (function()
} else if(status === "padHasData"){ } else if(status === "padHasData"){
msg = html10n.get("pad.impexp.padHasData"); msg = html10n.get("pad.impexp.padHasData");
} }
function showError(fade) function showError(fade)
{ {
$('#importmessagefail').html('<strong style="color: red">'+html10n.get('pad.impexp.importfailed')+':</strong> ' + (msg || html10n.get('pad.impexp.copypaste','')))[(fade ? "fadeIn" : "show")](); $('#importmessagefail').html('<strong style="color: red">'+html10n.get('pad.impexp.importfailed')+':</strong> ' + (msg || html10n.get('pad.impexp.copypaste','')))[(fade ? "fadeIn" : "show")]();
@ -206,9 +206,11 @@ var padimpexp = (function()
// activate action to import in the form // activate action to import in the form
$("#importform").attr('action', pad_root_url + "/import"); $("#importform").attr('action', pad_root_url + "/import");
//hide stuff thats not avaible if abiword is disabled console.log(clientVars);
if(clientVars.abiwordAvailable == "no")
//hide stuff thats not avaible if abiword/soffice is disabled
if(clientVars.exportAvailable == "no")
{ {
$("#exportworda").remove(); $("#exportworda").remove();
$("#exportpdfa").remove(); $("#exportpdfa").remove();
@ -216,13 +218,13 @@ var padimpexp = (function()
$("#importmessageabiword").show(); $("#importmessageabiword").show();
} }
else if(clientVars.abiwordAvailable == "withoutPDF") else if(clientVars.exportAvailable == "withoutPDF")
{ {
$("#exportpdfa").remove(); $("#exportpdfa").remove();
$("#exportworda").attr("href", pad_root_path + "/export/doc"); $("#exportworda").attr("href", pad_root_path + "/export/doc");
$("#exportopena").attr("href", pad_root_path + "/export/odt"); $("#exportopena").attr("href", pad_root_path + "/export/odt");
$("#importexport").css({"height":"142px"}); $("#importexport").css({"height":"142px"});
$("#importexportline").css({"height":"142px"}); $("#importexportline").css({"height":"142px"});
} }
@ -232,7 +234,7 @@ var padimpexp = (function()
$("#exportpdfa").attr("href", pad_root_path + "/export/pdf"); $("#exportpdfa").attr("href", pad_root_path + "/export/pdf");
$("#exportopena").attr("href", pad_root_path + "/export/odt"); $("#exportopena").attr("href", pad_root_path + "/export/odt");
} }
addImportFrames(); addImportFrames();
$("#importfileinput").change(fileInputUpdated); $("#importfileinput").change(fileInputUpdated);
$('#importform').unbind("submit").submit(fileInputSubmit); $('#importform').unbind("submit").submit(fileInputSubmit);