Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating #4

Merged
merged 6 commits into from
Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/node/handler/ImportHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async function doImport(req, res, padId)
let destFile = path.join(tmpDirectory, "etherpad_import_" + randNum + "." + exportExtension);

// Logic for allowing external Import Plugins
let result = await hooks.aCallAll("import", { srcFile, destFile });
let result = await hooks.aCallAll("import", { srcFile, destFile, fileEnding });
let importHandledByPlugin = (result.length > 0); // This feels hacky and wrong..

let fileIsEtherpad = (fileEnding === ".etherpad");
Expand Down
22 changes: 22 additions & 0 deletions src/node/handler/PadMessageHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,28 @@ async function handleClientReady(client, message)
let p = cached ? Promise.resolve(cached) : authorManager.getAuthor(author);

return p.then(authorInfo => {
// default fallback color to use if authorInfo.colorId is null
const defaultColor = "#daf0b2";

if (!authorInfo) {
console.warn(`handleClientReady(): no authorInfo parameter was received. Default values are going to be used. See issue #3612`);
authorInfo = {};
}

// For some reason sometimes name isn't set
// Catch this issue here and use a fixed name.
if (!authorInfo.name) {
console.warn(`handleClientReady(): client submitted no author name. Using "Anonymous". See: issue #3612`);
authorInfo.name = "Anonymous";
}

// For some reason sometimes colorId isn't set
// Catch this issue here and use a fixed color.
if (!authorInfo.colorId) {
console.warn(`handleClientReady(): author "${authorInfo.name}" has no property colorId. Using the default color ${defaultColor}. See issue #3612`);
authorInfo.colorId = defaultColor;
}

// Send the new User a Notification about this other user
let msg = {
"type": "COLLABROOM",
Expand Down
10 changes: 6 additions & 4 deletions src/node/utils/Minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ function getAceFile(callback) {
data += 'Ace2Editor.EMBEDED[' + JSON.stringify(filename) + '] = '
+ JSON.stringify(status == 200 ? body || '' : null) + ';\n';
} else {
// Silence?
console.error(`getAceFile(): error getting ${resourceURI}. Status code: ${status}`);
}
callback();
});
Expand Down Expand Up @@ -382,7 +382,7 @@ function getFileCompressed(filename, contentType, callback) {
try {
content = compressJS(content);
} catch (error) {
// silence
console.error(`getFile() returned an error in getFileCompressed(${filename}, ${contentType}): ${error}`);
}
callback(null, content);
} else if (contentType == 'text/css') {
Expand Down Expand Up @@ -417,14 +417,16 @@ function compressCSS(filename, content, callback)
var base = path.join(ROOT_DIR, path.dirname(filename));
new CleanCSS({relativeTo: base}).minify(content, function (errors, minified) {
if (errors) {
// On error, just yield the un-minified original.
// on error, just yield the un-minified original, but write a log message
console.error(`CleanCSS.minify() returned an error on ${filename} (base CSS path: ${base}): ${errors}`);
callback(null, content);
} else {
callback(null, minified.styles);
}
});
} catch (error) {
// On error, just yield the un-minified original.
// on error, just yield the un-minified original, but write a log message
console.error(`Unexpected error minifying ${filename} (base CSS path: ${base}): ${error}`);
callback(null, content);
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/node/utils/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,19 @@ module.exports = {
// Remove Save Revision from the right menu
removeItem(buttons[0],"savedrevision");
}
}else{
/* This pad is not read only
*
* Readd the savedrevision button (the "star") if is not already there.
*
* This is a quick fix for #3702: it was sufficient to visit a single read
* only pad to cause the disappearence of the star button from all the
* pads.
*/
if(buttons[0].indexOf("savedrevision") === -1){
// Add item back in for savedrevision
buttons[0].push("savedrevision");
}
}

var groups = _.map(buttons, function (group) {
Expand Down
7 changes: 3 additions & 4 deletions src/static/js/contentcollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,12 @@ function makeContentCollector(collectStyles, abrowser, apool, domInterface, clas
cc: this,
state: state,
tname: tname,
node: node,
text: txt,
node:node,
text:txt,
styl: null,
cls: null
});
var txt = (typeof(txtFromHook)=='object' && txtFromHook.length==0)
? dom.nodeValue(node).trim() : txtFromHook[0].trim();
var txt = (typeof(txtFromHook)=='object'&&txtFromHook.length==0)?dom.nodeValue(node):txtFromHook[0];

var rest = '';
var x = 0; // offset into original text
Expand Down
Loading