2023-10-20 22:35:26 +08:00
|
|
|
|
// SPDX-FileCopyrightText: 2023 XWiki CryptPad Team <contact@cryptpad.org> and contributors
|
|
|
|
|
//
|
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
|
2017-06-22 00:02:38 +08:00
|
|
|
|
define([
|
|
|
|
|
'jquery',
|
|
|
|
|
'/common/hyperscript.js',
|
|
|
|
|
'/customize/pages.js',
|
2023-01-07 19:49:46 +08:00
|
|
|
|
'/components/nthen/index.js',
|
2017-06-22 00:02:38 +08:00
|
|
|
|
|
2023-01-07 15:27:22 +08:00
|
|
|
|
'css!/components/components-font-awesome/css/font-awesome.min.css',
|
2018-10-25 17:41:18 +08:00
|
|
|
|
], function ($, h, Pages, nThen) {
|
2022-04-04 19:08:18 +08:00
|
|
|
|
// we consider that there is no valid reason to load any of the info pages
|
|
|
|
|
// in an iframe. abort everything if you detect that you are embedded.
|
|
|
|
|
if (window.top !== window) { return; }
|
|
|
|
|
|
2017-06-22 00:02:38 +08:00
|
|
|
|
$(function () {
|
|
|
|
|
var $body = $('body');
|
|
|
|
|
|
2017-06-22 17:06:11 +08:00
|
|
|
|
var pathname = location.pathname;
|
2017-06-22 22:01:33 +08:00
|
|
|
|
|
2018-03-20 17:44:26 +08:00
|
|
|
|
// add class on info-pages
|
2018-10-25 17:41:18 +08:00
|
|
|
|
var pageName = pathname.replace(/(index)?\.html$/gi, "") // .html
|
2018-03-20 17:44:26 +08:00
|
|
|
|
.replace(/[^a-zA-Z]+/gi, '-') // any non-alpha character
|
|
|
|
|
.replace(/^-|-$/g, ''); // starting/trailing dashes
|
2018-10-25 17:41:18 +08:00
|
|
|
|
if (pageName === '') { pageName = 'index'; }
|
|
|
|
|
$('body').addClass('cp-page-' + pageName);
|
|
|
|
|
|
|
|
|
|
var infoPage = function () {
|
|
|
|
|
return h('div#mainBlock.hidden', typeof(Pages[pathname]) === 'function'?
|
|
|
|
|
Pages[pathname](): [h('div#container')]);
|
|
|
|
|
};
|
2017-06-22 17:06:11 +08:00
|
|
|
|
|
2017-10-23 17:57:10 +08:00
|
|
|
|
window.Tether = function () {};
|
2018-10-25 17:41:18 +08:00
|
|
|
|
|
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
|
var w = waitFor();
|
|
|
|
|
require([
|
|
|
|
|
'/customize/pages/' + pageName + '.js',
|
|
|
|
|
], function (Page) {
|
|
|
|
|
infoPage = Page;
|
|
|
|
|
w();
|
|
|
|
|
}, function () {
|
|
|
|
|
w();
|
|
|
|
|
});
|
|
|
|
|
}).nThen(function () {
|
|
|
|
|
require([
|
2023-07-13 21:36:48 +08:00
|
|
|
|
'/api/config',
|
|
|
|
|
'/common/common-util.js',
|
|
|
|
|
'optional!/api/instance',
|
2018-10-25 17:41:18 +08:00
|
|
|
|
'less!/customize/src/less2/pages/page-' + pageName + '.less',
|
2023-01-07 19:41:33 +08:00
|
|
|
|
'css!/components/bootstrap/dist/css/bootstrap.min.css',
|
2018-11-05 19:02:27 +08:00
|
|
|
|
'css!/customize/fonts/cptools/style.css'
|
2023-07-13 21:36:48 +08:00
|
|
|
|
], function (ApiConfig, Util, Instance) {
|
2018-10-25 17:41:18 +08:00
|
|
|
|
var $main = $(infoPage());
|
2023-07-13 21:36:48 +08:00
|
|
|
|
var titleSuffix = (Util.find(Instance, ['name','default']) || '').trim();
|
|
|
|
|
if (!titleSuffix || titleSuffix === ApiConfig.httpUnsafeOrigin) {
|
|
|
|
|
titleSuffix = window.location.hostname;
|
|
|
|
|
}
|
|
|
|
|
document.title = document.title + ' - ' + titleSuffix;
|
2018-10-25 17:41:18 +08:00
|
|
|
|
|
2022-07-12 19:07:58 +08:00
|
|
|
|
$('#placeholder').remove();
|
2022-07-11 16:21:00 +08:00
|
|
|
|
|
2018-10-25 17:41:18 +08:00
|
|
|
|
$body.append($main);
|
|
|
|
|
|
|
|
|
|
if (/^\/register\//.test(pathname)) {
|
|
|
|
|
require([ '/register/main.js' ], function () {});
|
2022-12-20 23:56:41 +08:00
|
|
|
|
} else if (/^\/install\//.test(pathname)) {
|
|
|
|
|
require([ '/install/main.js' ], function () {});
|
2023-05-15 23:33:58 +08:00
|
|
|
|
} else if (/^\/recovery\//.test(pathname)) {
|
|
|
|
|
require([ '/recovery/main.js' ], function () {});
|
2023-06-27 22:04:32 +08:00
|
|
|
|
} else if (/^\/ssoauth\//.test(pathname)) {
|
|
|
|
|
require([ '/ssoauth/main.js' ], function () {});
|
2018-10-25 17:41:18 +08:00
|
|
|
|
} else if (/^\/login\//.test(pathname)) {
|
|
|
|
|
require([ '/login/main.js' ], function () {});
|
|
|
|
|
} else if (/^\/($|^\/index\.html$)/.test(pathname)) {
|
|
|
|
|
require([ '/customize/main.js', ], function () {});
|
|
|
|
|
} else {
|
|
|
|
|
require([ '/customize/main.js', ], function () {});
|
|
|
|
|
}
|
|
|
|
|
});
|
2017-06-27 20:25:02 +08:00
|
|
|
|
});
|
2017-06-22 16:04:46 +08:00
|
|
|
|
});
|
|
|
|
|
});
|