diff options
author | John McLear <john@mclear.co.uk> | 2015-12-21 16:12:25 +0000 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2015-12-21 16:12:25 +0000 |
commit | 41ced5e2390acbe3f11de46fe2384b62d51b259d (patch) | |
tree | c494e39e8b2a78bf44d7b39c80dec8636e0fb769 /src | |
parent | 34d757ff7ffb57f3319d2d6d56c22e3cd99ff85e (diff) | |
parent | d6033de0dafd5f8cf9f8ab943f63f41410b78bdd (diff) | |
download | etherpad-lite-41ced5e2390acbe3f11de46fe2384b62d51b259d.zip |
Merge pull request #2859 from cmbirk/develop
Check for SOffice before removing export links
Diffstat (limited to 'src')
-rw-r--r-- | src/node/handler/PadMessageHandler.js | 2 | ||||
-rw-r--r-- | src/node/hooks/express/importexport.js | 4 | ||||
-rw-r--r-- | src/node/utils/Settings.js | 35 | ||||
-rw-r--r-- | src/static/js/pad_impexp.js | 24 |
4 files changed, 51 insertions, 14 deletions
diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index bf8737fc..f48be604 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -1234,6 +1234,8 @@ function handleClientReady(client, message) "serverTimestamp": new Date().getTime(), "userId": author, "abiwordAvailable": settings.abiwordAvailable(), + "sofficeAvailable": settings.sofficeAvailable(), + "exportAvailable": settings.exportAvailable(), "plugins": { "plugins": plugins.plugins, "parts": plugins.parts, diff --git a/src/node/hooks/express/importexport.js b/src/node/hooks/express/importexport.js index f3f05163..5ebac1db 100644 --- a/src/node/hooks/express/importexport.js +++ b/src/node/hooks/express/importexport.js @@ -13,9 +13,9 @@ exports.expressCreateServer = function (hook_name, args, cb) { } //if abiword is disabled, and this is a format we only support with abiword, output a message - if (settings.abiword == null && + if (settings.exportAvailable() == "no" && ["odt", "pdf", "doc"].indexOf(req.params.type) !== -1) { - res.send("Abiword is not enabled at this Etherpad instance. Set the path to Abiword in settings.json to enable this feature"); + res.send("This export is not enabled at this Etherpad instance. Set the path to Abiword or SOffice in settings.json to enable this feature"); return; } diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index 325a997a..b765670a 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -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 exports.getGitCommit = function() { 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) { try { exports.sessionKey = fs.readFileSync("./SESSIONKEY.txt","utf8"); diff --git a/src/static/js/pad_impexp.js b/src/static/js/pad_impexp.js index 1648f34c..70220f87 100644 --- a/src/static/js/pad_impexp.js +++ b/src/static/js/pad_impexp.js @@ -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. * TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED */ @@ -46,7 +46,7 @@ var padimpexp = (function() $('#importmessagefail').fadeOut("fast"); var ret = window.confirm(html10n.get("pad.impexp.confirmimport")); if (ret) - { + { currentImportTimer = window.setTimeout(function() { if (!currentImportTimer) @@ -61,7 +61,7 @@ var padimpexp = (function() { disabled: true }).val(html10n.get("pad.impexp.importing")); - + window.setTimeout(function() { $('#importfileinput').attr( @@ -104,7 +104,7 @@ var padimpexp = (function() function importErrorMessage(status) { var msg=""; - + if(status === "convertFailed"){ msg = html10n.get("pad.impexp.convertFailed"); } else if(status === "uploadFailed"){ @@ -112,7 +112,7 @@ var padimpexp = (function() } else if(status === "padHasData"){ msg = html10n.get("pad.impexp.padHasData"); } - + function showError(fade) { $('#importmessagefail').html('<strong style="color: red">'+html10n.get('pad.impexp.importfailed')+':</strong> ' + (msg || html10n.get('pad.impexp.copypaste','')))[(fade ? "fadeIn" : "show")](); @@ -206,9 +206,9 @@ var padimpexp = (function() // activate action to import in the form $("#importform").attr('action', pad_root_url + "/import"); - - //hide stuff thats not avaible if abiword is disabled - if(clientVars.abiwordAvailable == "no") + + //hide stuff thats not avaible if abiword/soffice is disabled + if(clientVars.exportAvailable == "no") { $("#exportworda").remove(); $("#exportpdfa").remove(); @@ -216,13 +216,13 @@ var padimpexp = (function() $("#importmessageabiword").show(); } - else if(clientVars.abiwordAvailable == "withoutPDF") + else if(clientVars.exportAvailable == "withoutPDF") { $("#exportpdfa").remove(); - + $("#exportworda").attr("href", pad_root_path + "/export/doc"); $("#exportopena").attr("href", pad_root_path + "/export/odt"); - + $("#importexport").css({"height":"142px"}); $("#importexportline").css({"height":"142px"}); } @@ -232,7 +232,7 @@ var padimpexp = (function() $("#exportpdfa").attr("href", pad_root_path + "/export/pdf"); $("#exportopena").attr("href", pad_root_path + "/export/odt"); } - + addImportFrames(); $("#importfileinput").change(fileInputUpdated); $('#importform').unbind("submit").submit(fileInputSubmit); |