From a8d5dc0693504671126abcf8680a3a3aa6acaebb Mon Sep 17 00:00:00 2001 From: LokeshN Date: Sun, 22 May 2016 20:58:51 +0530 Subject: Issue #2960 - deactivate settings.json Deactivate settings.json in Admin dashboard --- src/node/hooks/express/adminsettings.js | 8 +++++++- src/node/utils/Settings.js | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/node') diff --git a/src/node/hooks/express/adminsettings.js b/src/node/hooks/express/adminsettings.js index 4986f093..73691837 100644 --- a/src/node/hooks/express/adminsettings.js +++ b/src/node/hooks/express/adminsettings.js @@ -30,7 +30,13 @@ exports.socketio = function (hook_name, args, cb) { } else { - socket.emit("settings", {results: data}); + //if showSettingsInAdminPage is set to false, then return NOT_ALLOWED in the result + if(settings.showSettingsInAdminPage === false) { + socket.emit("settings", {results:'NOT_ALLOWED'}); + } + else { + socket.emit("settings", {results: data}); + } } }); }); diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index b765670a..24bc25c3 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -209,6 +209,11 @@ exports.requireAuthentication = false; exports.requireAuthorization = false; exports.users = {}; +/* +* Show settings in admin page, by default it is true +*/ +exports.showSettingsInAdminPage = true; + //checks if abiword is avaiable exports.abiwordAvailable = function() { -- cgit v1.2.3 From 6b9711cb70c45c67224f4a12b371559883c78f19 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 20 Jun 2016 00:22:29 +0200 Subject: Fixed path check --- src/node/hooks/i18n.js | 2 +- src/node/utils/caching_middleware.js | 3 +-- src/node/utils/path_exists.js | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 src/node/utils/path_exists.js (limited to 'src/node') diff --git a/src/node/hooks/i18n.js b/src/node/hooks/i18n.js index d0be2d6f..1b5b354d 100644 --- a/src/node/hooks/i18n.js +++ b/src/node/hooks/i18n.js @@ -5,7 +5,7 @@ var languages = require('languages4translatewiki') , npm = require('npm') , plugins = require('ep_etherpad-lite/static/js/pluginfw/plugins.js').plugins , semver = require('semver') - , existsSync = fs.statSync || fs.existsSync || path.existsSync + , existsSync = require('../utils/path_exists') ; diff --git a/src/node/utils/caching_middleware.js b/src/node/utils/caching_middleware.js index 91b8143b..65fe5d2f 100644 --- a/src/node/utils/caching_middleware.js +++ b/src/node/utils/caching_middleware.js @@ -21,8 +21,7 @@ var path = require('path'); var zlib = require('zlib'); var settings = require('./Settings'); var semver = require('semver'); - -var existsSync = fs.statSync || fs.existsSync || path.existsSync; +var existsSync = require('./path_exists'); var CACHE_DIR = path.normalize(path.join(settings.root, 'var/')); CACHE_DIR = existsSync(CACHE_DIR) ? CACHE_DIR : undefined; diff --git a/src/node/utils/path_exists.js b/src/node/utils/path_exists.js new file mode 100644 index 00000000..c2d43f6c --- /dev/null +++ b/src/node/utils/path_exists.js @@ -0,0 +1,15 @@ +var fs = require('fs'); + +var check = function(path) { + var existsSync = fs.statSync || fs.existsSync || path.existsSync; + + var result; + try { + result = existsSync(path); + } catch (e) { + result = false; + } + return result; +} + +module.exports = check; -- cgit v1.2.3 From 6d7f128b870cc405151e44484a35999a0cbb69b0 Mon Sep 17 00:00:00 2001 From: Dan Bornstein Date: Wed, 24 Aug 2016 10:54:52 -0700 Subject: Use an EEJS template for HTML export instead of inlining it in the JS code. The semantics of all the substitutions are identical to what they were before. I _did_ take the liberty of formatting the CSS to be a bit more readable (at the cost of adding a little bit of whitespace). --- src/node/utils/ExportHtml.js | 110 ++++--------------------------------------- 1 file changed, 8 insertions(+), 102 deletions(-) (limited to 'src/node') diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index 836165b1..f2e275ee 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -22,6 +22,7 @@ var ERR = require("async-stacktrace"); var _ = require('underscore'); var Security = require('ep_etherpad-lite/static/js/security'); var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks'); +var eejs = require('ep_etherpad-lite/node/eejs'); var _analyzeLine = require('./ExportHelper')._analyzeLine; var _encodeWhitespace = require('./ExportHelper')._encodeWhitespace; @@ -490,112 +491,17 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback) stylesForExport.forEach(function(css){ stylesForExportCSS += css; }); - // Core inclusion of head etc. - var head = - (noDocType ? '' : '\n') + - '\n' + (noDocType ? '' : '\n' + - '' + Security.escapeHTML(padId) + '\n' + - '\n' + - '\n' + - '\n' + - '\n' + - '\n' + '\n') + - ''; - var foot = '\n\n'; getPadHTML(pad, revNum, function (err, html) { if(ERR(err, callback)) return; - callback(null, head + html + foot); + var exportedDoc = eejs.require("ep_etherpad-lite/templates/export_html.html", { + body: html, + doctype: noDocType ? '' : '', + padId: Security.escapeHTML(padId), + extraCSS: stylesForExportCSS + }); + callback(null, exportedDoc); }); }); }); -- cgit v1.2.3 From 879ae7c67d6b0c7fa78e0e09435861e5509678a8 Mon Sep 17 00:00:00 2001 From: Dan Bornstein Date: Thu, 8 Sep 2016 09:41:23 -0700 Subject: Remove the `noDocType` argument, which was only ever passed as `false`. --- src/node/handler/ExportHandler.js | 2 +- src/node/hooks/express/padreadonly.js | 4 ++-- src/node/utils/ExportHtml.js | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'src/node') diff --git a/src/node/handler/ExportHandler.js b/src/node/handler/ExportHandler.js index 8f91ced2..7cce6200 100644 --- a/src/node/handler/ExportHandler.js +++ b/src/node/handler/ExportHandler.js @@ -92,7 +92,7 @@ exports.doExport = function(req, res, padId, type) //render the html document function(callback) { - exporthtml.getPadHTMLDocument(padId, req.params.rev, false, function(err, _html) + exporthtml.getPadHTMLDocument(padId, req.params.rev, function(err, _html) { if(ERR(err, callback)) return; html = _html; diff --git a/src/node/hooks/express/padreadonly.js b/src/node/hooks/express/padreadonly.js index 66be3339..bff8adf7 100644 --- a/src/node/hooks/express/padreadonly.js +++ b/src/node/hooks/express/padreadonly.js @@ -7,7 +7,7 @@ var exporthtml = require("../../utils/ExportHtml"); exports.expressCreateServer = function (hook_name, args, cb) { //serve read only pad args.app.get('/ro/:id', function(req, res) - { + { var html; var padId; @@ -40,7 +40,7 @@ exports.expressCreateServer = function (hook_name, args, cb) { hasPadAccess(req, res, function() { //render the html document - exporthtml.getPadHTMLDocument(padId, null, false, function(err, _html) + exporthtml.getPadHTMLDocument(padId, null, function(err, _html) { if(ERR(err, callback)) return; html = _html; diff --git a/src/node/utils/ExportHtml.js b/src/node/utils/ExportHtml.js index f2e275ee..bd177ac4 100644 --- a/src/node/utils/ExportHtml.js +++ b/src/node/utils/ExportHtml.js @@ -479,7 +479,7 @@ function getHTMLFromAtext(pad, atext, authorColors) return pieces.join(''); } -exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback) +exports.getPadHTMLDocument = function (padId, revNum, callback) { padManager.getPad(padId, function (err, pad) { @@ -497,7 +497,6 @@ exports.getPadHTMLDocument = function (padId, revNum, noDocType, callback) if(ERR(err, callback)) return; var exportedDoc = eejs.require("ep_etherpad-lite/templates/export_html.html", { body: html, - doctype: noDocType ? '' : '', padId: Security.escapeHTML(padId), extraCSS: stylesForExportCSS }); -- cgit v1.2.3 From a0403ffc22da6e94c88f89ea0ff0d65704947415 Mon Sep 17 00:00:00 2001 From: Dan Bornstein Date: Thu, 8 Sep 2016 09:46:13 -0700 Subject: Remove unused parameter `noDocType`. My editor also auto-stripped some EOL whitespace. --- src/node/handler/ExportHandler.js | 2 +- src/node/utils/ExportTxt.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/node') diff --git a/src/node/handler/ExportHandler.js b/src/node/handler/ExportHandler.js index 7cce6200..fe7ab3db 100644 --- a/src/node/handler/ExportHandler.js +++ b/src/node/handler/ExportHandler.js @@ -76,7 +76,7 @@ exports.doExport = function(req, res, padId, type) } else if(type == "txt") { - exporttxt.getPadTXTDocument(padId, req.params.rev, false, function(err, txt) + exporttxt.getPadTXTDocument(padId, req.params.rev, function(err, txt) { if(ERR(err)) return; res.send(txt); diff --git a/src/node/utils/ExportTxt.js b/src/node/utils/ExportTxt.js index a6bec4a5..e3ce0152 100644 --- a/src/node/utils/ExportTxt.js +++ b/src/node/utils/ExportTxt.js @@ -192,7 +192,7 @@ function getTXTFromAtext(pad, atext, authorColors) tags2close.push(i); } } - + for (var i = 0; i < propVals.length; i++) { if (propVals[i] === ENTER || propVals[i] === STAY) @@ -208,10 +208,10 @@ function getTXTFromAtext(pad, atext, authorColors) { chars--; // exclude newline at end of line, if present } - + var s = taker.take(chars); - // removes the characters with the code 12. Don't know where they come + // removes the characters with the code 12. Don't know where they come // from but they break the abiword parser and are completly useless // s = s.replace(String.fromCharCode(12), ""); @@ -221,7 +221,7 @@ function getTXTFromAtext(pad, atext, authorColors) assem.append(s); } // end iteration over spans in line - + var tags2close = []; for (var i = propVals.length - 1; i >= 0; i--) { @@ -231,7 +231,7 @@ function getTXTFromAtext(pad, atext, authorColors) propVals[i] = false; } } - + } // end processNextChars processNextChars(text.length - idx); return(assem.toString()); @@ -271,7 +271,7 @@ function getTXTFromAtext(pad, atext, authorColors) } exports.getTXTFromAtext = getTXTFromAtext; -exports.getPadTXTDocument = function (padId, revNum, noDocType, callback) +exports.getPadTXTDocument = function (padId, revNum, callback) { padManager.getPad(padId, function (err, pad) { -- cgit v1.2.3 From 97fd1ab2feffa92494d837d2aefd842853d9f816 Mon Sep 17 00:00:00 2001 From: Nobody Really Date: Tue, 20 Sep 2016 09:06:07 +0200 Subject: Added LibreJS support --- src/node/hooks/express/specialpages.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/node') diff --git a/src/node/hooks/express/specialpages.js b/src/node/hooks/express/specialpages.js index e8d7795a..2840f82c 100644 --- a/src/node/hooks/express/specialpages.js +++ b/src/node/hooks/express/specialpages.js @@ -16,6 +16,13 @@ exports.expressCreateServer = function (hook_name, args, cb) { res.send(eejs.require("ep_etherpad-lite/templates/index.html")); }); + //serve javascript.html + args.app.get('/javascript', function(req, res) + { + res.send(eejs.require("ep_etherpad-lite/templates/javascript.html")); + }); + + //serve robots.txt args.app.get('/robots.txt', function(req, res) { -- cgit v1.2.3