Do not share the title in the doc if it is the default title
This commit is contained in:
parent
0f672f19f5
commit
17b4f91810
@ -158,9 +158,11 @@ define([
|
|||||||
|
|
||||||
// append the userlist to the hyperjson structure
|
// append the userlist to the hyperjson structure
|
||||||
obj.metadata = {
|
obj.metadata = {
|
||||||
users: userList,
|
users: userList
|
||||||
title: document.title
|
|
||||||
};
|
};
|
||||||
|
if (!isDefaultTitle()) {
|
||||||
|
obj.metadata.title = document.title;
|
||||||
|
}
|
||||||
|
|
||||||
// set mode too...
|
// set mode too...
|
||||||
obj.highlightMode = module.highlightMode;
|
obj.highlightMode = module.highlightMode;
|
||||||
@ -239,11 +241,15 @@ define([
|
|||||||
return text.trim();
|
return text.trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var isDefaultTitle = function () {
|
||||||
|
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
||||||
|
return Cryptpad.isDefaultName(parsed, document.title);
|
||||||
|
};
|
||||||
var suggestName = function () {
|
var suggestName = function () {
|
||||||
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
||||||
var name = Cryptpad.getDefaultName(parsed, []);
|
var name = Cryptpad.getDefaultName(parsed, []);
|
||||||
|
|
||||||
if (document.title.slice(0, name.length) === name) {
|
if (Cryptpad.isDefaultName(parsed, document.title)) {
|
||||||
return getHeadingText() || document.title;
|
return getHeadingText() || document.title;
|
||||||
} else {
|
} else {
|
||||||
return document.title || getHeadingText() || name;
|
return document.title || getHeadingText() || name;
|
||||||
@ -328,42 +334,42 @@ define([
|
|||||||
onLocal();
|
onLocal();
|
||||||
}));
|
}));
|
||||||
$rightside.append($import);
|
$rightside.append($import);
|
||||||
}
|
|
||||||
|
|
||||||
/* add a rename button */
|
/* add a rename button */
|
||||||
var $setTitle = Cryptpad.createButton('rename', true)
|
var $setTitle = Cryptpad.createButton('rename', true)
|
||||||
.click(function () {
|
.click(function () {
|
||||||
var suggestion = suggestName();
|
var suggestion = suggestName();
|
||||||
|
|
||||||
Cryptpad.prompt(Messages.renamePrompt,
|
Cryptpad.prompt(Messages.renamePrompt,
|
||||||
suggestion, function (title, ev) {
|
suggestion, function (title, ev) {
|
||||||
if (title === null) { return; }
|
if (title === null) { return; }
|
||||||
|
|
||||||
Cryptpad.causesNamingConflict(title, function (err, conflicts) {
|
Cryptpad.causesNamingConflict(title, function (err, conflicts) {
|
||||||
if (err) {
|
|
||||||
console.log("Unable to determine if name caused a conflict");
|
|
||||||
console.error(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conflicts) {
|
|
||||||
Cryptpad.alert(Messages.renameConflict);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Cryptpad.setPadTitle(title, function (err, data) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log("unable to set pad title");
|
console.log("Unable to determine if name caused a conflict");
|
||||||
console.log(err);
|
console.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
document.title = title;
|
|
||||||
onLocal();
|
if (conflicts) {
|
||||||
|
Cryptpad.alert(Messages.renameConflict);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cryptpad.setPadTitle(title, function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
console.log("unable to set pad title");
|
||||||
|
console.log(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
document.title = title;
|
||||||
|
onLocal();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
$rightside.append($setTitle);
|
||||||
$rightside.append($setTitle);
|
}
|
||||||
|
|
||||||
/* add a forget button */
|
/* add a forget button */
|
||||||
var $forgetPad = Cryptpad.createButton('forget', true)
|
var $forgetPad = Cryptpad.createButton('forget', true)
|
||||||
@ -657,11 +663,13 @@ define([
|
|||||||
var hjson2 = {
|
var hjson2 = {
|
||||||
content: localDoc,
|
content: localDoc,
|
||||||
metadata: {
|
metadata: {
|
||||||
users: userList,
|
users: userList
|
||||||
title: document.title
|
|
||||||
},
|
},
|
||||||
highlightMode: highlightMode,
|
highlightMode: highlightMode,
|
||||||
};
|
};
|
||||||
|
if (!isDefaultTitle()) {
|
||||||
|
hjson2.metadata.title = document.title;
|
||||||
|
}
|
||||||
var shjson2 = stringify(hjson2);
|
var shjson2 = stringify(hjson2);
|
||||||
if (shjson2 !== shjson) {
|
if (shjson2 !== shjson) {
|
||||||
console.error("shjson2 !== shjson");
|
console.error("shjson2 !== shjson");
|
||||||
|
|||||||
@ -295,6 +295,10 @@ define([
|
|||||||
while (!isNameAvailable(name + ' - ' + untitledIndex, parsed, recentPads)) { untitledIndex++; }
|
while (!isNameAvailable(name + ' - ' + untitledIndex, parsed, recentPads)) { untitledIndex++; }
|
||||||
return name + ' - ' + untitledIndex;
|
return name + ' - ' + untitledIndex;
|
||||||
};
|
};
|
||||||
|
var isDefaultName = common.isDefaultName = function (parsed, title) {
|
||||||
|
var name = getDefaultName(parsed, []);
|
||||||
|
return title.slice(0, name.length) === name;
|
||||||
|
};
|
||||||
|
|
||||||
var makePad = function (href, title) {
|
var makePad = function (href, title) {
|
||||||
var now = ''+new Date();
|
var now = ''+new Date();
|
||||||
|
|||||||
@ -294,6 +294,21 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var isDefaultTitle = function () {
|
||||||
|
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
||||||
|
return Cryptpad.isDefaultName(parsed, document.title);
|
||||||
|
};
|
||||||
|
var suggestName = function () {
|
||||||
|
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
||||||
|
var name = Cryptpad.getDefaultName(parsed, []);
|
||||||
|
|
||||||
|
if (Cryptpad.isDefaultName(parsed, document.title)) {
|
||||||
|
return getHeadingText() || document.title;
|
||||||
|
} else {
|
||||||
|
return document.title || getHeadingText() || name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var DD = new DiffDom(diffOptions);
|
var DD = new DiffDom(diffOptions);
|
||||||
|
|
||||||
// apply patches, and try not to lose the cursor in the process!
|
// apply patches, and try not to lose the cursor in the process!
|
||||||
@ -312,9 +327,11 @@ define([
|
|||||||
hjson[3] = {
|
hjson[3] = {
|
||||||
metadata: {
|
metadata: {
|
||||||
users: userList,
|
users: userList,
|
||||||
title: document.title
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
if (!isDefaultTitle()) {
|
||||||
|
hjson[3].metadata.title = document.title;
|
||||||
|
}
|
||||||
return stringify(hjson);
|
return stringify(hjson);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -472,17 +489,6 @@ define([
|
|||||||
})) { return text; }
|
})) { return text; }
|
||||||
};
|
};
|
||||||
|
|
||||||
var suggestName = module.suggestName = function () {
|
|
||||||
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
|
||||||
var name = Cryptpad.getDefaultName(parsed, []);
|
|
||||||
|
|
||||||
if (document.title.slice(0, name.length) === name) {
|
|
||||||
return getHeadingText() || document.title;
|
|
||||||
} else {
|
|
||||||
return document.title || getHeadingText() || name;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var exportFile = function () {
|
var exportFile = function () {
|
||||||
var html = getHTML();
|
var html = getHTML();
|
||||||
var suggestion = suggestName();
|
var suggestion = suggestName();
|
||||||
@ -536,34 +542,34 @@ define([
|
|||||||
realtimeOptions.onLocal();
|
realtimeOptions.onLocal();
|
||||||
}));
|
}));
|
||||||
$rightside.append($import);
|
$rightside.append($import);
|
||||||
}
|
|
||||||
|
|
||||||
/* add a rename button */
|
/* add a rename button */
|
||||||
var $rename = Cryptpad.createButton('rename', true)
|
var $rename = Cryptpad.createButton('rename', true)
|
||||||
.click(function () {
|
.click(function () {
|
||||||
var suggestion = suggestName();
|
var suggestion = suggestName();
|
||||||
|
|
||||||
Cryptpad.prompt(Messages.renamePrompt, suggestion, function (title) {
|
Cryptpad.prompt(Messages.renamePrompt, suggestion, function (title) {
|
||||||
if (title === null) { return; }
|
if (title === null) { return; }
|
||||||
Cryptpad.causesNamingConflict(title, function (err, conflicts) {
|
Cryptpad.causesNamingConflict(title, function (err, conflicts) {
|
||||||
if (conflicts) {
|
if (conflicts) {
|
||||||
Cryptpad.alert(Messages.renameConflict);
|
Cryptpad.alert(Messages.renameConflict);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Cryptpad.setPadTitle(title, function (err, data) {
|
|
||||||
if (err) {
|
|
||||||
console.log("Couldn't set pad title");
|
|
||||||
console.error(err);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
document.title = title;
|
|
||||||
editor.fire('change');
|
Cryptpad.setPadTitle(title, function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
console.log("Couldn't set pad title");
|
||||||
|
console.error(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
document.title = title;
|
||||||
|
editor.fire('change');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
$rightside.append($rename);
|
||||||
$rightside.append($rename);
|
}
|
||||||
|
|
||||||
/* add a forget button */
|
/* add a forget button */
|
||||||
var $forgetPad = Cryptpad.createButton('forget', true)
|
var $forgetPad = Cryptpad.createButton('forget', true)
|
||||||
|
|||||||
@ -193,10 +193,11 @@ define([
|
|||||||
|
|
||||||
// append the userlist to the hyperjson structure
|
// append the userlist to the hyperjson structure
|
||||||
obj.metadata = {
|
obj.metadata = {
|
||||||
users: userList,
|
users: userList
|
||||||
title: APP.title
|
|
||||||
};
|
};
|
||||||
|
if (!isDefaultTitle()) {
|
||||||
|
obj.metadata.title = APP.title;
|
||||||
|
}
|
||||||
// stringify the json and send it into chainpad
|
// stringify the json and send it into chainpad
|
||||||
var shjson = stringify(obj);
|
var shjson = stringify(obj);
|
||||||
|
|
||||||
@ -254,11 +255,15 @@ define([
|
|||||||
return text.trim();
|
return text.trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var isDefaultTitle = function () {
|
||||||
|
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
||||||
|
return Cryptpad.isDefaultName(parsed, APP.title);
|
||||||
|
};
|
||||||
var suggestName = function () {
|
var suggestName = function () {
|
||||||
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
var parsed = Cryptpad.parsePadUrl(window.location.href);
|
||||||
var name = Cryptpad.getDefaultName(parsed, []);
|
var name = Cryptpad.getDefaultName(parsed, []);
|
||||||
|
|
||||||
if (APP.title.slice(0, name.length) === name) {
|
if (Cryptpad.isDefaultName(parsed, APP.title)) {
|
||||||
return getHeadingText() || APP.title;
|
return getHeadingText() || APP.title;
|
||||||
} else {
|
} else {
|
||||||
return APP.title || getHeadingText() || name;
|
return APP.title || getHeadingText() || name;
|
||||||
@ -343,43 +348,43 @@ define([
|
|||||||
onLocal();
|
onLocal();
|
||||||
}));
|
}));
|
||||||
$rightside.append($import);
|
$rightside.append($import);
|
||||||
}
|
|
||||||
|
|
||||||
/* add a rename button */
|
/* add a rename button */
|
||||||
var $setTitle = Cryptpad.createButton('rename', true)
|
var $setTitle = Cryptpad.createButton('rename', true)
|
||||||
.click(function () {
|
.click(function () {
|
||||||
var suggestion = suggestName();
|
var suggestion = suggestName();
|
||||||
|
|
||||||
Cryptpad.prompt(Messages.renamePrompt,
|
Cryptpad.prompt(Messages.renamePrompt,
|
||||||
suggestion, function (title, ev) {
|
suggestion, function (title, ev) {
|
||||||
if (title === null) { return; }
|
if (title === null) { return; }
|
||||||
|
|
||||||
Cryptpad.causesNamingConflict(title, function (err, conflicts) {
|
Cryptpad.causesNamingConflict(title, function (err, conflicts) {
|
||||||
if (err) {
|
|
||||||
console.log("Unable to determine if name caused a conflict");
|
|
||||||
console.error(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conflicts) {
|
|
||||||
Cryptpad.alert(Messages.renameConflict);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Cryptpad.setPadTitle(title, function (err, data) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log("unable to set pad title");
|
console.log("Unable to determine if name caused a conflict");
|
||||||
console.log(err);
|
console.error(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
APP.title = title;
|
|
||||||
setTabTitle();
|
if (conflicts) {
|
||||||
onLocal();
|
Cryptpad.alert(Messages.renameConflict);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cryptpad.setPadTitle(title, function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
console.log("unable to set pad title");
|
||||||
|
console.log(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
APP.title = title;
|
||||||
|
setTabTitle();
|
||||||
|
onLocal();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
$rightside.append($setTitle);
|
||||||
$rightside.append($setTitle);
|
}
|
||||||
|
|
||||||
/* add a forget button */
|
/* add a forget button */
|
||||||
var $forgetPad = Cryptpad.createButton('forget', true)
|
var $forgetPad = Cryptpad.createButton('forget', true)
|
||||||
@ -684,11 +689,13 @@ define([
|
|||||||
var hjson2 = {
|
var hjson2 = {
|
||||||
content: localDoc,
|
content: localDoc,
|
||||||
metadata: {
|
metadata: {
|
||||||
users: userList,
|
users: userList
|
||||||
title: APP.title
|
|
||||||
},
|
},
|
||||||
highlightMode: highlightMode,
|
highlightMode: highlightMode,
|
||||||
};
|
};
|
||||||
|
if (!isDefaultTitle()) {
|
||||||
|
hjson2.metadata.title = APP.title;
|
||||||
|
}
|
||||||
var shjson2 = stringify(hjson2);
|
var shjson2 = stringify(hjson2);
|
||||||
if (shjson2 !== shjson) {
|
if (shjson2 !== shjson) {
|
||||||
console.error("shjson2 !== shjson");
|
console.error("shjson2 !== shjson");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user