Add instance name to page titles #1043

This commit is contained in:
yflory 2023-07-13 15:36:48 +02:00
parent a70800f928
commit a187222ed5
3 changed files with 19 additions and 3 deletions

View File

@ -35,6 +35,7 @@ define([
};
return function () {
document.title = Msg.homePage;
var icons = [
[ 'sheet', Msg.type.sheet],
[ 'doc', Msg.type.doc],

View File

@ -41,11 +41,19 @@ $(function () {
});
}).nThen(function () {
require([
'/api/config',
'/common/common-util.js',
'optional!/api/instance',
'less!/customize/src/less2/pages/page-' + pageName + '.less',
'css!/components/bootstrap/dist/css/bootstrap.min.css',
'css!/customize/fonts/cptools/style.css'
], function () {
], function (ApiConfig, Util, Instance) {
var $main = $(infoPage());
var titleSuffix = (Util.find(Instance, ['name','default']) || '').trim();
if (!titleSuffix || titleSuffix === ApiConfig.httpUnsafeOrigin) {
titleSuffix = window.location.hostname;
}
document.title = document.title + ' - ' + titleSuffix;
$('#placeholder').remove();

View File

@ -150,9 +150,11 @@ define([
'/customize/application_config.js',
//'/common/test.js',
'/common/userObject.js',
'optional!/api/instance'
], waitFor(function (_CpNfOuter, _Cryptpad, _Crypto, _Cryptget, _SFrameChannel,
_SecureIframe, _UnsafeIframe, _OOIframe, _Messaging, _Notifier, _Hash, _Util, _Realtime, _Notify,
_Constants, _Feedback, _LocalStore, _Cache, _AppConfig, /* _Test,*/ _UserObject) {
_Constants, _Feedback, _LocalStore, _Cache, _AppConfig, /* _Test,*/ _UserObject,
_Instance) {
CpNfOuter = _CpNfOuter;
Cryptpad = _Cryptpad;
Crypto = Utils.Crypto = _Crypto;
@ -173,6 +175,7 @@ define([
Utils.UserObject = _UserObject;
Utils.Notify = _Notify;
Utils.currentPad = currentPad;
Utils.Instance = _Instance;
AppConfig = _AppConfig;
//Test = _Test;
@ -1228,13 +1231,17 @@ define([
var currentTitle;
var currentTabTitle;
var titleSuffix = (Utils.Util.find(Utils, ['Instance','name','default']) || '').trim();
if (!titleSuffix || titleSuffix === ApiConfig.httpUnsafeOrigin) {
titleSuffix = window.location.hostname;
}
var setDocumentTitle = function () {
if (!currentTabTitle) {
document.title = currentTitle || 'CryptPad';
return;
}
var title = currentTabTitle.replace(/\{title\}/g, currentTitle || 'CryptPad');
document.title = title;
document.title = title + ' - ' + titleSuffix;
};
var setPadTitle = function (data, cb) {